@@ -1268,10 +1268,9 @@ func (s *StateDB) commit(deleteEmptyObjects bool) (*stateUpdate, error) {
1268
1268
storageTrieNodesUpdated int
1269
1269
storageTrieNodesDeleted int
1270
1270
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
1275
1274
1276
1275
// merge aggregates the dirty trie nodes into the global set.
1277
1276
//
@@ -1374,13 +1373,6 @@ func (s *StateDB) commit(deleteEmptyObjects bool) (*stateUpdate, error) {
1374
1373
return nil
1375
1374
})
1376
1375
}
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
- }
1384
1376
// Wait for everything to finish and update the metrics
1385
1377
if err := workers .Wait (); err != nil {
1386
1378
return nil , err
@@ -1423,6 +1415,19 @@ func (s *StateDB) commitAndFlush(block uint64, deleteEmptyObjects bool) (*stateU
1423
1415
return nil , err
1424
1416
}
1425
1417
}
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
+
1426
1431
if ! ret .empty () {
1427
1432
// If snapshotting is enabled, update the snapshot tree with this new version
1428
1433
if s .snap != nil {
0 commit comments