diff --git a/core/state/statedb.go b/core/state/statedb.go index acdad20481..ca9f778e0a 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -219,6 +219,18 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error) return sdb, nil } +func (s *StateDB) FilterTx() { + s.arbExtraData.arbTxFilter = true +} + +func (s *StateDB) ClearTxFilter() { + s.arbExtraData.arbTxFilter = false +} + +func (s *StateDB) IsTxFiltered() bool { + return s.arbExtraData.arbTxFilter +} + // SetLogger sets the logger for account update hooks. func (s *StateDB) SetLogger(l *tracing.Hooks) { s.logger = l @@ -736,6 +748,7 @@ func (s *StateDB) Copy() *StateDB { recentWasms: s.arbExtraData.recentWasms.Copy(), openWasmPages: s.arbExtraData.openWasmPages, everWasmPages: s.arbExtraData.everWasmPages, + arbTxFilter: s.arbExtraData.arbTxFilter, }, db: s.db, @@ -1220,6 +1233,9 @@ func (s *StateDB) GetTrie() Trie { // The associated block number of the state transition is also provided // for more chain context. func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) { + if s.arbExtraData.arbTxFilter { + return common.Hash{}, ErrArbTxFilter + } // Short circuit in case any database failure occurred earlier. if s.dbErr != nil { return common.Hash{}, fmt.Errorf("commit aborted due to earlier error: %v", s.dbErr) diff --git a/core/state/statedb_arbitrum.go b/core/state/statedb_arbitrum.go index 3a1cd28ce3..2f34effed1 100644 --- a/core/state/statedb_arbitrum.go +++ b/core/state/statedb_arbitrum.go @@ -164,6 +164,8 @@ func (s *StateDB) Deterministic() bool { return s.deterministic } +var ErrArbTxFilter error = errors.New("internal error") + type ArbitrumExtraData struct { unexpectedBalanceDelta *big.Int // total balance change across all accounts userWasms UserWasms // user wasms encountered during execution @@ -171,6 +173,7 @@ type ArbitrumExtraData struct { everWasmPages uint16 // largest number of pages ever allocated during this tx's execution activatedWasms map[common.Hash]ActivatedWasm // newly activated WASMs recentWasms RecentWasms + arbTxFilter bool } func (s *StateDB) SetArbFinalizer(f func(*ArbitrumExtraData)) { diff --git a/core/vm/interface.go b/core/vm/interface.go index 9b7e26ad59..c04aec6f8c 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -48,6 +48,11 @@ type StateDB interface { // Arbitrum: preserve old empty account behavior CreateZombieIfDeleted(common.Address) + // Arbitrum + FilterTx() + ClearTxFilter() + IsTxFiltered() bool + Deterministic() bool Database() state.Database