mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
Finish genesis for BeaconChain
This commit is contained in:
@@ -4,6 +4,7 @@ use super::{
|
||||
SpecialRecord,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ActiveState {
|
||||
pub pending_attestations: Vec<AttestationRecord>,
|
||||
pub pending_specials: Vec<SpecialRecord>,
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
use super::ValidatorRegistration;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct ChainConfig {
|
||||
pub cycle_length: u8,
|
||||
pub shard_count: u16,
|
||||
pub min_committee_size: u64,
|
||||
pub genesis_time: u64,
|
||||
pub initial_validators: Vec<ValidatorRegistration>,
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -17,6 +21,7 @@ impl ChainConfig {
|
||||
shard_count: 1024,
|
||||
min_committee_size: 128,
|
||||
genesis_time: GENESIS_TIME, // arbitrary
|
||||
initial_validators: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +46,7 @@ impl ChainConfig {
|
||||
shard_count: 2,
|
||||
min_committee_size: 2,
|
||||
genesis_time: GENESIS_TIME, // arbitrary
|
||||
initial_validators: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::Hash256;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct CrosslinkRecord {
|
||||
pub recently_changed: bool,
|
||||
pub slot: u64,
|
||||
|
||||
@@ -4,6 +4,7 @@ use super::shard_and_committee::ShardAndCommittee;
|
||||
use super::Hash256;
|
||||
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct CrystallizedState {
|
||||
pub validator_set_change_slot: u64,
|
||||
pub validators: Vec<ValidatorRecord>,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct ShardAndCommittee {
|
||||
pub shard_id: u16,
|
||||
pub committee: Vec<usize>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use bls::{
|
||||
create_proof_of_possession,
|
||||
Keypair,
|
||||
PublicKey,
|
||||
Signature,
|
||||
@@ -18,3 +19,17 @@ pub struct ValidatorRegistration {
|
||||
pub randao_commitment: Hash256,
|
||||
pub proof_of_possession: Signature,
|
||||
}
|
||||
|
||||
impl ValidatorRegistration {
|
||||
pub fn random() -> Self {
|
||||
let keypair = Keypair::random();
|
||||
|
||||
Self {
|
||||
pubkey: keypair.pk.clone(),
|
||||
withdrawal_shard: 0,
|
||||
withdrawal_address: Address::random(),
|
||||
randao_commitment: Hash256::random(),
|
||||
proof_of_possession: create_proof_of_possession(&keypair),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user