-
Notifications
You must be signed in to change notification settings - Fork 807
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove equivocating validators from fork choice
- Loading branch information
1 parent
8b42c53
commit 181fd0f
Showing
11 changed files
with
341 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
77 changes: 77 additions & 0 deletions
77
beacon_node/beacon_chain/src/schema_change/migration_schema_v11.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use crate::beacon_fork_choice_store::{PersistedForkChoiceStoreV10, PersistedForkChoiceStoreV11}; | ||
use crate::persisted_fork_choice::{PersistedForkChoiceV10, PersistedForkChoiceV11}; | ||
use slog::{warn, Logger}; | ||
use std::collections::BTreeSet; | ||
|
||
/// Add the equivocating indices field. | ||
pub fn update_fork_choice(fork_choice_v10: PersistedForkChoiceV10) -> PersistedForkChoiceV11 { | ||
let PersistedForkChoiceStoreV10 { | ||
balances_cache, | ||
time, | ||
finalized_checkpoint, | ||
justified_checkpoint, | ||
justified_balances, | ||
best_justified_checkpoint, | ||
unrealized_justified_checkpoint, | ||
unrealized_finalized_checkpoint, | ||
proposer_boost_root, | ||
} = fork_choice_v10.fork_choice_store; | ||
|
||
PersistedForkChoiceV11 { | ||
fork_choice: fork_choice_v10.fork_choice, | ||
fork_choice_store: PersistedForkChoiceStoreV11 { | ||
balances_cache, | ||
time, | ||
finalized_checkpoint, | ||
justified_checkpoint, | ||
justified_balances, | ||
best_justified_checkpoint, | ||
unrealized_justified_checkpoint, | ||
unrealized_finalized_checkpoint, | ||
proposer_boost_root, | ||
equivocating_indices: BTreeSet::new(), | ||
}, | ||
} | ||
} | ||
|
||
pub fn downgrade_fork_choice( | ||
fork_choice_v11: PersistedForkChoiceV11, | ||
log: Logger, | ||
) -> PersistedForkChoiceV10 { | ||
let PersistedForkChoiceStoreV11 { | ||
balances_cache, | ||
time, | ||
finalized_checkpoint, | ||
justified_checkpoint, | ||
justified_balances, | ||
best_justified_checkpoint, | ||
unrealized_justified_checkpoint, | ||
unrealized_finalized_checkpoint, | ||
proposer_boost_root, | ||
equivocating_indices, | ||
} = fork_choice_v11.fork_choice_store; | ||
|
||
if !equivocating_indices.is_empty() { | ||
warn!( | ||
log, | ||
"Deleting slashed validators from fork choice store"; | ||
"count" => equivocating_indices.len(), | ||
"message" => "this may make your node more susceptible to following the wrong chain", | ||
); | ||
} | ||
|
||
PersistedForkChoiceV10 { | ||
fork_choice: fork_choice_v11.fork_choice, | ||
fork_choice_store: PersistedForkChoiceStoreV10 { | ||
balances_cache, | ||
time, | ||
finalized_checkpoint, | ||
justified_checkpoint, | ||
justified_balances, | ||
best_justified_checkpoint, | ||
unrealized_justified_checkpoint, | ||
unrealized_finalized_checkpoint, | ||
proposer_boost_root, | ||
}, | ||
} | ||
} |
Oops, something went wrong.