Skip to content

Bound API submissions and proposer preparations - #453

Merged
ninaiiad merged 6 commits into
mainfrom
ac/api-submission-bounds
Nov 6, 2026
Merged

ninaiiad merged 6 commits into
mainfrom
ac/api-submission-bounds

Conversation

@adrianchifor

Copy link
Copy Markdown
Contributor

Stacked on #452, since both change the connection loop in beacon_api/src/server.rs. Retarget to main once that PR merges.

Summary

  • Submission size
    • Each entry of a submission becomes one message on the beacon_api_requests queue (capacity 2^14), and lists could hold up to 256K entries.
    • A submission may now carry at most 4096 entries; larger bodies get 400. That is a quarter of the queue, and one slot's attestations for 131,072 validators.
    • This applies to every multi-entry submission: attestations, sync committee messages, aggregates, contributions, payload attestations, BLS changes and proposer preferences. Larger BLS-change batches need splitting.
  • Outstanding messages
    • At most 8192 messages (half the queue) may await verdicts across all connections; a request that would exceed this gets 503.
    • A single-entry submission, such as a block, is always admitted.
    • The total is derived from each connection's pending state, so it is released as verdicts arrive or connections close and cannot drift.
  • Proposer preparations
    • prepare_beacon_proposer entries whose index is at or beyond the head registry length are dropped, and the request still gets 200, as Lighthouse does.
    • Validators pending activation already have registry indices.

Testing

  • New tests cover the per-request cap, the 503 budget (including release on verdicts and on reaping, and the single-entry exemption) and dropped preparations. Each fails without its fix.
  • silver_beacon_api tests pass.

dispatch ran httparse over the whole buffered head on every read. A head
arriving in small reads was rescanned from its start each time. The cost
grew with the square of the head size, up to the 16 MiB read cap.

dispatch now scans each new byte once for a possible end of head. It
parses when one is found, or when the buffered bytes have doubled. The
doubling keeps the early 400 for bytes that cannot start a request.
Leading empty lines are dropped first, as httparse would skip them. Once
the head is parsed, its request length is kept. The head is not parsed
again until the body is complete.

A head is now limited to 4 MiB and answered with 431 past it. A GET may
list 32768 validator ids by pubkey, about 3.2 MiB, so a smaller limit
would refuse it. A const assert keeps the two limits in step.

The 431 now arrives before the read buffer can fill, so
reject_exhausted is removed.
read_buf doubles up to the 16 MiB read cap and kept its peak size for
the life of the connection. Only write_buf was shrunk after a response.
A keep-alive connection that once received a large body held that
memory until it closed.

When the read buffer empties and has grown past 64 KiB, it now shrinks
back to its initial 4 KiB. Typical request bodies stay within 64 KiB, so
they keep reusing the buffer without regrowing it.
The only connection timeout was the 75 s idle deadline, and every byte
refreshed it. A request whose head or body kept arriving a few bytes at a
time could hold a connection slot for as long as it kept sending.

Each request now has a 60 s deadline, from its first byte until it is
complete. The idle sweep answers an overdue request with 408 and
lingers, like other rejects. The wait between keep-alive requests is
unchanged and still governed by the idle deadline.

A body at the 16 MiB read cap needs about 2.2 Mbit/s to meet the
deadline. Bodies that matter, such as blocks, are useless after one 12 s
slot anyway.
prepare_beacon_proposer recorded every well-formed validator_index.
The BeaconState tile kept each one in a map for two epochs.
Indices at or past the head registry length are now dropped.

Such an index cannot propose within the two retained epochs.
Validator clients resend preparations each epoch.
The request still answers 200, as Lighthouse does for unknown indices.
Each accepted submission entry becomes one message per topic on the
beacon_api_requests queue, emitted in one burst. That queue holds 2^14
messages and is shared with block and other requests. A single body could
carry up to 256K entries, more than the queue holds. Consumers that fall
that far behind skip ahead, losing unrelated requests.

Multi-entry submission bodies are now capped at 4096 entries. That covers
one slot's attestations for 131,072 validators.

The server also caps entries awaiting verdicts across all connections at
8192, half the queue. A body that would exceed it is answered 503. The
count is derived from each connection's pending submission. It is released
as verdicts arrive or when the connection is reaped.

A body of one entry is always admitted. The connection cap bounds those,
and refusing a block would lose its proposal.
Base automatically changed from ac/http-server-limits to main November 5, 2026 16:25
@ninaiiad
ninaiiad merged commit 1d74f87 into main Nov 6, 2026
11 checks passed
@ninaiiad
ninaiiad deleted the ac/api-submission-bounds branch November 6, 2026 12:13
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.

3 participants