Skip to content

Commit 7455a86

Browse files
authored
Merge branch 'merge-v1.14.6' into merge-v1.14.7
2 parents 800ead6 + c94acbc commit 7455a86

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

core/state/statedb.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,10 +1268,9 @@ func (s *StateDB) commit(deleteEmptyObjects bool) (*stateUpdate, error) {
12681268
storageTrieNodesUpdated int
12691269
storageTrieNodesDeleted int
12701270

1271-
lock sync.Mutex // protect two maps below
1272-
nodes = trienode.NewMergedNodeSet() // aggregated trie nodes
1273-
updates = make(map[common.Hash]*accountUpdate, len(s.mutations)) // aggregated account updates
1274-
wasmCodeWriter = s.db.WasmStore().NewBatch()
1271+
lock sync.Mutex // protect two maps below
1272+
nodes = trienode.NewMergedNodeSet() // aggregated trie nodes
1273+
updates = make(map[common.Hash]*accountUpdate, len(s.mutations)) // aggregated account updates
12751274

12761275
// merge aggregates the dirty trie nodes into the global set.
12771276
//
@@ -1374,13 +1373,6 @@ func (s *StateDB) commit(deleteEmptyObjects bool) (*stateUpdate, error) {
13741373
return nil
13751374
})
13761375
}
1377-
// Arbitrum: write Stylus programs to disk
1378-
for moduleHash, asmMap := range s.arbExtraData.activatedWasms {
1379-
rawdb.WriteActivation(wasmCodeWriter, moduleHash, asmMap)
1380-
}
1381-
if len(s.arbExtraData.activatedWasms) > 0 {
1382-
s.arbExtraData.activatedWasms = make(map[common.Hash]ActivatedWasm)
1383-
}
13841376
// Wait for everything to finish and update the metrics
13851377
if err := workers.Wait(); err != nil {
13861378
return nil, err
@@ -1423,6 +1415,19 @@ func (s *StateDB) commitAndFlush(block uint64, deleteEmptyObjects bool) (*stateU
14231415
return nil, err
14241416
}
14251417
}
1418+
1419+
if db := s.db.WasmStore(); db != nil && len(s.arbExtraData.activatedWasms) > 0 {
1420+
batch := db.NewBatch()
1421+
// Arbitrum: write Stylus programs to disk
1422+
for moduleHash, asmMap := range s.arbExtraData.activatedWasms {
1423+
rawdb.WriteActivation(batch, moduleHash, asmMap)
1424+
}
1425+
s.arbExtraData.activatedWasms = make(map[common.Hash]ActivatedWasm)
1426+
if err := batch.Write(); err != nil {
1427+
return nil, err
1428+
}
1429+
}
1430+
14261431
if !ret.empty() {
14271432
// If snapshotting is enabled, update the snapshot tree with this new version
14281433
if s.snap != nil {

0 commit comments

Comments
 (0)