From d96196d01d8ccc61d87e6b72416e3612032a28f1 Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Fri, 13 Sep 2024 13:41:34 +0200 Subject: [PATCH] Add support for BlockHeader by number in portal_bridge (#2621) --- .../tools/portal_bridge/portal_bridge_history.nim | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fluffy/tools/portal_bridge/portal_bridge_history.nim b/fluffy/tools/portal_bridge/portal_bridge_history.nim index ffa84dc5e..3249b764d 100644 --- a/fluffy/tools/portal_bridge/portal_bridge_history.nim +++ b/fluffy/tools/portal_bridge/portal_bridge_history.nim @@ -139,11 +139,11 @@ proc getBlockReceipts( proc gossipBlockHeader( client: RpcClient, - hash: common_types.BlockHash, + id: common_types.BlockHash | uint64, headerWithProof: BlockHeaderWithProof, ): Future[Result[void, string]] {.async: (raises: []).} = let - contentKey = blockHeaderContentKey(hash) + contentKey = blockHeaderContentKey(id) encodedContentKeyHex = contentKey.encode.asSeq().toHex() peers = @@ -250,9 +250,12 @@ proc runLatestLoop( error "Receipts root is invalid" continue - # gossip block header + # gossip block header by hash (await portalClient.gossipBlockHeader(hash, headerWithProof)).isOkOr: error "Failed to gossip block header", error, hash + # gossip block header by number + (await portalClient.gossipBlockHeader(blockNumber, headerWithProof)).isOkOr: + error "Failed to gossip block header", error, hash # For bodies & receipts to get verified, the header needs to be available # on the network. Wait a little to get the headers propagated through @@ -508,8 +511,12 @@ proc runBackfillLoopAuditMode( headerWithProof = buildHeaderWithProof(header, epochRecord).valueOr: raiseAssert "Failed to build header with proof: " & error + # gossip block header by hash (await portalClient.gossipBlockHeader(blockHash, headerWithProof)).isOkOr: error "Failed to gossip block header", error, blockHash + # gossip block header by number + (await portalClient.gossipBlockHeader(blockNumber, headerWithProof)).isOkOr: + error "Failed to gossip block header", error, blockHash if not bodySuccess: ( await portalClient.gossipBlockBody(