Skip to content

Commit

Permalink
handle new fields in statedb
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-bousfield committed Jun 13, 2023
1 parent c8c33a2 commit f997cb3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error)
}
sdb := &StateDB{
unexpectedBalanceDelta: new(big.Int),
userWasms: make(UserWasms),
openWasmPages: 0,
everWasmPages: 0,

db: db,
trie: tr,
Expand Down Expand Up @@ -725,6 +728,9 @@ func (s *StateDB) Copy() *StateDB {
// Copy all the basic fields, initialize the memory ones
state := &StateDB{
unexpectedBalanceDelta: new(big.Int).Set(s.unexpectedBalanceDelta),
userWasms: make(UserWasms, len(s.userWasms)),
openWasmPages: s.openWasmPages,
everWasmPages: s.everWasmPages,

db: s.db,
trie: s.db.CopyTrie(s.trie),
Expand Down Expand Up @@ -796,6 +802,11 @@ func (s *StateDB) Copy() *StateDB {
state.accessList = s.accessList.Copy()
state.transientStorage = s.transientStorage.Copy()

// Arbitrum: copy wasm calls
for call, wasm := range s.userWasms {
state.userWasms[call] = wasm
}

// If there's a prefetcher running, make an inactive copy of it that can
// only access data but does not actively preload (since the user will not
// know that they need to explicitly terminate an active copy).
Expand Down Expand Up @@ -989,6 +1000,10 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
func (s *StateDB) SetTxContext(thash common.Hash, ti int) {
s.thash = thash
s.txIndex = ti

// Arbitrum: clear memory charging state for new tx
s.openWasmPages = 0
s.everWasmPages = 0
}

func (s *StateDB) clearJournalAndRefund() {
Expand Down

0 comments on commit f997cb3

Please sign in to comment.