Skip to content

fix: pin getAttesters reads to a single L1 block (A-819)#23920

Merged
spalladino merged 1 commit into
merge-train/spartan-v5from
phil/a-819-audit-164-getattesters-stale-timestamp-across-chunked-rpc
Jun 9, 2026
Merged

fix: pin getAttesters reads to a single L1 block (A-819)#23920
spalladino merged 1 commit into
merge-train/spartan-v5from
phil/a-819-audit-164-getattesters-stale-timestamp-across-chunked-rpc

Conversation

@PhilWindle

Copy link
Copy Markdown
Collaborator

Fixes A-819 (Audit #164).

Problem

RollupContract.getAttesters (yarn-project/ethereum/src/contracts/rollup.ts) made several sequential RPC reads with no pinned block:

  • getActiveAttesterCount() (read at latest)
  • N chunked getAttestersFromIndicesAtTime(...) reads, one per 1000 indices (each read at latest)

The ts timestamp argument was already captured once and reused consistently across chunks, so the literal "stale timestamp across chunks" framing of the title doesn't occur. The real defect is that the reads are not pinned to a single L1 block: across a block boundary or reorg, the count and the individual chunk reads can observe different attester sets, yielding an inconsistent or truncated result. This only bites for attester sets larger than the 1000-entry chunk size, read precisely across a set-changing block — hence low impact, but real.

Fix

Fetch the current block once in getAttesters, then thread its number as a blockNumber option through getActiveAttesterCount and every chunked getAttestersFromIndicesAtTime read so they all evaluate against the same L1 block. This follows the existing checkBlockTag(options?.blockNumber, ...) pattern already used by many reads in rollup.ts (e.g. getCheckpointNumber, status, canPruneAtTime).

  • getActiveAttesterCount and GSEContract.getAttestersFromIndicesAtTime now accept an optional { blockNumber }.

Testing

Verified the full TypeScript build passes. No automated test added: reproducing the block-drift race deterministically would require anvil plus a hook to advance an L1 block between the count read and the chunk reads (or deep viem-client mocking), which isn't justified for this low-impact, pattern-following change. The block-pinning behavior mirrors other pinned reads in the same file.

getAttesters issued an unpinned getActiveAttesterCount read followed by N
chunked getAttestersFromIndicesAtTime reads, each defaulting to `latest`.
Across a block boundary or reorg the count and chunks could observe
different attester sets, producing an inconsistent or truncated result
for sets larger than the 1000-entry chunk size.

Fetch the current block once and thread its number as a blockNumber
option through getActiveAttesterCount and every chunked read so they all
evaluate against the same L1 block.
@PhilWindle PhilWindle added the ci-draft Run CI on draft PRs. label Jun 6, 2026
@PhilWindle PhilWindle marked this pull request as ready for review June 7, 2026 18:47
@spalladino spalladino merged commit b90c188 into merge-train/spartan-v5 Jun 9, 2026
31 checks passed
@spalladino spalladino deleted the phil/a-819-audit-164-getattesters-stale-timestamp-across-chunked-rpc branch June 9, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants