@@ -1196,10 +1196,9 @@ func (s *StateDB) commit(deleteEmptyObjects bool) (*stateUpdate, error) {
1196
1196
storageTrieNodesUpdated int
1197
1197
storageTrieNodesDeleted int
1198
1198
1199
- lock sync.Mutex // protect two maps below
1200
- nodes = trienode .NewMergedNodeSet () // aggregated trie nodes
1201
- updates = make (map [common.Hash ]* accountUpdate , len (s .mutations )) // aggregated account updates
1202
- wasmCodeWriter = s .db .WasmStore ().NewBatch ()
1199
+ lock sync.Mutex // protect two maps below
1200
+ nodes = trienode .NewMergedNodeSet () // aggregated trie nodes
1201
+ updates = make (map [common.Hash ]* accountUpdate , len (s .mutations )) // aggregated account updates
1203
1202
1204
1203
// merge aggregates the dirty trie nodes into the global set.
1205
1204
//
@@ -1305,13 +1304,6 @@ func (s *StateDB) commit(deleteEmptyObjects bool) (*stateUpdate, error) {
1305
1304
return nil
1306
1305
})
1307
1306
}
1308
- // Arbitrum: write Stylus programs to disk
1309
- for moduleHash , asmMap := range s .arbExtraData .activatedWasms {
1310
- rawdb .WriteActivation (wasmCodeWriter , moduleHash , asmMap )
1311
- }
1312
- if len (s .arbExtraData .activatedWasms ) > 0 {
1313
- s .arbExtraData .activatedWasms = make (map [common.Hash ]ActivatedWasm )
1314
- }
1315
1307
// Wait for everything to finish and update the metrics
1316
1308
if err := workers .Wait (); err != nil {
1317
1309
return nil , err
@@ -1354,6 +1346,19 @@ func (s *StateDB) commitAndFlush(block uint64, deleteEmptyObjects bool) (*stateU
1354
1346
return nil , err
1355
1347
}
1356
1348
}
1349
+
1350
+ if db := s .db .WasmStore (); db != nil && len (s .arbExtraData .activatedWasms ) > 0 {
1351
+ batch := db .NewBatch ()
1352
+ // Arbitrum: write Stylus programs to disk
1353
+ for moduleHash , asmMap := range s .arbExtraData .activatedWasms {
1354
+ rawdb .WriteActivation (batch , moduleHash , asmMap )
1355
+ }
1356
+ s .arbExtraData .activatedWasms = make (map [common.Hash ]ActivatedWasm )
1357
+ if err := batch .Write (); err != nil {
1358
+ return nil , err
1359
+ }
1360
+ }
1361
+
1357
1362
if ! ret .empty () {
1358
1363
// If snapshotting is enabled, update the snapshot tree with this new version
1359
1364
if s .snap != nil {
0 commit comments