Add support for BlockHeader by number in portal_bridge (#2621)
This commit is contained in:
parent
b11701c75a
commit
d96196d01d
|
@ -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(
|
||||||
|
|
Loading…
Reference in New Issue