From c525590a5102981c1e5c77185f093a4d924e19fa Mon Sep 17 00:00:00 2001 From: andri lim Date: Thu, 21 Nov 2024 21:58:12 +0700 Subject: [PATCH] Fix simulator RPC object: add fields from latest spec (#2859) --- .../nodocker/engine/engine_client.nim | 8 +++++ nimbus/beacon/web3_eth_conv.nim | 36 ++++++++++++++----- nimbus/config.nim | 1 - 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/hive_integration/nodocker/engine/engine_client.nim b/hive_integration/nodocker/engine/engine_client.nim index 45c3c1288..4e14be591 100644 --- a/hive_integration/nodocker/engine/engine_client.nim +++ b/hive_integration/nodocker/engine/engine_client.nim @@ -269,12 +269,17 @@ proc toBlockHeader*(bc: BlockObject): Header = blobGasUsed : maybeU64(bc.blobGasUsed), excessBlobGas : maybeU64(bc.excessBlobGas), parentBeaconBlockRoot: bc.parentBeaconBlockRoot, + requestsHash : bc.requestsHash, ) func vHashes(x: Opt[seq[Hash32]]): seq[VersionedHash] = if x.isNone: return else: x.get +func authList(x: Opt[seq[AuthorizationObject]]): seq[Authorization] = + if x.isNone: return + else: ethAuthList x.get + proc toTransaction(tx: TransactionObject): Transaction = Transaction( txType : tx.`type`.get(0.Web3Quantity).TxType, @@ -293,6 +298,7 @@ proc toTransaction(tx: TransactionObject): Transaction = V : tx.v.uint64, R : tx.r, S : tx.s, + authorizationList: authList(tx.authorizationList), ) proc toTransactions*(txs: openArray[TxOrHash]): seq[Transaction] = @@ -360,6 +366,7 @@ type accessList*: Opt[seq[AccessPair]] maxFeePerBlobGas*: Opt[UInt256] versionedHashes*: Opt[seq[VersionedHash]] + authorizationList*: Opt[seq[Authorization]] proc toRPCReceipt(rec: ReceiptObject): RPCReceipt = RPCReceipt( @@ -408,6 +415,7 @@ proc toRPCTx(tx: eth_api.TransactionObject): RPCTx = Opt.some(vHashes tx.blobVersionedHashes) else: Opt.none(seq[VersionedHash]), + authorizationList: ethAuthList(tx.authorizationList), ) proc waitForTTD*(client: RpcClient, diff --git a/nimbus/beacon/web3_eth_conv.nim b/nimbus/beacon/web3_eth_conv.nim index d4947707d..a4a61937b 100644 --- a/nimbus/beacon/web3_eth_conv.nim +++ b/nimbus/beacon/web3_eth_conv.nim @@ -63,17 +63,16 @@ func u256*(x: FixedBytes[32]): UInt256 = func ethTime*(x: Web3Quantity): EthTime = EthTime(x) -func ethGasInt*(x: Web3Quantity): GasInt = - GasInt x - func ethBlob*(x: Web3ExtraData): seq[byte] = distinctBase x -func ethWithdrawal*(x: WithdrawalV1): common.Withdrawal = - result.index = x.index.uint64 - result.validatorIndex = x.validatorIndex.uint64 - result.address = x.address - result.amount = x.amount.uint64 +func ethWithdrawal*(x: WithdrawalV1): Withdrawal = + Withdrawal( + index: x.index.uint64, + validatorIndex: x.validatorIndex.uint64, + address: x.address, + amount: x.amount.uint64, + ) func ethWithdrawals*(list: openArray[WithdrawalV1]): seq[Withdrawal] = @@ -95,6 +94,27 @@ func ethTxs*(list: openArray[Web3Tx]): for x in list: result.add ethTx(x) +func ethAuth*(x: AuthorizationObject): Authorization = + Authorization( + chainId: ChainId x.chainId, + address: x.address, + nonce: distinctBase x.nonce, + v: distinctBase x.v, + r: x.r, + s: x.s, + ) + +func ethAuthList*(list: openArray[AuthorizationObject]): + seq[Authorization] = + result = newSeqOfCap[Authorization](list.len) + for x in list: + result.add ethAuth(x) + +func ethAuthList*(x: Opt[seq[AuthorizationObject]]): + Opt[seq[Authorization]] = + if x.isNone: Opt.none(seq[Authorization]) + else: Opt.some(ethAuthList x.get) + # ------------------------------------------------------------------------------ # Eth types to Web3 types # ------------------------------------------------------------------------------ diff --git a/nimbus/config.nim b/nimbus/config.nim index 6e56261ae..f3fbd9768 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -12,7 +12,6 @@ import std/[ options, strutils, - times, os, uri, net