-
Notifications
You must be signed in to change notification settings - Fork 773
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 (#3371)
## Issue Addressed Closes #3241 Closes #3242 ## Proposed Changes * [x] Implement logic to remove equivocating validators from fork choice per ethereum/consensus-specs#2845 * [x] Update tests to v1.2.0-rc.1. The new test which exercises `equivocating_indices` is passing. * [x] Pull in some SSZ abstractions from the `tree-states` branch that make implementing Vec-compatible encoding for types like `BTreeSet` and `BTreeMap`. * [x] Implement schema upgrades and downgrades for the database (new schema version is V11). * [x] Apply attester slashings from blocks to fork choice ## Additional Info * This PR doesn't need the `BTreeMap` impl, but `tree-states` does, and I don't think there's any harm in keeping it. But I could also be convinced to drop it. Blocked on #3322.
1 parent
cf3bcca
commit c598945
Showing
25 changed files
with
745 additions
and
154 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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, | ||
}, | ||
} | ||
} |
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
Oops, something went wrong.