Repository navigation
fix(p2p): bound envelopes-by-range answers by bytes and read them as they are sent - #956
Open
pablodeymo wants to merge 1 commit into
Open
pablodeymo wants to merge 1 commit into
pablodeymo wants to merge 1 commit into
Conversation
…they are sent `execution_payload_envelopes_by_range` answered with every canonical envelope in the window, up to `MAX_REQUEST_PAYLOADS` (128), collected in memory by the P2P actor before responding. An execution block may be 8 MiB, so one request could make the node load and send about 1 GiB. Server: - The answer stops once `ENVELOPES_BY_RANGE_BYTE_BUDGET` (16 MiB of SSZ) has gone out. It always carries the first envelope the window has and overshoots by less than one envelope. - The handler only plans the answer. The codec reads each envelope row as it writes that chunk (`EnvelopesByRange`, `CanonicalEnvelopes`), so the answer is never in memory whole and the P2P actor reads no envelope. Planning does not touch the envelope table: on RocksDB an existence check loads the value it finds. - A row that fails to read ends the answer where it is, instead of a panic. Requester: - An answer that stops short of the span is followed by a request to the same peer for the slots after its last envelope, with range sync's next batch still held, for up to `ENVELOPE_FOLLOW_UP_WINDOW` (30 s). - A session's last batch is followed up too; a session ended for cause is not, and neither is a span once another session runs. Closes #895
This branch has not been deployed
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.
Closes #895.
Motivation
execution_payload_envelopes_by_rangeanswered with every canonical envelope in the window, up toMAX_REQUEST_PAYLOADS(128), and the P2P actor collected them all in memory before responding. Nothing bounded their total size.What changed
A byte budget on the answer (
req_resp/envelopes.rs)ENVELOPES_BY_RANGE_BYTE_BUDGET(16 MiB of SSZ, before compression) has gone out. The specification allows it: "Clients MAY limit the number of payload envelopes in the response".Envelopes are read as they are sent (
storage/src/store.rs,req_resp/codec.rs,beacon/encoding.rs)Store::canonical_execution_payload_envelopesnow returns a plan (CanonicalEnvelopes): the canonical blocks of the window and theparent_block_hasheach successor builds on, from one view. It reads rows one at a time as an iterator.ResponsePayload::ExecutionPayloadEnvelopesByRange, and the codec reads each row just before writing its chunk. The answer is never in memory whole, the P2P actor reads no envelope, and a peer that stops reading stops the reads.Table::ExecutionPayloadEnvelopes, not even for an existence check: on RocksDBcontainsis a pinned get, which loads the value. A block with no envelope is passed over at its turn, for one point read that misses.expect, and it now runs on the connection task, where a panic takes the swarm down.The requester asks again after a short answer (
req_resp/envelope_client.rs)ENVELOPE_FOLLOW_UP_WINDOW(30 s) after the batch's envelopes were first asked for. They hold the next batch back, and an envelope counts as progress before any check of it, so unbounded, a peer answering one envelope per request could hold a 128-slot batch for about 21 minutes.release_envelope_requests_of) and names no session from then.end_range_session) is not followed up, and neither is any span once another session is running.Docs.
docs/beacon_wire.mdandCLAUDE.md.Behaviour preserved
mainserved: the successor's bidparent_block_hashmust equal the payload'sblock_hash, the head's envelope is served only on the FULL node, and the successor of the window's last block is searched for pastend_slot.countisINVALID_REQUEST, astart_slotbelow the anchor isRESOURCE_UNAVAILABLE, and acountoverMAX_REQUEST_PAYLOADSis truncated.payload.slot_number. The two are equal for a stored envelope.Limits
execution_payload_envelopes_by_rootstill collects up to 128 envelopes with no byte bound, and does not deduplicate roots, so a request naming one large block's root 128 times loads about 1 GiB. Out of this issue's scope; a follow-up PR covers it.MAX_PAYLOAD_SIZEwith no total cap. Unchanged here.Context. The pieces on either side are tested.Testing
make fmt,make lintandmake test-nodepass (2,843 passed, 0 failed, 9 ignored).make test-consensusandmake test-ethrexwere not run; neither half builds the changed code paths' tests.CountingBackend), each step reads one row, and a corrupt row is an error rather than a panic.Codec::write_responseandread_response.