-
-
Notifications
You must be signed in to change notification settings - Fork 479
feat: enhance NetworkProcessor for gloas #9025
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
257ff69
feat: implement network processor for gloas
twoeths 00c1ba4
fix: add PreprocessResult = action + ?root
twoeths e523ef5
feat: update gossip handler to queue block+envelope in UnknownBlockSync
twoeths 0ad8f98
feat: handle beacon_block and execution_payload_envelope in network p…
twoeths c01cfbf
fix: ts import
twoeths d6b8617
fix: do not await block for data_column_sidecar + fix comments
twoeths e297ba2
fix: implement hasBlock and hasEnvelope
twoeths 27a9b2c
refactor: rename forkchoice.hasEnvelope -> forkchoice.hasPayload
twoeths 7be4b16
chore: use hasPayload in ProtoArray.isPayloadTimely()
twoeths c7794b0
fix: use unsafe version for BeaconChain.seenBlock()
twoeths 104c833
chore: add comment for data_column_sidecar root extraction
twoeths d7860f2
fix: handle data_column_sidecar unknown envelope
twoeths bfeb5f4
chore: tweak event names
twoeths e957cb0
fix: outdated method reference
twoeths 6b458b4
fix: comment in execution_payload root extraction
twoeths 134a7fe
chore: add comment for getParentBlockHashFromGloasSignedBeaconBlockSe…
twoeths 25156fa
chore: more comments for beacon_block topic
twoeths 546a109
fix: await for routes.events.EventType.executionPayload event
twoeths 457e7db
Merge branch 'unstable' into te/gloas_network_processor
nflaig 126da70
Merge remote-tracking branch 'origin/unstable' into te/gloas_network_…
twoeths 946c38d
refactor: rename hasEnvelope() -> hasPayload()
twoeths File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,16 +169,19 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand | |
|
|
||
| logger.debug("Received gossip block", {...logCtx}); | ||
|
|
||
| let blockInput: IBlockInput | undefined; | ||
| // optimistically add gossip block to the seen cache | ||
|
twoeths marked this conversation as resolved.
|
||
| // if validation fails, we will NOT forward this gossip block to peers | ||
| // - if PARENT_UNKNOWN error, blockInput will then be queued inside BlockInputSync. If the gossip block is really invalid, it will be pruned there | ||
| // - if other validator errors, blockInput will stay in the seen cache and will be pruned on finalization | ||
| const blockInput = chain.seenBlockInputCache.getByBlock({ | ||
|
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. we have dead code without this change, see line 193 below (to handle |
||
| block: signedBlock, | ||
| blockRootHex, | ||
| source: BlockInputSource.gossip, | ||
| seenTimestampSec, | ||
| peerIdStr, | ||
| }); | ||
| try { | ||
| await validateGossipBlock(config, chain, signedBlock, fork); | ||
| blockInput = chain.seenBlockInputCache.getByBlock({ | ||
| block: signedBlock, | ||
| blockRootHex, | ||
| source: BlockInputSource.gossip, | ||
| seenTimestampSec, | ||
| peerIdStr, | ||
| }); | ||
| const blockInputMeta = blockInput.getLogMeta(); | ||
|
|
||
| const recvToValidation = Date.now() / 1000 - seenTimestampSec; | ||
|
|
@@ -194,9 +197,9 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand | |
| return blockInput; | ||
| } catch (e) { | ||
| if (e instanceof BlockGossipError) { | ||
| logger.debug("Gossip block has error", {slot, root: blockShortHex, code: e.type.code}); | ||
| if (e.type.code === BlockErrorCode.PARENT_UNKNOWN && blockInput) { | ||
| logger.debug("Gossip block has error", {slot, root: blockShortHex, code: e.type.code}); | ||
| chain.emitter.emit(ChainEvent.unknownParent, { | ||
| chain.emitter.emit(ChainEvent.blockUnknownParent, { | ||
| blockInput, | ||
| peer: peerIdStr, | ||
| source: BlockInputSource.gossip, | ||
|
|
@@ -1037,8 +1040,37 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand | |
| const {serializedData} = gossipData; | ||
| const signedEnvelope = sszDeserialize(topic, serializedData); | ||
| const envelope = signedEnvelope.message; | ||
| // TODO GLOAS: handle BLOCK_ROOT_UNKNOWN error to trigger sync | ||
| await validateGossipExecutionPayloadEnvelope(chain, signedEnvelope); | ||
|
|
||
| // TODO GLOAS: consider optimistically create PayloadEnvelopeInput here similar to how we do that for beacon_block | ||
| // so that UnknownBlockSync can handle backward sync | ||
| // the problem now is we cannot create a PayloadEnvelopeInput without the beacon block being known, we need at least the proposer index | ||
| // we can achieve that by looking into the EpochCache | ||
| try { | ||
| await validateGossipExecutionPayloadEnvelope(chain, signedEnvelope); | ||
| } catch (e) { | ||
| if (e instanceof ExecutionPayloadEnvelopeError) { | ||
| const {slot, beaconBlockRoot} = signedEnvelope.message; | ||
| logger.debug("Gossip envelope has error", {slot, root: toRootHex(beaconBlockRoot), code: e.type.code}); | ||
| if (e.type.code === ExecutionPayloadEnvelopeErrorCode.BLOCK_ROOT_UNKNOWN) { | ||
| // TODO GLOAS: UnknownBlockSync to handle this | ||
| chain.emitter.emit(ChainEvent.envelopeUnknownBlock, { | ||
| envelope: signedEnvelope, | ||
| peer: peerIdStr, | ||
| source: BlockInputSource.gossip, | ||
| }); | ||
| } | ||
|
|
||
| if (e.action === GossipAction.REJECT) { | ||
| chain.persistInvalidSszValue( | ||
| ssz.gloas.SignedExecutionPayloadEnvelope, | ||
| signedEnvelope, | ||
| `gossip_reject_slot_${slot}` | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| throw e; | ||
| } | ||
|
|
||
| const slot = envelope.slot; | ||
| const delaySec = seenTimestampSec - computeTimeAtSlot(config, slot, chain.genesisTime); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.