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(
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(