Avoid creating database transaction for every block (#2379)

Broadly, when importing blocks we don't need a transaction / frame per
block because we can simply abort the whole update and try again with a
smaller range if we find a faulty block.

Of course, this applies mainly to semi-trusted blocks where we're not
expected to fail in applying them - this could be blocks either from
files or header-verified blocks as given by consensus.
This commit is contained in:
Jacek Sieka 2024-06-17 15:28:44 +02:00 committed by GitHub
parent a6960c3d0a
commit 9cf7e6aea3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -165,10 +165,6 @@ proc processBlock*(
skipUncles: bool = false,
): Result[void, string] =
## Generalised function to processes `blk` for any network.
var dbTx = vmState.com.db.newTransaction()
defer:
dbTx.dispose()
?vmState.procBlkPreamble(blk, skipValidation, skipReceipts, skipUncles)
# EIP-3675: no reward for miner in POA/POS
@ -177,8 +173,6 @@ proc processBlock*(
?vmState.procBlkEpilogue(blk.header, skipValidation)
dbTx.commit()
ok()
# ------------------------------------------------------------------------------