mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 21:38:31 +00:00
Added Capella Epoch Processing Logic (#3666)
This commit is contained in:
@@ -73,6 +73,7 @@ pub struct ChainSpec {
|
||||
*/
|
||||
pub genesis_fork_version: [u8; 4],
|
||||
pub bls_withdrawal_prefix_byte: u8,
|
||||
pub eth1_address_withdrawal_prefix_byte: u8,
|
||||
|
||||
/*
|
||||
* Time parameters
|
||||
@@ -519,7 +520,8 @@ impl ChainSpec {
|
||||
* Initial Values
|
||||
*/
|
||||
genesis_fork_version: [0; 4],
|
||||
bls_withdrawal_prefix_byte: 0,
|
||||
bls_withdrawal_prefix_byte: 0x00,
|
||||
eth1_address_withdrawal_prefix_byte: 0x01,
|
||||
|
||||
/*
|
||||
* Time parameters
|
||||
@@ -748,7 +750,8 @@ impl ChainSpec {
|
||||
* Initial Values
|
||||
*/
|
||||
genesis_fork_version: [0x00, 0x00, 0x00, 0x64],
|
||||
bls_withdrawal_prefix_byte: 0,
|
||||
bls_withdrawal_prefix_byte: 0x00,
|
||||
eth1_address_withdrawal_prefix_byte: 0x01,
|
||||
|
||||
/*
|
||||
* Time parameters
|
||||
|
||||
@@ -65,6 +65,27 @@ impl Validator {
|
||||
// Has not yet been activated
|
||||
&& self.activation_epoch == spec.far_future_epoch
|
||||
}
|
||||
|
||||
/// Returns `true` if the validator has eth1 withdrawal credential
|
||||
pub fn has_eth1_withdrawal_credential(&self, spec: &ChainSpec) -> bool {
|
||||
self.withdrawal_credentials
|
||||
.as_bytes()
|
||||
.first()
|
||||
.map(|byte| *byte == spec.eth1_address_withdrawal_prefix_byte)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Returns `true` if the validator is fully withdrawable at some epoch
|
||||
pub fn is_fully_withdrawable_at(&self, balance: u64, epoch: Epoch, spec: &ChainSpec) -> bool {
|
||||
self.has_eth1_withdrawal_credential(spec) && self.withdrawable_epoch <= epoch && balance > 0
|
||||
}
|
||||
|
||||
/// Returns `true` if the validator is partially withdrawable
|
||||
pub fn is_partially_withdrawable_validator(&self, balance: u64, spec: &ChainSpec) -> bool {
|
||||
self.has_eth1_withdrawal_credential(spec)
|
||||
&& self.effective_balance == spec.max_effective_balance
|
||||
&& balance > spec.max_effective_balance
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Validator {
|
||||
|
||||
@@ -15,6 +15,7 @@ use tree_hash_derive::TreeHash;
|
||||
pub struct Withdrawal {
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
pub index: u64,
|
||||
pub validator_index: u64,
|
||||
pub address: Address,
|
||||
pub amount: u64,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user