Skip to content

Parent envelope unknown lookup#9039

Open
eserilev wants to merge 29 commits intosigp:unstablefrom
eserilev:gloas-parent-envelope-unknown-lookup
Open

Parent envelope unknown lookup#9039
eserilev wants to merge 29 commits intosigp:unstablefrom
eserilev:gloas-parent-envelope-unknown-lookup

Conversation

@eserilev
Copy link
Copy Markdown
Member

@eserilev eserilev commented Mar 27, 2026

Issue Addressed

#8994

When we attempt to import a block whose parent envelope is unknown push the block into the reprocessing queue and attempt to lookup the parent envelope

@eserilev eserilev requested a review from jxs as a code owner March 27, 2026 07:12
@eserilev eserilev added work-in-progress PR is a work-in-progress gloas labels Mar 27, 2026
@eserilev eserilev changed the title Parent envelope unkown lookup [WIP][ Parent envelope unkown lookup [WIP] Mar 27, 2026
@eserilev eserilev mentioned this pull request Apr 1, 2026
Comment thread beacon_node/beacon_chain/src/block_verification.rs Outdated
Comment thread beacon_node/beacon_chain/src/block_verification.rs Outdated
dapplion added a commit to dapplion/lighthouse that referenced this pull request Apr 4, 2026
- Implement payload_lookup_request() (previously stubbed as NoRequestNeeded)
- Add PayloadEnvelopesByRoot RPC request/response handling
- Route envelope responses through router -> sync manager -> block lookups
- Add envelope processing via verify_envelope_for_gossip + import
- Add SinglePayloadEnvelope variant to SyncRequestId and BlockProcessType
- Wire PayloadRequest state machine transitions (Downloaded -> Processing -> Done)

Based on sigp#9039 by @eserilev, adapted for three-stream
lookup model from gloas-lookup-sync-fixes.
dapplion added a commit to dapplion/lighthouse that referenced this pull request Apr 4, 2026
- Implement payload_lookup_request() (previously stubbed as NoRequestNeeded)
- Add PayloadEnvelopesByRoot RPC request/response handling
- Route envelope responses through router -> sync manager -> block lookups
- Add envelope processing via verify_envelope_for_gossip + import
- Add SinglePayloadEnvelope variant to SyncRequestId and BlockProcessType
- Wire PayloadRequest state machine transitions (Downloaded -> Processing -> Done)

Based on sigp#9039 by @eserilev, adapted for three-stream
lookup model from gloas-lookup-sync-fixes.
dapplion added a commit to dapplion/lighthouse that referenced this pull request Apr 4, 2026
- Implement payload_lookup_request() (previously stubbed as NoRequestNeeded)
- Add PayloadEnvelopesByRoot RPC request/response handling
- Route envelope responses through router -> sync manager -> block lookups
- Add envelope processing via verify_envelope_for_gossip + import
- Add SinglePayloadEnvelope variant to SyncRequestId and BlockProcessType
- Wire PayloadRequest state machine transitions (Downloaded -> Processing -> Done)

Based on sigp#9039 by @eserilev, adapted for three-stream
lookup model from gloas-lookup-sync-fixes.
@michaelsproul michaelsproul changed the title Parent envelope unkown lookup [WIP] Parent envelope unknown lookup [WIP] Apr 5, 2026
@eserilev
Copy link
Copy Markdown
Member Author

I'd like to write tests for this before merging. I'll hold off marking this ready for review until the gloas beacon chain harness support lands

@eserilev eserilev changed the title Parent envelope unknown lookup [WIP] Parent envelope unknown lookup Apr 22, 2026
@eserilev eserilev added ready-for-review The code is ready for review and removed work-in-progress PR is a work-in-progress labels Apr 22, 2026
@mergify
Copy link
Copy Markdown

mergify Bot commented Apr 22, 2026

This pull request has merge conflicts. Could you please resolve them @eserilev? 🙏

@mergify mergify Bot added the waiting-on-author The reviewer has suggested changes and awaits thier implementation. label Apr 22, 2026
@mergify mergify Bot removed the ready-for-review The code is ready for review label Apr 22, 2026
@eserilev eserilev mentioned this pull request Apr 27, 2026
- block_verification: skip ParentEnvelopeUnknown check when parent is the
  proto-array anchor. The anchor's `payload_received` is intentionally
  false per spec (never added to `store.payloads`), but no envelope is
  expected for it; without this exception the check rejects every
  post-anchor gloas block.

- network tests: disable `engineGetBlobs` in the TestRig harness. Under
  real crypto the mock EL's blob fetch raced the gossip path, importing
  via a spawned task that the test didn't await -- leaving `head_root()`
  unchanged when the assertion ran. The tests are designed to exercise
  the gossip + data-column path; the engine fetch was incidental.

- network tests: relax `data_column_reconstruction_at_deadline` to allow
  trailing duplicate reconstruction work items. The reprocess queue
  removes its dedup entry on dispatch, so a column processed during an
  in-flight reconstruction can dispatch a second one. The second is a
  no-op via `reconstruction_started`, so accept >= 1 trailing event.
Replace `assert_event_journal_contains_at_least_ordered` helper with an
inline drain that just counts the gossip + reconstruction events. The
helper was carrying around `WORKER_FREED` bookkeeping and a strict
prefix-match for one caller; counting the two relevant work types until
both thresholds are met is the same check with much less code.
Wires the lookup test rig for Gloas:
- Capture per-block execution payload envelopes from the external harness
  and serve them to peers via a new `network_envelopes_by_root` map.
- Handle `RequestType::PayloadEnvelopesByRoot` in `simulate_on_request` and
  `Work::RpcPayloadEnvelope` in the simulator processor branch.
- Allow `TestRig` callers to override the genesis validator count and
  bump initial balances to `max_effective_balance_electra` post-Electra,
  which Gloas committee-selection requires for genesis init to converge.

Adds four tests for the parent-envelope-unknown flow (each verified
red/green by stubbing the corresponding source path):

- `creates_envelope_and_child_lookups` — `UnknownParentEnvelope` produces
  exactly one envelope-only lookup for the parent root and one child
  lookup awaiting that envelope.
- `idempotent_triggers` — repeated triggers for the same parent merge
  into the existing envelope lookup; no duplicate lookups are created.
- `issues_payload_envelopes_by_root_rpc` — the envelope-only lookup
  dispatches a `PayloadEnvelopesByRoot` RPC for the parent block_root.
- `drops_cascade_on_rpc_error` — when the envelope RPC errors, the
  envelope lookup is dropped and the awaiting child cascades with it.

The end-to-end happy path (envelope arrives → child unblocks → block
imports → head advances) is gated on
`process_execution_payload_envelope` supporting `AvailabilityPending`,
which today returns `InternalError("Pending payload envelope not yet
implemented")`. That gap is independent of this PR's lookup machinery.
- bad_peer_wrong_envelope_response — peer responds with a different block_root
  than requested; request items raise UnrequestedBlockRoot, both lookups drop.
- crypto_on_fail_with_bad_envelope_signature — signature corruption rejected
  in gossip verification, peer scored with lookup_envelope_processing_failure.

Rename the four already-landed tests to match the existing happy_path /
bad_peer / envelope_* / crypto_on_fail_with_* naming.
Implementation:
- payload_envelope_verification: implement the AvailabilityPending branch
  in the envelope import flow. Previously returned
  InternalError("Pending payload envelope not yet implemented") for any
  envelope whose data columns hadn't yet been received, blocking the
  end-to-end RPC import path. New `import_pending_execution_payload_envelope`
  marks the payload as received in fork choice and persists the envelope to
  the store; columns are still expected to arrive separately (gossip /
  engineGetBlobs / reconstruction) and persist their own ops.

- sync manager: short-circuit `handle_unknown_parent_envelope` when the
  parent's payload was received between gossip-verification and the trigger
  reaching sync. No lookup is created; the trigger is treated as a no-op.

- gossip→sync hook: when a Gloas envelope is imported via the gossip path,
  emit `SyncMessage::GossipEnvelopeImported { block_root }` so any lookups
  awaiting that parent envelope unblock without depending on the in-flight
  RPC response landing first. Closes the review-flagged race where a
  gossip-imported envelope left child lookups pinned.

Tests (3 new):
- envelope_already_received_skips_lookup — trigger after envelope already
  in fork choice creates zero lookups.
- happy_path_unknown_parent_envelope — end-to-end RPC import path: lookups
  complete, head advances to the gossip block.
- happy_path_unknown_parent_envelope_via_gossip — pending envelope-only
  lookup unblocked by a concurrent gossip import via the new sync hook.

Existing tests updated:
- bad_peer_envelope_rpc_failure / bad_peer_wrong_envelope_response now
  expect the lookup to retry and succeed (mirroring `bad_peer_*` tests for
  blocks/blobs/columns), reflecting the now-working import path.
@dapplion dapplion added work-in-progress PR is a work-in-progress and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Apr 28, 2026
/// store, but does not write data column ops. Columns are expected to arrive separately
/// (gossip, engineGetBlobs, or reconstruction).
#[instrument(skip_all)]
pub async fn import_pending_execution_payload_envelope(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a hack since we arent dealing with columns post-gloas at the moment. we should actually be sending this envelope to the da checker insteawd of just importing it immediately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gloas work-in-progress PR is a work-in-progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants