eth: avoid sink (#2331)

* eth: avoid sink

* bump

* fix extra transactions

from #2330
This commit is contained in:
Jacek Sieka 2024-06-10 09:16:22 +02:00 committed by GitHub
parent 0b32078c4b
commit 359f7ada65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 19 deletions

View File

@ -719,18 +719,18 @@ proc getWithdrawals*(
proc getTransactions*( proc getTransactions*(
db: CoreDbRef; db: CoreDbRef;
header: BlockHeader; txRoot: Hash256;
output: var seq[Transaction]) output: var seq[Transaction])
{.gcsafe, raises: [RlpError].} = {.gcsafe, raises: [RlpError].} =
for encodedTx in db.getBlockTransactionData(header.txRoot): for encodedTx in db.getBlockTransactionData(txRoot):
output.add(rlp.decode(encodedTx, Transaction)) output.add(rlp.decode(encodedTx, Transaction))
proc getTransactions*( proc getTransactions*(
db: CoreDbRef; db: CoreDbRef;
header: BlockHeader; txRoot: Hash256;
): seq[Transaction] ): seq[Transaction]
{.gcsafe, raises: [RlpError].} = {.gcsafe, raises: [RlpError].} =
db.getTransactions(header, result) db.getTransactions(txRoot, result)
proc getBlockBody*( proc getBlockBody*(
db: CoreDbRef; db: CoreDbRef;
@ -738,23 +738,12 @@ proc getBlockBody*(
output: var BlockBody; output: var BlockBody;
): bool ): bool
{.gcsafe, raises: [RlpError].} = {.gcsafe, raises: [RlpError].} =
db.getTransactions(header, output.transactions) output.transactions = db.getTransactions(header.txRoot)
output.uncles = @[] output.uncles = db.getUncles(header.ommersHash)
for encodedTx in db.getBlockTransactionData(header.txRoot):
output.transactions.add(rlp.decode(encodedTx, Transaction))
if header.withdrawalsRoot.isSome: if header.withdrawalsRoot.isSome:
output.withdrawals = some(db.getWithdrawals(header.withdrawalsRoot.get)) output.withdrawals = some(db.getWithdrawals(header.withdrawalsRoot.get))
if header.ommersHash != EMPTY_UNCLE_HASH:
let
key = genericHashKey(header.ommersHash)
encodedUncles = db.newKvt().get(key.toOpenArray).valueOr:
if error.error == KvtNotFound:
warn logTxt "getBlockBody()",
ommersHash=header.ommersHash, action="get()", `error`=($$error)
return false
output.uncles = rlp.decode(encodedUncles, seq[BlockHeader])
true true
proc getBlockBody*( proc getBlockBody*(

View File

@ -62,7 +62,7 @@ proc setupDebugRpc*(com: CommonRef, txPool: TxPoolRef, rpcsrv: RpcServer) =
txHash = ethHash(data) txHash = ethHash(data)
txDetails = chainDB.getTransactionKey(txHash) txDetails = chainDB.getTransactionKey(txHash)
header = chainDB.getBlockHeader(txDetails.blockNumber) header = chainDB.getBlockHeader(txDetails.blockNumber)
transactions = chainDB.getTransactions(header) transactions = chainDB.getTransactions(header.txRoot)
flags = traceOptionsToFlags(options) flags = traceOptionsToFlags(options)
traceTransaction(com, header, transactions, txDetails.index, flags) traceTransaction(com, header, transactions, txDetails.index, flags)

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit 55994359018e6d3e7d45e8f8d211fa819f3843cf Subproject commit ea3dbaa621361c31c3395c0ba1b578e1e085d251