mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 06:14:38 +00:00
Merge master and remove ssz length encoding from FakeBLS
This commit is contained in:
@@ -37,6 +37,19 @@ impl BeaconBlockHeader {
|
||||
pub fn canonical_root(&self) -> Hash256 {
|
||||
Hash256::from_slice(&self.hash_tree_root()[..])
|
||||
}
|
||||
|
||||
/// Given a `body`, consumes `self` and returns a complete `BeaconBlock`.
|
||||
///
|
||||
/// Spec v0.5.0
|
||||
pub fn into_block(self, body: BeaconBlockBody) -> BeaconBlock {
|
||||
BeaconBlock {
|
||||
slot: self.slot,
|
||||
previous_block_root: self.previous_block_root,
|
||||
state_root: self.state_root,
|
||||
body,
|
||||
signature: self.signature,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -120,7 +120,7 @@ pub struct ChainSpec {
|
||||
*
|
||||
*/
|
||||
pub boot_nodes: Vec<Multiaddr>,
|
||||
pub network_id: u8,
|
||||
pub chain_id: u8,
|
||||
}
|
||||
|
||||
impl ChainSpec {
|
||||
@@ -257,7 +257,7 @@ impl ChainSpec {
|
||||
* Boot nodes
|
||||
*/
|
||||
boot_nodes: vec![],
|
||||
network_id: 1, // foundation network id
|
||||
chain_id: 1, // foundation chain id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ impl ChainSpec {
|
||||
|
||||
Self {
|
||||
boot_nodes,
|
||||
network_id: 2, // lighthouse testnet network id
|
||||
chain_id: 2, // lighthouse testnet chain id
|
||||
..ChainSpec::few_validators()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,6 @@ pub type AttesterMap = HashMap<(u64, u64), Vec<usize>>;
|
||||
pub type ProposerMap = HashMap<u64, usize>;
|
||||
|
||||
pub use bls::{AggregatePublicKey, AggregateSignature, Keypair, PublicKey, SecretKey, Signature};
|
||||
pub use libp2p::floodsub::{Topic, TopicBuilder};
|
||||
pub use libp2p::floodsub::{Topic, TopicBuilder, TopicHash};
|
||||
pub use libp2p::multiaddr;
|
||||
pub use libp2p::Multiaddr;
|
||||
|
||||
@@ -5,13 +5,13 @@ macro_rules! ssz_tests {
|
||||
#[test]
|
||||
pub fn test_ssz_round_trip() {
|
||||
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
|
||||
use ssz::{decode, ssz_encode};
|
||||
use ssz::{ssz_encode, Decodable};
|
||||
|
||||
let mut rng = XorShiftRng::from_seed([42; 16]);
|
||||
let original = $type::random_for_test(&mut rng);
|
||||
|
||||
let bytes = ssz_encode(&original);
|
||||
let decoded: $type = decode(&bytes).unwrap();
|
||||
let (decoded, _): ($type, usize) = <_>::ssz_decode(&bytes, 0).unwrap();
|
||||
|
||||
assert_eq!(original, decoded);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ pub fn keypairs_path() -> PathBuf {
|
||||
/// Builds a beacon state to be used for testing purposes.
|
||||
///
|
||||
/// This struct should **never be used for production purposes.**
|
||||
#[derive(Clone)]
|
||||
pub struct TestingBeaconStateBuilder {
|
||||
state: BeaconState,
|
||||
keypairs: Vec<Keypair>,
|
||||
@@ -119,8 +120,10 @@ impl TestingBeaconStateBuilder {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let genesis_time = 1553753928; // arbitrary
|
||||
|
||||
let mut state = BeaconState::genesis(
|
||||
0,
|
||||
genesis_time,
|
||||
Eth1Data {
|
||||
deposit_root: Hash256::zero(),
|
||||
block_hash: Hash256::zero(),
|
||||
|
||||
Reference in New Issue
Block a user