From 52d83088216144ba59a5bd398306a68965c5842f Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Wed, 12 Apr 2023 14:20:52 +0200 Subject: [PATCH] Some quick fixes for Shanghai support in Fluffy (#1541) - Remove failing on withdrawalsRoot to allow Shanghai BlockHeader. Still need to add real checks in block header / body validation. - Add withdrawals array to Block object for JSON-RPC API --- fluffy/network/history/history_network.nim | 7 +++++-- nimbus/rpc/rpc_types.nim | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fluffy/network/history/history_network.nim b/fluffy/network/history/history_network.nim index b17c62242..27d9beb74 100644 --- a/fluffy/network/history/history_network.nim +++ b/fluffy/network/history/history_network.nim @@ -159,8 +159,8 @@ func validateBlockHeaderBytes*( if header.excessDataGas.isSome: return err("EIP-4844 not yet implemented") - if header.withdrawalsRoot.isSome: - return err("Withdrawals not yet implemented") + # TODO: Verify timestamp with Shanghai timestamp to if isSome() + # TODO 2: Verify block number with merge block to check ommerhash if not (header.blockHash() == hash): err("Block header hash does not match") @@ -171,6 +171,7 @@ proc validateBlockBody( body: BlockBodySSZ, txsRoot, ommersHash: KeccakHash): Result[void, string] = ## Validate the block body against the txRoot amd ommersHash from the header. + # TODO: should be checked for hash for empty uncles after merge block let calculatedOmmersHash = keccakHash(body.uncles.asSeq()) if calculatedOmmersHash != ommersHash: return err("Invalid ommers hash") @@ -179,6 +180,8 @@ proc validateBlockBody( if calculatedTxsRoot != txsRoot: return err("Invalid transactions root") + # TODO: Add root check for withdrawals after Shanghai + ok() proc validateBlockBodyBytes*( diff --git a/nimbus/rpc/rpc_types.nim b/nimbus/rpc/rpc_types.nim index d1d84d95c..e33e5e61f 100644 --- a/nimbus/rpc/rpc_types.nim +++ b/nimbus/rpc/rpc_types.nim @@ -74,6 +74,7 @@ type 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. + withdrawals*: seq[WithdrawalObject] # list of validator withdrawals TransactionObject* = object # A transaction object, or null when no transaction was found: # Returned to user @@ -92,6 +93,12 @@ type r*: HexQuantityStr # 32 Bytes - ECDSA signature r s*: HexQuantityStr # 32 Bytes - ECDSA signature s + WithdrawalObject* = object + index*: HexQuantityStr + validatorIndex*: HexQuantityStr + address*: EthAddress + amount*: HexQuantityStr + FilterLog* = object # Returned to user removed*: bool # true when the log was removed, due to a chain reorganization. false if its a valid log.