Use PooledTransaction in nimbus-eth1 tests

This commit is contained in:
jangko 2024-05-14 17:44:15 +07:00
parent 0023d704eb
commit 82455d1c99
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
7 changed files with 31 additions and 38 deletions

View File

@ -82,7 +82,7 @@ proc put*(api: var PayloadQueue, id: PayloadID,
blobsBundle: Option[BlobsBundleV1]) =
doAssert blobsBundle.isNone == (payload is
ExecutionPayloadV1 | ExecutionPayloadV2)
api.put(id, blockValue, payload.executionPayload, blobsBundle: blobsBundle)
api.put(id, blockValue, payload.executionPayload, blobsBundle = blobsBundle)
proc put*(api: var PayloadQueue, id: PayloadID,
blockValue: UInt256,

View File

@ -134,7 +134,12 @@ proc debug*(tx: Transaction): string =
result.add "accessList : " & $tx.accessList & "\n"
result.add "maxFeePerBlobGas: " & $tx.maxFeePerBlobGas & "\n"
result.add "versionedHashes.len: " & $tx.versionedHashes.len & "\n"
result.add "V : " & $tx.V & "\n"
result.add "R : " & $tx.R & "\n"
result.add "S : " & $tx.S & "\n"
proc debug*(tx: PooledTransaction): string =
result.add debug(tx.tx)
if tx.networkPayload.isNil:
result.add "networkPaylod : nil\n"
else:
@ -143,10 +148,6 @@ proc debug*(tx: Transaction): string =
result.add " - commitments : " & $tx.networkPayload.commitments.len & "\n"
result.add " - proofs : " & $tx.networkPayload.proofs.len & "\n"
result.add "V : " & $tx.V & "\n"
result.add "R : " & $tx.R & "\n"
result.add "S : " & $tx.S & "\n"
proc debugSum*(h: BlockHeader): string =
result.add "txRoot : " & $h.txRoot & "\n"
result.add "ommersHash : " & $h.ommersHash & "\n"

View File

@ -100,7 +100,6 @@ func pp*(t: Transaction; sep = " "): string =
&"accessList=[#{t.accessList.len}]{sep}" &
&"maxFeePerBlobGas={t.maxFeePerBlobGas}{sep}" &
&"versionedHashes=[#{t.versionedHashes.len}]{sep}" &
&"networkPayload={t.networkPayload.pp}{sep}" &
&"V={t.V}{sep}" &
&"R={t.R}{sep}" &
&"S={t.S}{sep}"

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2023 Status Research & Development GmbH
# Copyright (c) 2023-2024 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
@ -16,11 +16,9 @@ import
const
recipient = hexToByteArray[20]("095e7baea6a6c7c4c2dfeb977efac326af552d87")
zeroG1 = hexToByteArray[48]("0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
source = hexToByteArray[20]("0x0000000000000000000000000000000000000001")
storageKey= default(StorageKey)
accesses = @[AccessPair(address: source, storageKeys: @[storageKey])]
blob = default(NetworkBlob)
abcdef = hexToSeqByte("abcdef")
hexKey = "af1a9be9f1a54421cac82943820a0fe0f601bb5f4f6d0bccc81c613f0ce6ae22"
senderTop = hexToByteArray[20]("73cf19657412508833f618a15e8251306b3e6ee5")
@ -98,12 +96,7 @@ proc tx6(i: int): Transaction =
maxPriorityFee: 42.GasInt,
maxFee: 10.GasInt,
accessList: accesses,
versionedHashes: @[digest],
networkPayload: NetworkPayload(
commitments: @[zeroG1],
blobs: @[blob],
proofs: @[zeroG1],
)
versionedHashes: @[digest]
)
proc tx7(i: int): Transaction =

View File

@ -287,7 +287,7 @@ proc runTxPoolTests(noisy = true) =
# insert some txs
for triple in testTxs:
xq.add(triple[1], triple[0].info)
xq.add(PooledTransaction(tx: triple[1]), triple[0].info)
check xq.nItems.total == testTxs.len
check xq.nItems.disposed == 0
@ -296,7 +296,7 @@ proc runTxPoolTests(noisy = true) =
# re-insert modified transactions
for triple in testTxs:
xq.add(triple[2], "alt " & triple[0].info)
xq.add(PooledTransaction(tx: triple[2]), "alt " & triple[0].info)
check xq.nItems.total == testTxs.len
check xq.nItems.disposed == testTxs.len
@ -505,7 +505,7 @@ proc runTxPoolTests(noisy = true) =
check txList.len == xq.nItems.total + xq.nItems.disposed
# re-add item
xq.add(thisItem.tx)
xq.add(thisItem.pooledTx)
# verify that the pivot item was moved out from the waste basket
check not xq.txDB.byRejects.hasKey(thisItem.itemID)
@ -793,7 +793,7 @@ proc runTxPackerTests(noisy = true) =
check false
return
let blk = r.get
let blk = r.get.blk
# Make sure that there are at least two txs on the packed block so
# this test does not degenerate.
check 1 < xq.chain.receipts.len

View File

@ -103,7 +103,7 @@ proc toTxPool*(
status = statusInfo[getStatus()]
info = &"{txCount} #{num}({chainNo}) {n}/{txs.len} {status}"
noisy.showElapsed(&"insert: {info}"):
result[0].add(txs[n], info)
result[0].add(PooledTransaction(tx: txs[n]), info)
if loadTxs <= txCount:
break
@ -132,11 +132,11 @@ proc toTxPool*(
noisy.showElapsed(&"Loading {itList.len} transactions"):
for item in itList:
if noLocals:
result.add(item.tx, item.info)
result.add(item.pooledTx, item.info)
elif localAddr.hasKey(item.sender):
doAssert result.addLocal(item.tx, true).isOk
doAssert result.addLocal(item.pooledTx, true).isOk
else:
doAssert result.addRemote(item.tx, true).isOk
doAssert result.addRemote(item.pooledTx, true).isOk
doAssert result.nItems.total == itList.len
@ -174,11 +174,11 @@ proc toTxPool*(
for n in 0 ..< itList.len:
let item = itList[n]
if noLocals:
result.add(item.tx, item.info)
result.add(item.pooledTx, item.info)
elif localAddr.hasKey(item.sender):
doAssert result.addLocal(item.tx, true).isOk
doAssert result.addLocal(item.pooledTx, true).isOk
else:
doAssert result.addRemote(item.tx, true).isOk
doAssert result.addRemote(item.pooledTx, true).isOk
if n < 3 or delayAt-3 <= n and n <= delayAt+3 or itList.len-4 < n:
let t = result.getItem(item.itemID).value.timeStamp.format(tFmt, utc())
noisy.say &"added item {n} time={t}"

View File

@ -156,7 +156,7 @@ proc runTxPoolCliqueTest*() =
suite "Test TxPool with Clique sealer":
test "TxPool addLocal":
let res = xp.addLocal(tx, force = true)
let res = xp.addLocal(PooledTransaction(tx: tx), force = true)
check res.isOk
if res.isErr:
debugEcho res.error
@ -172,7 +172,7 @@ proc runTxPoolCliqueTest*() =
check false
return
blk = res.get
blk = res.get.blk
body = BlockBody(
transactions: blk.txs,
uncles: blk.uncles
@ -201,7 +201,7 @@ proc runTxPoolCliqueTest*() =
check xp.smartHead(blk.header)
let tx = env.makeTx(recipient, amount)
let res = xp.addLocal(tx, force = true)
let res = xp.addLocal(PooledTransaction(tx: tx), force = true)
check res.isOk
if res.isErr:
debugEcho res.error
@ -214,7 +214,7 @@ proc runTxPoolCliqueTest*() =
check false
return
blk = r.get
blk = r.get.blk
body = BlockBody(
transactions: blk.txs,
uncles: blk.uncles
@ -249,7 +249,7 @@ proc runTxPoolPosTest*() =
suite "Test TxPool with PoS block":
test "TxPool addLocal":
let res = xp.addLocal(tx, force = true)
let res = xp.addLocal(PooledTransaction(tx: tx), force = true)
check res.isOk
if res.isErr:
debugEcho res.error
@ -269,7 +269,7 @@ proc runTxPoolPosTest*() =
check false
return
blk = r.get
blk = r.get.blk
check com.isBlockAfterTtd(blk.header)
body = BlockBody(
@ -310,12 +310,12 @@ proc runTxPoolBlobhashTest*() =
suite "Test TxPool with blobhash block":
test "TxPool addLocal":
let res = xp.addLocal(tx1, force = true)
let res = xp.addLocal(PooledTransaction(tx: tx1), force = true)
check res.isOk
if res.isErr:
debugEcho res.error
return
let res2 = xp.addLocal(tx2, force = true)
let res2 = xp.addLocal(PooledTransaction(tx: tx2), force = true)
check res2.isOk
test "TxPool jobCommit":
@ -332,7 +332,7 @@ proc runTxPoolBlobhashTest*() =
check false
return
blk = r.get
blk = r.get.blk
check com.isBlockAfterTtd(blk.header)
body = BlockBody(
@ -366,7 +366,7 @@ proc runTxPoolBlobhashTest*() =
xp = env.xp
check xp.smartHead(blk.header)
let res = xp.addLocal(tx4, force = true)
let res = xp.addLocal(PooledTransaction(tx: tx4), force = true)
check res.isOk
if res.isErr:
debugEcho res.error
@ -400,7 +400,7 @@ proc runTxHeadDelta*(noisy = true) =
let tx = env.makeTx(recipient, amount)
# Instead of `add()`, the functions `addRemote()` or `addLocal()`
# also would do.
xp.add(tx)
xp.add(PooledTransaction(tx: tx))
noisy.say "***", "txDB",
&" n={n}",
@ -418,7 +418,7 @@ proc runTxHeadDelta*(noisy = true) =
check false
return
let blk = r.get
let blk = r.get.blk
check com.isBlockAfterTtd(blk.header)
let body = BlockBody(