Skip to content

Conversation

pawanjay176
Copy link
Member

@pawanjay176 pawanjay176 commented Aug 27, 2025

Issue Addressed

N/A

The Problem

Our current strategy of syncing blocks + columns by range works roughly as follows for each batch:

  1. Find a peer from the current SyncingChain to fetch blocks from and send a BlocksByRange request
  2. Find peer(s) from the global peer pool that should have columns for the same batch based on their status message and the columns they are supposed to custody , and send them a by DataColumnsByRange request at the same time
  3. Once we get responses for all blocks + columns components, try to couple them by checking that the block_root and the kzg_commitment matches. If the coupling failed, try to re-request the failed columns.
  4. Send them for processing and try to progress the chain

This strategy works decently well when the chain is finalizing as most of our peers are on the same chain. However, in times of non-finality we need to potentially sync multiple head chains.
This leads to issues with our current approach because the block peer and the data column peers might have a different view of the canonical chain due to multiple heads. So when we use the above approach, it is possible that the block peer returns us a batch of blocks for chain A while some or all data column peers send us the batch of data columns for a different chain B. Different data column peers might also be following different chains.

We initially tried to get around this problem by selecting column peers only from within the current SyncingChain. Each SyncingChain represents a head_root that we are trying to sync to and we group peers based on same head_root. That way, we know for sure that the block and column peers are on the same chain. This works in theory, but in practice, during long periods of non-finality, we tend to create multiple head chains based on the head_root and split the global peerset. Pre-fulu, this isn't a big deal since all peers are supposed to have all the blob data.
But splitting peers with peerdas is a big challenge due to not all peers having the full data available. There are supernodes, but during bad network conditions, supernodes would be getting way too many requests and not even have any incoming peer slots. As we saw on fusaka devnets, this strategy leads to sync getting stalled and not progressing.

Proposed Changes

1. Use DataColumnsByRoot instead of DataColumnsByRange to fetch columns for forward sync

This is the main change. The new strategy would go as follows:

  1. Find a peer from the current SyncingChain to fetch blocks from and send a BlocksByRange request
  2. Hold off on requesting for columns until we receive the response for the above blocks request
  3. Once we get the blocks response, extract all the block_roots and trigger a DataColumnsByRoot request for every block in the response that has any blobs based on the expected_kzg_commitments field.
  4. Since we request by root, we know what we are expecting in the response. The column peer's view of the canonical chain might be chain A, but if we ask for chain B and they have chain B in their fork choice, they can still serve us what we need.
  5. We couple the block + column responses and send them for processing as before.

(4) kinda assumes that most synced/advanced peers would have different chains in their fork choice to be able to serve specific by root requests. My hunch is that this is true, but we should validate this in a devnet 4 like chain split scenario.

Note: that we currently use this by root strategy only for forward sync, not for backfill. Backfill has to deal with only a single canonical chain so byrange requests should work well there.

2. ResponsiblePeers to attribute peer fault correctly

Adds the ResponsiblePeers struct which stores the block and the column peers that we made the download requests to.
For most of our peer attributable errors, the processing error indicates whether the block peer was at fault or if the column peer was at fault.

We now communicate this information back to sync and downscore specific peers based on the fault type. This imo, is an improvement over current unstable where most of the time, we attribute fault to the peer that "completed" the request by being the last peer to respond.
Due to this ambiguity in fault attribution, we weren't downscoring pretty serious processing errors like InvalidKzgProofs, InvalidExecutionPayload etc. I think this PR attributes the errors to the right peers. Reviewers please check that this claim is actually true.

3. Make AwaitingDownload an allowable in-between state

Note: This has been extracted to its own PR here and merged #7984
Prior to peerdas, a batch should never have been in AwaitingDownload state because we immediataly try to move from AwaitingDownload to Downloading state by sending batches. This was always possible as long as we had peers in the SyncingChain in the pre-peerdas world.

However, this is no longer the case as a batch can be stuck waiting in AwaitingDownload state if we have no peers to request the columns from. This PR makes AwaitingDownload to be an allowable in between state. If a batch is found to be in this state, then we attempt to send the batch instead of erroring like before.
Note to reviewer: We need to make sure that this doesn't lead to a bunch of batches stuck in AwaitingDownload state if the chain can be progressed.

@jimmygchen jimmygchen added syncing v8.0.0-rc.0 Q3 2025 release for Fusaka on Holesky labels Aug 27, 2025
@jimmygchen jimmygchen self-requested a review August 29, 2025 08:35
@pawanjay176 pawanjay176 added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Sep 17, 2025
@pawanjay176
Copy link
Member Author

This one should be ready for another round of review. Used claude to fix up the sync tests, lmk if you wanted a different approach. I don't have strong opinions on the test suite.

Copy link

mergify bot commented Sep 22, 2025

This pull request has merge conflicts. Could you please resolve them @pawanjay176? 🙏

@mergify mergify bot added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Sep 22, 2025
Copy link
Member

@eserilev eserilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone through about half of this PR. Mostly just nits

In general there are probably opportunities to refactor/reduce code duplication but I agree with you that this PR is already big and any refactors should be made in a subsequent PR

I'll aim to finish my review tomorrow

