Skip to content
Open
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 @@ -20,6 +20,7 @@
- [\#589](https://github.com/cosmos/evm/pull/589) Remove parallelization blockers via migration from transient to object store, refactoring of gas, indexing, and bloom utilities.
- [\#768](https://github.com/cosmos/evm/pull/768) Added ICS-02 Client Router precompile
- [\#815](https://github.com/cosmos/evm/pull/815) Support for multi gRPC query clients serve with old binary.
- [\#1096](https://github.com/cosmos/evm/pull/1096) Allow eth_call overrides work with static precompiles.

### BUG FIXES

Expand Down
30 changes: 30 additions & 0 deletions tests/integration/x/vm/test_state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ func (s *KeeperTestSuite) TestApplyMessageWithConfig() {
testAddr := utiltx.GenerateAddress()
balance := (*hexutil.Big)(big.NewInt(1000000000000000000))
nonce := hexutil.Uint64(0)
movedStaticPrecompileAddr := utiltx.GenerateAddress()

overrides := rpctypes.StateOverride{
testAddr: rpctypes.OverrideAccount{
Expand All @@ -931,6 +932,12 @@ func (s *KeeperTestSuite) TestApplyMessageWithConfig() {
},
}

staticPrecompileMoveOverrides := rpctypes.StateOverride{
common.HexToAddress(types.DistributionPrecompileAddress): rpctypes.OverrideAccount{
MovePrecompileTo: &movedStaticPrecompileAddr,
},
}

testCases := []struct {
name string
getMessage func() core.Message
Expand Down Expand Up @@ -1104,6 +1111,29 @@ func (s *KeeperTestSuite) TestApplyMessageWithConfig() {
expVMErr: false,
expectedGasUsed: params.TxGas,
},
{
name: "success - move cosmos static precompile with state overrides",
getMessage: func() core.Message {
sender := s.Keyring.GetKey(0)
recipient := s.Keyring.GetAddr(1)
msg, err := s.Factory.GenerateGethCoreMsg(sender.Priv, types.EvmTxArgs{
To: &recipient,
Amount: big.NewInt(100),
})
s.Require().NoError(err)
return *msg
},
getEVMParams: func() types.Params {
params := types.DefaultParams()
params.ActiveStaticPrecompiles = append([]string(nil), types.AvailableStaticPrecompiles...)
return params
},
getFeeMarketParams: feemarkettypes.DefaultParams,
overrides: &staticPrecompileMoveOverrides,
expErr: false,
expVMErr: false,
expectedGasUsed: params.TxGas,
},
{
name: "call contract tx with config param EnableCall = false",
getMessage: func() core.Message {
Expand Down
7 changes: 7 additions & 0 deletions x/vm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,13 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, stateDB *statedb.StateD
rules := ethCfg.Rules(evm.Context.BlockNumber, true, evm.Context.Time)
if overrides != nil {
precompiles := vm.ActivePrecompiledContracts(rules)
params := k.GetParams(ctx)
for _, precompileAddr := range params.ActiveStaticPrecompiles {
address := common.HexToAddress(precompileAddr)
if precompile, found := k.precompiles[address]; found {
precompiles[address] = precompile
}
}
if err := overrides.Apply(stateDB, precompiles); err != nil {
return nil, errorsmod.Wrap(err, "failed to apply state override")
}
Expand Down
Loading