Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to beacon node fallback feature #6568

Open
wants to merge 110 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
71ee4cf
Rework Validator Client fallback mechanism
macladson Jun 13, 2023
52f2be5
Add CI workflow for fallback simulator
macladson Jun 13, 2023
ce4df50
Tie-break with sync distance for non-synced nodes
macladson Jun 13, 2023
6262013
Fix simulator
macladson Jun 13, 2023
f5154be
Cleanup unused code
macladson Jun 14, 2023
d659671
More improvements
macladson Jun 14, 2023
dbce701
Add IsOptimistic enum for readability
macladson Jun 15, 2023
774eb91
Use configurable sync distance tiers
macladson Jun 16, 2023
d839620
Fix tests
macladson Jun 19, 2023
5153aff
Combine status and health and improve logging
macladson Jun 21, 2023
61bc700
Fix nodes not being marked as available
macladson Jun 22, 2023
1295685
Fix simulator
macladson Jul 21, 2023
59c6b09
Fix tests again
macladson Jul 24, 2023
6fc12e6
Increase fallback simulator tolerance
macladson Jul 24, 2023
c9bb547
Add http api endpoint
macladson Aug 1, 2023
b25a135
Fix todos and tests
macladson Aug 1, 2023
23f68ad
Update simulator
macladson Aug 2, 2023
235c452
Merge branch 'unstable' into vc-fallback
macladson Nov 2, 2023
1d70441
Add suggestions
macladson Nov 3, 2023
4ddfc7d
Add id to ui endpoint
macladson Nov 3, 2023
21c34c2
Remove unnecessary clones
macladson Nov 3, 2023
ba92f5d
Formatting
macladson Nov 3, 2023
f87ab63
Merge branch 'unstable' into vc-fallback
macladson Dec 1, 2023
88ebe36
Merge branch 'unstable' into vc-fallback
macladson Dec 13, 2023
6117cef
Fix flag tests
macladson Dec 13, 2023
6dc44b2
Merge branch 'unstable' into vc-fallback
macladson Jan 5, 2024
e555dc9
Merge branch 'unstable' into vc-fallback
macladson Jan 16, 2024
ba32239
Fix conflicts
macladson Jan 16, 2024
5672afe
Merge branch 'unstable' into vc-fallback
macladson Jan 31, 2024
1802080
Remove unnecessary pubs
macladson Feb 1, 2024
a5e9348
Simplify `compute_distance_tier` and reduce notifier awaits
macladson Feb 1, 2024
e368397
Use the more descriptive `user_index` instead of `id`
macladson Feb 5, 2024
ee75a72
Combine sync distance tolerance flags into one
macladson Feb 6, 2024
1d9dc26
Merge branch 'unstable' into vc-fallback
macladson Apr 15, 2024
9897626
Merge branch 'unstable' into vc-fallback
macladson Apr 26, 2024
4c5dd67
wip
macladson Apr 26, 2024
85443e8
Use new simulator from unstable
macladson Apr 26, 2024
037448b
Fix cli text
macladson Apr 26, 2024
b72d219
Remove leftover files
macladson Apr 26, 2024
7e3866a
Remove old commented code
macladson Apr 26, 2024
7f574b3
Merge branch 'unstable' into vc-fallback
macladson Jun 5, 2024
e348231
Update cli text
macladson Jun 5, 2024
5c8dc21
Silence candidate errors when pre-genesis
macladson Jun 6, 2024
3d5e277
Merge branch 'unstable' into vc-fallback
macladson Jun 27, 2024
a431d94
Merge branch 'unstable' into vc-fallback
macladson Jul 8, 2024
c373891
Retry on failure
macladson Jul 16, 2024
95466f0
Merge branch 'unstable' into vc-fallback
macladson Jul 16, 2024
517fae9
Merge branch 'unstable' into vc-fallback
macladson Jul 23, 2024
453e003
Remove disable_run_on_all
macladson Jul 24, 2024
500dbe5
Remove unused error variant
macladson Jul 24, 2024
a63ec8f
Fix out of date comment
macladson Jul 24, 2024
8aa97a8
Merge branch 'unstable' into vc-fallback
macladson Jul 25, 2024
1653484
Remove unnecessary as_u64
macladson Jul 25, 2024
9c206d5
Remove more out of date comments
macladson Jul 25, 2024
526a894
Use tokio RwLock and remove parking_lot
macladson Aug 19, 2024
1fdb4ec
Merge branch 'unstable' into vc-fallback
macladson Aug 19, 2024
2de68ed
Formatting
macladson Aug 19, 2024
4bf2f59
Ensure nodes are still added to total when not available
macladson Aug 22, 2024
4c55b03
Allow VC to detect when BN comes online
macladson Aug 22, 2024
5cc2c13
Fix ui endpoint
macladson Aug 22, 2024
b5445a0
Don't have block_service as an Option
macladson Aug 23, 2024
2675f0d
Merge branch 'unstable' into vc-fallback
macladson Aug 23, 2024
7eab573
Clean up lifetimes and futures
michaelsproul Sep 2, 2024
fff8637
Revert "Don't have block_service as an Option"
macladson Sep 11, 2024
5a55bd6
Merge branch 'unstable' into vc-fallback
macladson Sep 11, 2024
4052827
Merge branch 'unstable' into vc-fallback
jimmygchen Sep 30, 2024
c0afb96
Initial validator test setup.
jimmygchen Oct 1, 2024
464a110
Jimmy's guidance
chong-he Oct 24, 2024
0bf34c4
vc fallback
chong-he Oct 24, 2024
245a1bc
Fix fallback test.
jimmygchen Oct 24, 2024
c0b7a4b
blinded
chong-he Oct 24, 2024
433f753
Merge remote-tracking branch 'Jimmy/vc-fallback-test' into vc-fallbac…
chong-he Oct 29, 2024
00adb54
Store blocks and add test
chong-he Nov 5, 2024
e59fd3a
Changed to signed
chong-he Nov 5, 2024
8d2c669
Minor revisision
chong-he Nov 5, 2024
dcfe832
Add update_all_candidate
chong-he Nov 5, 2024
2ace7c7
first_beacon_node
chong-he Nov 5, 2024
e87f9b9
sync status
chong-he Nov 6, 2024
9b81cc0
Complete `update_all_candidates` test.
jimmygchen Nov 6, 2024
6f23a55
Merge branch 'unstable' into vc-fallback-test
jimmygchen Nov 6, 2024
ed63f70
Fix clippy
chong-he Nov 6, 2024
77c59db
temporarily disable storing blocks test
chong-he Nov 6, 2024
dc97d8a
commented
chong-he Nov 6, 2024
24c243a
ssz
chong-he Nov 6, 2024
93c7b02
Update validator_client/src/beacon_node_fallback.rs
chong-he Nov 7, 2024
636345a
Simplify
chong-he Nov 8, 2024
6d60826
Add first_success test
chong-he Nov 20, 2024
79acbf7
Merge remote-tracking branch 'origin/unstable' into vc-fallback-test
chong-he Nov 21, 2024
3c536dc
Fix
chong-he Nov 21, 2024
8a0d98b
Try to fix
chong-he Nov 22, 2024
3fe3e64
Try to fix
chong-he Nov 22, 2024
cccdc50
small change
chong-he Nov 22, 2024
06af376
Fix test compile
chong-he Nov 26, 2024
20d0f6f
Fix test compile
chong-he Nov 26, 2024
820d056
Move around files
chong-he Dec 8, 2024
e0c74f0
Merge branch 'unstable' into vc-fallback-test
chong-he Dec 8, 2024
eb92dd5
Fix compilation issue and clean up.
jimmygchen Dec 10, 2024
aa67fad
Remove unnecessary changes.
jimmygchen Dec 10, 2024
77702fa
Merge branch 'unstable' into vc-fallback-test
jimmygchen Dec 10, 2024
a59a59a
Remove unused dependency
chong-he Dec 10, 2024
807c6d2
Merge branch 'vc-fallback-test' of https://github.com/chong-he/lighth…
chong-he Dec 10, 2024
e30b2f0
Merge branch 'unstable' into vc-fallback-test
chong-he Dec 19, 2024
1f6a7d1
test rig cargo.toml
chong-he Dec 19, 2024
3d69f09
sort validator_test_rig dependency
chong-he Dec 19, 2024
49ea48a
main Cargo.toml
chong-he Dec 19, 2024
7c27440
Update Cargo.toml
chong-he Dec 19, 2024
61fbe20
Remove unused dependency
chong-he Dec 19, 2024
8376b9b
Minor rearrange
chong-he Dec 24, 2024
46d15b9
Add mock1 and mock2 expect assert
chong-he Dec 24, 2024
a406704
remove debug
chong-he Dec 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'unstable' into vc-fallback
  • Loading branch information
