Fix bugs discovered by engine api simulator

This commit is contained in:
jangko 2023-08-17 11:08:01 +07:00
parent 2e85e6b2de
commit 5644749de9
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
5 changed files with 53 additions and 50 deletions

View File

@ -319,6 +319,7 @@ proc persistStorage(acc: RefAccount, db: CoreDbRef, clearCache: bool) =
if not clearCache and acc.originalStorage.isNil:
acc.originalStorage = newTable[UInt256, UInt256]()
db.compensateLegacySetup()
var storageTrie = getStorageTrie(db, acc)
for slot, value in acc.overlayStorage:

View File

@ -425,6 +425,8 @@ proc start(nimbus: NimbusNode, conf: NimbusConf) =
)
com.initializeEmptyDb()
com.db.compensateLegacySetup()
let protocols = conf.getProtocolFlags()
case conf.cmd

View File

@ -493,8 +493,9 @@ proc handle_getPayloadBodiesByHash(sealingEngine: SealingEngineRef,
for tx in body.transactions:
typedTransactions.add(tx.toTypedTransaction)
var withdrawals: seq[WithdrawalV1]
for w in body.withdrawals.get:
withdrawals.add(w.toWithdrawalV1)
if body.withdrawals.isSome:
for w in body.withdrawals.get:
withdrawals.add(w.toWithdrawalV1)
result.add(
some(ExecutionPayloadBodyV1(
transactions: typedTransactions,
@ -529,8 +530,9 @@ proc handle_getPayloadBodiesByRange(sealingEngine: SealingEngineRef,
for tx in body.transactions:
typedTransactions.add(tx.toTypedTransaction)
var withdrawals: seq[WithdrawalV1]
for w in body.withdrawals.get:
withdrawals.add(w.toWithdrawalV1)
if body.withdrawals.isSome:
for w in body.withdrawals.get:
withdrawals.add(w.toWithdrawalV1)
result.add(
some(ExecutionPayloadBodyV1(
transactions: typedTransactions,

View File

@ -53,27 +53,27 @@ type
## Note that this includes slightly different information from eth/common.BlockHeader
BlockObject* = object
# Returned to user
number*: Option[HexQuantityStr] # the block number. null when its pending block.
hash*: Option[Hash256] # hash of the block. null when its pending block.
parentHash*: Hash256 # hash of the parent block.
nonce*: Option[HexDataStr] # hash of the generated proof-of-work. null when its pending block.
sha3Uncles*: Hash256 # SHA3 of the uncles data in the block.
logsBloom*: FixedBytes[256] # the bloom filter for the logs of the block. null when its pending block.
transactionsRoot*: Hash256 # the root of the transaction trie of the block.
stateRoot*: Hash256 # the root of the final state trie of the block.
receiptsRoot*: Hash256 # the root of the receipts trie of the block.
miner*: EthAddress # the address of the beneficiary to whom the mining rewards were given.
difficulty*: HexQuantityStr # integer of the difficulty for this block.
totalDifficulty*: HexQuantityStr# integer of the total difficulty of the chain until this block.
extraData*: HexDataStr # the "extra data" field of this block.
number*: Option[HexQuantityStr] # the block number. null when its pending block.
hash*: Option[Hash256] # hash of the block. null when its pending block.
parentHash*: Hash256 # hash of the parent block.
nonce*: Option[HexDataStr] # hash of the generated proof-of-work. null when its pending block.
sha3Uncles*: Hash256 # SHA3 of the uncles data in the block.
logsBloom*: FixedBytes[256] # the bloom filter for the logs of the block. null when its pending block.
transactionsRoot*: Hash256 # the root of the transaction trie of the block.
stateRoot*: Hash256 # the root of the final state trie of the block.
receiptsRoot*: Hash256 # the root of the receipts trie of the block.
miner*: EthAddress # the address of the beneficiary to whom the mining rewards were given.
difficulty*: HexQuantityStr # integer of the difficulty for this block.
totalDifficulty*: HexQuantityStr # integer of the total difficulty of the chain until this block.
extraData*: HexDataStr # the "extra data" field of this block.
mixHash*: Hash256
size*: HexQuantityStr # integer the size of this block in bytes.
gasLimit*: HexQuantityStr # the maximum gas allowed in this block.
gasUsed*: HexQuantityStr # the total used gas by all transactions in this block.
timestamp*: HexQuantityStr # the unix timestamp for when the block was collated.
size*: HexQuantityStr # integer the size of this block in bytes.
gasLimit*: HexQuantityStr # the maximum gas allowed in this block.
gasUsed*: HexQuantityStr # the total used gas by all transactions in this block.
timestamp*: HexQuantityStr # the unix timestamp for when the block was collated.
baseFeePerGas*: Option[HexQuantityStr]
transactions*: seq[JsonNode] # list of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
uncles*: seq[Hash256] # list of uncle hashes.
transactions*: seq[JsonNode] # list of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
uncles*: seq[Hash256] # list of uncle hashes.
withdrawals*: Option[seq[WithdrawalObject]] # list of validator withdrawals
withdrawalsRoot*: Option[Hash256] # EIP-4895
blobGasUsed*: Option[HexQuantityStr] # EIP-4844
@ -81,27 +81,27 @@ type
TransactionObject* = object # A transaction object, or null when no transaction was found:
# Returned to user
blockHash*: Option[Hash256] # hash of the block where this transaction was in. null when its pending.
blockNumber*: Option[HexQuantityStr] # block number where this transaction was in. null when its pending.
`from`*: EthAddress # address of the sender.
gas*: HexQuantityStr # gas provided by the sender.
gasPrice*: HexQuantityStr # gas price provided by the sender in Wei.
hash*: Hash256 # hash of the transaction.
input*: Blob # the data send along with the transaction.
nonce*: HexQuantityStr # the number of transactions made by the sender prior to this one.
to*: Option[EthAddress] # address of the receiver. null when its a contract creation transaction.
`type`*: HexQuantityStr # EIP-2718, with 0x0 for Legacy
blockHash*: Option[Hash256] # hash of the block where this transaction was in. null when its pending.
blockNumber*: Option[HexQuantityStr] # block number where this transaction was in. null when its pending.
`from`*: EthAddress # address of the sender.
gas*: HexQuantityStr # gas provided by the sender.
gasPrice*: HexQuantityStr # gas price provided by the sender in Wei.
maxFeePerGas*: HexQuantityStr # EIP-1559
maxPriorityFeePerGas*: HexQuantityStr # EIP-1559
hash*: Hash256 # hash of the transaction.
input*: Blob # the data send along with the transaction.
nonce*: HexQuantityStr # the number of transactions made by the sender prior to this one.
to*: Option[EthAddress] # address of the receiver. null when its a contract creation transaction.
transactionIndex*: Option[HexQuantityStr] # integer of the transactions index position in the block. null when its pending.
value*: HexQuantityStr # value transferred in Wei.
v*: HexQuantityStr # ECDSA recovery id
r*: HexQuantityStr # 32 Bytes - ECDSA signature r
s*: HexQuantityStr # 32 Bytes - ECDSA signature s
`type`*: Option[HexQuantityStr] # EIP-2718, with 0x0 for Legacy
chainId*: Option[HexQuantityStr] # EIP-159
accessList*: Option[seq[AccessTuple]] # EIP-2930
maxFeePerGas*: Option[HexQuantityStr] # EIP-1559
maxPriorityFeePerGas*: Option[HexQuantityStr] # EIP-1559
maxFeePerBlobGas*: Option[HexQuantityStr] # EIP-4844
versionedHashes*: Option[VersionedHashes] # EIP-4844
value*: HexQuantityStr # value transferred in Wei.
v*: HexQuantityStr # ECDSA recovery id
r*: HexQuantityStr # 32 Bytes - ECDSA signature r
s*: HexQuantityStr # 32 Bytes - ECDSA signature s
chainId*: Option[HexQuantityStr] # EIP-159
accessList*: Option[seq[AccessTuple]] # EIP-2930
maxFeePerBlobGas*: Option[HexQuantityStr] # EIP-4844
versionedHashes*: Option[VersionedHashes] # EIP-4844
AccessTuple* = object
address*: EthAddress

View File

@ -166,6 +166,7 @@ proc toAccessTupleList(list: openArray[AccessPair]): seq[AccessTuple] =
proc populateTransactionObject*(tx: Transaction, header: BlockHeader, txIndex: int): TransactionObject
{.gcsafe, raises: [ValidationError].} =
result.`type` = encodeQuantity(tx.txType.uint64)
result.blockHash = some(header.hash)
result.blockNumber = some(encodeQuantity(header.blockNumber))
result.`from` = tx.getSender()
@ -180,16 +181,13 @@ proc populateTransactionObject*(tx: Transaction, header: BlockHeader, txIndex: i
result.v = encodeQuantity(tx.V.uint)
result.r = encodeQuantity(tx.R)
result.s = encodeQuantity(tx.S)
result.maxFeePerGas = encodeQuantity(tx.maxFee.uint64)
result.maxPriorityFeePerGas = encodeQuantity(tx.maxPriorityFee.uint64)
if tx.txType >= TxEip2930:
result.chainId = some(encodeQuantity(tx.chainId.uint64))
result.`type` = some(encodeQuantity(tx.txType.uint64))
result.accessList = some(toAccessTupleList(tx.accessList))
if tx.txType >= TxEIP1559:
result.maxFeePerGas = some(encodeQuantity(tx.maxFee.uint64))
result.maxPriorityFeePerGas = some(encodeQuantity(tx.maxPriorityFee.uint64))
if tx.txType >= TxEIP4844:
result.maxFeePerBlobGas = some(encodeQuantity(tx.maxFeePerBlobGas.uint64))
#result.versionedHashes = some(tx.versionedHashes)