Merge pull request #84 from sigp/state-update
Update `BeaconState` object Closes #83
This commit is contained in:
commit
25364c337e
13
beacon_chain/types/src/attestation_data.rs
Normal file
13
beacon_chain/types/src/attestation_data.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use super::Hash256;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct AttestationData {
|
||||||
|
pub slot: u64,
|
||||||
|
pub shard: u64,
|
||||||
|
pub beacon_block_hash: Hash256,
|
||||||
|
pub epoch_boundary_hash: Hash256,
|
||||||
|
pub shard_block_hash: Hash256,
|
||||||
|
pub latest_crosslink_hash: Hash256,
|
||||||
|
pub justified_slot: u64,
|
||||||
|
pub justified_block_hash: Hash256,
|
||||||
|
}
|
34
beacon_chain/types/src/beacon_state.rs
Normal file
34
beacon_chain/types/src/beacon_state.rs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
use super::candidate_pow_receipt_root_record::CandidatePoWReceiptRootRecord;
|
||||||
|
use super::crosslink_record::CrosslinkRecord;
|
||||||
|
use super::fork_data::ForkData;
|
||||||
|
use super::pending_attestation_record::PendingAttestationRecord;
|
||||||
|
use super::shard_and_committee::ShardAndCommittee;
|
||||||
|
use super::shard_reassignment_record::ShardReassignmentRecord;
|
||||||
|
use super::validator_record::ValidatorRecord;
|
||||||
|
use super::Hash256;
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct BeaconState {
|
||||||
|
validator_registry: Vec<ValidatorRecord>,
|
||||||
|
validator_registry_latest_change_slot: u64,
|
||||||
|
validator_registry_exit_count: u64,
|
||||||
|
validator_registry_delta_chain_tip: Hash256,
|
||||||
|
randao_mix: Hash256,
|
||||||
|
next_seed: Hash256,
|
||||||
|
shard_and_committee_for_slots: Vec<Vec<ShardAndCommittee>>,
|
||||||
|
persistent_committees: Vec<Vec<u32>>,
|
||||||
|
persistent_committee_reassignments: Vec<ShardReassignmentRecord>,
|
||||||
|
previous_justified_slot: u64,
|
||||||
|
justified_slot: u64,
|
||||||
|
justified_slot_bitfield: u64,
|
||||||
|
finalized_slot: u64,
|
||||||
|
latest_crosslinks: Vec<CrosslinkRecord>,
|
||||||
|
latest_state_recalculation_slot: u64,
|
||||||
|
latest_block_hashes: Vec<Hash256>,
|
||||||
|
latest_penalized_exit_balances: Vec<u64>,
|
||||||
|
latest_attestations: Vec<PendingAttestationRecord>,
|
||||||
|
processed_pow_receipt_root: Hash256,
|
||||||
|
candidate_pow_receipt_roots: Vec<CandidatePoWReceiptRootRecord>,
|
||||||
|
genesis_time: u64,
|
||||||
|
fork_data: ForkData,
|
||||||
|
}
|
6
beacon_chain/types/src/fork_data.rs
Normal file
6
beacon_chain/types/src/fork_data.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct ForkData {
|
||||||
|
pub pre_fork_version: u64,
|
||||||
|
pub post_fork_version: u64,
|
||||||
|
pub fork_slot: u64,
|
||||||
|
}
|
@ -4,16 +4,19 @@ extern crate ethereum_types;
|
|||||||
extern crate ssz;
|
extern crate ssz;
|
||||||
|
|
||||||
pub mod active_state;
|
pub mod active_state;
|
||||||
|
pub mod attestation_data;
|
||||||
pub mod attestation_record;
|
pub mod attestation_record;
|
||||||
pub mod beacon_block;
|
pub mod beacon_block;
|
||||||
|
pub mod beacon_state;
|
||||||
pub mod candidate_pow_receipt_root_record;
|
pub mod candidate_pow_receipt_root_record;
|
||||||
pub mod chain_config;
|
pub mod chain_config;
|
||||||
pub mod crosslink_record;
|
pub mod crosslink_record;
|
||||||
pub mod crystallized_state;
|
pub mod crystallized_state;
|
||||||
|
pub mod fork_data;
|
||||||
|
pub mod pending_attestation_record;
|
||||||
pub mod shard_and_committee;
|
pub mod shard_and_committee;
|
||||||
pub mod shard_reassignment_record;
|
pub mod shard_reassignment_record;
|
||||||
pub mod special_record;
|
pub mod special_record;
|
||||||
pub mod state;
|
|
||||||
pub mod validator_record;
|
pub mod validator_record;
|
||||||
pub mod validator_registration;
|
pub mod validator_registration;
|
||||||
|
|
||||||
@ -21,11 +24,15 @@ use self::ethereum_types::{H160, H256, U256};
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub use active_state::ActiveState;
|
pub use active_state::ActiveState;
|
||||||
|
pub use attestation_data::AttestationData;
|
||||||
pub use attestation_record::AttestationRecord;
|
pub use attestation_record::AttestationRecord;
|
||||||
pub use beacon_block::BeaconBlock;
|
pub use beacon_block::BeaconBlock;
|
||||||
|
pub use beacon_state::BeaconState;
|
||||||
pub use chain_config::ChainConfig;
|
pub use chain_config::ChainConfig;
|
||||||
pub use crosslink_record::CrosslinkRecord;
|
pub use crosslink_record::CrosslinkRecord;
|
||||||
pub use crystallized_state::CrystallizedState;
|
pub use crystallized_state::CrystallizedState;
|
||||||
|
pub use fork_data::ForkData;
|
||||||
|
pub use pending_attestation_record::PendingAttestationRecord;
|
||||||
pub use shard_and_committee::ShardAndCommittee;
|
pub use shard_and_committee::ShardAndCommittee;
|
||||||
pub use special_record::{SpecialRecord, SpecialRecordKind};
|
pub use special_record::{SpecialRecord, SpecialRecordKind};
|
||||||
pub use validator_record::{ValidatorRecord, ValidatorStatus};
|
pub use validator_record::{ValidatorRecord, ValidatorStatus};
|
||||||
|
9
beacon_chain/types/src/pending_attestation_record.rs
Normal file
9
beacon_chain/types/src/pending_attestation_record.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
use super::{AttestationData, Bitfield};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct PendingAttestationRecord {
|
||||||
|
pub data: AttestationData,
|
||||||
|
pub participation_bitfield: Bitfield,
|
||||||
|
pub custody_bitfield: Bitfield,
|
||||||
|
pub slot_included: u64,
|
||||||
|
}
|
@ -1,54 +0,0 @@
|
|||||||
use super::attestation_record::AttestationRecord;
|
|
||||||
use super::candidate_pow_receipt_root_record::CandidatePoWReceiptRootRecord;
|
|
||||||
use super::crosslink_record::CrosslinkRecord;
|
|
||||||
use super::shard_and_committee::ShardAndCommittee;
|
|
||||||
use super::shard_reassignment_record::ShardReassignmentRecord;
|
|
||||||
use super::validator_record::ValidatorRecord;
|
|
||||||
use super::Hash256;
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
|
||||||
pub struct BeaconState {
|
|
||||||
// Slot of last validator set change
|
|
||||||
validator_set_change_slot: u64,
|
|
||||||
// List of validators
|
|
||||||
validators: Vec<ValidatorRecord>,
|
|
||||||
// Most recent crosslink for each shard
|
|
||||||
crosslinks: Vec<CrosslinkRecord>,
|
|
||||||
// Last cycle-boundary state recalculation
|
|
||||||
last_state_recalculation_slot: u64,
|
|
||||||
// Last finalized slot
|
|
||||||
last_finalized_slot: u64,
|
|
||||||
// Last justified slot
|
|
||||||
last_justified_slot: u64,
|
|
||||||
// Number of consecutive justified slots
|
|
||||||
justified_streak: u64,
|
|
||||||
// Committee members and their assigned shard, per slot
|
|
||||||
shard_and_committee_for_slots: Vec<Vec<ShardAndCommittee>>,
|
|
||||||
// Persistent shard committees
|
|
||||||
persistent_committees: Vec<Vec<u32>>,
|
|
||||||
persistent_committee_reassignments: Vec<ShardReassignmentRecord>,
|
|
||||||
// Randao seed used for next shuffling
|
|
||||||
next_shuffling_seed: Hash256,
|
|
||||||
// Total deposits penalized in the given withdrawal period
|
|
||||||
deposits_penalized_in_period: Vec<u64>,
|
|
||||||
// Hash chain of validator set changes (for light clients to easily track deltas)
|
|
||||||
validator_set_delta_hash_chain: Hash256,
|
|
||||||
// Current sequence number for withdrawals
|
|
||||||
current_exit_seq: u64,
|
|
||||||
// Genesis time
|
|
||||||
genesis_time: u64,
|
|
||||||
// PoW receipt root
|
|
||||||
processed_pow_receipt_root: Hash256,
|
|
||||||
candidate_pow_receipt_roots: Vec<CandidatePoWReceiptRootRecord>,
|
|
||||||
// Parameters relevant to hard forks / versioning.
|
|
||||||
// Should be updated only by hard forks.
|
|
||||||
pre_fork_version: u64,
|
|
||||||
post_fork_version: u64,
|
|
||||||
fork_slot_number: u64,
|
|
||||||
// Attestations not yet processed
|
|
||||||
pending_attestations: Vec<AttestationRecord>,
|
|
||||||
// recent beacon block hashes needed to process attestations, older to newer
|
|
||||||
recent_block_hashes: Vec<Hash256>,
|
|
||||||
// RANDAO state
|
|
||||||
randao_mix: Hash256,
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user