macladson committed Jan 31, 2024
commit 5672afeab0dd2ea0e633726d18de08e3c73c747e
92 changes: 91 additions & 1 deletion testing/simulator/src/checks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::local_network::LocalNetwork;
use crate::ACCEPTABLE_FALLBACK_ATTESTATION_HIT_PERCENTAGE;
use node_test_rig::eth2::types::{BlockId, StateId};
use node_test_rig::eth2::types::{BlockId, FinalityCheckpointsData, StateId};
use std::time::Duration;
use types::{Epoch, EthSpec, ExecPayload, ExecutionBlockHash, Hash256, Slot, Unsigned};

Expand Down Expand Up @@ -245,6 +245,96 @@ pub async fn verify_transition_block_finalized<E: EthSpec>(
}
}

pub(crate) async fn verify_light_client_updates<E: EthSpec>(
network: LocalNetwork<E>,
start_slot: Slot,
end_slot: Slot,
slot_duration: Duration,
) -> Result<(), String> {
slot_delay(start_slot, slot_duration).await;

// Tolerance of 2 slot allows for 1 single missed slot.
let light_client_update_slot_tolerance = Slot::new(2);
let remote_nodes = network.remote_nodes()?;
let client = remote_nodes.first().unwrap();
let mut have_seen_block = false;
let mut have_achieved_finality = false;

for slot in start_slot.as_u64()..=end_slot.as_u64() {
slot_delay(Slot::new(1), slot_duration).await;
let slot = Slot::new(slot);
let previous_slot = slot - 1;

let previous_slot_block = client
.get_beacon_blocks::<E>(BlockId::Slot(previous_slot))
.await
.map_err(|e| {
format!("Unable to get beacon block for previous slot {previous_slot:?}: {e:?}")
})?;
let previous_slot_has_block = previous_slot_block.is_some();

if !have_seen_block {
// Make sure we have seen the first block in Altair, to make sure we have sync aggregates available.
if previous_slot_has_block {
have_seen_block = true;
}
// Wait for another slot before we check the first update to avoid race condition.
continue;
}

// Make sure previous slot has a block, otherwise skip checking for the signature slot distance
if !previous_slot_has_block {
continue;
}

// Verify light client optimistic update. `signature_slot_distance` should be 1 in the ideal scenario.
let signature_slot = client
.get_beacon_light_client_optimistic_update::<E>()
.await
.map_err(|e| format!("Error while getting light client updates: {:?}", e))?
.ok_or(format!("Light client optimistic update not found {slot:?}"))?
.data
.signature_slot;
let signature_slot_distance = slot - signature_slot;
if signature_slot_distance > light_client_update_slot_tolerance {
return Err(format!("Existing optimistic update too old: signature slot {signature_slot}, current slot {slot:?}"));
}

// Verify light client finality update. `signature_slot_distance` should be 1 in the ideal scenario.
// NOTE: Currently finality updates are produced as long as the finalized block is known, even if the finalized header
// sync committee period does not match the signature slot committee period.
// TODO: This complies with the current spec, but we should check if this is a bug.
if !have_achieved_finality {
let FinalityCheckpointsData { finalized, .. } = client
.get_beacon_states_finality_checkpoints(StateId::Head)
.await
.map_err(|e| format!("Unable to get beacon state finality checkpoint: {e:?}"))?
.ok_or("Unable to get head state".to_string())?
.data;
if !finalized.root.is_zero() {
// Wait for another slot before we check the first finality update to avoid race condition.
have_achieved_finality = true;
}
continue;
}
let signature_slot = client
.get_beacon_light_client_finality_update::<E>()
.await
.map_err(|e| format!("Error while getting light client updates: {:?}", e))?
.ok_or(format!("Light client finality update not found {slot:?}"))?
.data
.signature_slot;
let signature_slot_distance = slot - signature_slot;
if signature_slot_distance > light_client_update_slot_tolerance {
return Err(format!(
"Existing finality update too old: signature slot {signature_slot}, current slot {slot:?}"
));
}
}

Ok(())
}