Comment on lines 809 to 821
if matches!(epe, ExecutionPayloadError::RejectedByExecutionEngine { .. }) {
debug!(
error = ?err,
"Invalid execution payload rejected by EE"
);
Err(ChainSegmentFailed {
message: format!(
"Peer sent a block containing invalid execution payload. Reason: {:?}",
err
),
peer_action: Some(PeerAction::LowToleranceError),
faulty_component: Some(FaultyComponent::Blocks), // todo(pawan): recheck this
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why RejectedExecutionEngine is a low tolerance error but other ExecutionPayloadErrors are not? Like InvalidPayoadTimestamp for example

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agree this is quite opaque. I created a new penalize_sync_peer method to extract the functionality in aa6a1bc
Would be good to get extra eyes on this cc @dapplion

/// Note: this variant starts out in an uninitialized state because we typically make
/// the column requests by root only **after** we have fetched the corresponding blocks.
/// We can initialize this variant only after the columns requests have been made.
DataColumnsFromRoot {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we could rename the old DataColumns variant to DataColumnsByRange just for clarity

Copy link
Member

@eserilev eserilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this branch on devnet-3. I ran both range sync and backfill sync in the fullnode and supernode case and it worked well. Supernode backfill is slow, but its also the same on unstable. I guess we wouldn't really see any sync improvements unless we tried syncing on a forky network. I'm happy to green check this once CI is passing

@dapplion
Copy link
Collaborator

dapplion commented Sep 25, 2025

@pawanjay176 this commit merges data_columns_by_root_range_requests and data_columns_by_root_requests with a -216 lines diff. Feel free to cherry-pick into your branch but I feel the SyncNetworkContext is easier to understand this way 26ed0ebae

}
debug!(?requests, "Successfully retried requests");
}
Err(err) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should match Err(RpcRequestSendError::NoPeer(err)) explicitly and if it's an InternalError discard the request. Otherwise we may infinte loop

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discarding the request is also not great as that may stall sync silently. I thought this way, atleast we know what's causing the stalling by making some noise in the logs

/// can result in undefined state, so it's treated as a hard error and the lookup is dropped.
UnexpectedRequestId {
expected_req_id: DataColumnsByRootRequestId,
req_id: DataColumnsByRootRequestId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary? Pushed a commit that reverts this change and everything compiles fine. Feel free to cherry-pick 51ab53b

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah don't remember why i did this tbh

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh I remember now. In this PR, the DataColumnsByRootRequestId struct became larger because DataColumnsByRootRequester became an enum.

So the linter was throwing a bunch of errors like

error: the `Err`-variant returned from this function is very large
   --> beacon_node/network/src/sync/network_context/custody.rs:455:10
    |
48  | /     UnexpectedRequestId {
49  | |         expected_req_id: DataColumnsByRootRequestId,
50  | |         req_id: DataColumnsByRootRequestId,
51  | |     },
    | |_____- the largest variant contains at least 224 bytes
...
455 |       ) -> Result<(), Error> {
    |            ^^^^^^^^^^^^^^^^^
    |
    = help: try reducing the size of `sync::network_context::custody::Error`, for example by boxing large elements or replacing it with `Box<sync::network_context::custody::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

Changed it to Id to keep the struct smaller. I felt it gave us similar info to debug if required.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We implement custom impl Display for all these Id types so the visual result is the same

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but we would need to silence the clippy warnings all around places which return RpcRequestErrors in that case.

dapplion and others added 8 commits September 25, 2025 16:18
…uled (sigp#8109)

sigp#8105 (to be confirmed)

I noticed a large number of failed discovery requests after deploying latest `unstable` to some of our testnet and mainnet nodes. This is because of a recent PeerDAS change to attempt to maintain sufficient peers across data column subnets - this shouldn't be enabled on network without peerdas scheduled, otherwise it will keep retrying discovery on these subnets and never succeed.

Also removed some unused files.


  


Co-Authored-By: Jimmy Chen <[email protected]>

Co-Authored-By: Jimmy Chen <[email protected]>
…igp#8112)

- PR sigp#8045 introduced a regression of how lookup sync interacts with the da_checker.

Now in unstable block import from the HTTP API also insert the block in the da_checker while the block is being execution verified. If lookup sync finds the block in the da_checker in `NotValidated` state it expects a `GossipBlockProcessResult` message sometime later. That message is only sent after block import in gossip.

I confirmed in our node's logs for 4/4 cases of stuck lookups are caused by this sequence of events:
- Receive block through API, insert into da_checker in fn process_block in put_pre_execution_block
- Create lookup and leave in AwaitingDownload(block in processing cache) state
- Block from HTTP API finishes importing
- Lookup is left stuck

Closes sigp#8104

  - sigp#8110 was my initial solution attempt but we can't send the `GossipBlockProcessResult` event from the `http_api` crate without adding new channels, which seems messy.

For a given node it's rare that a lookup is created at the same time that a block is being published. This PR solves sigp#8104 by allowing lookup sync to import the block twice in that case.

Co-Authored-By: dapplion <[email protected]>
This reverts commit 6ea14016f3d164456bc4c3cae0355ab532fe1a86.
@jimmygchen jimmygchen added v8.0.0 Q4 2025 Fusaka Mainnet Release and removed v8.0.0-rc.0 Q3 2025 release for Fusaka on Holesky labels Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
syncing v8.0.0 Q4 2025 Fusaka Mainnet Release waiting-on-author The reviewer has suggested changes and awaits thier implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants