mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-09 11:25:55 +00:00
Added/modified types and constants according to specs
This commit is contained in:
@@ -2,7 +2,6 @@ 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_committee::ShardCommittee;
|
||||
use super::validator_record::ValidatorRecord;
|
||||
use super::Hash256;
|
||||
use crate::test_utils::TestRandom;
|
||||
@@ -30,7 +29,12 @@ pub struct BeaconState {
|
||||
// Randomness and committees
|
||||
pub latest_randao_mixes: Vec<Hash256>,
|
||||
pub latest_vdf_outputs: Vec<Hash256>,
|
||||
pub shard_committees_at_slots: Vec<Vec<ShardCommittee>>,
|
||||
pub previous_epoch_start_shard: u64,
|
||||
pub current_epoch_start_shard: u64,
|
||||
pub previous_epoch_calculation_slot: u64,
|
||||
pub current_epoch_calculation_slot: u64,
|
||||
pub previous_epoch_randao_mix: Hash256,
|
||||
pub current_epoch_randao_mix: Hash256,
|
||||
|
||||
// Custody challenges
|
||||
pub custody_challenges: Vec<CustodyChallenge>,
|
||||
@@ -73,7 +77,12 @@ impl Encodable for BeaconState {
|
||||
s.append(&self.validator_registry_delta_chain_tip);
|
||||
s.append(&self.latest_randao_mixes);
|
||||
s.append(&self.latest_vdf_outputs);
|
||||
s.append(&self.shard_committees_at_slots);
|
||||
s.append(&self.previous_epoch_start_shard);
|
||||
s.append(&self.current_epoch_start_shard);
|
||||
s.append(&self.previous_epoch_calculation_slot);
|
||||
s.append(&self.current_epoch_calculation_slot);
|
||||
s.append(&self.previous_epoch_randao_mix);
|
||||
s.append(&self.current_epoch_randao_mix);
|
||||
s.append(&self.custody_challenges);
|
||||
s.append(&self.previous_justified_slot);
|
||||
s.append(&self.justified_slot);
|
||||
@@ -101,7 +110,12 @@ impl Decodable for BeaconState {
|
||||
let (validator_registry_delta_chain_tip, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_randao_mixes, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_vdf_outputs, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (shard_committees_at_slots, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (previous_epoch_start_shard, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (current_epoch_start_shard, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (previous_epoch_calculation_slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (current_epoch_calculation_slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (previous_epoch_randao_mix, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (current_epoch_randao_mix, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (custody_challenges, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (previous_justified_slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (justified_slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
@@ -127,7 +141,12 @@ impl Decodable for BeaconState {
|
||||
validator_registry_delta_chain_tip,
|
||||
latest_randao_mixes,
|
||||
latest_vdf_outputs,
|
||||
shard_committees_at_slots,
|
||||
previous_epoch_start_shard,
|
||||
current_epoch_start_shard,
|
||||
previous_epoch_calculation_slot,
|
||||
current_epoch_calculation_slot,
|
||||
previous_epoch_randao_mix,
|
||||
current_epoch_randao_mix,
|
||||
custody_challenges,
|
||||
previous_justified_slot,
|
||||
justified_slot,
|
||||
@@ -159,7 +178,12 @@ impl<T: RngCore> TestRandom<T> for BeaconState {
|
||||
validator_registry_delta_chain_tip: <_>::random_for_test(rng),
|
||||
latest_randao_mixes: <_>::random_for_test(rng),
|
||||
latest_vdf_outputs: <_>::random_for_test(rng),
|
||||
shard_committees_at_slots: <_>::random_for_test(rng),
|
||||
previous_epoch_start_shard: <_>::random_for_test(rng),
|
||||
current_epoch_start_shard: <_>::random_for_test(rng),
|
||||
previous_epoch_calculation_slot: <_>::random_for_test(rng),
|
||||
current_epoch_calculation_slot: <_>::random_for_test(rng),
|
||||
previous_epoch_randao_mix: <_>::random_for_test(rng),
|
||||
current_epoch_randao_mix: <_>::random_for_test(rng),
|
||||
custody_challenges: <_>::random_for_test(rng),
|
||||
previous_justified_slot: <_>::random_for_test(rng),
|
||||
justified_slot: <_>::random_for_test(rng),
|
||||
|
||||
@@ -3,6 +3,7 @@ use super::Hash256;
|
||||
use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
|
||||
// Note: this is refer to as DepositRootVote in specs
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct CandidatePoWReceiptRootRecord {
|
||||
pub candidate_pow_receipt_root: Hash256,
|
||||
|
||||
@@ -35,6 +35,10 @@ pub struct ValidatorRecord {
|
||||
pub withdrawal_credentials: Hash256,
|
||||
pub randao_commitment: Hash256,
|
||||
pub randao_layers: u64,
|
||||
pub activation_slot: u64,
|
||||
pub exit_slot: u64,
|
||||
pub withdrawal_slot: u64,
|
||||
pub penalized_slot: u64,
|
||||
pub status: ValidatorStatus,
|
||||
pub latest_status_change_slot: u64,
|
||||
pub exit_count: u64,
|
||||
@@ -99,6 +103,10 @@ impl Encodable for ValidatorRecord {
|
||||
s.append(&self.withdrawal_credentials);
|
||||
s.append(&self.randao_commitment);
|
||||
s.append(&self.randao_layers);
|
||||
s.append(&self.activation_slot);
|
||||
s.append(&self.exit_slot);
|
||||
s.append(&self.withdrawal_slot);
|
||||
s.append(&self.penalized_slot);
|
||||
s.append(&self.status);
|
||||
s.append(&self.latest_status_change_slot);
|
||||
s.append(&self.exit_count);
|
||||
@@ -114,6 +122,10 @@ impl Decodable for ValidatorRecord {
|
||||
let (withdrawal_credentials, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (randao_commitment, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (randao_layers, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (activation_slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (exit_slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (withdrawal_slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (penalized_slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (status, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_status_change_slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (exit_count, i) = <_>::ssz_decode(bytes, i)?;
|
||||
@@ -127,6 +139,10 @@ impl Decodable for ValidatorRecord {
|
||||
withdrawal_credentials,
|
||||
randao_commitment,
|
||||
randao_layers,
|
||||
activation_slot,
|
||||
exit_slot,
|
||||
withdrawal_slot,
|
||||
penalized_slot,
|
||||
status,
|
||||
latest_status_change_slot,
|
||||
exit_count,
|
||||
@@ -146,6 +162,10 @@ impl<T: RngCore> TestRandom<T> for ValidatorRecord {
|
||||
withdrawal_credentials: <_>::random_for_test(rng),
|
||||
randao_commitment: <_>::random_for_test(rng),
|
||||
randao_layers: <_>::random_for_test(rng),
|
||||
activation_slot: <_>::random_for_test(rng),
|
||||
exit_slot: <_>::random_for_test(rng),
|
||||
withdrawal_slot: <_>::random_for_test(rng),
|
||||
penalized_slot: <_>::random_for_test(rng),
|
||||
status: <_>::random_for_test(rng),
|
||||
latest_status_change_slot: <_>::random_for_test(rng),
|
||||
exit_count: <_>::random_for_test(rng),
|
||||
|
||||
Reference in New Issue
Block a user