diff --git a/action/protocol/execution/evm/evm.go b/action/protocol/execution/evm/evm.go index 5cba20c6af..0b7a83d370 100644 --- a/action/protocol/execution/evm/evm.go +++ b/action/protocol/execution/evm/evm.go @@ -325,8 +325,9 @@ func getChainConfig(g genesis.Blockchain, height uint64) *params.ChainConfig { if g.IsIceland(height) { chainConfig.ChainID = new(big.Int).SetUint64(uint64(config.EVMNetworkID())) } - // enable Berlin + // enable Berlin and London chainConfig.BerlinBlock = new(big.Int).SetUint64(g.ToBeEnabledBlockHeight) + chainConfig.LondonBlock = new(big.Int).SetUint64(g.ToBeEnabledBlockHeight) return &chainConfig } @@ -365,8 +366,10 @@ func executeInEVM(ctx context.Context, evmParams *Params, stateDB *StateDBAdapte var ( contractRawAddress = action.EmptyAddress executor = vm.AccountRef(evmParams.txCtx.Origin) + london = evm.ChainConfig().IsLondon(evm.Context.BlockNumber) ret []byte evmErr error + refund uint64 ) if evmParams.contract == nil { // create contract @@ -395,7 +398,11 @@ func executeInEVM(ctx context.Context, evmParams *Params, stateDB *StateDBAdapte if stateDB.Error() != nil { log.L().Debug("statedb error", zap.Error(stateDB.Error())) } - refund := (evmParams.gas - remainingGas) / 2 + if !london { + refund = (evmParams.gas - remainingGas) / params.RefundQuotient + } else { + refund = (evmParams.gas - remainingGas) / params.RefundQuotientEIP3529 + } if refund > stateDB.GetRefund() { refund = stateDB.GetRefund() } diff --git a/action/protocol/execution/evm/evm_test.go b/action/protocol/execution/evm/evm_test.go index 876d4d5a8f..999bf51eeb 100644 --- a/action/protocol/execution/evm/evm_test.go +++ b/action/protocol/execution/evm/evm_test.go @@ -9,6 +9,7 @@ package evm import ( "context" "errors" + "math" "math/big" "testing" @@ -149,14 +150,41 @@ func TestConstantinople(t *testing.T) { "io1pcg2ja9krrhujpazswgz77ss46xgt88afqlk6y", 12289321, }, - // after Jutland + // Jutland - Kamchatka { action.EmptyAddress, - 20000000, + 13685401, }, { "io1pcg2ja9krrhujpazswgz77ss46xgt88afqlk6y", - 20000000, + 13816440, + }, + // Kamchatka - LordHowe + { + action.EmptyAddress, + 13816441, + }, + { + "io1pcg2ja9krrhujpazswgz77ss46xgt88afqlk6y", + 13979160, + }, + // LordHowe - Midway + { + action.EmptyAddress, + 13979161, + }, + { + "io1pcg2ja9krrhujpazswgz77ss46xgt88afqlk6y", + 16509240, + }, + // after Midway + { + action.EmptyAddress, + 16509241, + }, + { + "io1pcg2ja9krrhujpazswgz77ss46xgt88afqlk6y", + math.MaxUint64, }, } @@ -235,12 +263,13 @@ func TestConstantinople(t *testing.T) { require.Equal(isIceland, evmChainConfig.IsMuirGlacier(evm.Context.BlockNumber)) require.Equal(isIceland, chainRules.IsIstanbul) - // enable Berlin + // enable Berlin and London isBerlin := g.IsToBeEnabled(e.height) require.Equal(isBerlin, evmChainConfig.IsBerlin(evm.Context.BlockNumber)) require.Equal(isBerlin, chainRules.IsBerlin) - require.False(evmChainConfig.IsLondon(evm.Context.BlockNumber)) - require.False(chainRules.IsLondon) + isLondon := g.IsToBeEnabled(e.height) + require.Equal(isLondon, evmChainConfig.IsLondon(evm.Context.BlockNumber)) + require.Equal(isLondon, chainRules.IsLondon) require.False(evmChainConfig.IsCatalyst(evm.Context.BlockNumber)) require.False(chainRules.IsCatalyst) }