mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
Broadcast address changes at Capella (#3919)
* Add first efforts at broadcast * Tidy * Move broadcast code to client * Progress with broadcast impl * Rename to address change * Fix compile errors * Use `while` loop * Tidy * Flip broadcast condition * Switch to forgetting individual indices * Always broadcast when the node starts * Refactor into two functions * Add testing * Add another test * Tidy, add more testing * Tidy * Add test, rename enum * Rename enum again * Tidy * Break loop early * Add V15 schema migration * Bump schema version * Progress with migration * Update beacon_node/client/src/address_change_broadcast.rs Co-authored-by: Michael Sproul <micsproul@gmail.com> * Fix typo in function name --------- Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
@@ -9,12 +9,13 @@ mod persistence;
|
||||
mod reward_cache;
|
||||
mod sync_aggregate_id;
|
||||
|
||||
pub use crate::bls_to_execution_changes::ReceivedPreCapella;
|
||||
pub use attestation::AttMaxCover;
|
||||
pub use attestation_storage::{AttestationRef, SplitAttestation};
|
||||
pub use max_cover::MaxCover;
|
||||
pub use persistence::{
|
||||
PersistedOperationPool, PersistedOperationPoolV12, PersistedOperationPoolV14,
|
||||
PersistedOperationPoolV5,
|
||||
PersistedOperationPoolV15, PersistedOperationPoolV5,
|
||||
};
|
||||
pub use reward_cache::RewardCache;
|
||||
|
||||
@@ -24,6 +25,8 @@ use crate::sync_aggregate_id::SyncAggregateId;
|
||||
use attester_slashing::AttesterSlashingMaxCover;
|
||||
use max_cover::maximum_cover;
|
||||
use parking_lot::{RwLock, RwLockWriteGuard};
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::thread_rng;
|
||||
use state_processing::per_block_processing::errors::AttestationValidationError;
|
||||
use state_processing::per_block_processing::{
|
||||
get_slashable_indices_modular, verify_exit, VerifySignatures,
|
||||
@@ -533,10 +536,11 @@ impl<T: EthSpec> OperationPool<T> {
|
||||
pub fn insert_bls_to_execution_change(
|
||||
&self,
|
||||
verified_change: SigVerifiedOp<SignedBlsToExecutionChange, T>,
|
||||
received_pre_capella: ReceivedPreCapella,
|
||||
) -> bool {
|
||||
self.bls_to_execution_changes
|
||||
.write()
|
||||
.insert(verified_change)
|
||||
.insert(verified_change, received_pre_capella)
|
||||
}
|
||||
|
||||
/// Get a list of execution changes for inclusion in a block.
|
||||
@@ -562,6 +566,42 @@ impl<T: EthSpec> OperationPool<T> {
|
||||
)
|
||||
}
|
||||
|
||||
/// Get a list of execution changes to be broadcast at the Capella fork.
|
||||
///
|
||||
/// The list that is returned will be shuffled to help provide a fair
|
||||
/// broadcast of messages.
|
||||
pub fn get_bls_to_execution_changes_received_pre_capella(
|
||||
&self,
|
||||
state: &BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Vec<SignedBlsToExecutionChange> {
|
||||
let mut changes = filter_limit_operations(
|
||||
self.bls_to_execution_changes
|
||||
.read()
|
||||
.iter_received_pre_capella(),
|
||||
|address_change| {
|
||||
address_change.signature_is_still_valid(&state.fork())
|
||||
&& state
|
||||
.get_validator(address_change.as_inner().message.validator_index as usize)
|
||||
.map_or(false, |validator| {
|
||||
!validator.has_eth1_withdrawal_credential(spec)
|
||||
})
|
||||
},
|
||||
|address_change| address_change.as_inner().clone(),
|
||||
usize::max_value(),
|
||||
);
|
||||
changes.shuffle(&mut thread_rng());
|
||||
changes
|
||||
}
|
||||
|
||||
/// Removes `broadcasted` validators from the set of validators that should
|
||||
/// have their BLS changes broadcast at the Capella fork boundary.
|
||||
pub fn register_indices_broadcasted_at_capella(&self, broadcasted: &HashSet<u64>) {
|
||||
self.bls_to_execution_changes
|
||||
.write()
|
||||
.register_indices_broadcasted_at_capella(broadcasted);
|
||||
}
|
||||
|
||||
/// Prune BLS to execution changes that have been applied to the state more than 1 block ago.
|
||||
pub fn prune_bls_to_execution_changes<Payload: AbstractExecPayload<T>>(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user