mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
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:
13
Makefile
13
Makefile
@@ -36,8 +36,12 @@ PROFILE ?= release
|
||||
RECENT_FORKS_BEFORE_GLOAS=electra fulu
|
||||
|
||||
# List of all recent hard forks. This list is used to set env variables for http_api tests
|
||||
# Include phase0 to test the code paths in sync that are pre blobs
|
||||
RECENT_FORKS=electra fulu gloas
|
||||
|
||||
# For network tests include phase0 to cover genesis syncing (blocks without blobs or columns)
|
||||
TEST_NETWORK_FORKS=phase0 $(RECENT_FORKS_BEFORE_GLOAS)
|
||||
|
||||
# Extra flags for Cargo
|
||||
CARGO_INSTALL_EXTRA_FLAGS?=
|
||||
|
||||
@@ -226,12 +230,15 @@ test-op-pool-%:
|
||||
|
||||
# Run the tests in the `network` crate for all known forks.
|
||||
# TODO(EIP-7732) Extend to support gloas by using RECENT_FORKS instead
|
||||
test-network: $(patsubst %,test-network-%,$(RECENT_FORKS_BEFORE_GLOAS))
|
||||
test-network: $(patsubst %,test-network-%,$(TEST_NETWORK_FORKS))
|
||||
|
||||
test-network-%:
|
||||
env FORK_NAME=$* cargo nextest run --release \
|
||||
--features "fork_from_env,$(TEST_FEATURES)" \
|
||||
env FORK_NAME=$* cargo nextest run --no-fail-fast --release \
|
||||
--features "fork_from_env,fake_crypto,$(TEST_FEATURES)" \
|
||||
-p network
|
||||
env FORK_NAME=$* cargo nextest run --no-fail-fast --release \
|
||||
--features "fork_from_env,$(TEST_FEATURES)" \
|
||||
-p network crypto_on
|
||||
|
||||
# Run the tests in the `slasher` crate for all supported database backends.
|
||||
test-slasher:
|
||||
|
||||
Reference in New Issue
Block a user