Skip to content

Commit 6205f5e

Browse files
address PR comments
1 parent e9a5f8a commit 6205f5e

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

core/state/statedb.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package state
1919

2020
import (
2121
"bytes"
22-
"errors"
2322
"fmt"
2423
"maps"
2524
"math/big"
@@ -75,8 +74,6 @@ func (m *mutation) isDelete() bool {
7574
return m.typ == deletion
7675
}
7776

78-
var ErrArbTxFilter error = errors.New("internal error")
79-
8077
// StateDB structs within the ethereum protocol are used to store anything
8178
// within the merkle trie. StateDBs take care of caching and storing
8279
// nested states. It's the general query interface to retrieve:
@@ -90,7 +87,6 @@ var ErrArbTxFilter error = errors.New("internal error")
9087
// commit states.
9188
type StateDB struct {
9289
arbExtraData *ArbitrumExtraData // must be a pointer - can't be a part of StateDB allocation, otherwise its finalizer might not get called
93-
arbTxFilter bool
9490

9591
db Database
9692
prefetcher *triePrefetcher
@@ -225,13 +221,11 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error)
225221
}
226222

227223
func (s *StateDB) FilterTx() {
228-
if !s.arbTxFilter {
229-
s.arbTxFilter = true
230-
}
224+
s.arbExtraData.arbTxFilter = true
231225
}
232226

233227
func (s *StateDB) IsTxFiltered() bool {
234-
return s.arbTxFilter
228+
return s.arbExtraData.arbTxFilter
235229
}
236230

237231
// SetLogger sets the logger for account update hooks.
@@ -751,6 +745,7 @@ func (s *StateDB) Copy() *StateDB {
751745
recentWasms: s.arbExtraData.recentWasms.Copy(),
752746
openWasmPages: s.arbExtraData.openWasmPages,
753747
everWasmPages: s.arbExtraData.everWasmPages,
748+
arbTxFilter: s.arbExtraData.arbTxFilter,
754749
},
755750

756751
db: s.db,
@@ -834,7 +829,7 @@ func (s *StateDB) Copy() *StateDB {
834829
func (s *StateDB) Snapshot() int {
835830
id := s.nextRevisionId
836831
s.nextRevisionId++
837-
s.validRevisions = append(s.validRevisions, revision{id, s.journal.length(), new(big.Int).Set(s.arbExtraData.unexpectedBalanceDelta), s.arbTxFilter})
832+
s.validRevisions = append(s.validRevisions, revision{id, s.journal.length(), new(big.Int).Set(s.arbExtraData.unexpectedBalanceDelta), s.arbExtraData.arbTxFilter})
838833
return id
839834
}
840835

@@ -850,7 +845,7 @@ func (s *StateDB) RevertToSnapshot(revid int) {
850845
revision := s.validRevisions[idx]
851846
snapshot := revision.journalIndex
852847
s.arbExtraData.unexpectedBalanceDelta = new(big.Int).Set(revision.unexpectedBalanceDelta)
853-
s.arbTxFilter = revision.arbTxFilter
848+
s.arbExtraData.arbTxFilter = revision.arbTxFilter
854849

855850
// Replay the journal to undo changes and remove invalidated snapshots
856851
s.journal.revert(s, snapshot)
@@ -1236,7 +1231,7 @@ func (s *StateDB) GetTrie() Trie {
12361231
// The associated block number of the state transition is also provided
12371232
// for more chain context.
12381233
func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) {
1239-
if s.arbTxFilter {
1234+
if s.arbExtraData.arbTxFilter {
12401235
return common.Hash{}, ErrArbTxFilter
12411236
}
12421237
// Short circuit in case any database failure occurred earlier.

core/state/statedb_arbitrum.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,16 @@ func (s *StateDB) Deterministic() bool {
164164
return s.deterministic
165165
}
166166

167+
var ErrArbTxFilter error = errors.New("internal error")
168+
167169
type ArbitrumExtraData struct {
168170
unexpectedBalanceDelta *big.Int // total balance change across all accounts
169171
userWasms UserWasms // user wasms encountered during execution
170172
openWasmPages uint16 // number of pages currently open
171173
everWasmPages uint16 // largest number of pages ever allocated during this tx's execution
172174
activatedWasms map[common.Hash]ActivatedWasm // newly activated WASMs
173175
recentWasms RecentWasms
176+
arbTxFilter bool
174177
}
175178

176179
func (s *StateDB) SetArbFinalizer(f func(*ArbitrumExtraData)) {

0 commit comments

Comments
 (0)