diff --git a/action/protocol/execution/evm/evmstatedbadapter.go b/action/protocol/execution/evm/evmstatedbadapter.go index 2620899874..0e12f46d95 100644 --- a/action/protocol/execution/evm/evmstatedbadapter.go +++ b/action/protocol/execution/evm/evmstatedbadapter.go @@ -556,6 +556,27 @@ func (stateDB *StateDBAdapter) RevertToSnapshot(snapshot int) { // restore gas refund if !stateDB.manualCorrectGasRefund { stateDB.refund = stateDB.refundSnapshot[snapshot] + delete(stateDB.refundSnapshot, snapshot) + for i := snapshot + 1; ; i++ { + if _, ok := stateDB.refundSnapshot[i]; ok { + delete(stateDB.refundSnapshot, i) + } else { + break + } + } + } + // restore access list + stateDB.accessList = nil + stateDB.accessList = stateDB.accessListSnapshot[snapshot] + { + delete(stateDB.accessListSnapshot, snapshot) + for i := snapshot + 1; ; i++ { + if _, ok := stateDB.accessListSnapshot[i]; ok { + delete(stateDB.accessListSnapshot, i) + } else { + break + } + } } // restore logs and txLogs if stateDB.revertLog { @@ -624,19 +645,6 @@ func (stateDB *StateDBAdapter) RevertToSnapshot(snapshot int) { } } } - // restore access list - stateDB.accessList = nil - stateDB.accessList = stateDB.accessListSnapshot[snapshot] - { - delete(stateDB.accessListSnapshot, snapshot) - for i := snapshot + 1; ; i++ { - if _, ok := stateDB.accessListSnapshot[i]; ok { - delete(stateDB.accessListSnapshot, i) - } else { - break - } - } - } } func (stateDB *StateDBAdapter) cachedContractAddrs() []hash.Hash160 { diff --git a/action/protocol/execution/evm/evmstatedbadapter_test.go b/action/protocol/execution/evm/evmstatedbadapter_test.go index fcaf5f5167..b2da2cd081 100644 --- a/action/protocol/execution/evm/evmstatedbadapter_test.go +++ b/action/protocol/execution/evm/evmstatedbadapter_test.go @@ -634,10 +634,16 @@ func TestSnapshotRevertAndCommit(t *testing.T) { require.Equal(1, len(stateDB.contractSnapshot)) require.Equal(1, len(stateDB.suicideSnapshot)) require.Equal(1, len(stateDB.preimageSnapshot)) + require.Equal(1, len(stateDB.accessListSnapshot)) + require.Equal(1, len(stateDB.refundSnapshot)) } else { require.Equal(3, len(stateDB.contractSnapshot)) require.Equal(3, len(stateDB.suicideSnapshot)) require.Equal(3, len(stateDB.preimageSnapshot)) + // refund fix and accessList are introduced after fixSnapshot + // so their snapshot are always properly cleared + require.Zero(len(stateDB.accessListSnapshot)) + require.Zero(len(stateDB.refundSnapshot)) } // commit snapshot 0's state require.NoError(stateDB.CommitContracts()) diff --git a/api/web3server.go b/api/web3server.go index 54de6dfc13..ab02014c41 100644 --- a/api/web3server.go +++ b/api/web3server.go @@ -22,8 +22,8 @@ import ( "go.uber.org/zap" "github.com/iotexproject/iotex-core/action" - stakingabi "github.com/iotexproject/iotex-core/action/protocol/staking/ethabi" rewardingabi "github.com/iotexproject/iotex-core/action/protocol/rewarding/ethabi" + stakingabi "github.com/iotexproject/iotex-core/action/protocol/staking/ethabi" apitypes "github.com/iotexproject/iotex-core/api/types" "github.com/iotexproject/iotex-core/pkg/log" "github.com/iotexproject/iotex-core/pkg/tracer" diff --git a/go.mod b/go.mod index 0f618a277b..2eb7ac6e47 100644 --- a/go.mod +++ b/go.mod @@ -200,6 +200,6 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/ethereum/go-ethereum => github.com/iotexproject/go-ethereum v1.7.4-0.20221123031803-9e576f7b3e4b +replace github.com/ethereum/go-ethereum => github.com/iotexproject/go-ethereum v0.4.2 replace golang.org/x/xerrors => golang.org/x/xerrors v0.0.0-20190212162355-a5947ffaace3 diff --git a/go.sum b/go.sum index d7afac391c..c5f000b1fe 100644 --- a/go.sum +++ b/go.sum @@ -486,8 +486,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/iotexproject/go-ethereum v1.7.4-0.20221123031803-9e576f7b3e4b h1:ImtTdFM8yaH8mYL4sd4idxHiV5J0r12B1SYiyBezdCs= -github.com/iotexproject/go-ethereum v1.7.4-0.20221123031803-9e576f7b3e4b/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= +github.com/iotexproject/go-ethereum v0.4.2 h1:aXfCHX4tL6/Gnh24p4KZGwiKmu63bjMrAAshPRBp6Pk= +github.com/iotexproject/go-ethereum v0.4.2/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= github.com/iotexproject/go-fsm v1.0.0 h1:Zrg9JnNDUZg4Anpj6oa0Tk4+sXbHTpJzI0v5/Cj5N6A= github.com/iotexproject/go-fsm v1.0.0/go.mod h1:t3aYXtCCcQxyS7oduQZyuUpPnVI4ddFTwbAagHN7fT0= github.com/iotexproject/go-p2p v0.3.5 h1:F71XxYQtR25youD+dCXnMgtfiCKGUFh8KDIqU7u5xOk=