Tree-sync friendly lookup sync tests (#8592)

- Step 0 of the tree-sync roadmap https://github.com/sigp/lighthouse/issues/7678

Current lookup sync tests are written in an explicit way that assume how the internals of lookup sync work. For example the test would do:

- Emit unknown block parent message
- Expect block request for X
- Respond with successful block request
- Expect block processing request for X
- Response with successful processing request
- etc..

This is unnecessarily verbose. And it will requires a complete re-write when something changes in the internals of lookup sync (has happened a few times, mostly for deneb and fulu).

What we really want to assert is:

- WHEN: we receive an unknown block parent message
- THEN: Lookup sync can sync that block
- ASSERT: Without penalizing peers, without unnecessary retries


  Keep all existing tests and add new cases but written in the new style described above. The logic to serve and respond to request is in this function `fn simulate` 2288a3aeb1/beacon_node/network/src/sync/tests/lookups.rs (L301)
- It controls peer behavior based on a `CompleteStrategy` where you can set for example "respond to BlocksByRoot requests with empty"
- It actually runs beacon processor messages running their clousures. Now sync tests actually import blocks, increasing the test coverage to the interaction of sync and the da_checker.
- To achieve the above the tests create real blocks with the test harness. To make the tests as fast as before, I disabled crypto with `TestConfig`

Along the way I found a couple bugs, which I documented on the diff.


Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com>
This commit is contained in:
Lion - dapplion
2026-02-12 21:24:51 -07:00
committed by GitHub
parent c59e4a0cee
commit f4a6b8d9b9
27 changed files with 2298 additions and 2381 deletions

View File

@@ -18,6 +18,7 @@ use ssz_types::VariableList;
use std::cmp::max;
use std::collections::HashMap;
use std::sync::Arc;
use tracing::warn;
use tree_hash::TreeHash;
use tree_hash_derive::TreeHash;
use types::{
@@ -537,6 +538,21 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
.contains_key(&forkchoice_state.finalized_block_hash);
if unknown_head_block_hash || unknown_safe_block_hash || unknown_finalized_block_hash {
if unknown_head_block_hash {
warn!(?head_block_hash, "Received unknown head block hash");
}
if unknown_safe_block_hash {
warn!(
safe_block_hash = ?forkchoice_state.safe_block_hash,
"Received unknown safe block hash"
);
}
if unknown_finalized_block_hash {
warn!(
finalized_block_hash = ?forkchoice_state.finalized_block_hash,
"Received unknown finalized block hash"
)
}
return Ok(JsonForkchoiceUpdatedV1Response {
payload_status: JsonPayloadStatusV1 {
status: JsonPayloadStatusV1Status::Syncing,

View File

@@ -5,6 +5,7 @@ use crate::test_utils::{DEFAULT_CLIENT_VERSION, DEFAULT_MOCK_EL_PAYLOAD_VALUE_WE
use serde::{Deserialize, de::DeserializeOwned};
use serde_json::Value as JsonValue;
use std::sync::Arc;
use tracing::debug;
pub const GENERIC_ERROR_CODE: i64 = -1234;
pub const BAD_PARAMS_ERROR_CODE: i64 = -32602;
@@ -28,6 +29,8 @@ pub async fn handle_rpc<E: EthSpec>(
.ok_or_else(|| "missing/invalid params field".to_string())
.map_err(|s| (s, GENERIC_ERROR_CODE))?;
debug!(method, "Mock execution engine");
match method {
ETH_SYNCING => ctx
.syncing_response
@@ -517,6 +520,12 @@ pub async fn handle_rpc<E: EthSpec>(
_ => unreachable!(),
};
debug!(
?payload_attributes,
?forkchoice_state,
"ENGINE_FORKCHOICE_UPDATED"
);
// validate method called correctly according to fork time
if let Some(pa) = payload_attributes.as_ref() {
match ctx