Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [\#467](https://github.com/cosmos/evm/pull/467) Replace GlobalEVMMempool by passing to JSONRPC on initiate.
- [\#352](https://github.com/cosmos/evm/pull/352) Remove the creation of a Geth EVM instance, stateDB during the AnteHandler balance check.
- [\#496](https://github.com/cosmos/evm/pull/496) Simplify mempool instantiation by using configs instead of objects.
- [\#511](https://github.com/cosmos/evm/pull/511) Minor code cleanup for `AddPrecompileFn`.

### FEATURES

Expand Down
2 changes: 1 addition & 1 deletion precompiles/common/precompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (p Precompile) RunSetup(

// add precompileCall entry on the stateDB journal
// this allows to revert the changes within an evm tx
err = stateDB.AddPrecompileFn(p.Address(), snapshot, events)
err = stateDB.AddPrecompileFn(snapshot, events)
if err != nil {
return sdk.Context{}, nil, nil, uint64(0), nil, err
}
Expand Down
12 changes: 0 additions & 12 deletions x/vm/statedb/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"github.com/holiman/uint256"

"github.com/cosmos/evm/x/vm/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// Account is the Ethereum consensus representation of accounts.
Expand Down Expand Up @@ -136,16 +134,6 @@ func (s *stateObject) SetBalance(amount *uint256.Int) uint256.Int {
return prev
}

// AddPrecompileFn appends to the journal an entry
// with a snapshot of the multi-store and events
// previous to the precompile call
func (s *stateObject) AddPrecompileFn(snapshot int, events sdk.Events) {
s.db.journal.append(precompileCallChange{
snapshot: snapshot,
events: events,
})
}

func (s *stateObject) setBalance(amount *uint256.Int) {
s.account.Balance = amount
}
Expand Down
11 changes: 5 additions & 6 deletions x/vm/statedb/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,11 @@ func (s *StateDB) setStateObject(object *stateObject) {
// AddPrecompileFn adds a precompileCall journal entry
// with a snapshot of the multi-store and events previous
// to the precompile call.
func (s *StateDB) AddPrecompileFn(addr common.Address, snapshot int, events sdk.Events) error {
stateObject := s.getOrNewStateObject(addr)
if stateObject == nil {
return fmt.Errorf("could not add precompile call to address %s. State object not found", addr)
}
stateObject.AddPrecompileFn(snapshot, events)
func (s *StateDB) AddPrecompileFn(snapshot int, events sdk.Events) error {
s.journal.append(precompileCallChange{
snapshot: snapshot,
events: events,
})
s.precompileCallsCounter++
if s.precompileCallsCounter > types.MaxPrecompileCalls {
return fmt.Errorf("max calls to precompiles (%d) reached", types.MaxPrecompileCalls)
Expand Down
Loading