Repository navigation
fix: process REPEAT_PROPOSAL block #9805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
aff7f38
4ac0456
7c02c02
f5b2b9b
c7d0c64
5dcc6b0
d87bb3a
09c5037
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -208,24 +208,29 @@ export function getBeaconBlockApi({ | |
| const blockLocallyProduced = chain.blockProductionCache.has(blockRoot); | ||
| const valLogMeta = {slot, blockRoot, bodyRoot, broadcastValidation, blockLocallyProduced}; | ||
|
|
||
| // For a REPEAT_PROPOSAL (equivocating) block we still import it into fork choice but must not | ||
| // re-publish it (or its sidecars) to the network; this flag gates the publish thunks below. | ||
| let skipPublish = false; | ||
|
|
||
| switch (broadcastValidation) { | ||
| case routes.beacon.BroadcastValidation.gossip: { | ||
| if (!blockLocallyProduced) { | ||
| try { | ||
| await validateGossipBlock(config, chain, signedBlock, fork); | ||
| } catch (error) { | ||
| if (error instanceof BlockGossipError) { | ||
| switch (error.type.code) { | ||
| case BlockErrorCode.ALREADY_KNOWN: | ||
| // Block has already been seen, e.g. via gossip racing the publish API. Benign. | ||
| chain.logger.debug("Ignoring already-known block during publishing", valLogMeta); | ||
| return; | ||
| case BlockErrorCode.REPEAT_PROPOSAL: | ||
| // The proposer already produced a block for this slot. For a solo setup this is a | ||
| // notable signal (duplicate-proposal attempt). For fallback / DVT setups it is | ||
| // expected on every block where another node published first. | ||
| chain.logger.warn("Ignoring repeat-proposal block during publishing", valLogMeta); | ||
| return; | ||
| if (error.type.code === BlockErrorCode.ALREADY_KNOWN) { | ||
| // Block has already been seen, e.g. via gossip racing the publish API. Benign. | ||
| chain.logger.debug("Ignoring already-known block during publishing", valLogMeta); | ||
| return; | ||
| } | ||
| if (error.type.code === BlockErrorCode.REPEAT_PROPOSAL) { | ||
| // the proposer already produced a block for this slot | ||
| // Spec: do NOT re-publish it, but we should still import because each node may receive different block | ||
| // and this block may become canonical | ||
| chain.logger.warn("Importing repeat-proposal block without publishing", valLogMeta); | ||
| skipPublish = true; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -371,9 +376,15 @@ export function getBeaconBlockApi({ | |
| // b) getting block first allows nodes to use getBlobs from local ELs and save | ||
| // import latency and hopefully bandwidth | ||
| // | ||
| () => network.publishBeaconBlock(signedBlock), | ||
| ...dataColumnSidecars.map((dataColumnSidecar) => () => network.publishDataColumnSidecar(dataColumnSidecar)), | ||
| ...blobSidecars.map((blobSidecar) => () => network.publishBlobSidecar(blobSidecar)), | ||
| // For a REPEAT_PROPOSAL (equivocating) block we still import it (below) but do not re-publish | ||
| // it or its sidecars to the network. | ||
| ...(skipPublish | ||
|
twoeths marked this conversation as resolved.
Resolved
|
||
| ? [] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in 4ac0456 |
||
| : [ | ||
| () => network.publishBeaconBlock(signedBlock), | ||
| ...dataColumnSidecars.map((dataColumnSidecar) => () => network.publishDataColumnSidecar(dataColumnSidecar)), | ||
| ...blobSidecars.map((blobSidecar) => () => network.publishBlobSidecar(blobSidecar)), | ||
| ]), | ||
| () => | ||
| // there is no rush to persist block since we published it to gossip anyway | ||
| chain | ||
|
|
@@ -397,7 +408,8 @@ export function getBeaconBlockApi({ | |
| publishPromises | ||
| ); | ||
|
|
||
| if (isForkPostGloas(fork)) { | ||
| if (skipPublish || isForkPostGloas(fork)) { | ||
| // For a REPEAT_PROPOSAL block we published nothing, so there are no sent-peers metrics to record. | ||
| // After gloas, data columns are not published with the block but when publishing the execution payload envelope | ||
| } else if (isForkPostFulu(fork)) { | ||
| let columnsPublishedWithZeroPeers = 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -713,9 +713,30 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand | |||
| const {serializedData} = gossipData; | ||||
|
|
||||
| const signedBlock = sszDeserialize(topic, serializedData); | ||||
| const blockInput = await validateBeaconBlock(signedBlock, topic.boundary.fork, peerIdStr, seenTimestampSec); | ||||
| chain.serializedCache.set(signedBlock, serializedData); | ||||
| handleValidBeaconBlock(blockInput, peerIdStr, seenTimestampSec); | ||||
| try { | ||||
| const blockInput = await validateBeaconBlock(signedBlock, topic.boundary.fork, peerIdStr, seenTimestampSec); | ||||
| chain.serializedCache.set(signedBlock, serializedData); | ||||
| handleValidBeaconBlock(blockInput, peerIdStr, seenTimestampSec); | ||||
| } catch (e) { | ||||
| // Spec: IGNORE the block, ie not to re-publish to peers | ||||
| // but we should still import an equivocating (REPEAT_PROPOSAL) block into fork choice because we don't | ||||
| // know if this block (or the 1st known block with same slot) will become canonical yet | ||||
| if ( | ||||
| e instanceof BlockGossipError && | ||||
| e.type.code === BlockErrorCode.REPEAT_PROPOSAL && | ||||
| // this is make sure the block's proposer signature was verified, it should be true anyway | ||||
| chain.seenBlockProposers.hasBlockRoot(signedBlock.message.slot, e.type.proposerIndex, e.type.root) | ||||
| ) { | ||||
| // blockInput was optimistically seeded in validateBeaconBlock and retained on IGNORE | ||||
| const blockInput = chain.seenBlockInputCache.get(e.type.root); | ||||
| if (blockInput) { | ||||
| chain.serializedCache.set(signedBlock, serializedData); | ||||
| handleValidBeaconBlock(blockInput, peerIdStr, seenTimestampSec); | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to revisit the ordering in also it's before this check if (blockState.getBeaconProposer(blockSlot) !== proposerIndex) {
throw new BlockGossipError(GossipAction.REJECT, {code: BlockErrorCode.INCORRECT_PROPOSER, proposerIndex});
}which seems questionable?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the p2p rules are just quick checks to forward the gossip block without having to run state transition
it's worth to mention this in the code
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that is probably fine was thinking the same way, but we should be more explicit about it, so adding a comment as suggested makes sense. there was one worry that we could receive many invalid blocks and fill our cache but due to how gossip re-propagation works this should be unlikely unless a peer sends them directly to us, but I think we still wanna make sure that we at least validate the proposer signature in any case, although my worry here is that we run
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
it's already checked at line 718 above
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yeah that looks fine |
||||
| } | ||||
| } | ||||
| // rethrow so gossipValidatorFn maps IGNORE -> TopicValidatorResult.Ignore (message not forwarded) | ||||
| throw e; | ||||
| } | ||||
| }, | ||||
|
|
||||
| [GossipType.blob_sidecar]: async ({ | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.