From 8f0d910422b12497852f80c22d1cee48a971d246 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Wed, 2 Oct 2024 15:26:11 +0200 Subject: [PATCH] web: bump to new nim-eth types (#6590) --- .../consensus_object_pools/consensus_manager.nim | 2 +- beacon_chain/el/el_manager.nim | 10 +++++----- beacon_chain/el/engine_api_conversions.nim | 10 +++++----- beacon_chain/libnimbus_lc/libnimbus_lc.nim | 4 ++-- beacon_chain/spec/helpers.nim | 2 +- beacon_chain/validators/beacon_validators.nim | 2 +- research/wss_sim.nim | 2 +- vendor/nim-eth | 2 +- vendor/nim-web3 | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/beacon_chain/consensus_object_pools/consensus_manager.nim b/beacon_chain/consensus_object_pools/consensus_manager.nim index 54194df98..1c33d316c 100644 --- a/beacon_chain/consensus_object_pools/consensus_manager.nim +++ b/beacon_chain/consensus_object_pools/consensus_manager.nim @@ -388,7 +388,7 @@ proc runProposalForkchoiceUpdated*( suggestedFeeRecipient: feeRecipient, withdrawals: toEngineWithdrawals get_expected_withdrawals(forkyState.data), - parentBeaconBlockRoot: beaconHead.blck.bid.root.asBlockHash)) + parentBeaconBlockRoot: beaconHead.blck.bid.root.to(Hash32))) elif consensusFork >= ConsensusFork.Capella: callForkchoiceUpdated(PayloadAttributesV2( timestamp: Quantity timestamp, diff --git a/beacon_chain/el/el_manager.nim b/beacon_chain/el/el_manager.nim index ce03e8013..e0133a248 100644 --- a/beacon_chain/el/el_manager.nim +++ b/beacon_chain/el/el_manager.nim @@ -534,7 +534,7 @@ proc getPayloadFromSingleEL( prevRandao: FixedBytes[32] randomData.data, suggestedFeeRecipient: suggestedFeeRecipient, withdrawals: withdrawals, - parentBeaconBlockRoot: consensusHead.asBlockHash)) + parentBeaconBlockRoot: consensusHead.to(Hash32))) else: static: doAssert false @@ -817,7 +817,7 @@ proc sendNewPayloadToSingleEL( ): Future[PayloadStatusV1] {.async: (raises: [CatchableError]).} = let rpcClient = await connection.connectedRpcClient() await rpcClient.engine_newPayloadV3( - payload, versioned_hashes, parent_beacon_block_root) + payload, versioned_hashes, Hash32 parent_beacon_block_root) proc sendNewPayloadToSingleEL( connection: ELConnection, @@ -827,7 +827,7 @@ proc sendNewPayloadToSingleEL( ): Future[PayloadStatusV1] {.async: (raises: [CatchableError]).} = let rpcClient = await connection.connectedRpcClient() await rpcClient.engine_newPayloadV4( - payload, versioned_hashes, parent_beacon_block_root) + payload, versioned_hashes, Hash32 parent_beacon_block_root) type StatusRelation = enum @@ -1096,7 +1096,7 @@ proc forkchoiceUpdated*( prevRandao: payloadAttributes.get.prevRandao, suggestedFeeRecipient: payloadAttributes.get.suggestedFeeRecipient, withdrawals: payloadAttributes.get.withdrawals, - parentBeaconBlockRoot: static(default(FixedBytes[32]))) + parentBeaconBlockRoot: default(Hash32)) else: # As timestamp and prevRandao are both 0, won't false-positive match (static(default(PayloadAttributesV3))) @@ -1108,7 +1108,7 @@ proc forkchoiceUpdated*( prevRandao: payloadAttributes.get.prevRandao, suggestedFeeRecipient: payloadAttributes.get.suggestedFeeRecipient, withdrawals: @[], - parentBeaconBlockRoot: static(default(FixedBytes[32]))) + parentBeaconBlockRoot: default(Hash32)) else: # As timestamp and prevRandao are both 0, won't false-positive match (static(default(PayloadAttributesV3))) diff --git a/beacon_chain/el/engine_api_conversions.nim b/beacon_chain/el/engine_api_conversions.nim index f9d60529f..6c1032c0b 100644 --- a/beacon_chain/el/engine_api_conversions.nim +++ b/beacon_chain/el/engine_api_conversions.nim @@ -19,7 +19,7 @@ type executionPayload*: ExecutionPayloadV1 blockValue*: UInt256 -func asEth2Digest*(x: BlockHash): Eth2Digest = +func asEth2Digest*(x: BlockHash|Bytes32): Eth2Digest = Eth2Digest(data: array[32, byte](x)) template asBlockHash*(x: Eth2Digest): BlockHash = @@ -232,7 +232,7 @@ func asEngineExecutionPayload*(blockBody: bellatrix.BeaconBlockBody): receiptsRoot: executionPayload.receipts_root.asBlockHash, logsBloom: FixedBytes[BYTES_PER_LOGS_BLOOM](executionPayload.logs_bloom.data), - prevRandao: executionPayload.prev_randao.asBlockHash, + prevRandao: executionPayload.prev_randao.data.to(Bytes32), blockNumber: Quantity(executionPayload.block_number), gasLimit: Quantity(executionPayload.gas_limit), gasUsed: Quantity(executionPayload.gas_used), @@ -262,7 +262,7 @@ func asEngineExecutionPayload*(blockBody: capella.BeaconBlockBody): receiptsRoot: executionPayload.receipts_root.asBlockHash, logsBloom: FixedBytes[BYTES_PER_LOGS_BLOOM](executionPayload.logs_bloom.data), - prevRandao: executionPayload.prev_randao.asBlockHash, + prevRandao: executionPayload.prev_randao.data.to(Bytes32), blockNumber: Quantity(executionPayload.block_number), gasLimit: Quantity(executionPayload.gas_limit), gasUsed: Quantity(executionPayload.gas_used), @@ -287,7 +287,7 @@ func asEngineExecutionPayload*(blockBody: deneb.BeaconBlockBody): receiptsRoot: executionPayload.receipts_root.asBlockHash, logsBloom: FixedBytes[BYTES_PER_LOGS_BLOOM](executionPayload.logs_bloom.data), - prevRandao: executionPayload.prev_randao.asBlockHash, + prevRandao: executionPayload.prev_randao.data.to(Bytes32), blockNumber: Quantity(executionPayload.block_number), gasLimit: Quantity(executionPayload.gas_limit), gasUsed: Quantity(executionPayload.gas_used), @@ -337,7 +337,7 @@ func asEngineExecutionPayload*(blockBody: electra.BeaconBlockBody): receiptsRoot: executionPayload.receipts_root.asBlockHash, logsBloom: FixedBytes[BYTES_PER_LOGS_BLOOM](executionPayload.logs_bloom.data), - prevRandao: executionPayload.prev_randao.asBlockHash, + prevRandao: executionPayload.prev_randao.data.to(Bytes32), blockNumber: Quantity(executionPayload.block_number), gasLimit: Quantity(executionPayload.gas_limit), gasUsed: Quantity(executionPayload.gas_used), diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.nim b/beacon_chain/libnimbus_lc/libnimbus_lc.nim index 1e6299449..f545371be 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.nim +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.nim @@ -1295,7 +1295,7 @@ proc ETHExecutionBlockHeaderCreateFromJson( gasUsed: distinctBase(data.gasUsed), timestamp: EthTime(distinctBase(data.timestamp)), extraData: distinctBase(data.extraData), - mixHash: data.mixHash.asEth2Digest.to(Hash32), + mixHash: Bytes32 data.mixHash, nonce: distinctBase(data.nonce.get).to(Bytes8), baseFeePerGas: data.baseFeePerGas, withdrawalsRoot: @@ -1793,7 +1793,7 @@ proc ETHTransactionsCreateFromJson( versionedHashes: if data.blobVersionedHashes.isSome: data.blobVersionedHashes.get.mapIt( - Bytes32(distinctBase(it))) + Hash32(distinctBase(it))) else: @[], authorizationList: diff --git a/beacon_chain/spec/helpers.nim b/beacon_chain/spec/helpers.nim index 9ea8216d3..37dfe06ee 100644 --- a/beacon_chain/spec/helpers.nim +++ b/beacon_chain/spec/helpers.nim @@ -599,7 +599,7 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = gasUsed : payload.gas_used, timestamp : EthTime(payload.timestamp), extraData : payload.extra_data.asSeq, - mixHash : payload.prev_randao.to(Hash32), # EIP-4399 `mixHash` -> `prevRandao` + mixHash : Bytes32 payload.prev_randao.data, # EIP-4399 `mixHash` -> `prevRandao` nonce : default(BlockNonce), baseFeePerGas : Opt.some payload.base_fee_per_gas, withdrawalsRoot : withdrawalsRoot, diff --git a/beacon_chain/validators/beacon_validators.nim b/beacon_chain/validators/beacon_validators.nim index 30761f1b2..3700a6efd 100644 --- a/beacon_chain/validators/beacon_validators.nim +++ b/beacon_chain/validators/beacon_validators.nim @@ -81,7 +81,7 @@ type blck*: ForkedBeaconBlock executionPayloadValue*: Wei consensusBlockValue*: UInt256 - blobsBundleOpt*: Opt[BlobsBundle] + blobsBundleOpt*: Opt[deneb.BlobsBundle] BuilderBid[SBBB] = object blindedBlckPart*: SBBB diff --git a/research/wss_sim.nim b/research/wss_sim.nim index 5047f88d5..8dadd671a 100644 --- a/research/wss_sim.nim +++ b/research/wss_sim.nim @@ -256,7 +256,7 @@ cli do(validatorsDir: string, secretsDir: string, when consensusFork >= ConsensusFork.Capella: get_expected_withdrawals(forkyState.data) else: - newSeq[Withdrawal]() + newSeq[capella.Withdrawal]() var pl: consensusFork.ExecutionPayloadForSigning while true: diff --git a/vendor/nim-eth b/vendor/nim-eth index 6bd6bae86..5ce3c4557 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit 6bd6bae86c437a61bcd6426571204dd7cdb88123 +Subproject commit 5ce3c4557fc78ee425fcb8f30f80cb336bbe0b7c diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 0cc03e67d..b41316b25 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 0cc03e67dda6c4d9be0f9d9abde7508e46156fd9 +Subproject commit b41316b25c77c525a2d33192a52958a6972b839d