v0.6: update all spec version comments

This commit is contained in:
Michael Sproul 2019-06-17 16:25:57 +10:00
parent 1823378bfa
commit 03c50354f4
No known key found for this signature in database
GPG Key ID: 77B1309D2E54E914
44 changed files with 159 additions and 159 deletions

View File

@ -3,7 +3,7 @@ use types::*;
/// Returns validator indices which participated in the attestation, sorted by increasing index.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_attesting_indices<T: EthSpec>(
state: &BeaconState<T>,
attestation_data: &AttestationData,
@ -18,7 +18,7 @@ pub fn get_attesting_indices<T: EthSpec>(
/// Returns validator indices which participated in the attestation, unsorted.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_attesting_indices_unsorted<T: EthSpec>(
state: &BeaconState<T>,
attestation_data: &AttestationData,

View File

@ -3,7 +3,7 @@ use types::{BeaconStateError as Error, *};
/// Initiate the exit of the validator of the given `index`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn initiate_validator_exit<T: EthSpec>(
state: &mut BeaconState<T>,
index: usize,

View File

@ -3,7 +3,7 @@ use types::{BeaconStateError as Error, *};
/// Slash the validator with index ``index``.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn slash_validator<T: EthSpec>(
state: &mut BeaconState<T>,
slashed_index: usize,

View File

@ -4,7 +4,7 @@ use types::*;
///
/// Is title `verify_bitfield` in spec.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_bitfield_length(bitfield: &Bitfield, committee_size: usize) -> bool {
if bitfield.num_bytes() != ((committee_size + 7) / 8) {
return false;

View File

@ -9,7 +9,7 @@ pub enum GenesisError {
/// Returns the genesis `BeaconState`
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_genesis_beacon_state<T: EthSpec>(
genesis_validator_deposits: &[Deposit],
genesis_time: u64,

View File

@ -40,7 +40,7 @@ mod verify_transfer;
/// Returns `Ok(())` if the block is valid and the state was successfully updated. Otherwise
/// returns an error describing why the block was invalid or how the function failed to execute.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn per_block_processing<T: EthSpec>(
state: &mut BeaconState<T>,
block: &BeaconBlock,
@ -55,7 +55,7 @@ pub fn per_block_processing<T: EthSpec>(
/// Returns `Ok(())` if the block is valid and the state was successfully updated. Otherwise
/// returns an error describing why the block was invalid or how the function failed to execute.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn per_block_processing_without_verifying_block_signature<T: EthSpec>(
state: &mut BeaconState<T>,
block: &BeaconBlock,
@ -70,7 +70,7 @@ pub fn per_block_processing_without_verifying_block_signature<T: EthSpec>(
/// Returns `Ok(())` if the block is valid and the state was successfully updated. Otherwise
/// returns an error describing why the block was invalid or how the function failed to execute.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn per_block_processing_signature_optional<T: EthSpec>(
mut state: &mut BeaconState<T>,
block: &BeaconBlock,
@ -97,7 +97,7 @@ fn per_block_processing_signature_optional<T: EthSpec>(
/// Processes the block header.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_block_header<T: EthSpec>(
state: &mut BeaconState<T>,
block: &BeaconBlock,
@ -132,7 +132,7 @@ pub fn process_block_header<T: EthSpec>(
/// Verifies the signature of a block.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_block_signature<T: EthSpec>(
state: &BeaconState<T>,
block: &BeaconBlock,
@ -160,7 +160,7 @@ pub fn verify_block_signature<T: EthSpec>(
/// Verifies the `randao_reveal` against the block's proposer pubkey and updates
/// `state.latest_randao_mixes`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_randao<T: EthSpec>(
state: &mut BeaconState<T>,
block: &BeaconBlock,
@ -191,7 +191,7 @@ pub fn process_randao<T: EthSpec>(
/// Update the `state.eth1_data_votes` based upon the `eth1_data` provided.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_eth1_data<T: EthSpec>(
state: &mut BeaconState<T>,
eth1_data: &Eth1Data,
@ -217,7 +217,7 @@ pub fn process_eth1_data<T: EthSpec>(
/// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_proposer_slashings<T: EthSpec>(
state: &mut BeaconState<T>,
proposer_slashings: &[ProposerSlashing],
@ -250,7 +250,7 @@ pub fn process_proposer_slashings<T: EthSpec>(
/// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_attester_slashings<T: EthSpec>(
state: &mut BeaconState<T>,
attester_slashings: &[AttesterSlashing],
@ -308,7 +308,7 @@ pub fn process_attester_slashings<T: EthSpec>(
/// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_attestations<T: EthSpec>(
state: &mut BeaconState<T>,
attestations: &[Attestation],
@ -357,7 +357,7 @@ pub fn process_attestations<T: EthSpec>(
/// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_deposits<T: EthSpec>(
state: &mut BeaconState<T>,
deposits: &[Deposit],
@ -434,7 +434,7 @@ pub fn process_deposits<T: EthSpec>(
/// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_exits<T: EthSpec>(
state: &mut BeaconState<T>,
voluntary_exits: &[VoluntaryExit],
@ -466,7 +466,7 @@ pub fn process_exits<T: EthSpec>(
/// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_transfers<T: EthSpec>(
state: &mut BeaconState<T>,
transfers: &[Transfer],

View File

@ -11,7 +11,7 @@ use types::*;
///
/// Returns `Ok(())` if the `Attestation` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn validate_attestation<T: EthSpec>(
state: &BeaconState<T>,
attestation: &Attestation,
@ -34,7 +34,7 @@ pub fn validate_attestation_time_independent_only<T: EthSpec>(
///
/// Returns `Ok(())` if the `Attestation` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn validate_attestation_without_signature<T: EthSpec>(
state: &BeaconState<T>,
attestation: &Attestation,
@ -47,7 +47,7 @@ pub fn validate_attestation_without_signature<T: EthSpec>(
/// given state, optionally validating the aggregate signature.
///
///
/// Spec v0.6.1
/// Spec v0.6.3
fn validate_attestation_parametric<T: EthSpec>(
state: &BeaconState<T>,
attestation: &Attestation,
@ -99,7 +99,7 @@ fn validate_attestation_parametric<T: EthSpec>(
/// Check target epoch, source epoch, source root, and source crosslink.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn verify_casper_ffg_vote<T: EthSpec>(
attestation: &Attestation,
state: &BeaconState<T>,

View File

@ -8,7 +8,7 @@ use types::*;
///
/// Returns `Ok(())` if the `AttesterSlashing` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_attester_slashing<T: EthSpec>(
state: &BeaconState<T>,
attester_slashing: &AttesterSlashing,
@ -39,7 +39,7 @@ pub fn verify_attester_slashing<T: EthSpec>(
///
/// Returns Ok(indices) if `indices.len() > 0`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_slashable_indices<T: EthSpec>(
state: &BeaconState<T>,
attester_slashing: &AttesterSlashing,

View File

@ -5,7 +5,7 @@ use types::*;
/// Verify `Deposit.pubkey` signed `Deposit.signature`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_deposit_signature<T: EthSpec>(
state: &BeaconState<T>,
deposit: &Deposit,
@ -25,7 +25,7 @@ pub fn verify_deposit_signature<T: EthSpec>(
/// Verify that the `Deposit` index is correct.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_deposit_index<T: EthSpec>(
state: &BeaconState<T>,
deposit: &Deposit,
@ -57,7 +57,7 @@ pub fn get_existing_validator_index<T: EthSpec>(
/// Verify that a deposit is included in the state's eth1 deposit root.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_deposit_merkle_proof<T: EthSpec>(
state: &BeaconState<T>,
deposit: &Deposit,

View File

@ -7,7 +7,7 @@ use types::*;
///
/// Returns `Ok(())` if the `Exit` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_exit<T: EthSpec>(
state: &BeaconState<T>,
exit: &VoluntaryExit,
@ -18,7 +18,7 @@ pub fn verify_exit<T: EthSpec>(
/// Like `verify_exit` but doesn't run checks which may become true in future states.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_exit_time_independent_only<T: EthSpec>(
state: &BeaconState<T>,
exit: &VoluntaryExit,
@ -29,7 +29,7 @@ pub fn verify_exit_time_independent_only<T: EthSpec>(
/// Parametric version of `verify_exit` that skips some checks if `time_independent_only` is true.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn verify_exit_parametric<T: EthSpec>(
state: &BeaconState<T>,
exit: &VoluntaryExit,

View File

@ -8,7 +8,7 @@ use types::*;
/// Verify an `IndexedAttestation`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_indexed_attestation<T: EthSpec>(
state: &BeaconState<T>,
indexed_attestation: &IndexedAttestation,
@ -19,7 +19,7 @@ pub fn verify_indexed_attestation<T: EthSpec>(
/// Verify but don't check the signature.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_indexed_attestation_without_signature<T: EthSpec>(
state: &BeaconState<T>,
indexed_attestation: &IndexedAttestation,
@ -30,7 +30,7 @@ pub fn verify_indexed_attestation_without_signature<T: EthSpec>(
/// Optionally check the signature.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn verify_indexed_attestation_parametric<T: EthSpec>(
state: &BeaconState<T>,
indexed_attestation: &IndexedAttestation,
@ -107,7 +107,7 @@ where
/// Verify the signature of an IndexedAttestation.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn verify_indexed_attestation_signature<T: EthSpec>(
state: &BeaconState<T>,
indexed_attestation: &IndexedAttestation,

View File

@ -7,7 +7,7 @@ use types::*;
///
/// Returns `Ok(())` if the `ProposerSlashing` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_proposer_slashing<T: EthSpec>(
proposer_slashing: &ProposerSlashing,
state: &BeaconState<T>,
@ -65,7 +65,7 @@ pub fn verify_proposer_slashing<T: EthSpec>(
///
/// Returns `true` if the signature is valid.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn verify_header_signature<T: EthSpec>(
header: &BeaconBlockHeader,
pubkey: &PublicKey,

View File

@ -8,7 +8,7 @@ use types::*;
///
/// Returns `Ok(())` if the `Transfer` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_transfer<T: EthSpec>(
state: &BeaconState<T>,
transfer: &Transfer,
@ -19,7 +19,7 @@ pub fn verify_transfer<T: EthSpec>(
/// Like `verify_transfer` but doesn't run checks which may become true in future states.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn verify_transfer_time_independent_only<T: EthSpec>(
state: &BeaconState<T>,
transfer: &Transfer,
@ -37,7 +37,7 @@ pub fn verify_transfer_time_independent_only<T: EthSpec>(
/// present or future.
/// - Validator transfer eligibility (e.g., is withdrawable)
///
/// Spec v0.6.1
/// Spec v0.6.3
fn verify_transfer_parametric<T: EthSpec>(
state: &BeaconState<T>,
transfer: &Transfer,
@ -154,7 +154,7 @@ fn verify_transfer_parametric<T: EthSpec>(
///
/// Does not check that the transfer is valid, however checks for overflow in all actions.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn execute_transfer<T: EthSpec>(
state: &mut BeaconState<T>,
transfer: &Transfer,

View File

@ -26,7 +26,7 @@ pub type WinningRootHashSet = HashMap<u64, WinningRoot>;
/// Mutates the given `BeaconState`, returning early if an error is encountered. If an error is
/// returned, a state might be "half-processed" and therefore in an invalid state.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn per_epoch_processing<T: EthSpec>(
state: &mut BeaconState<T>,
spec: &ChainSpec,
@ -80,7 +80,7 @@ pub fn per_epoch_processing<T: EthSpec>(
/// - `finalized_epoch`
/// - `finalized_root`
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_justification_and_finalization<T: EthSpec>(
state: &mut BeaconState<T>,
total_balances: &TotalBalances,
@ -147,7 +147,7 @@ pub fn process_justification_and_finalization<T: EthSpec>(
///
/// Also returns a `WinningRootHashSet` for later use during epoch processing.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_crosslinks<T: EthSpec>(
state: &mut BeaconState<T>,
spec: &ChainSpec,
@ -183,7 +183,7 @@ pub fn process_crosslinks<T: EthSpec>(
/// Finish up an epoch update.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_final_updates<T: EthSpec>(
state: &mut BeaconState<T>,
spec: &ChainSpec,

View File

@ -32,7 +32,7 @@ impl std::ops::AddAssign for Delta {
/// Apply attester and proposer rewards.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_rewards_and_penalties<T: EthSpec>(
state: &mut BeaconState<T>,
validator_statuses: &mut ValidatorStatuses,
@ -74,7 +74,7 @@ pub fn process_rewards_and_penalties<T: EthSpec>(
/// For each attesting validator, reward the proposer who was first to include their attestation.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn get_proposer_deltas<T: EthSpec>(
deltas: &mut Vec<Delta>,
state: &BeaconState<T>,
@ -111,7 +111,7 @@ fn get_proposer_deltas<T: EthSpec>(
/// Apply rewards for participation in attestations during the previous epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn get_attestation_deltas<T: EthSpec>(
deltas: &mut Vec<Delta>,
state: &BeaconState<T>,
@ -144,7 +144,7 @@ fn get_attestation_deltas<T: EthSpec>(
/// Determine the delta for a single validator, sans proposer rewards.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn get_attestation_delta(
validator: &ValidatorStatus,
total_balances: &TotalBalances,
@ -224,7 +224,7 @@ fn get_attestation_delta(
/// Calculate the deltas based upon the winning roots for attestations during the previous epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn get_crosslink_deltas<T: EthSpec>(
deltas: &mut Vec<Delta>,
state: &BeaconState<T>,
@ -258,7 +258,7 @@ fn get_crosslink_deltas<T: EthSpec>(
/// Returns the base reward for some validator.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn get_base_reward<T: EthSpec>(
state: &BeaconState<T>,
index: usize,

View File

@ -2,7 +2,7 @@ use types::{BeaconStateError as Error, *};
/// Process slashings.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_slashings<T: EthSpec>(
state: &mut BeaconState<T>,
current_total_balance: u64,

View File

@ -5,7 +5,7 @@ use types::*;
/// Peforms a validator registry update, if required.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_registry_updates<T: EthSpec>(
state: &mut BeaconState<T>,
spec: &ChainSpec,

View File

@ -162,7 +162,7 @@ impl ValidatorStatuses {
/// - Active validators
/// - Total balances for the current and previous epochs.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn new<T: EthSpec>(
state: &BeaconState<T>,
spec: &ChainSpec,
@ -202,7 +202,7 @@ impl ValidatorStatuses {
/// Process some attestations from the given `state` updating the `statuses` and
/// `total_balances` fields.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_attestations<T: EthSpec>(
&mut self,
state: &BeaconState<T>,
@ -289,7 +289,7 @@ impl ValidatorStatuses {
/// Update the `statuses` for each validator based upon whether or not they attested to the
/// "winning" shard block root for the previous epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn process_winning_roots<T: EthSpec>(
&mut self,
state: &BeaconState<T>,
@ -323,7 +323,7 @@ impl ValidatorStatuses {
/// Returns `true` if some `PendingAttestation` is from the supplied `epoch`.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn is_from_epoch(a: &PendingAttestation, epoch: Epoch) -> bool {
a.data.target_epoch == epoch
}
@ -331,7 +331,7 @@ fn is_from_epoch(a: &PendingAttestation, epoch: Epoch) -> bool {
/// Returns `true` if the attestation's FFG target is equal to the hash of the `state`'s first
/// beacon block in the given `epoch`.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn target_matches_epoch_start_block<T: EthSpec>(
a: &PendingAttestation,
state: &BeaconState<T>,
@ -346,7 +346,7 @@ fn target_matches_epoch_start_block<T: EthSpec>(
/// Returns `true` if a `PendingAttestation` and `BeaconState` share the same beacon block hash for
/// the current slot of the `PendingAttestation`.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn has_common_beacon_block_root<T: EthSpec>(
a: &PendingAttestation,
state: &BeaconState<T>,

View File

@ -16,7 +16,7 @@ impl WinningRoot {
/// A winning root is "better" than another if it has a higher `total_attesting_balance`. Ties
/// are broken by favouring the higher `crosslink_data_root` value.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn is_better_than(&self, other: &Self) -> bool {
(
self.total_attesting_balance,
@ -34,7 +34,7 @@ impl WinningRoot {
/// The `WinningRoot` object also contains additional fields that are useful in later stages of
/// per-epoch processing.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn winning_root<T: EthSpec>(
state: &BeaconState<T>,
shard: u64,

View File

@ -9,7 +9,7 @@ pub enum Error {
/// Advances a state forward by one slot, performing per-epoch processing if required.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn per_slot_processing<T: EthSpec>(
state: &mut BeaconState<T>,
spec: &ChainSpec,

View File

@ -9,7 +9,7 @@ use tree_hash_derive::{CachedTreeHash, SignedRoot, TreeHash};
/// Details an attestation that can be slashable.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
Clone,

View File

@ -9,7 +9,7 @@ use tree_hash_derive::{CachedTreeHash, SignedRoot, TreeHash};
/// The data upon which an attestation is based.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
Clone,

View File

@ -7,7 +7,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// Used for pairing an attestation with a proof-of-custody.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
Clone,

View File

@ -7,7 +7,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// Two conflicting attestations.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,

View File

@ -10,7 +10,7 @@ use tree_hash_derive::{CachedTreeHash, SignedRoot, TreeHash};
/// A block of the `BeaconChain`.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,
@ -36,7 +36,7 @@ pub struct BeaconBlock {
impl BeaconBlock {
/// Returns an empty block to be used during genesis.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn empty(spec: &ChainSpec) -> BeaconBlock {
BeaconBlock {
slot: spec.genesis_slot,
@ -63,7 +63,7 @@ impl BeaconBlock {
/// Returns the `tree_hash_root | update` of the block.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn canonical_root(&self) -> Hash256 {
Hash256::from_slice(&self.tree_hash_root()[..])
}
@ -75,7 +75,7 @@ impl BeaconBlock {
///
/// Note: performs a full tree-hash of `self.body`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn block_header(&self) -> BeaconBlockHeader {
BeaconBlockHeader {
slot: self.slot,
@ -88,7 +88,7 @@ impl BeaconBlock {
/// Returns a "temporary" header, where the `state_root` is `spec.zero_hash`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn temporary_block_header(&self, spec: &ChainSpec) -> BeaconBlockHeader {
BeaconBlockHeader {
state_root: spec.zero_hash,

View File

@ -8,7 +8,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// The body of a `BeaconChain` block, containing operations.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,

View File

@ -10,7 +10,7 @@ use tree_hash_derive::{CachedTreeHash, SignedRoot, TreeHash};
/// A header of a `BeaconBlock`.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,
@ -36,14 +36,14 @@ pub struct BeaconBlockHeader {
impl BeaconBlockHeader {
/// Returns the `tree_hash_root` of the header.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn canonical_root(&self) -> Hash256 {
Hash256::from_slice(&self.signed_root()[..])
}
/// Given a `body`, consumes `self` and returns a complete `BeaconBlock`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn into_block(self, body: BeaconBlockBody) -> BeaconBlock {
BeaconBlock {
slot: self.slot,

View File

@ -63,7 +63,7 @@ pub enum Error {
/// The state of the `BeaconChain` at some slot.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,
@ -157,7 +157,7 @@ impl<T: EthSpec> BeaconState<T> {
/// This does not fully build a genesis beacon state, it omits processing of initial validator
/// deposits. To obtain a full genesis beacon state, use the `BeaconStateBuilder`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn genesis(
genesis_time: u64,
latest_eth1_data: Eth1Data,
@ -234,7 +234,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Returns the `tree_hash_root` of the state.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn canonical_root(&self) -> Hash256 {
Hash256::from_slice(&self.tree_hash_root()[..])
}
@ -263,7 +263,7 @@ impl<T: EthSpec> BeaconState<T> {
/// The epoch corresponding to `self.slot`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn current_epoch(&self) -> Epoch {
self.slot.epoch(T::slots_per_epoch())
}
@ -272,7 +272,7 @@ impl<T: EthSpec> BeaconState<T> {
///
/// If the current epoch is the genesis epoch, the genesis_epoch is returned.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn previous_epoch(&self) -> Epoch {
let current_epoch = self.current_epoch();
if current_epoch > T::genesis_epoch() {
@ -284,7 +284,7 @@ impl<T: EthSpec> BeaconState<T> {
/// The epoch following `self.current_epoch()`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn next_epoch(&self) -> Epoch {
self.current_epoch() + 1
}
@ -313,7 +313,7 @@ impl<T: EthSpec> BeaconState<T> {
///
/// Note: Utilizes the cache and will fail if the appropriate cache is not initialized.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_attestation_slot(&self, attestation_data: &AttestationData) -> Result<Slot, Error> {
let target_relative_epoch =
RelativeEpoch::from_epoch(self.current_epoch(), attestation_data.target_epoch)?;
@ -342,7 +342,7 @@ impl<T: EthSpec> BeaconState<T> {
///
/// Does not utilize the cache, performs a full iteration over the validator registry.
///
/// Spec v0.5.1
/// Spec v0.6.3
pub fn get_active_validator_indices(&self, epoch: Epoch) -> Vec<usize> {
get_active_validator_indices(&self.validator_registry, epoch)
}
@ -362,7 +362,7 @@ impl<T: EthSpec> BeaconState<T> {
///
/// Note: Utilizes the cache and will fail if the appropriate cache is not initialized.
///
/// Spec v0.5.1
/// Spec v0.6.3
pub fn get_crosslink_committees_at_slot(
&self,
slot: Slot,
@ -379,7 +379,7 @@ impl<T: EthSpec> BeaconState<T> {
///
/// Note: Utilizes the cache and will fail if the appropriate cache is not initialized.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_crosslink_committee_for_shard(
&self,
shard: u64,
@ -396,7 +396,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Returns the beacon proposer index for the `slot` in the given `relative_epoch`.
///
/// Spec v0.6.1
/// Spec v0.6.3
// NOTE: be sure to test this bad boy.
pub fn get_beacon_proposer_index(
&self,
@ -433,7 +433,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Safely obtains the index for latest block roots, given some `slot`.
///
/// Spec v0.5.1
/// Spec v0.6.3
fn get_latest_block_roots_index(&self, slot: Slot) -> Result<usize, Error> {
if (slot < self.slot) && (self.slot <= slot + self.latest_block_roots.len() as u64) {
Ok(slot.as_usize() % self.latest_block_roots.len())
@ -444,7 +444,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Return the block root at a recent `slot`.
///
/// Spec v0.5.1
/// Spec v0.6.3
pub fn get_block_root(&self, slot: Slot) -> Result<&Hash256, BeaconStateError> {
let i = self.get_latest_block_roots_index(slot)?;
Ok(&self.latest_block_roots[i])
@ -452,7 +452,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Return the block root at a recent `epoch`.
///
/// Spec v0.6.0
/// Spec v0.6.3
// NOTE: the spec calls this get_block_root
pub fn get_block_root_at_epoch(&self, epoch: Epoch) -> Result<&Hash256, BeaconStateError> {
self.get_block_root(epoch.start_slot(T::slots_per_epoch()))
@ -460,7 +460,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Sets the block root for some given slot.
///
/// Spec v0.5.1
/// Spec v0.6.3
pub fn set_block_root(
&mut self,
slot: Slot,
@ -473,7 +473,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Safely obtains the index for `latest_randao_mixes`
///
/// Spec v0.5.1
/// Spec v0.6.3
fn get_randao_mix_index(&self, epoch: Epoch) -> Result<usize, Error> {
let current_epoch = self.current_epoch();
let len = T::LatestRandaoMixesLength::to_u64();
@ -491,7 +491,7 @@ impl<T: EthSpec> BeaconState<T> {
///
/// See `Self::get_randao_mix`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn update_randao_mix(&mut self, epoch: Epoch, signature: &Signature) -> Result<(), Error> {
let i = epoch.as_usize() % T::LatestRandaoMixesLength::to_usize();
@ -504,7 +504,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Return the randao mix at a recent ``epoch``.
///
/// Spec v0.5.1
/// Spec v0.6.3
pub fn get_randao_mix(&self, epoch: Epoch) -> Result<&Hash256, Error> {
let i = self.get_randao_mix_index(epoch)?;
Ok(&self.latest_randao_mixes[i])
@ -512,7 +512,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Set the randao mix at a recent ``epoch``.
///
/// Spec v0.5.1
/// Spec v0.6.3
pub fn set_randao_mix(&mut self, epoch: Epoch, mix: Hash256) -> Result<(), Error> {
let i = self.get_randao_mix_index(epoch)?;
self.latest_randao_mixes[i] = mix;
@ -521,7 +521,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Safely obtains the index for `latest_active_index_roots`, given some `epoch`.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn get_active_index_root_index(&self, epoch: Epoch, spec: &ChainSpec) -> Result<usize, Error> {
let current_epoch = self.current_epoch();
@ -537,7 +537,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Return the `active_index_root` at a recent `epoch`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_active_index_root(&self, epoch: Epoch, spec: &ChainSpec) -> Result<Hash256, Error> {
let i = self.get_active_index_root_index(epoch, spec)?;
Ok(self.latest_active_index_roots[i])
@ -545,7 +545,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Set the `active_index_root` at a recent `epoch`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn set_active_index_root(
&mut self,
epoch: Epoch,
@ -559,7 +559,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Replace `active_index_roots` with clones of `index_root`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn fill_active_index_roots_with(&mut self, index_root: Hash256) {
self.latest_active_index_roots =
vec![index_root; self.latest_active_index_roots.len()].into()
@ -567,7 +567,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Safely obtains the index for latest state roots, given some `slot`.
///
/// Spec v0.5.1
/// Spec v0.6.3
fn get_latest_state_roots_index(&self, slot: Slot) -> Result<usize, Error> {
if (slot < self.slot) && (self.slot <= slot + self.latest_state_roots.len() as u64) {
Ok(slot.as_usize() % self.latest_state_roots.len())
@ -578,7 +578,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Gets the state root for some slot.
///
/// Spec v0.5.1
/// Spec v0.6.3
pub fn get_state_root(&mut self, slot: Slot) -> Result<&Hash256, Error> {
let i = self.get_latest_state_roots_index(slot)?;
Ok(&self.latest_state_roots[i])
@ -586,7 +586,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Sets the latest state root for slot.
///
/// Spec v0.5.1
/// Spec v0.6.3
pub fn set_state_root(&mut self, slot: Slot, state_root: Hash256) -> Result<(), Error> {
let i = self.get_latest_state_roots_index(slot)?;
self.latest_state_roots[i] = state_root;
@ -595,7 +595,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Safely obtains the index for `latest_slashed_balances`, given some `epoch`.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn get_slashed_balance_index(&self, epoch: Epoch) -> Result<usize, Error> {
let i = epoch.as_usize() % self.latest_slashed_balances.len();
@ -610,7 +610,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Gets the total slashed balances for some epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_slashed_balance(&self, epoch: Epoch) -> Result<u64, Error> {
let i = self.get_slashed_balance_index(epoch)?;
Ok(self.latest_slashed_balances[i])
@ -618,7 +618,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Sets the total slashed balances for some epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn set_slashed_balance(&mut self, epoch: Epoch, balance: u64) -> Result<(), Error> {
let i = self.get_slashed_balance_index(epoch)?;
self.latest_slashed_balances[i] = balance;
@ -627,7 +627,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Get the attestations from the current or previous epoch.
///
/// Spec v0.6.0
/// Spec v0.6.3
pub fn get_matching_source_attestations(
&self,
epoch: Epoch,
@ -643,7 +643,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Get the current crosslink for a shard.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_current_crosslink(&self, shard: u64) -> Result<&Crosslink, Error> {
self.current_crosslinks
.get(shard as usize)
@ -652,7 +652,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Get the previous crosslink for a shard.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_previous_crosslink(&self, shard: u64) -> Result<&Crosslink, Error> {
self.previous_crosslinks
.get(shard as usize)
@ -661,7 +661,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Transform an attestation into the crosslink that it reinforces.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_crosslink_from_attestation_data(
&self,
data: &AttestationData,
@ -680,7 +680,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Generate a seed for the given `epoch`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn generate_seed(&self, epoch: Epoch, spec: &ChainSpec) -> Result<Hash256, Error> {
// Bypass the safe getter for RANDAO so we can gracefully handle the scenario where `epoch
// == 0`.
@ -701,7 +701,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Return the effective balance (also known as "balance at stake") for a validator with the given ``index``.
///
/// Spec v0.6.0
/// Spec v0.6.3
pub fn get_effective_balance(
&self,
validator_index: usize,
@ -715,7 +715,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Return the epoch at which an activation or exit triggered in ``epoch`` takes effect.
///
/// Spec v0.5.1
/// Spec v0.6.3
pub fn get_delayed_activation_exit_epoch(&self, epoch: Epoch, spec: &ChainSpec) -> Epoch {
epoch + 1 + spec.activation_exit_delay
}
@ -724,7 +724,7 @@ impl<T: EthSpec> BeaconState<T> {
///
/// Uses the epoch cache, and will error if it isn't initialized.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_churn_limit(&self, spec: &ChainSpec) -> Result<u64, Error> {
Ok(std::cmp::max(
spec.min_per_epoch_churn_limit,
@ -738,7 +738,7 @@ impl<T: EthSpec> BeaconState<T> {
///
/// Note: Utilizes the cache and will fail if the appropriate cache is not initialized.
///
/// Spec v0.6.2
/// Spec v0.6.3
pub fn get_attestation_duties(
&self,
validator_index: usize,
@ -751,7 +751,7 @@ impl<T: EthSpec> BeaconState<T> {
/// Return the combined effective balance of an array of validators.
///
/// Spec v0.6.0
/// Spec v0.6.3
pub fn get_total_balance(
&self,
validator_indices: &[usize],

View File

@ -22,7 +22,7 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq {
/// Return the number of committees in one epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn get_epoch_committee_count(
active_validator_count: usize,
target_committee_size: usize,
@ -60,42 +60,42 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq {
/// Returns the `SLOTS_PER_EPOCH` constant for this specification.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn slots_per_epoch() -> u64 {
Self::SlotsPerEpoch::to_u64()
}
/// Returns the `SHARD_COUNT` constant for this specification.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn shard_count() -> usize {
Self::ShardCount::to_usize()
}
/// Returns the `SLOTS_PER_HISTORICAL_ROOT` constant for this specification.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn slots_per_historical_root() -> usize {
Self::SlotsPerHistoricalRoot::to_usize()
}
/// Returns the `LATEST_RANDAO_MIXES_LENGTH` constant for this specification.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn latest_randao_mixes_length() -> usize {
Self::LatestRandaoMixesLength::to_usize()
}
/// Returns the `LATEST_ACTIVE_INDEX_ROOTS` constant for this specification.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn latest_active_index_roots() -> usize {
Self::LatestActiveIndexRootsLength::to_usize()
}
/// Returns the `LATEST_SLASHED_EXIT_LENGTH` constant for this specification.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn latest_slashed_exit_length() -> usize {
Self::LatestSlashedExitLength::to_usize()
}
@ -103,7 +103,7 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq {
/// Ethereum Foundation specifications.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize)]
pub struct MainnetEthSpec;

View File

@ -24,7 +24,7 @@ pub struct CommitteeCache {
impl CommitteeCache {
/// Return a new, fully initialized cache.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn initialized<T: EthSpec>(
state: &BeaconState<T>,
epoch: Epoch,
@ -128,7 +128,7 @@ impl CommitteeCache {
///
/// Always returns `&[]` for a non-initialized epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn active_validator_indices(&self) -> &[usize] {
&self.shuffling
}
@ -137,7 +137,7 @@ impl CommitteeCache {
///
/// Always returns `&[]` for a non-initialized epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn shuffling(&self) -> &[usize] {
&self.shuffling
}
@ -147,7 +147,7 @@ impl CommitteeCache {
///
/// Always returns `None` for a non-initialized epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_crosslink_committee_for_shard(&self, shard: Shard) -> Option<CrosslinkCommittee> {
if shard >= self.shard_count || self.initialized_epoch.is_none() {
return None;
@ -201,7 +201,7 @@ impl CommitteeCache {
///
/// Always returns `usize::default()` for a non-initialized epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn active_validator_count(&self) -> usize {
self.shuffling.len()
}
@ -210,7 +210,7 @@ impl CommitteeCache {
///
/// Always returns `usize::default()` for a non-initialized epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn epoch_committee_count(&self) -> usize {
self.committee_count
}
@ -226,7 +226,7 @@ impl CommitteeCache {
///
/// Returns `None` if `slot` is not in the initialized epoch, or if `Self` is not initialized.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_crosslink_committees_for_slot(&self, slot: Slot) -> Option<Vec<CrosslinkCommittee>> {
let position = self
.initialized_epoch?
@ -258,7 +258,7 @@ impl CommitteeCache {
///
/// Always returns `None` for a non-initialized epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn first_committee_at_slot(&self, slot: Slot) -> Option<&[usize]> {
self.get_crosslink_committees_for_slot(slot)?
.first()
@ -267,7 +267,7 @@ impl CommitteeCache {
/// Returns a slice of `self.shuffling` that represents the `index`'th committee in the epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn compute_committee(&self, index: usize) -> Option<&[usize]> {
Some(&self.shuffling[self.compute_committee_range(index)?])
}
@ -276,7 +276,7 @@ impl CommitteeCache {
///
/// To avoid a divide-by-zero, returns `None` if `self.committee_count` is zero.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn compute_committee_range(&self, index: usize) -> Option<Range<usize>> {
if self.committee_count == 0 {
return None;
@ -295,7 +295,7 @@ impl CommitteeCache {
///
/// Always returns `None` for a non-initialized epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn crosslink_slot_for_shard(&self, shard: u64) -> Option<Slot> {
let offset = (shard + self.shard_count - self.shuffling_start_shard) % self.shard_count;
Some(
@ -317,7 +317,7 @@ impl CommitteeCache {
/// Returns a list of all `validator_registry` indices where the validator is active at the given
/// `epoch`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_active_validator_indices(validators: &[Validator], epoch: Epoch) -> Vec<usize> {
let mut active = Vec::with_capacity(validators.len());
@ -335,7 +335,7 @@ pub fn get_active_validator_indices(validators: &[Validator], epoch: Epoch) -> V
/// Returns the count of all `validator_registry` indices where the validator is active at the given
/// `epoch`.
///
/// Spec v0.6.1
/// Spec v0.6.3
fn get_active_validator_count(validators: &[Validator], epoch: Epoch) -> usize {
validators.iter().filter(|v| v.is_active_at(epoch)).count()
}

View File

@ -5,7 +5,7 @@ use test_utils::{u8_from_hex_str, u8_to_hex_str};
/// Each of the BLS signature domains.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub enum Domain {
BeaconProposer,
Randao,
@ -17,7 +17,7 @@ pub enum Domain {
/// Holds all the "constants" for a BeaconChain.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct ChainSpec {
@ -115,7 +115,7 @@ pub struct ChainSpec {
impl ChainSpec {
/// Get the domain number that represents the fork meta and signature domain.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_domain(&self, epoch: Epoch, domain: Domain, fork: &Fork) -> u64 {
let domain_constant = match domain {
Domain::BeaconProposer => self.domain_beacon_proposer,
@ -137,7 +137,7 @@ impl ChainSpec {
/// Returns a `ChainSpec` compatible with the Ethereum Foundation specification.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn mainnet() -> Self {
Self {
/*

View File

@ -8,7 +8,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// Specifies the block hash for a shard at an epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
Clone,

View File

@ -9,7 +9,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// A deposit to potentially become a beacon chain validator.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,

View File

@ -10,7 +10,7 @@ use tree_hash_derive::{CachedTreeHash, SignedRoot, TreeHash};
/// The data supplied by the user to the deposit contract.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,
@ -35,7 +35,7 @@ pub struct DepositData {
impl DepositData {
/// Generate the signature for a given DepositData details.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn create_signature(
&self,
secret_key: &SecretKey,

View File

@ -8,7 +8,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// Contains data obtained from the Eth1 chain.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,

View File

@ -10,7 +10,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// Specifies a fork of the `BeaconChain`, to prevent replay attacks.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
Clone,
@ -35,7 +35,7 @@ pub struct Fork {
impl Fork {
/// Initialize the `Fork` from the genesis parameters in the `spec`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn genesis(genesis_epoch: Epoch) -> Self {
Self {
previous_version: [0; 4],
@ -46,7 +46,7 @@ impl Fork {
/// Return the fork version of the given ``epoch``.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn get_fork_version(&self, epoch: Epoch) -> [u8; 4] {
if epoch < self.epoch {
return self.previous_version;

View File

@ -9,7 +9,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// Historical block and state roots.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
Clone,

View File

@ -9,7 +9,7 @@ use tree_hash_derive::{CachedTreeHash, SignedRoot, TreeHash};
///
/// To be included in an `AttesterSlashing`.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,
@ -35,14 +35,14 @@ pub struct IndexedAttestation {
impl IndexedAttestation {
/// Check if ``attestation_data_1`` and ``attestation_data_2`` have the same target.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn is_double_vote(&self, other: &IndexedAttestation) -> bool {
self.data.target_epoch == other.data.target_epoch && self.data != other.data
}
/// Check if ``attestation_data_1`` surrounds ``attestation_data_2``.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn is_surround_vote(&self, other: &IndexedAttestation) -> bool {
self.data.source_epoch < other.data.source_epoch
&& other.data.target_epoch < self.data.target_epoch

View File

@ -8,7 +8,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// An attestation that has been included in the state but not yet fully processed.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
Clone,

View File

@ -8,7 +8,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// Two conflicting proposals from the same proposer (validator).
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,

View File

@ -9,7 +9,7 @@ pub enum Error {
/// Defines the epochs relative to some epoch. Most useful when referring to the committees prior
/// to and following some epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum RelativeEpoch {
/// The prior epoch.
@ -23,7 +23,7 @@ pub enum RelativeEpoch {
impl RelativeEpoch {
/// Returns the `epoch` that `self` refers to, with respect to the `base` epoch.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn into_epoch(self, base: Epoch) -> Epoch {
match self {
// Due to saturating nature of epoch, check for current first.
@ -40,7 +40,7 @@ impl RelativeEpoch {
/// - `EpochTooLow` when `other` is more than 1 prior to `base`.
/// - `EpochTooHigh` when `other` is more than 1 after `base`.
///
/// Spec v0.6.1
/// Spec v0.6.3
pub fn from_epoch(base: Epoch, other: Epoch) -> Result<Self, Error> {
// Due to saturating nature of epoch, check for current first.
if other == base {

View File

@ -11,7 +11,7 @@ use tree_hash_derive::{CachedTreeHash, SignedRoot, TreeHash};
/// The data submitted to the deposit contract.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
Clone,

View File

@ -7,7 +7,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// Information about a `BeaconChain` validator.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
Clone,

View File

@ -9,7 +9,7 @@ use tree_hash_derive::{CachedTreeHash, SignedRoot, TreeHash};
/// An exit voluntarily submitted a validator who wishes to withdraw.
///
/// Spec v0.6.1
/// Spec v0.6.3
#[derive(
Debug,
PartialEq,