// Causes the execution node at `node_index` to disconnect from the execution layer 1 epoch after
// the merge transition.
pub async fn disconnect_from_execution_layer<E: EthSpec>(
Expand Down
3 changes: 3 additions & 0 deletions testing/simulator/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ pub async fn create_local_network<E: EthSpec>(
beacon_config.network.target_peers = node_count + proposer_nodes - 1;

beacon_config.network.enr_address = (Some(Ipv4Addr::LOCALHOST), None);
beacon_config.network.enable_light_client_server = true;
beacon_config.chain.enable_light_client_server = true;
beacon_config.http_api.enable_light_client_server = true;

if post_merge_sim {
let el_config = execution_layer::Config {
Expand Down
22 changes: 20 additions & 2 deletions validator_client/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,24 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.default_value("500")
.takes_value(true),
)
.arg(
Arg::with_name("builder-boost-factor")
.long("builder-boost-factor")
.value_name("UINT64")
.help("Defines the boost factor, \
a percentage multiplier to apply to the builder's payload value \
when choosing between a builder payload header and payload from \
the local execution node.")
.conflicts_with("prefer-builder-proposals")
.takes_value(true),
)
.arg(
Arg::with_name("prefer-builder-proposals")
.long("prefer-builder-proposals")
.help("If this flag is set, Lighthouse will always prefer blocks \
constructed by builders, regardless of payload value.")
.takes_value(false),
)
.arg(
Arg::with_name("beacon-node-sync-tolerance")
.long("beacon-node-sync-tolerance")
Expand All @@ -364,7 +382,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
can result in suboptimal fallback behaviour. Sets the size (in slots) of the \
`small` sync distance range when calculating the health tiers of connected \
Beacon Nodes. The range falls immediately after the end of the `synced` range.")
.takes_value(true)
.takes_value(true),
)
.arg(
Arg::with_name("beacon-node-medium-sync-distance-modifier")
Expand All @@ -373,6 +391,6 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
can result in suboptimal fallback behaviour. Sets the size (in slots) of the \
`medium` sync distance range when calculating the health tiers of connected \
Beacon Nodes. The range falls immediately after the end of the `small` range.")
.takes_value(true)
.takes_value(true),
)
}
You are viewing a condensed version of this merge commit. You can view the full changes here.