Add incomplete per-block processing benchmarks

Still needs to fill block with operations
This commit is contained in:
Paul Hauner
2019-03-09 14:11:49 +11:00
parent ca5d9658ce
commit 73ebb4bc2e
9 changed files with 583 additions and 223 deletions

View File

@@ -1,9 +1,9 @@
use crate::test_utils::TestRandom;
use crate::{BeaconBlockBody, ChainSpec, Eth1Data, Hash256, Slot};
use crate::{BeaconBlockBody, ChainSpec, Eth1Data, Hash256, Proposal, Slot};
use bls::Signature;
use rand::RngCore;
use serde_derive::Serialize;
use ssz::TreeHash;
use ssz::{SignedRoot, TreeHash};
use ssz_derive::{Decode, Encode, SignedRoot, TreeHash};
use test_random_derive::TestRandom;
@@ -33,7 +33,6 @@ impl BeaconBlock {
deposit_root: spec.zero_hash,
block_hash: spec.zero_hash,
},
signature: spec.empty_signature.clone(),
body: BeaconBlockBody {
proposer_slashings: vec![],
attester_slashings: vec![],
@@ -42,6 +41,7 @@ impl BeaconBlock {
voluntary_exits: vec![],
transfers: vec![],
},
signature: spec.empty_signature.clone(),
}
}
@@ -49,6 +49,16 @@ impl BeaconBlock {
pub fn canonical_root(&self) -> Hash256 {
Hash256::from_slice(&self.hash_tree_root()[..])
}
/// Returns an unsigned proposal for block.
pub fn proposal(&self, spec: &ChainSpec) -> Proposal {
Proposal {
slot: self.slot,
shard: spec.beacon_chain_shard_number,
block_root: Hash256::from_slice(&self.signed_root()),
signature: spec.empty_signature.clone(),
}
}
}
#[cfg(test)]