mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-25 21:17:17 +00:00
Implement genesis signature
This commit is contained in:
parent
79093f6ad1
commit
d79d0182a6
@ -7,6 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
bls = { path = "../utils/bls" }
|
||||
spec = { path = "../spec" }
|
||||
ssz = { path = "../utils/ssz" }
|
||||
types = { path = "../types" }
|
||||
validator_induction = { path = "../validator_induction" }
|
||||
validator_shuffling = { path = "../validator_shuffling" }
|
||||
|
@ -1,5 +1,6 @@
|
||||
use bls::Signature;
|
||||
use bls::{Signature, BLS_AGG_SIG_BYTE_SIZE};
|
||||
use spec::ChainSpec;
|
||||
use ssz::{encode::encode_length, Decodable, LENGTH_BYTES};
|
||||
use types::{BeaconBlock, BeaconBlockBody};
|
||||
|
||||
/// Generate a genesis BeaconBlock.
|
||||
@ -10,7 +11,7 @@ pub fn genesis_beacon_block(spec: &ChainSpec) -> BeaconBlock {
|
||||
state_root: spec.zero_hash,
|
||||
randao_reveal: spec.zero_hash,
|
||||
candidate_pow_receipt_root: spec.zero_hash,
|
||||
signature: Signature::default(),
|
||||
signature: genesis_signature(),
|
||||
body: BeaconBlockBody {
|
||||
proposer_slashings: vec![],
|
||||
casper_slashings: vec![],
|
||||
@ -21,6 +22,16 @@ pub fn genesis_beacon_block(spec: &ChainSpec) -> BeaconBlock {
|
||||
}
|
||||
}
|
||||
|
||||
fn genesis_signature() -> Signature {
|
||||
let mut bytes = encode_length(BLS_AGG_SIG_BYTE_SIZE, LENGTH_BYTES);
|
||||
bytes.append(&mut vec![0; BLS_AGG_SIG_BYTE_SIZE]);
|
||||
let (signature, _) = match Signature::ssz_decode(&bytes, 0) {
|
||||
Ok(sig) => sig,
|
||||
Err(_) => unreachable!(),
|
||||
};
|
||||
signature
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
Loading…
Reference in New Issue
Block a user