Skip to content

feat: validator streaming acceptance conditions, flag off (A-1383)#24788

Open
spalladino wants to merge 4 commits into
spl/a-1382-sequencer-streamingfrom
spl/a-1383-validator-streaming
Open

feat: validator streaming acceptance conditions, flag off (A-1383)#24788
spalladino wants to merge 4 commits into
spl/a-1382-sequencer-streamingfrom
spl/a-1383-validator-streaming

Conversation

@spalladino

Copy link
Copy Markdown
Contributor

Implements A-1383: the validator's streaming-Inbox acceptance conditions (AZIP-22 Fast Inbox), behind the shared streamingInbox flag (default off). Flag off ⇒ byte-identical behavior. Stacked on #24787 (A-1382).

The four block-proposal checks (validator-client/src/streaming_inbox_checks.ts, wired in proposal_handler.handleBlockProposal)

  • Exists: the referenced bucket resolves in the node's own Inbox view and its consensus rolling hash matches the reference. An unknown bucket is an immediate reject (bucket_unknown); the bounded-wait soft path is A-1393. The reference is trusted only as a bucketSeq lookup hint — timestamp/counts are read from the locally resolved bucket.
  • Moves forward: the bucket's cumulative total is at least the parent block's (equal ⇒ empty bundle).
  • Not too new: the bucket is at least INBOX_LAG_SECONDS old at validation time (dateProvider.now(), inclusive boundary).
  • Caps: the per-block count and the running per-checkpoint total fit MAX_L1_TO_L2_MSGS_PER_BLOCK / MAX_L1_TO_L2_MSGS_PER_CHECKPOINT.

The derived bundle is fed into per-block re-execution (insertMessagesPerBlock threaded through openCheckpointreexecuteTransactions); the existing state-ref comparison after re-execution stays the final arbiter.

Last-block censorship check (validateCheckpointProposal)

Before attesting, the minimum-consumption rule runs via the shared isInboxConsumptionSufficient predicate: the first unconsumed bucket must be absent, past the cutoff, or a cap-escape. A mandatory unconsumed bucket rejects the checkpoint (no attestation, inbox_consumption_insufficient).

Shared-predicate extraction (refactor commit)

The cutoff formula and the minimum-consumption/cap-escape rule moved to stdlib/messaging/inbox_consumption, so the sequencer's bucket selection and the validator share one source of truth. The sequencer's selectStreamingBundle now calls getInboxCutoffTimestamp instead of inlining it — behavior unchanged (selector suite still green).

Corrected cutoff anchor

The cutoff is getTimestampForSlot(slot - 1) - INBOX_LAG_SECONDS (mirroring ProposeLib.validateInboxConsumption), not getBuildFrameStart. The A-1371 §13 cross-layer vectors are pinned in inbox_consumption.test.ts.

Parent-ref derivation

Parent/last-consumed buckets are resolved from L1-to-L2 tree leaf counts (compact post-flip indexing == bucket cumulative total) via a new getInboxBucketByTotalMsgCount archiver lookup. A leaf count that does not land on a bucket boundary (a pre-flip padded parent) is rejected/deferred; the flip (A-1384) closes that gap.

CI must typecheck what can't be verified locally

tsc -b cannot complete locally due to pre-existing noir-protocol-circuits-types breakage (missing artifacts / stale generated types), which cascades to archiver/validator-client. stdlib builds clean; no errors in the changed files outside the broken zone. Runnable unit suites are green: streaming_inbox_checks (14), inbox_consumption (10), proposal_handler (34, incl. flag-off unchanged + new streaming/censorship tests), message_store (35), stdlib archiver interface (RPC schema). CI is the typecheck of record for the unbuildable zone.

Out of scope: bounded-wait (A-1393), the flip (A-1384), reorg rejection (A-1389), the full streaming checkpoint rebuild (A-1385).

…383)

Move the streaming-Inbox cutoff formula and the mandatory-consumption / cap-escape
rule into a shared `stdlib/messaging/inbox_consumption` module so the sequencer's
bucket selection and the validator's last-block censorship check share one source of
truth for the boundary semantics.

- `getInboxCutoffTimestamp(slot, l1Constants, lagSeconds)`: buildFrameStart(slot) -
  lagSeconds, mirroring `ProposeLib.validateInboxConsumption`. The sequencer's
  `selectStreamingBundle` now calls it instead of inlining the computation (behavior
  unchanged).
- `isInboxConsumptionSufficient(...)`: the none / past-cutoff (strict >) / cap-escape
  predicate.
- Tests pin the A-1371 section-13 cross-layer vectors (genesisTime=100000,
  slotDuration=36): the cutoff table and the S=10 mandatory-consumption boundary.
…REAMING_INBOX (A-1383)

Behind the shared `streamingInbox` flag (default off), the validator applies the AZIP-22
Fast Inbox acceptance conditions in place of the legacy per-checkpoint inHash comparison.
Flag off, behavior is byte-identical.

Block proposals (`proposal_handler.handleBlockProposal`), via a new pure
`streaming_inbox_checks` module:
- exists: the referenced bucket resolves in the node's own Inbox view and its rolling
  hash matches the reference (unknown bucket is an immediate reject; the bounded wait is
  A-1393);
- moves forward: the bucket's cumulative total is at least the parent block's;
- not too new: the bucket is at least INBOX_LAG_SECONDS old at validation time
  (dateProvider.now, inclusive boundary);
- caps: the per-block count and the running per-checkpoint total fit their caps.
The derived bundle is fed into per-block re-execution (insertMessagesPerBlock threaded
through openCheckpoint/reexecuteTransactions), whose state-ref comparison stays the final
arbiter.

Checkpoint proposals (`validateCheckpointProposal`): the last-block minimum-consumption
(censorship) rule runs before attesting, via the shared `isInboxConsumptionSufficient`
predicate and the corrected cutoff anchor `getTimestampForSlot(slot - 1) -
INBOX_LAG_SECONDS`; a mandatory unconsumed bucket rejects the checkpoint (no attestation).

Parent/last-consumed buckets are resolved from L1-to-L2 tree leaf counts via a new
`getInboxBucketByTotalMsgCount` archiver lookup (compact post-flip indexing); a leaf count
that does not land on a bucket boundary (a pre-flip padded parent) is rejected/deferred,
the flip (A-1384) closes that gap.

The flag is picked up on the validator config via pickConfigMappings of the shared
`streamingInbox` key. New reasons are non-slashable while the path lands. Full tsc -b
cannot run locally (pre-existing noir-protocol-circuits-types breakage); CI is the
typecheck of record for validator-client. Unit tests cover each check, the caps and lag
boundaries, running-total accumulation, the censorship predicate, and the handler wiring.
…lidator (A-1383)

Consolidate the three `BigInt(block.header.state.l1ToL2MessageTree.nextAvailableLeafIndex)`
reads into a single `blockLeafCount` helper.
The archiver only writes bucket snapshots for ingested messages, whose first bucket is
sequence 1, so `getInboxBucket(0)` / `getInboxBucketByTotalMsgCount(0)` returned undefined.
That broke streaming resolution of a genesis parent (first block would reject
`parent_bucket_unresolved`), of an empty genesis block's own bucket reference, and let an
empty checkpoint skip the last-block censorship enforcement. Synthesize the sequence-0
sentinel (rolling hash 0, total 0) on read, mirroring the on-chain Inbox's base case, with
a store-level test exercising it through a populated MessageStore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant