mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-14 22:34:23 +00:00
txpool: use common txroot computation (#2755)
Avoids CoreDb overhead for this simple operation
This commit is contained in:
parent
133387e6a7
commit
d4bb2088ea
@ -500,6 +500,7 @@ proc assembleBlock*(
|
|||||||
blobsBundle.proofs.add p
|
blobsBundle.proofs.add p
|
||||||
for blob in tx.networkPayload.blobs:
|
for blob in tx.networkPayload.blobs:
|
||||||
blobsBundle.blobs.add blob
|
blobsBundle.blobs.add blob
|
||||||
|
blk.header.transactionsRoot = calcTxRoot(blk.txs)
|
||||||
|
|
||||||
let com = xp.vmState.com
|
let com = xp.vmState.com
|
||||||
if com.isShanghaiOrLater(blk.header.timestamp):
|
if com.isShanghaiOrLater(blk.header.timestamp):
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
stew/sorted_set,
|
stew/sorted_set,
|
||||||
../../db/[ledger, core_db],
|
../../db/ledger,
|
||||||
../../common/common,
|
../../common/common,
|
||||||
../../utils/utils,
|
../../utils/utils,
|
||||||
../../constants,
|
../../constants,
|
||||||
@ -34,14 +34,12 @@ type
|
|||||||
# Packer state
|
# Packer state
|
||||||
vmState: BaseVMState
|
vmState: BaseVMState
|
||||||
txDB: TxTabsRef
|
txDB: TxTabsRef
|
||||||
tr: CoreDbMptRef
|
|
||||||
cleanState: bool
|
cleanState: bool
|
||||||
numBlobPerBlock: int
|
numBlobPerBlock: int
|
||||||
|
|
||||||
# Packer results
|
# Packer results
|
||||||
blockValue: UInt256
|
blockValue: UInt256
|
||||||
stateRoot: Hash32
|
stateRoot: Hash32
|
||||||
txRoot: Hash32
|
|
||||||
receiptsRoot: Hash32
|
receiptsRoot: Hash32
|
||||||
logsBloom: Bloom
|
logsBloom: Bloom
|
||||||
|
|
||||||
@ -161,10 +159,6 @@ proc runTxCommit(pst: var TxPacker; item: TxItemRef; gasBurned: GasInt)
|
|||||||
vmState.cumulativeGasUsed += gasBurned
|
vmState.cumulativeGasUsed += gasBurned
|
||||||
vmState.receipts[inx] = vmState.makeReceipt(item.tx.txType)
|
vmState.receipts[inx] = vmState.makeReceipt(item.tx.txType)
|
||||||
|
|
||||||
# Update txRoot
|
|
||||||
pst.tr.merge(rlp.encode(inx.uint64), rlp.encode(item.tx)).isOkOr:
|
|
||||||
raiseAssert "runTxCommit(): merge failed, " & $$error
|
|
||||||
|
|
||||||
# Add the item to the `packed` bucket. This implicitely increases the
|
# Add the item to the `packed` bucket. This implicitely increases the
|
||||||
# receipts index `inx` at the next visit of this function.
|
# receipts index `inx` at the next visit of this function.
|
||||||
discard pst.txDB.reassign(item,txItemPacked)
|
discard pst.txDB.reassign(item,txItemPacked)
|
||||||
@ -182,10 +176,8 @@ proc vmExecInit(xp: TxPoolRef): Result[TxPacker, string]
|
|||||||
let packer = TxPacker(
|
let packer = TxPacker(
|
||||||
vmState: xp.vmState,
|
vmState: xp.vmState,
|
||||||
txDB: xp.txDB,
|
txDB: xp.txDB,
|
||||||
tr: AristoDbMemory.newCoreDbRef().ctx.getGeneric(clearData=true),
|
|
||||||
numBlobPerBlock: 0,
|
numBlobPerBlock: 0,
|
||||||
blockValue: 0.u256,
|
blockValue: 0.u256,
|
||||||
txRoot: EMPTY_ROOT_HASH,
|
|
||||||
stateRoot: xp.vmState.parent.stateRoot,
|
stateRoot: xp.vmState.parent.stateRoot,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -267,8 +259,6 @@ proc vmExecCommit(pst: var TxPacker) =
|
|||||||
|
|
||||||
pst.receiptsRoot = vmState.receipts.calcReceiptsRoot
|
pst.receiptsRoot = vmState.receipts.calcReceiptsRoot
|
||||||
pst.logsBloom = vmState.receipts.createBloom
|
pst.logsBloom = vmState.receipts.createBloom
|
||||||
pst.txRoot = pst.tr.state(updateOk=true).valueOr:
|
|
||||||
raiseAssert "vmExecCommit(): state() failed " & $$error
|
|
||||||
pst.stateRoot = vmState.stateDB.rootHash
|
pst.stateRoot = vmState.stateDB.rootHash
|
||||||
|
|
||||||
|
|
||||||
@ -314,7 +304,6 @@ proc assembleHeader*(pst: TxPacker): Header =
|
|||||||
ommersHash: EMPTY_UNCLE_HASH,
|
ommersHash: EMPTY_UNCLE_HASH,
|
||||||
coinbase: pos.feeRecipient,
|
coinbase: pos.feeRecipient,
|
||||||
stateRoot: pst.stateRoot,
|
stateRoot: pst.stateRoot,
|
||||||
transactionsRoot: pst.txRoot,
|
|
||||||
receiptsRoot: pst.receiptsRoot,
|
receiptsRoot: pst.receiptsRoot,
|
||||||
logsBloom: pst.logsBloom,
|
logsBloom: pst.logsBloom,
|
||||||
difficulty: UInt256.zero(),
|
difficulty: UInt256.zero(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user