mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
Queue deposit requests and apply them during epoch processing
This commit is contained in:
@@ -134,7 +134,7 @@ where
|
|||||||
pub earliest_consolidation_epoch: Epoch,
|
pub earliest_consolidation_epoch: Epoch,
|
||||||
|
|
||||||
#[superstruct(only(Electra))]
|
#[superstruct(only(Electra))]
|
||||||
pub pending_balance_deposits: List<PendingBalanceDeposit, E::PendingBalanceDepositsLimit>,
|
pub pending_deposits: List<PendingDeposit, E::PendingDepositsLimit>,
|
||||||
#[superstruct(only(Electra))]
|
#[superstruct(only(Electra))]
|
||||||
pub pending_partial_withdrawals:
|
pub pending_partial_withdrawals:
|
||||||
List<PendingPartialWithdrawal, E::PendingPartialWithdrawalsLimit>,
|
List<PendingPartialWithdrawal, E::PendingPartialWithdrawalsLimit>,
|
||||||
@@ -290,7 +290,7 @@ impl<E: EthSpec> PartialBeaconState<E> {
|
|||||||
earliest_exit_epoch,
|
earliest_exit_epoch,
|
||||||
consolidation_balance_to_consume,
|
consolidation_balance_to_consume,
|
||||||
earliest_consolidation_epoch,
|
earliest_consolidation_epoch,
|
||||||
pending_balance_deposits,
|
pending_deposits,
|
||||||
pending_partial_withdrawals,
|
pending_partial_withdrawals,
|
||||||
pending_consolidations
|
pending_consolidations
|
||||||
],
|
],
|
||||||
@@ -563,7 +563,7 @@ impl<E: EthSpec> TryInto<BeaconState<E>> for PartialBeaconState<E> {
|
|||||||
earliest_exit_epoch,
|
earliest_exit_epoch,
|
||||||
consolidation_balance_to_consume,
|
consolidation_balance_to_consume,
|
||||||
earliest_consolidation_epoch,
|
earliest_consolidation_epoch,
|
||||||
pending_balance_deposits,
|
pending_deposits,
|
||||||
pending_partial_withdrawals,
|
pending_partial_withdrawals,
|
||||||
pending_consolidations
|
pending_consolidations
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
|
|||||||
let post = upgrade_state_to_electra(&mut state, Epoch::new(0), Epoch::new(0), spec)?;
|
let post = upgrade_state_to_electra(&mut state, Epoch::new(0), Epoch::new(0), spec)?;
|
||||||
state = post;
|
state = post;
|
||||||
|
|
||||||
|
// TODO(electra): do we need to iterate over an empty pending_deposits list here and increase balance?!
|
||||||
|
|
||||||
// Remove intermediate Deneb fork from `state.fork`.
|
// Remove intermediate Deneb fork from `state.fork`.
|
||||||
state.fork_mut().previous_version = spec.electra_fork_version;
|
state.fork_mut().previous_version = spec.electra_fork_version;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use crate::common::{
|
|||||||
};
|
};
|
||||||
use crate::per_block_processing::errors::{BlockProcessingError, IntoWithIndex};
|
use crate::per_block_processing::errors::{BlockProcessingError, IntoWithIndex};
|
||||||
use crate::VerifySignatures;
|
use crate::VerifySignatures;
|
||||||
|
use errors::DepositInvalid;
|
||||||
use types::consts::altair::{PARTICIPATION_FLAG_WEIGHTS, PROPOSER_WEIGHT, WEIGHT_DENOMINATOR};
|
use types::consts::altair::{PARTICIPATION_FLAG_WEIGHTS, PROPOSER_WEIGHT, WEIGHT_DENOMINATOR};
|
||||||
use types::typenum::U33;
|
use types::typenum::U33;
|
||||||
|
|
||||||
@@ -449,47 +450,73 @@ pub fn apply_deposit<E: EthSpec>(
|
|||||||
|
|
||||||
if let Some(index) = validator_index {
|
if let Some(index) = validator_index {
|
||||||
// [Modified in Electra:EIP7251]
|
// [Modified in Electra:EIP7251]
|
||||||
if let Ok(pending_balance_deposits) = state.pending_balance_deposits_mut() {
|
if let Ok(pending_deposits) = state.pending_deposits_mut() {
|
||||||
pending_balance_deposits.push(PendingBalanceDeposit { index, amount })?;
|
pending_deposits.push(PendingDeposit {
|
||||||
|
pubkey: deposit_data.pubkey,
|
||||||
|
withdrawal_credentials: deposit_data.withdrawal_credentials,
|
||||||
|
amount,
|
||||||
|
signature: deposit_data.signature.decompress().map_err(|_| {
|
||||||
|
BlockProcessingError::DepositInvalid {
|
||||||
|
index: deposit_index,
|
||||||
|
reason: DepositInvalid::BadBlsBytes,
|
||||||
|
}
|
||||||
|
})?,
|
||||||
|
slot: spec.genesis_slot, // Use `genesis_slot` to distinguish from a pending deposit request
|
||||||
|
})?;
|
||||||
} else {
|
} else {
|
||||||
// Update the existing validator balance.
|
// Update the existing validator balance.
|
||||||
increase_balance(state, index as usize, amount)?;
|
increase_balance(state, index as usize, amount)?;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
// New validator
|
||||||
|
else {
|
||||||
// The signature should be checked for new validators. Return early for a bad
|
// The signature should be checked for new validators. Return early for a bad
|
||||||
// signature.
|
// signature.
|
||||||
if is_valid_deposit_signature(&deposit_data, spec).is_err() {
|
if is_valid_deposit_signature(&deposit_data, spec).is_err() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_validator_index = state.validators().len();
|
|
||||||
|
|
||||||
// [Modified in Electra:EIP7251]
|
// [Modified in Electra:EIP7251]
|
||||||
let (effective_balance, state_balance) = if state.fork_name_unchecked() >= ForkName::Electra
|
if state.fork_name_unchecked() >= ForkName::Electra {
|
||||||
{
|
// Create a new validator.
|
||||||
(0, 0)
|
let mut validator = Validator {
|
||||||
|
pubkey: deposit_data.pubkey,
|
||||||
|
withdrawal_credentials: deposit_data.withdrawal_credentials,
|
||||||
|
activation_eligibility_epoch: spec.far_future_epoch,
|
||||||
|
activation_epoch: spec.far_future_epoch,
|
||||||
|
exit_epoch: spec.far_future_epoch,
|
||||||
|
withdrawable_epoch: spec.far_future_epoch,
|
||||||
|
effective_balance: 0,
|
||||||
|
slashed: false,
|
||||||
|
};
|
||||||
|
let max_effective_balance =
|
||||||
|
validator.get_max_effective_balance(spec, state.fork_name_unchecked());
|
||||||
|
validator.effective_balance = std::cmp::min(
|
||||||
|
amount.safe_sub(amount.safe_rem(spec.effective_balance_increment)?)?,
|
||||||
|
max_effective_balance,
|
||||||
|
);
|
||||||
|
|
||||||
|
state.validators_mut().push(validator)?;
|
||||||
|
// state balances is set to 0 in electra
|
||||||
|
state.balances_mut().push(0)?;
|
||||||
} else {
|
} else {
|
||||||
(
|
let validator = Validator {
|
||||||
std::cmp::min(
|
pubkey: deposit_data.pubkey,
|
||||||
|
withdrawal_credentials: deposit_data.withdrawal_credentials,
|
||||||
|
activation_eligibility_epoch: spec.far_future_epoch,
|
||||||
|
activation_epoch: spec.far_future_epoch,
|
||||||
|
exit_epoch: spec.far_future_epoch,
|
||||||
|
withdrawable_epoch: spec.far_future_epoch,
|
||||||
|
effective_balance: std::cmp::min(
|
||||||
amount.safe_sub(amount.safe_rem(spec.effective_balance_increment)?)?,
|
amount.safe_sub(amount.safe_rem(spec.effective_balance_increment)?)?,
|
||||||
spec.max_effective_balance,
|
spec.max_effective_balance,
|
||||||
),
|
),
|
||||||
amount,
|
slashed: false,
|
||||||
)
|
};
|
||||||
|
state.validators_mut().push(validator)?;
|
||||||
|
// state balances is set to 0 in electra
|
||||||
|
state.balances_mut().push(amount)?;
|
||||||
};
|
};
|
||||||
// Create a new validator.
|
|
||||||
let validator = Validator {
|
|
||||||
pubkey: deposit_data.pubkey,
|
|
||||||
withdrawal_credentials: deposit_data.withdrawal_credentials,
|
|
||||||
activation_eligibility_epoch: spec.far_future_epoch,
|
|
||||||
activation_epoch: spec.far_future_epoch,
|
|
||||||
exit_epoch: spec.far_future_epoch,
|
|
||||||
withdrawable_epoch: spec.far_future_epoch,
|
|
||||||
effective_balance,
|
|
||||||
slashed: false,
|
|
||||||
};
|
|
||||||
state.validators_mut().push(validator)?;
|
|
||||||
state.balances_mut().push(state_balance)?;
|
|
||||||
|
|
||||||
// Altair or later initializations.
|
// Altair or later initializations.
|
||||||
if let Ok(previous_epoch_participation) = state.previous_epoch_participation_mut() {
|
if let Ok(previous_epoch_participation) = state.previous_epoch_participation_mut() {
|
||||||
@@ -503,10 +530,18 @@ pub fn apply_deposit<E: EthSpec>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// [New in Electra:EIP7251]
|
// [New in Electra:EIP7251]
|
||||||
if let Ok(pending_balance_deposits) = state.pending_balance_deposits_mut() {
|
if let Ok(pending_deposits) = state.pending_deposits_mut() {
|
||||||
pending_balance_deposits.push(PendingBalanceDeposit {
|
pending_deposits.push(PendingDeposit {
|
||||||
index: new_validator_index as u64,
|
pubkey: deposit_data.pubkey,
|
||||||
|
withdrawal_credentials: deposit_data.withdrawal_credentials,
|
||||||
amount,
|
amount,
|
||||||
|
signature: deposit_data.signature.decompress().map_err(|_| {
|
||||||
|
BlockProcessingError::DepositInvalid {
|
||||||
|
index: deposit_index,
|
||||||
|
reason: DepositInvalid::BadBlsBytes,
|
||||||
|
}
|
||||||
|
})?,
|
||||||
|
slot: spec.genesis_slot, // Use `genesis_slot` to distinguish from a pending deposit request
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -620,13 +655,18 @@ pub fn process_deposit_requests<E: EthSpec>(
|
|||||||
if state.deposit_requests_start_index()? == spec.unset_deposit_requests_start_index {
|
if state.deposit_requests_start_index()? == spec.unset_deposit_requests_start_index {
|
||||||
*state.deposit_requests_start_index_mut()? = request.index
|
*state.deposit_requests_start_index_mut()? = request.index
|
||||||
}
|
}
|
||||||
let deposit_data = DepositData {
|
let slot = state.slot();
|
||||||
pubkey: request.pubkey,
|
|
||||||
withdrawal_credentials: request.withdrawal_credentials,
|
// [New in Electra:EIP7251]
|
||||||
amount: request.amount,
|
if let Ok(pending_deposits) = state.pending_deposits_mut() {
|
||||||
signature: request.signature.clone().into(),
|
pending_deposits.push(PendingDeposit {
|
||||||
};
|
pubkey: request.pubkey,
|
||||||
apply_deposit(state, deposit_data, None, false, spec)?
|
withdrawal_credentials: request.withdrawal_credentials,
|
||||||
|
amount: request.amount,
|
||||||
|
signature: request.signature.clone(),
|
||||||
|
slot,
|
||||||
|
})?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use crate::{
|
|||||||
update_progressive_balances_cache::initialize_progressive_balances_cache,
|
update_progressive_balances_cache::initialize_progressive_balances_cache,
|
||||||
},
|
},
|
||||||
epoch_cache::{initialize_epoch_cache, PreEpochCache},
|
epoch_cache::{initialize_epoch_cache, PreEpochCache},
|
||||||
|
per_block_processing::is_valid_deposit_signature,
|
||||||
per_epoch_processing::{Delta, Error, ParticipationEpochSummary},
|
per_epoch_processing::{Delta, Error, ParticipationEpochSummary},
|
||||||
};
|
};
|
||||||
use itertools::izip;
|
use itertools::izip;
|
||||||
@@ -16,9 +17,9 @@ use types::{
|
|||||||
TIMELY_TARGET_FLAG_INDEX, WEIGHT_DENOMINATOR,
|
TIMELY_TARGET_FLAG_INDEX, WEIGHT_DENOMINATOR,
|
||||||
},
|
},
|
||||||
milhouse::Cow,
|
milhouse::Cow,
|
||||||
ActivationQueue, BeaconState, BeaconStateError, ChainSpec, Checkpoint, Epoch, EthSpec,
|
ActivationQueue, BeaconState, BeaconStateError, ChainSpec, Checkpoint, DepositData, Epoch,
|
||||||
ExitCache, ForkName, List, ParticipationFlags, PendingBalanceDeposit, ProgressiveBalancesCache,
|
EthSpec, ExitCache, ForkName, List, ParticipationFlags, PendingDeposit,
|
||||||
RelativeEpoch, Unsigned, Validator,
|
ProgressiveBalancesCache, RelativeEpoch, Unsigned, Validator,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct SinglePassConfig {
|
pub struct SinglePassConfig {
|
||||||
@@ -26,7 +27,7 @@ pub struct SinglePassConfig {
|
|||||||
pub rewards_and_penalties: bool,
|
pub rewards_and_penalties: bool,
|
||||||
pub registry_updates: bool,
|
pub registry_updates: bool,
|
||||||
pub slashings: bool,
|
pub slashings: bool,
|
||||||
pub pending_balance_deposits: bool,
|
pub pending_deposits: bool,
|
||||||
pub pending_consolidations: bool,
|
pub pending_consolidations: bool,
|
||||||
pub effective_balance_updates: bool,
|
pub effective_balance_updates: bool,
|
||||||
}
|
}
|
||||||
@@ -44,7 +45,7 @@ impl SinglePassConfig {
|
|||||||
rewards_and_penalties: true,
|
rewards_and_penalties: true,
|
||||||
registry_updates: true,
|
registry_updates: true,
|
||||||
slashings: true,
|
slashings: true,
|
||||||
pending_balance_deposits: true,
|
pending_deposits: true,
|
||||||
pending_consolidations: true,
|
pending_consolidations: true,
|
||||||
effective_balance_updates: true,
|
effective_balance_updates: true,
|
||||||
}
|
}
|
||||||
@@ -56,7 +57,7 @@ impl SinglePassConfig {
|
|||||||
rewards_and_penalties: false,
|
rewards_and_penalties: false,
|
||||||
registry_updates: false,
|
registry_updates: false,
|
||||||
slashings: false,
|
slashings: false,
|
||||||
pending_balance_deposits: false,
|
pending_deposits: false,
|
||||||
pending_consolidations: false,
|
pending_consolidations: false,
|
||||||
effective_balance_updates: false,
|
effective_balance_updates: false,
|
||||||
}
|
}
|
||||||
@@ -85,15 +86,17 @@ struct SlashingsContext {
|
|||||||
penalty_per_effective_balance_increment: u64,
|
penalty_per_effective_balance_increment: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PendingBalanceDepositsContext {
|
struct PendingDepositsContext {
|
||||||
/// The value to set `next_deposit_index` to *after* processing completes.
|
/// The value to set `next_deposit_index` to *after* processing completes.
|
||||||
next_deposit_index: usize,
|
next_deposit_index: usize,
|
||||||
/// The value to set `deposit_balance_to_consume` to *after* processing completes.
|
/// The value to set `deposit_balance_to_consume` to *after* processing completes.
|
||||||
deposit_balance_to_consume: u64,
|
deposit_balance_to_consume: u64,
|
||||||
/// Total balance increases for each validator due to pending balance deposits.
|
/// Total balance increases for each validator due to pending balance deposits.
|
||||||
validator_deposits_to_process: HashMap<usize, u64>,
|
validator_deposits_to_process: HashMap<usize, u64>,
|
||||||
/// The deposits to append to `pending_balance_deposits` after processing all applicable deposits.
|
/// The deposits to append to `pending_deposits` after processing all applicable deposits.
|
||||||
deposits_to_postpone: Vec<PendingBalanceDeposit>,
|
deposits_to_postpone: Vec<PendingDeposit>,
|
||||||
|
/// New validators to be added to the state *after* processing completes.
|
||||||
|
new_validator_deposits: Vec<PendingDeposit>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EffectiveBalancesContext {
|
struct EffectiveBalancesContext {
|
||||||
@@ -138,6 +141,7 @@ pub fn process_epoch_single_pass<E: EthSpec>(
|
|||||||
state.build_exit_cache(spec)?;
|
state.build_exit_cache(spec)?;
|
||||||
state.build_committee_cache(RelativeEpoch::Previous, spec)?;
|
state.build_committee_cache(RelativeEpoch::Previous, spec)?;
|
||||||
state.build_committee_cache(RelativeEpoch::Current, spec)?;
|
state.build_committee_cache(RelativeEpoch::Current, spec)?;
|
||||||
|
state.update_pubkey_cache()?;
|
||||||
|
|
||||||
let previous_epoch = state.previous_epoch();
|
let previous_epoch = state.previous_epoch();
|
||||||
let current_epoch = state.current_epoch();
|
let current_epoch = state.current_epoch();
|
||||||
@@ -163,12 +167,11 @@ pub fn process_epoch_single_pass<E: EthSpec>(
|
|||||||
let slashings_ctxt = &SlashingsContext::new(state, state_ctxt, spec)?;
|
let slashings_ctxt = &SlashingsContext::new(state, state_ctxt, spec)?;
|
||||||
let mut next_epoch_cache = PreEpochCache::new_for_next_epoch(state)?;
|
let mut next_epoch_cache = PreEpochCache::new_for_next_epoch(state)?;
|
||||||
|
|
||||||
let pending_balance_deposits_ctxt =
|
let pending_deposits_ctxt = if fork_name.electra_enabled() && conf.pending_deposits {
|
||||||
if fork_name.electra_enabled() && conf.pending_balance_deposits {
|
Some(PendingDepositsContext::new(state, spec)?)
|
||||||
Some(PendingBalanceDepositsContext::new(state, spec)?)
|
} else {
|
||||||
} else {
|
None
|
||||||
None
|
};
|
||||||
};
|
|
||||||
|
|
||||||
let mut earliest_exit_epoch = state.earliest_exit_epoch().ok();
|
let mut earliest_exit_epoch = state.earliest_exit_epoch().ok();
|
||||||
let mut exit_balance_to_consume = state.exit_balance_to_consume().ok();
|
let mut exit_balance_to_consume = state.exit_balance_to_consume().ok();
|
||||||
@@ -303,9 +306,9 @@ pub fn process_epoch_single_pass<E: EthSpec>(
|
|||||||
process_single_slashing(&mut balance, &validator, slashings_ctxt, state_ctxt, spec)?;
|
process_single_slashing(&mut balance, &validator, slashings_ctxt, state_ctxt, spec)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// `process_pending_balance_deposits`
|
// `process_pending_deposits`
|
||||||
if let Some(pending_balance_deposits_ctxt) = &pending_balance_deposits_ctxt {
|
if let Some(pending_balance_deposits_ctxt) = &pending_deposits_ctxt {
|
||||||
process_pending_balance_deposits_for_validator(
|
process_pending_deposits_for_validator(
|
||||||
&mut balance,
|
&mut balance,
|
||||||
validator_info,
|
validator_info,
|
||||||
pending_balance_deposits_ctxt,
|
pending_balance_deposits_ctxt,
|
||||||
@@ -342,20 +345,66 @@ pub fn process_epoch_single_pass<E: EthSpec>(
|
|||||||
// Finish processing pending balance deposits if relevant.
|
// Finish processing pending balance deposits if relevant.
|
||||||
//
|
//
|
||||||
// This *could* be reordered after `process_pending_consolidations` which pushes only to the end
|
// This *could* be reordered after `process_pending_consolidations` which pushes only to the end
|
||||||
// of the `pending_balance_deposits` list. But we may as well preserve the write ordering used
|
// of the `pending_deposits` list. But we may as well preserve the write ordering used
|
||||||
// by the spec and do this first.
|
// by the spec and do this first.
|
||||||
if let Some(ctxt) = pending_balance_deposits_ctxt {
|
if let Some(ctxt) = pending_deposits_ctxt {
|
||||||
let mut new_pending_balance_deposits = List::try_from_iter(
|
let mut new_balance_deposits = List::try_from_iter(
|
||||||
state
|
state
|
||||||
.pending_balance_deposits()?
|
.pending_deposits()?
|
||||||
.iter_from(ctxt.next_deposit_index)?
|
.iter_from(ctxt.next_deposit_index)?
|
||||||
.cloned(),
|
.cloned(),
|
||||||
)?;
|
)?;
|
||||||
for deposit in ctxt.deposits_to_postpone {
|
for deposit in ctxt.deposits_to_postpone {
|
||||||
new_pending_balance_deposits.push(deposit)?;
|
new_balance_deposits.push(deposit)?;
|
||||||
}
|
}
|
||||||
*state.pending_balance_deposits_mut()? = new_pending_balance_deposits;
|
*state.pending_deposits_mut()? = new_balance_deposits;
|
||||||
*state.deposit_balance_to_consume_mut()? = ctxt.deposit_balance_to_consume;
|
*state.deposit_balance_to_consume_mut()? = ctxt.deposit_balance_to_consume;
|
||||||
|
|
||||||
|
// Apply the new deposits to the state
|
||||||
|
for deposit in ctxt.new_validator_deposits.into_iter() {
|
||||||
|
if is_valid_deposit_signature(
|
||||||
|
&DepositData {
|
||||||
|
pubkey: deposit.pubkey,
|
||||||
|
withdrawal_credentials: deposit.withdrawal_credentials,
|
||||||
|
amount: deposit.amount,
|
||||||
|
signature: deposit.signature.into(),
|
||||||
|
},
|
||||||
|
spec,
|
||||||
|
)
|
||||||
|
.is_ok()
|
||||||
|
{
|
||||||
|
let mut validator = Validator {
|
||||||
|
pubkey: deposit.pubkey,
|
||||||
|
withdrawal_credentials: deposit.withdrawal_credentials,
|
||||||
|
activation_eligibility_epoch: spec.far_future_epoch,
|
||||||
|
activation_epoch: spec.far_future_epoch,
|
||||||
|
exit_epoch: spec.far_future_epoch,
|
||||||
|
withdrawable_epoch: spec.far_future_epoch,
|
||||||
|
effective_balance: 0,
|
||||||
|
slashed: false,
|
||||||
|
};
|
||||||
|
let amount = deposit.amount;
|
||||||
|
let max_effective_balance =
|
||||||
|
validator.get_max_effective_balance(spec, state.fork_name_unchecked());
|
||||||
|
validator.effective_balance = std::cmp::min(
|
||||||
|
amount.safe_sub(amount.safe_rem(spec.effective_balance_increment)?)?,
|
||||||
|
max_effective_balance,
|
||||||
|
);
|
||||||
|
|
||||||
|
state.validators_mut().push(validator)?;
|
||||||
|
state.balances_mut().push(amount)?;
|
||||||
|
// Altair or later initializations.
|
||||||
|
if let Ok(previous_epoch_participation) = state.previous_epoch_participation_mut() {
|
||||||
|
previous_epoch_participation.push(ParticipationFlags::default())?;
|
||||||
|
}
|
||||||
|
if let Ok(current_epoch_participation) = state.current_epoch_participation_mut() {
|
||||||
|
current_epoch_participation.push(ParticipationFlags::default())?;
|
||||||
|
}
|
||||||
|
if let Ok(inactivity_scores) = state.inactivity_scores_mut() {
|
||||||
|
inactivity_scores.push(0)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process consolidations outside the single-pass loop, as they depend on balances for multiple
|
// Process consolidations outside the single-pass loop, as they depend on balances for multiple
|
||||||
@@ -819,7 +868,7 @@ fn process_single_slashing(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PendingBalanceDepositsContext {
|
impl PendingDepositsContext {
|
||||||
fn new<E: EthSpec>(state: &BeaconState<E>, spec: &ChainSpec) -> Result<Self, Error> {
|
fn new<E: EthSpec>(state: &BeaconState<E>, spec: &ChainSpec) -> Result<Self, Error> {
|
||||||
let available_for_processing = state
|
let available_for_processing = state
|
||||||
.deposit_balance_to_consume()?
|
.deposit_balance_to_consume()?
|
||||||
@@ -830,10 +879,31 @@ impl PendingBalanceDepositsContext {
|
|||||||
let mut next_deposit_index = 0;
|
let mut next_deposit_index = 0;
|
||||||
let mut validator_deposits_to_process = HashMap::new();
|
let mut validator_deposits_to_process = HashMap::new();
|
||||||
let mut deposits_to_postpone = vec![];
|
let mut deposits_to_postpone = vec![];
|
||||||
|
let mut new_validator_deposits = vec![];
|
||||||
|
let mut is_churn_limit_reached = false;
|
||||||
|
let finalized_slot = state
|
||||||
|
.finalized_checkpoint()
|
||||||
|
.epoch
|
||||||
|
.start_slot(E::slots_per_epoch());
|
||||||
|
|
||||||
let pending_balance_deposits = state.pending_balance_deposits()?;
|
let pending_deposits = state.pending_deposits()?;
|
||||||
|
|
||||||
for deposit in pending_balance_deposits.iter() {
|
for deposit in pending_deposits.iter() {
|
||||||
|
// Do not process deposit requests if the Eth1 bridge deposits are not yet applied.
|
||||||
|
if deposit.slot > spec.genesis_slot
|
||||||
|
&& state.eth1_deposit_index() < state.deposit_requests_start_index()?
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Do not process is deposit slot has not been finalized.
|
||||||
|
if deposit.slot > finalized_slot {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Do not process if we have reached the limit for the number of deposits
|
||||||
|
// processed in an epoch.
|
||||||
|
if next_deposit_index >= E::max_pending_deposits_per_epoch() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
// We have to do a bit of indexing into `validators` here, but I can't see any way
|
// We have to do a bit of indexing into `validators` here, but I can't see any way
|
||||||
// around that without changing the spec.
|
// around that without changing the spec.
|
||||||
//
|
//
|
||||||
@@ -844,48 +914,71 @@ impl PendingBalanceDepositsContext {
|
|||||||
// take, just whether it is non-default. Nor do we need to know the value of
|
// take, just whether it is non-default. Nor do we need to know the value of
|
||||||
// `withdrawable_epoch`, because `next_epoch <= withdrawable_epoch` will evaluate to
|
// `withdrawable_epoch`, because `next_epoch <= withdrawable_epoch` will evaluate to
|
||||||
// `true` both for the actual value & the default placeholder value (`FAR_FUTURE_EPOCH`).
|
// `true` both for the actual value & the default placeholder value (`FAR_FUTURE_EPOCH`).
|
||||||
let validator = state.get_validator(deposit.index as usize)?;
|
let mut is_validator_exited = false;
|
||||||
let already_exited = validator.exit_epoch < spec.far_future_epoch;
|
let mut is_validator_withdrawn = false;
|
||||||
// In the spec process_registry_updates is called before process_pending_balance_deposits
|
if let Some(validator_index) = state.pubkey_cache().get(&deposit.pubkey) {
|
||||||
// so we must account for process_registry_updates ejecting the validator for low balance
|
let validator = state.get_validator(validator_index)?;
|
||||||
// and setting the exit_epoch to < far_future_epoch. Note that in the spec the effective
|
let already_exited = validator.exit_epoch < spec.far_future_epoch;
|
||||||
// balance update does not happen until *after* the registry update, so we don't need to
|
// In the spec process_registry_updates is called before process_pending_deposits
|
||||||
// account for changes to the effective balance that would push it below the ejection
|
// so we must account for process_registry_updates ejecting the validator for low balance
|
||||||
// balance here.
|
// and setting the exit_epoch to < far_future_epoch. Note that in the spec the effective
|
||||||
let will_be_exited = validator.is_active_at(current_epoch)
|
// balance update does not happen until *after* the registry update, so we don't need to
|
||||||
&& validator.effective_balance <= spec.ejection_balance;
|
// account for changes to the effective balance that would push it below the ejection
|
||||||
if already_exited || will_be_exited {
|
// balance here.
|
||||||
if next_epoch <= validator.withdrawable_epoch {
|
let will_be_exited = validator.is_active_at(current_epoch)
|
||||||
deposits_to_postpone.push(deposit.clone());
|
&& validator.effective_balance <= spec.ejection_balance;
|
||||||
} else {
|
is_validator_exited = already_exited || will_be_exited;
|
||||||
// Deposited balance will never become active. Increase balance but do not
|
is_validator_withdrawn = validator.withdrawable_epoch < next_epoch;
|
||||||
// consume churn.
|
}
|
||||||
|
|
||||||
|
if is_validator_withdrawn {
|
||||||
|
// Deposited balance will never become active. Queue a balance increase
|
||||||
|
// but do not consume churn
|
||||||
|
if let Some(validator_index) = state.pubkey_cache().get(&deposit.pubkey) {
|
||||||
validator_deposits_to_process
|
validator_deposits_to_process
|
||||||
.entry(deposit.index as usize)
|
.entry(validator_index)
|
||||||
.or_insert(0)
|
.or_insert(0)
|
||||||
.safe_add_assign(deposit.amount)?;
|
.safe_add_assign(deposit.amount)?;
|
||||||
|
} else {
|
||||||
|
// The `PendingDeposit` is for a new validator
|
||||||
|
// We add the new validator to the state at the end of all processing.
|
||||||
|
// Note that the new validator will not be eligible for activation until
|
||||||
|
// next epoch, so none of the operations will affect a newly added validator.
|
||||||
|
new_validator_deposits.push(deposit.clone());
|
||||||
}
|
}
|
||||||
|
} else if is_validator_exited {
|
||||||
|
// Validator is exiting, postpone the deposit until after withdrawable epoch
|
||||||
|
deposits_to_postpone.push(deposit.clone());
|
||||||
} else {
|
} else {
|
||||||
// Deposit does not fit in the churn, no more deposit processing in this epoch.
|
// Check if deposit fits in the churn, otherwise, do no more deposit processing in this epoch.
|
||||||
if processed_amount.safe_add(deposit.amount)? > available_for_processing {
|
is_churn_limit_reached =
|
||||||
|
processed_amount.safe_add(deposit.amount)? > available_for_processing;
|
||||||
|
if is_churn_limit_reached {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Deposit fits in the churn, process it. Increase balance and consume churn.
|
|
||||||
validator_deposits_to_process
|
|
||||||
.entry(deposit.index as usize)
|
|
||||||
.or_insert(0)
|
|
||||||
.safe_add_assign(deposit.amount)?;
|
|
||||||
processed_amount.safe_add_assign(deposit.amount)?;
|
processed_amount.safe_add_assign(deposit.amount)?;
|
||||||
|
|
||||||
|
// Deposit fits in the churn, process it. Increase balance and consume churn.
|
||||||
|
if let Some(validator_index) = state.pubkey_cache().get(&deposit.pubkey) {
|
||||||
|
validator_deposits_to_process
|
||||||
|
.entry(validator_index)
|
||||||
|
.or_insert(0)
|
||||||
|
.safe_add_assign(deposit.amount)?;
|
||||||
|
} else {
|
||||||
|
// The `PendingDeposit` is for a new validator
|
||||||
|
new_validator_deposits.push(deposit.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regardless of how the deposit was handled, we move on in the queue.
|
// Regardless of how the deposit was handled, we move on in the queue.
|
||||||
next_deposit_index.safe_add_assign(1)?;
|
next_deposit_index.safe_add_assign(1)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let deposit_balance_to_consume = if next_deposit_index == pending_balance_deposits.len() {
|
// Accumulate churn only if the churn limit has been hit.
|
||||||
0
|
let deposit_balance_to_consume = if is_churn_limit_reached {
|
||||||
} else {
|
|
||||||
available_for_processing.safe_sub(processed_amount)?
|
available_for_processing.safe_sub(processed_amount)?
|
||||||
|
} else {
|
||||||
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@@ -893,14 +986,15 @@ impl PendingBalanceDepositsContext {
|
|||||||
deposit_balance_to_consume,
|
deposit_balance_to_consume,
|
||||||
validator_deposits_to_process,
|
validator_deposits_to_process,
|
||||||
deposits_to_postpone,
|
deposits_to_postpone,
|
||||||
|
new_validator_deposits,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_pending_balance_deposits_for_validator(
|
fn process_pending_deposits_for_validator(
|
||||||
balance: &mut Cow<u64>,
|
balance: &mut Cow<u64>,
|
||||||
validator_info: &ValidatorInfo,
|
validator_info: &ValidatorInfo,
|
||||||
pending_balance_deposits_ctxt: &PendingBalanceDepositsContext,
|
pending_balance_deposits_ctxt: &PendingDepositsContext,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
if let Some(deposit_amount) = pending_balance_deposits_ctxt
|
if let Some(deposit_amount) = pending_balance_deposits_ctxt
|
||||||
.validator_deposits_to_process
|
.validator_deposits_to_process
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
|
use bls::Signature;
|
||||||
use safe_arith::SafeArith;
|
use safe_arith::SafeArith;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use types::{
|
use types::{
|
||||||
BeaconState, BeaconStateElectra, BeaconStateError as Error, ChainSpec, Epoch, EpochCache,
|
BeaconState, BeaconStateElectra, BeaconStateError as Error, ChainSpec, Epoch, EpochCache,
|
||||||
EthSpec, Fork, PendingBalanceDeposit,
|
EthSpec, Fork, PendingDeposit,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Transform a `Deneb` state into an `Electra` state.
|
/// Transform a `Deneb` state into an `Electra` state.
|
||||||
@@ -70,11 +71,16 @@ pub fn upgrade_to_electra<E: EthSpec>(
|
|||||||
.ok_or(Error::UnknownValidator(index))?;
|
.ok_or(Error::UnknownValidator(index))?;
|
||||||
validator.effective_balance = 0;
|
validator.effective_balance = 0;
|
||||||
validator.activation_eligibility_epoch = spec.far_future_epoch;
|
validator.activation_eligibility_epoch = spec.far_future_epoch;
|
||||||
|
let pubkey = validator.pubkey;
|
||||||
|
let withdrawal_credentials = validator.withdrawal_credentials;
|
||||||
|
|
||||||
post.pending_balance_deposits_mut()?
|
post.pending_deposits_mut()?
|
||||||
.push(PendingBalanceDeposit {
|
.push(PendingDeposit {
|
||||||
index: index as u64,
|
pubkey,
|
||||||
|
withdrawal_credentials,
|
||||||
amount: balance_copy,
|
amount: balance_copy,
|
||||||
|
signature: Signature::infinity()?,
|
||||||
|
slot: spec.genesis_slot,
|
||||||
})
|
})
|
||||||
.map_err(Error::MilhouseError)?;
|
.map_err(Error::MilhouseError)?;
|
||||||
}
|
}
|
||||||
@@ -156,7 +162,7 @@ pub fn upgrade_state_to_electra<E: EthSpec>(
|
|||||||
earliest_exit_epoch,
|
earliest_exit_epoch,
|
||||||
consolidation_balance_to_consume: 0,
|
consolidation_balance_to_consume: 0,
|
||||||
earliest_consolidation_epoch,
|
earliest_consolidation_epoch,
|
||||||
pending_balance_deposits: Default::default(),
|
pending_deposits: Default::default(),
|
||||||
pending_partial_withdrawals: Default::default(),
|
pending_partial_withdrawals: Default::default(),
|
||||||
pending_consolidations: Default::default(),
|
pending_consolidations: Default::default(),
|
||||||
// Caches
|
// Caches
|
||||||
|
|||||||
@@ -510,7 +510,7 @@ where
|
|||||||
#[compare_fields(as_iter)]
|
#[compare_fields(as_iter)]
|
||||||
#[test_random(default)]
|
#[test_random(default)]
|
||||||
#[superstruct(only(Electra))]
|
#[superstruct(only(Electra))]
|
||||||
pub pending_balance_deposits: List<PendingBalanceDeposit, E::PendingBalanceDepositsLimit>,
|
pub pending_deposits: List<PendingDeposit, E::PendingDepositsLimit>,
|
||||||
#[compare_fields(as_iter)]
|
#[compare_fields(as_iter)]
|
||||||
#[test_random(default)]
|
#[test_random(default)]
|
||||||
#[superstruct(only(Electra))]
|
#[superstruct(only(Electra))]
|
||||||
@@ -2147,11 +2147,14 @@ impl<E: EthSpec> BeaconState<E> {
|
|||||||
if *balance > spec.min_activation_balance {
|
if *balance > spec.min_activation_balance {
|
||||||
let excess_balance = balance.safe_sub(spec.min_activation_balance)?;
|
let excess_balance = balance.safe_sub(spec.min_activation_balance)?;
|
||||||
*balance = spec.min_activation_balance;
|
*balance = spec.min_activation_balance;
|
||||||
self.pending_balance_deposits_mut()?
|
let validator = self.get_validator(validator_index)?.clone();
|
||||||
.push(PendingBalanceDeposit {
|
self.pending_deposits_mut()?.push(PendingDeposit {
|
||||||
index: validator_index as u64,
|
pubkey: validator.pubkey,
|
||||||
amount: excess_balance,
|
withdrawal_credentials: validator.withdrawal_credentials,
|
||||||
})?;
|
amount: excess_balance,
|
||||||
|
signature: Signature::infinity()?,
|
||||||
|
slot: spec.genesis_slot,
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ pub trait EthSpec:
|
|||||||
/*
|
/*
|
||||||
* New in Electra
|
* New in Electra
|
||||||
*/
|
*/
|
||||||
type PendingBalanceDepositsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
type PendingDepositsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||||
type PendingPartialWithdrawalsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
type PendingPartialWithdrawalsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||||
type PendingConsolidationsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
type PendingConsolidationsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||||
type MaxConsolidationRequestsPerPayload: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
type MaxConsolidationRequestsPerPayload: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||||
@@ -159,6 +159,7 @@ pub trait EthSpec:
|
|||||||
type MaxAttesterSlashingsElectra: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
type MaxAttesterSlashingsElectra: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||||
type MaxAttestationsElectra: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
type MaxAttestationsElectra: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||||
type MaxWithdrawalRequestsPerPayload: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
type MaxWithdrawalRequestsPerPayload: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||||
|
type MaxPendingDepositsPerEpoch: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||||
|
|
||||||
fn default_spec() -> ChainSpec;
|
fn default_spec() -> ChainSpec;
|
||||||
|
|
||||||
@@ -331,9 +332,9 @@ pub trait EthSpec:
|
|||||||
.expect("Preset values are not configurable and never result in non-positive block body depth")
|
.expect("Preset values are not configurable and never result in non-positive block body depth")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the `PENDING_BALANCE_DEPOSITS_LIMIT` constant for this specification.
|
/// Returns the `PENDING_DEPOSITS_LIMIT` constant for this specification.
|
||||||
fn pending_balance_deposits_limit() -> usize {
|
fn pending_deposits_limit() -> usize {
|
||||||
Self::PendingBalanceDepositsLimit::to_usize()
|
Self::PendingDepositsLimit::to_usize()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the `PENDING_PARTIAL_WITHDRAWALS_LIMIT` constant for this specification.
|
/// Returns the `PENDING_PARTIAL_WITHDRAWALS_LIMIT` constant for this specification.
|
||||||
@@ -371,6 +372,11 @@ pub trait EthSpec:
|
|||||||
Self::MaxWithdrawalRequestsPerPayload::to_usize()
|
Self::MaxWithdrawalRequestsPerPayload::to_usize()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the `MAX_PENDING_DEPOSITS_PER_EPOCH` constant for this specification.
|
||||||
|
fn max_pending_deposits_per_epoch() -> usize {
|
||||||
|
Self::MaxPendingDepositsPerEpoch::to_usize()
|
||||||
|
}
|
||||||
|
|
||||||
fn kzg_commitments_inclusion_proof_depth() -> usize {
|
fn kzg_commitments_inclusion_proof_depth() -> usize {
|
||||||
Self::KzgCommitmentsInclusionProofDepth::to_usize()
|
Self::KzgCommitmentsInclusionProofDepth::to_usize()
|
||||||
}
|
}
|
||||||
@@ -430,7 +436,7 @@ impl EthSpec for MainnetEthSpec {
|
|||||||
type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch
|
type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch
|
||||||
type MaxBlsToExecutionChanges = U16;
|
type MaxBlsToExecutionChanges = U16;
|
||||||
type MaxWithdrawalsPerPayload = U16;
|
type MaxWithdrawalsPerPayload = U16;
|
||||||
type PendingBalanceDepositsLimit = U134217728;
|
type PendingDepositsLimit = U134217728;
|
||||||
type PendingPartialWithdrawalsLimit = U134217728;
|
type PendingPartialWithdrawalsLimit = U134217728;
|
||||||
type PendingConsolidationsLimit = U262144;
|
type PendingConsolidationsLimit = U262144;
|
||||||
type MaxConsolidationRequestsPerPayload = U1;
|
type MaxConsolidationRequestsPerPayload = U1;
|
||||||
@@ -438,6 +444,7 @@ impl EthSpec for MainnetEthSpec {
|
|||||||
type MaxAttesterSlashingsElectra = U1;
|
type MaxAttesterSlashingsElectra = U1;
|
||||||
type MaxAttestationsElectra = U8;
|
type MaxAttestationsElectra = U8;
|
||||||
type MaxWithdrawalRequestsPerPayload = U16;
|
type MaxWithdrawalRequestsPerPayload = U16;
|
||||||
|
type MaxPendingDepositsPerEpoch = U16;
|
||||||
|
|
||||||
fn default_spec() -> ChainSpec {
|
fn default_spec() -> ChainSpec {
|
||||||
ChainSpec::mainnet()
|
ChainSpec::mainnet()
|
||||||
@@ -500,7 +507,8 @@ impl EthSpec for MinimalEthSpec {
|
|||||||
MaxBlsToExecutionChanges,
|
MaxBlsToExecutionChanges,
|
||||||
MaxBlobsPerBlock,
|
MaxBlobsPerBlock,
|
||||||
BytesPerFieldElement,
|
BytesPerFieldElement,
|
||||||
PendingBalanceDepositsLimit,
|
PendingDepositsLimit,
|
||||||
|
MaxPendingDepositsPerEpoch,
|
||||||
MaxConsolidationRequestsPerPayload,
|
MaxConsolidationRequestsPerPayload,
|
||||||
MaxAttesterSlashingsElectra,
|
MaxAttesterSlashingsElectra,
|
||||||
MaxAttestationsElectra
|
MaxAttestationsElectra
|
||||||
@@ -557,7 +565,7 @@ impl EthSpec for GnosisEthSpec {
|
|||||||
type BytesPerFieldElement = U32;
|
type BytesPerFieldElement = U32;
|
||||||
type BytesPerBlob = U131072;
|
type BytesPerBlob = U131072;
|
||||||
type KzgCommitmentInclusionProofDepth = U17;
|
type KzgCommitmentInclusionProofDepth = U17;
|
||||||
type PendingBalanceDepositsLimit = U134217728;
|
type PendingDepositsLimit = U134217728;
|
||||||
type PendingPartialWithdrawalsLimit = U134217728;
|
type PendingPartialWithdrawalsLimit = U134217728;
|
||||||
type PendingConsolidationsLimit = U262144;
|
type PendingConsolidationsLimit = U262144;
|
||||||
type MaxConsolidationRequestsPerPayload = U1;
|
type MaxConsolidationRequestsPerPayload = U1;
|
||||||
@@ -565,6 +573,7 @@ impl EthSpec for GnosisEthSpec {
|
|||||||
type MaxAttesterSlashingsElectra = U1;
|
type MaxAttesterSlashingsElectra = U1;
|
||||||
type MaxAttestationsElectra = U8;
|
type MaxAttestationsElectra = U8;
|
||||||
type MaxWithdrawalRequestsPerPayload = U16;
|
type MaxWithdrawalRequestsPerPayload = U16;
|
||||||
|
type MaxPendingDepositsPerEpoch = U16;
|
||||||
type FieldElementsPerCell = U64;
|
type FieldElementsPerCell = U64;
|
||||||
type FieldElementsPerExtBlob = U8192;
|
type FieldElementsPerExtBlob = U8192;
|
||||||
type BytesPerCell = U2048;
|
type BytesPerCell = U2048;
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ pub mod light_client_finality_update;
|
|||||||
pub mod light_client_optimistic_update;
|
pub mod light_client_optimistic_update;
|
||||||
pub mod light_client_update;
|
pub mod light_client_update;
|
||||||
pub mod pending_attestation;
|
pub mod pending_attestation;
|
||||||
pub mod pending_balance_deposit;
|
|
||||||
pub mod pending_consolidation;
|
pub mod pending_consolidation;
|
||||||
|
pub mod pending_deposit;
|
||||||
pub mod pending_partial_withdrawal;
|
pub mod pending_partial_withdrawal;
|
||||||
pub mod proposer_preparation_data;
|
pub mod proposer_preparation_data;
|
||||||
pub mod proposer_slashing;
|
pub mod proposer_slashing;
|
||||||
@@ -210,8 +210,8 @@ pub use crate::payload::{
|
|||||||
FullPayloadRef, OwnedExecPayload,
|
FullPayloadRef, OwnedExecPayload,
|
||||||
};
|
};
|
||||||
pub use crate::pending_attestation::PendingAttestation;
|
pub use crate::pending_attestation::PendingAttestation;
|
||||||
pub use crate::pending_balance_deposit::PendingBalanceDeposit;
|
|
||||||
pub use crate::pending_consolidation::PendingConsolidation;
|
pub use crate::pending_consolidation::PendingConsolidation;
|
||||||
|
pub use crate::pending_deposit::PendingDeposit;
|
||||||
pub use crate::pending_partial_withdrawal::PendingPartialWithdrawal;
|
pub use crate::pending_partial_withdrawal::PendingPartialWithdrawal;
|
||||||
pub use crate::preset::{
|
pub use crate::preset::{
|
||||||
AltairPreset, BasePreset, BellatrixPreset, CapellaPreset, DenebPreset, ElectraPreset,
|
AltairPreset, BasePreset, BellatrixPreset, CapellaPreset, DenebPreset, ElectraPreset,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::test_utils::TestRandom;
|
use crate::test_utils::TestRandom;
|
||||||
|
use crate::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
use test_random_derive::TestRandom;
|
use test_random_derive::TestRandom;
|
||||||
@@ -18,16 +19,18 @@ use tree_hash_derive::TreeHash;
|
|||||||
TreeHash,
|
TreeHash,
|
||||||
TestRandom,
|
TestRandom,
|
||||||
)]
|
)]
|
||||||
pub struct PendingBalanceDeposit {
|
pub struct PendingDeposit {
|
||||||
#[serde(with = "serde_utils::quoted_u64")]
|
pub pubkey: PublicKeyBytes,
|
||||||
pub index: u64,
|
pub withdrawal_credentials: Hash256,
|
||||||
#[serde(with = "serde_utils::quoted_u64")]
|
#[serde(with = "serde_utils::quoted_u64")]
|
||||||
pub amount: u64,
|
pub amount: u64,
|
||||||
|
pub signature: Signature,
|
||||||
|
pub slot: Slot,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
ssz_and_tree_hash_tests!(PendingBalanceDeposit);
|
ssz_and_tree_hash_tests!(PendingDeposit);
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ impl ElectraPreset {
|
|||||||
whistleblower_reward_quotient_electra: spec.whistleblower_reward_quotient_electra,
|
whistleblower_reward_quotient_electra: spec.whistleblower_reward_quotient_electra,
|
||||||
max_pending_partials_per_withdrawals_sweep: spec
|
max_pending_partials_per_withdrawals_sweep: spec
|
||||||
.max_pending_partials_per_withdrawals_sweep,
|
.max_pending_partials_per_withdrawals_sweep,
|
||||||
pending_balance_deposits_limit: E::pending_balance_deposits_limit() as u64,
|
pending_balance_deposits_limit: E::pending_deposits_limit() as u64,
|
||||||
pending_partial_withdrawals_limit: E::pending_partial_withdrawals_limit() as u64,
|
pending_partial_withdrawals_limit: E::pending_partial_withdrawals_limit() as u64,
|
||||||
pending_consolidations_limit: E::pending_consolidations_limit() as u64,
|
pending_consolidations_limit: E::pending_consolidations_limit() as u64,
|
||||||
max_consolidation_requests_per_payload: E::max_consolidation_requests_per_payload()
|
max_consolidation_requests_per_payload: E::max_consolidation_requests_per_payload()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
TESTS_TAG := v1.5.0-alpha.6
|
TESTS_TAG := v1.5.0-alpha.7
|
||||||
TESTS = general minimal mainnet
|
TESTS = general minimal mainnet
|
||||||
TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS))
|
TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS))
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ type_name!(RewardsAndPenalties, "rewards_and_penalties");
|
|||||||
type_name!(RegistryUpdates, "registry_updates");
|
type_name!(RegistryUpdates, "registry_updates");
|
||||||
type_name!(Slashings, "slashings");
|
type_name!(Slashings, "slashings");
|
||||||
type_name!(Eth1DataReset, "eth1_data_reset");
|
type_name!(Eth1DataReset, "eth1_data_reset");
|
||||||
type_name!(PendingBalanceDeposits, "pending_balance_deposits");
|
type_name!(PendingBalanceDeposits, "pending_deposits");
|
||||||
type_name!(PendingConsolidations, "pending_consolidations");
|
type_name!(PendingConsolidations, "pending_consolidations");
|
||||||
type_name!(EffectiveBalanceUpdates, "effective_balance_updates");
|
type_name!(EffectiveBalanceUpdates, "effective_balance_updates");
|
||||||
type_name!(SlashingsReset, "slashings_reset");
|
type_name!(SlashingsReset, "slashings_reset");
|
||||||
@@ -193,7 +193,7 @@ impl<E: EthSpec> EpochTransition<E> for PendingBalanceDeposits {
|
|||||||
state,
|
state,
|
||||||
spec,
|
spec,
|
||||||
SinglePassConfig {
|
SinglePassConfig {
|
||||||
pending_balance_deposits: true,
|
pending_deposits: true,
|
||||||
..SinglePassConfig::disable_all()
|
..SinglePassConfig::disable_all()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -363,7 +363,7 @@ impl<E: EthSpec, T: EpochTransition<E>> Case for EpochProcessing<E, T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !fork_name.electra_enabled()
|
if !fork_name.electra_enabled()
|
||||||
&& (T::name() == "pending_consolidations" || T::name() == "pending_balance_deposits")
|
&& (T::name() == "pending_consolidations" || T::name() == "pending_deposits")
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ type_name_generic!(LightClientUpdateElectra, "LightClientUpdate");
|
|||||||
type_name_generic!(PendingAttestation);
|
type_name_generic!(PendingAttestation);
|
||||||
type_name!(PendingConsolidation);
|
type_name!(PendingConsolidation);
|
||||||
type_name!(PendingPartialWithdrawal);
|
type_name!(PendingPartialWithdrawal);
|
||||||
type_name!(PendingBalanceDeposit);
|
type_name!(PendingDeposit);
|
||||||
type_name!(ProposerSlashing);
|
type_name!(ProposerSlashing);
|
||||||
type_name_generic!(SignedAggregateAndProof);
|
type_name_generic!(SignedAggregateAndProof);
|
||||||
type_name_generic!(SignedAggregateAndProofBase, "SignedAggregateAndProof");
|
type_name_generic!(SignedAggregateAndProofBase, "SignedAggregateAndProof");
|
||||||
|
|||||||
@@ -243,8 +243,7 @@ mod ssz_static {
|
|||||||
use types::historical_summary::HistoricalSummary;
|
use types::historical_summary::HistoricalSummary;
|
||||||
use types::{
|
use types::{
|
||||||
AttesterSlashingBase, AttesterSlashingElectra, ConsolidationRequest, DepositRequest,
|
AttesterSlashingBase, AttesterSlashingElectra, ConsolidationRequest, DepositRequest,
|
||||||
LightClientBootstrapAltair, PendingBalanceDeposit, PendingPartialWithdrawal,
|
LightClientBootstrapAltair, PendingDeposit, PendingPartialWithdrawal, WithdrawalRequest, *,
|
||||||
WithdrawalRequest, *,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ssz_static_test!(attestation_data, AttestationData);
|
ssz_static_test!(attestation_data, AttestationData);
|
||||||
@@ -664,8 +663,8 @@ mod ssz_static {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pending_balance_deposit() {
|
fn pending_balance_deposit() {
|
||||||
SszStaticHandler::<PendingBalanceDeposit, MinimalEthSpec>::electra_and_later().run();
|
SszStaticHandler::<PendingDeposit, MinimalEthSpec>::electra_and_later().run();
|
||||||
SszStaticHandler::<PendingBalanceDeposit, MainnetEthSpec>::electra_and_later().run();
|
SszStaticHandler::<PendingDeposit, MainnetEthSpec>::electra_and_later().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user