Add support for BlockHeader by number in portal_bridge (#2621)

This commit is contained in:
Kim De Mey 2024-09-13 13:41:34 +02:00 committed by GitHub
parent b11701c75a
commit d96196d01d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 3 deletions

View File

@ -139,11 +139,11 @@ proc getBlockReceipts(
proc gossipBlockHeader( proc gossipBlockHeader(
client: RpcClient, client: RpcClient,
hash: common_types.BlockHash, id: common_types.BlockHash | uint64,
headerWithProof: BlockHeaderWithProof, headerWithProof: BlockHeaderWithProof,
): Future[Result[void, string]] {.async: (raises: []).} = ): Future[Result[void, string]] {.async: (raises: []).} =
let let
contentKey = blockHeaderContentKey(hash) contentKey = blockHeaderContentKey(id)
encodedContentKeyHex = contentKey.encode.asSeq().toHex() encodedContentKeyHex = contentKey.encode.asSeq().toHex()
peers = peers =
@ -250,9 +250,12 @@ proc runLatestLoop(
error "Receipts root is invalid" error "Receipts root is invalid"
continue continue
# gossip block header # gossip block header by hash
(await portalClient.gossipBlockHeader(hash, headerWithProof)).isOkOr: (await portalClient.gossipBlockHeader(hash, headerWithProof)).isOkOr:
error "Failed to gossip block header", error, hash 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 # For bodies & receipts to get verified, the header needs to be available
# on the network. Wait a little to get the headers propagated through # on the network. Wait a little to get the headers propagated through
@ -508,8 +511,12 @@ proc runBackfillLoopAuditMode(
headerWithProof = buildHeaderWithProof(header, epochRecord).valueOr: headerWithProof = buildHeaderWithProof(header, epochRecord).valueOr:
raiseAssert "Failed to build header with proof: " & error raiseAssert "Failed to build header with proof: " & error
# gossip block header by hash
(await portalClient.gossipBlockHeader(blockHash, headerWithProof)).isOkOr: (await portalClient.gossipBlockHeader(blockHash, headerWithProof)).isOkOr:
error "Failed to gossip block header", error, blockHash 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: if not bodySuccess:
( (
await portalClient.gossipBlockBody( await portalClient.gossipBlockBody(