Repository navigation
fix(p2p): bound envelopes-by-root answers by bytes and read them as they are sent - #958
Merged
pablodeymo merged 5 commits intoDec 2, 2026
Conversation
…hey are sent `execution_payload_envelopes_by_root` collected up to `MAX_REQUEST_PAYLOADS` (128) decoded envelopes in the P2P actor with no byte bound, and answered a root once per mention. A request naming one large block's root 128 times loaded about 1 GiB from a single stored envelope. - The answer stops once `ENVELOPES_BY_ROOT_BYTE_BUDGET` (the range's 16 MiB of SSZ) has gone out, always carrying the first envelope it has. - The handler resolves each root to its block's slot and the codec reads each row as it writes that chunk (`EnvelopesByRoot`, `Store::execution_payload_envelopes_of`), the way the by-range answer already does. `EnvelopeAnswer<I>` is the budgeted answer both share. - A root named more than once is answered once, at its first place.
Collaborator
Author
|
/review |
AI security review: 0 finding(s) to checkReviewed by Opus, GPT, Kimi, GLM, DeepSeek. A judge model checked every one of the findings against the code. No findings to check. Pre-existing (real, but already on the base branch): 1
Cost of this review: ~$1.90 of a $30 budget (estimated from token counts). |
…by-root-byte-budget # Conflicts: # CLAUDE.md # crates/storage/src/store.rs # docs/beacon_wire.md
…by-root-byte-budget
A peer answering either envelope protocol may send MAX_REQUEST_PAYLOADS chunks of MAX_PAYLOAD_SIZE, whatever was asked for, and the reader decoded and held every one until the stream ended: about 1.25 GiB for one request. The serving budgets bound what this node sends, not what it reads. ChunkLimits gains max_bytes: once that many payload bytes have been read no further chunk is, and what was read is the answer. The chunk that crosses the limit is kept, so the first always is. Envelope answers are read under ENVELOPE_RESPONSE_BYTE_BUDGET, the servers' 16 MiB, so one answer holds under 26 MiB and an answer from a node with this serving budget is read whole. A longer one is cut rather than refused and reads as a short answer: by range the requester already asks again for the slots after its last envelope, and by root this node names one root a request. The block and column readers are unchanged.
Collaborator
Author
|
/review |
…by-root-byte-budget # Conflicts: # crates/net/p2p/src/req_resp/messages.rs
AI security review: 0 finding(s) to checkReviewed by Opus, GPT, Kimi, GLM, DeepSeek. A judge model checked every one of the findings against the code. No findings to check. Pre-existing (real, but already on the base branch): 4
Cost of this review: ~$2.73 of a $30 budget (estimated from token counts). |
pablodeymo
merged commit Dec 2, 2026
40f8098
into
fix/envelopes-by-range-byte-budget
14 checks passed
pablodeymo
added a commit
that referenced
this pull request
Dec 2, 2026
…they are sent (#968) ## 🗒️ Description / Motivation Backport of #956 to `release/v2.0.0`, for `v2.0.0-rc.2`. #956 is approved and not merged on `main` yet, so this is taken from its head (`36232dcf`) and not from a squash commit on `main`. If #956 changes before it merges, this branch has to be refreshed from the new head. ## What Changed The ten commits of #956 as one commit on top of `release/v2.0.0` (`3ed99c86`): the diff from its branch point on `main` (`e48246f8`) to its head (`36232dcf`), applied with `git apply --3way`. It applied without conflicts and nothing was edited by hand. That includes #958, the by-root counterpart, which was merged into #956's branch. What it does, from #956: - An `execution_payload_envelopes_by_range` answer stops once 16 MiB of SSZ has gone out, always carrying the first envelope its window has. Before, one request could make the node load and send about 1 GiB. - Envelopes are read as they are sent: the codec reads each row just before writing its chunk, and a row that fails to read or decode ends the answer where it is. - The requester asks the same peer again after an answer that stops short, for up to 30 s. - `execution_payload_envelopes_by_root` answers are bounded and read the same way (#958). ## Tests Added / Run On this branch: - `cargo fmt --all -- --check` and `make lint`: clean. - `cargo test -p ethlambda-p2p --profile release-fast --lib`: 587 passed, 0 failed, 1 ignored. - `cargo test -p ethlambda-storage --profile release-fast --features rocksdb`: 256 passed, 0 failed, 2 ignored. Not run locally: the rest of `make test`. ## Related Issues / PRs - Original: #956 (closes #895 on `main`), with #958. - The other PRs open against the release branch: #954, #962 (backport of #950) and #965 (backport of #952). This one merges with each of them without conflicts (checked with `git merge-tree`), though it shares `crates/net/p2p/src/lib.rs`, `CLAUDE.md` and `docs/beacon_wire.md` with some of them. - Release checklist: #943.
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 #956. Review and merge that one first; this PR's diff is only the by-root part.
Motivation
#956 bounds
execution_payload_envelopes_by_range(#895).execution_payload_envelopes_by_roothas the same shape and was left open there:MAX_REQUEST_PAYLOADS(128) decoded envelopes in the P2P actor, with no bound on their total size.What changed
The by-root answer uses the by-range mechanism (
req_resp/envelopes.rs,storage/src/store.rs)ENVELOPES_BY_ROOT_BYTE_BUDGEThas gone out. It is the range's 16 MiB of SSZ, for the same reasons. The specification allows it ("Clients MAY limit the number of payload envelopes in the response") and asks for "at least one payload envelope, if they have it", which stopping only once the budget is spent gives.Store::execution_payload_envelopes_of). The codec reads each envelope row as it writes that chunk (EnvelopesByRoot), so the answer is never in memory whole and the P2P actor reads no envelope.EnvelopeAnswer<I>is the budgeted answer both protocols now share.EnvelopesByRangeandEnvelopesByRootare aliases over where the envelopes come from. The budget, the oversized-envelope skip and the end-on-read-failure rule are written once.A repeated root is answered once, at its first place. The answer is "a list [...] whose length is less than or equal to the number of requested" envelopes either way.
The requester stops reading an answer at a byte budget (
req_resp/encoding.rs,beacon/encoding.rs)MAX_REQUEST_PAYLOADSchunks ofMAX_PAYLOAD_SIZEto either envelope protocol, whatever was asked, and the reader held every decoded envelope until the stream ended: about 1.25 GiB for one request. The automated review listed this as present onmain.ChunkLimitsgainsmax_bytes. Envelope answers are read underENVELOPE_RESPONSE_BYTE_BUDGET, the servers' 16 MiB: the envelope that crosses it is kept, so the first always is, and one answer holds under 26 MiB.Docs.
docs/beacon_wire.mdandCLAUDE.md.Behaviour preserved
MAX_REQUEST_PAYLOADSroots are looked at.Limits
Testing
make fmt,make lintandmake test-nodepass (2,853 passed, 0 failed, 9 ignored).make test-consensusandmake test-ethrexwere not run locally; the changed crates (ethlambda-storage,ethlambda-p2p) are in thetest-nodehalf.Codec::write_responseandread_response.