Repository navigation
Bound API submissions and proposer preparations - #453
Merged
Merged
Conversation
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.
vladimir-ea
approved these changes
Nov 6, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #452, since both change the connection loop in
beacon_api/src/server.rs. Retarget tomainonce that PR merges.Summary
beacon_api_requestsqueue (capacity 2^14), and lists could hold up to 256K entries.prepare_beacon_proposerentries whose index is at or beyond the head registry length are dropped, and the request still gets 200, as Lighthouse does.Testing
silver_beacon_apitests pass.