Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
Revert "fix(evm): missing things when init or export genesis (#1129)"
Browse files Browse the repository at this point in the history
This reverts commit 326426f.
  • Loading branch information
itsdevbear committed Sep 25, 2023
1 parent 326426f commit bc36040
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
21 changes: 0 additions & 21 deletions cosmos/x/evm/plugins/state/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ func (p *plugin) InitGenesis(ctx sdk.Context, ethGen *core.Genesis) {
p.SetState(address, k, v)
}
}
if account.Nonce != 0 {
p.SetNonce(address, account.Nonce)
}
}
p.Finalize()
}
Expand All @@ -71,7 +68,6 @@ func (p *plugin) ExportGenesis(ctx sdk.Context, ethGen *core.Genesis) {
account.Storage = make(map[common.Hash]common.Hash)
}
account.Balance = p.GetBalance(address)
account.Nonce = p.GetNonce(address)
ethGen.Alloc[address] = account
return false
})
Expand All @@ -89,23 +85,6 @@ func (p *plugin) ExportGenesis(ctx sdk.Context, ethGen *core.Genesis) {

account.Code = p.GetCode(address)
account.Balance = p.GetBalance(address)
account.Nonce = p.GetNonce(address)
ethGen.Alloc[address] = account

return false
})

// Iterate Code and set the genesis accounts.
p.IterateCode(func(address common.Address, codeHash common.Hash) bool {
account, ok := ethGen.Alloc[address]
if !ok {
account = core.GenesisAccount{}
}
account.Code = p.GetCode(address)
account.Nonce = p.GetNonce(address)
if account.Balance == nil {
account.Balance = big.NewInt(0)
}
ethGen.Alloc[address] = account

return false
Expand Down
21 changes: 0 additions & 21 deletions cosmos/x/evm/plugins/state/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,27 +362,6 @@ func (p *plugin) SetCode(addr common.Address, code []byte) {
}
}

// IterateCode iterates over all the contract code, and calls the given function.
func (p *plugin) IterateCode(fn func(addr common.Address, value common.Hash) bool) {
it := storetypes.KVStorePrefixIterator(
p.cms.GetKVStore(p.storeKey),
[]byte{types.CodeHashKeyPrefix},
)
defer func() {
if err := it.Close(); err != nil {
p.savedErr = err
}
}()

for ; it.Valid(); it.Next() {
k := it.Key()
addr := AddressFromCodeHashKey(k)
if fn(addr, p.GetCodeHash(addr)) {
break
}
}
}

// =============================================================================
// Storage
// =============================================================================
Expand Down

0 comments on commit bc36040

Please sign in to comment.