From c95ad0432bd98bba2aaf94ac57ff78eadca9ec57 Mon Sep 17 00:00:00 2001 From: KamiD <44460798+KamiD@users.noreply.github.com> Date: Fri, 29 Jan 2021 00:30:38 +0800 Subject: [PATCH] x/evm: open eip2028 when the version of Istanbul was enabled (#731) * open eip2028 when Istanbul version enabled * Update x/evm/types/chain_config.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/evm/types/chain_config.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * add change log * update development * fix rpc test error Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> --- CHANGELOG.md | 2 ++ tests/rpc_test.go | 2 +- x/evm/types/chain_config.go | 10 ++++++++++ x/evm/types/state_transition.go | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f26394c..dab4eb58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (evm) [\#670](https://github.com/cosmos/ethermint/pull/670) Migrate types to the ones defined by the protobuf messages, which are required for the stargate release. ### Bug Fixes + +* (evm) [\#730](https://github.com/cosmos/ethermint/issues/730) Fix 'EIP2028' not open when Istanbul version has been enabled. * (evm) [\#749](https://github.com/cosmos/ethermint/issues/749) Fix panic in `AnteHandler` when gas price larger than 100000 * (evm) [\#747](https://github.com/cosmos/ethermint/issues/747) Fix format errors in String() of QueryETHLogs * (evm) [\#742](https://github.com/cosmos/ethermint/issues/742) Add parameter check for evm query func. diff --git a/tests/rpc_test.go b/tests/rpc_test.go index c1813dfe..b69f90ae 100644 --- a/tests/rpc_test.go +++ b/tests/rpc_test.go @@ -558,7 +558,7 @@ func TestEth_EstimateGas_ContractDeployment(t *testing.T) { err := json.Unmarshal(rpcRes.Result, &gas) require.NoError(t, err, string(rpcRes.Result)) - require.Equal(t, "0x1c2c4", gas.String()) + require.Equal(t, "0x1a724", gas.String()) } func TestEth_GetBlockByNumber(t *testing.T) { diff --git a/x/evm/types/chain_config.go b/x/evm/types/chain_config.go index c3725c5a..9d0f1ec7 100644 --- a/x/evm/types/chain_config.go +++ b/x/evm/types/chain_config.go @@ -66,6 +66,16 @@ func (cc ChainConfig) EthereumConfig(chainID *big.Int) *params.ChainConfig { } } +// IsIstanbul returns whether the Istanbul version is enabled. +func (cc ChainConfig) IsIstanbul() bool { + return getBlockValue(cc.IstanbulBlock) != nil +} + +// IsHomestead returns whether the Homestead version is enabled. +func (cc ChainConfig) IsHomestead() bool { + return getBlockValue(cc.HomesteadBlock) != nil +} + // String implements the fmt.Stringer interface func (cc ChainConfig) String() string { out, _ := yaml.Marshal(cc) diff --git a/x/evm/types/state_transition.go b/x/evm/types/state_transition.go index 79332069..f9a5ffd8 100644 --- a/x/evm/types/state_transition.go +++ b/x/evm/types/state_transition.go @@ -115,7 +115,7 @@ func (st StateTransition) newEVM( func (st StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (*ExecutionResult, error) { contractCreation := st.Recipient == nil - cost, err := core.IntrinsicGas(st.Payload, contractCreation, true, false) + cost, err := core.IntrinsicGas(st.Payload, contractCreation, config.IsHomestead(), config.IsIstanbul()) if err != nil { return nil, sdkerrors.Wrap(err, "invalid intrinsic gas for transaction") }