mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 18:21:45 +00:00
Unify EthSpecs in Mainnet and Minimal
This commit is contained in:
@@ -17,7 +17,7 @@ pub const SMALL_BENCHING_SAMPLE_SIZE: usize = 10;
|
||||
|
||||
/// Run the benchmarking suite on a foundation spec with 16,384 validators.
|
||||
pub fn bench_epoch_processing_n_validators(c: &mut Criterion, validator_count: usize) {
|
||||
let spec = ChainSpec::foundation();
|
||||
let spec = ChainSpec::mainnet();
|
||||
|
||||
let mut builder =
|
||||
TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(validator_count, &spec);
|
||||
|
||||
@@ -25,7 +25,7 @@ pub fn block_processing_worst_case(c: &mut Criterion) {
|
||||
);
|
||||
|
||||
// Use the specifications from the Eth2.0 spec.
|
||||
let spec = ChainSpec::foundation();
|
||||
let spec = ChainSpec::mainnet();
|
||||
|
||||
// Create a builder for configuring the block and state for benching.
|
||||
let mut bench_builder = BlockBenchingBuilder::new(VALIDATOR_COUNT, &spec);
|
||||
@@ -59,7 +59,7 @@ pub fn block_processing_reasonable_case(c: &mut Criterion) {
|
||||
);
|
||||
|
||||
// Use the specifications from the Eth2.0 spec.
|
||||
let spec = ChainSpec::foundation();
|
||||
let spec = ChainSpec::mainnet();
|
||||
|
||||
// Create a builder for configuring the block and state for benching.
|
||||
let mut bench_builder = BlockBenchingBuilder::new(VALIDATOR_COUNT, &spec);
|
||||
|
||||
@@ -9,7 +9,7 @@ pub const VALIDATOR_COUNT: usize = 10;
|
||||
|
||||
#[test]
|
||||
fn valid_block_ok() {
|
||||
let spec = FoundationEthSpec::default_spec();
|
||||
let spec = MainnetEthSpec::default_spec();
|
||||
let builder = get_builder(&spec);
|
||||
let (block, mut state) = builder.build(None, None, &spec);
|
||||
|
||||
@@ -20,7 +20,7 @@ fn valid_block_ok() {
|
||||
|
||||
#[test]
|
||||
fn invalid_block_header_state_slot() {
|
||||
let spec = FoundationEthSpec::default_spec();
|
||||
let spec = MainnetEthSpec::default_spec();
|
||||
let builder = get_builder(&spec);
|
||||
let (mut block, mut state) = builder.build(None, None, &spec);
|
||||
|
||||
@@ -39,7 +39,7 @@ fn invalid_block_header_state_slot() {
|
||||
|
||||
#[test]
|
||||
fn invalid_parent_block_root() {
|
||||
let spec = FoundationEthSpec::default_spec();
|
||||
let spec = MainnetEthSpec::default_spec();
|
||||
let builder = get_builder(&spec);
|
||||
let invalid_parent_root = Hash256::from([0xAA; 32]);
|
||||
let (block, mut state) = builder.build(None, Some(invalid_parent_root), &spec);
|
||||
@@ -59,14 +59,14 @@ fn invalid_parent_block_root() {
|
||||
|
||||
#[test]
|
||||
fn invalid_block_signature() {
|
||||
let spec = FoundationEthSpec::default_spec();
|
||||
let spec = MainnetEthSpec::default_spec();
|
||||
let builder = get_builder(&spec);
|
||||
let (mut block, mut state) = builder.build(None, None, &spec);
|
||||
|
||||
// sign the block with a keypair that is not the expected proposer
|
||||
let keypair = Keypair::random();
|
||||
let message = block.signed_root();
|
||||
let epoch = block.slot.epoch(FoundationEthSpec::slots_per_epoch());
|
||||
let epoch = block.slot.epoch(MainnetEthSpec::slots_per_epoch());
|
||||
let domain = spec.get_domain(epoch, Domain::BeaconProposer, &state.fork);
|
||||
block.signature = Signature::new(&message, domain, &keypair.sk);
|
||||
|
||||
@@ -82,7 +82,7 @@ fn invalid_block_signature() {
|
||||
|
||||
#[test]
|
||||
fn invalid_randao_reveal_signature() {
|
||||
let spec = FoundationEthSpec::default_spec();
|
||||
let spec = MainnetEthSpec::default_spec();
|
||||
let builder = get_builder(&spec);
|
||||
|
||||
// sign randao reveal with random keypair
|
||||
@@ -100,12 +100,12 @@ fn invalid_randao_reveal_signature() {
|
||||
);
|
||||
}
|
||||
|
||||
fn get_builder(spec: &ChainSpec) -> (BlockProcessingBuilder<FoundationEthSpec>) {
|
||||
fn get_builder(spec: &ChainSpec) -> (BlockProcessingBuilder<MainnetEthSpec>) {
|
||||
let mut builder = BlockProcessingBuilder::new(VALIDATOR_COUNT, &spec);
|
||||
|
||||
// Set the state and block to be in the last slot of the 4th epoch.
|
||||
let last_slot_of_epoch =
|
||||
(FoundationEthSpec::genesis_epoch() + 4).end_slot(FoundationEthSpec::slots_per_epoch());
|
||||
(MainnetEthSpec::genesis_epoch() + 4).end_slot(MainnetEthSpec::slots_per_epoch());
|
||||
builder.set_slot(last_slot_of_epoch, &spec);
|
||||
builder.build_caches(&spec);
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ use types::*;
|
||||
fn runs_without_error() {
|
||||
Builder::from_env(Env::default().default_filter_or("error")).init();
|
||||
|
||||
let spec = FewValidatorsEthSpec::default_spec();
|
||||
let spec = MinimalEthSpec::default_spec();
|
||||
|
||||
let mut builder: TestingBeaconStateBuilder<FewValidatorsEthSpec> =
|
||||
let mut builder: TestingBeaconStateBuilder<MinimalEthSpec> =
|
||||
TestingBeaconStateBuilder::from_deterministic_keypairs(8, &spec);
|
||||
|
||||
let target_slot = (FewValidatorsEthSpec::genesis_epoch() + 4)
|
||||
.end_slot(FewValidatorsEthSpec::slots_per_epoch());
|
||||
let target_slot =
|
||||
(MinimalEthSpec::genesis_epoch() + 4).end_slot(MinimalEthSpec::slots_per_epoch());
|
||||
builder.teleport_to_slot(target_slot, &spec);
|
||||
|
||||
let (mut state, _keypairs) = builder.build();
|
||||
|
||||
Reference in New Issue
Block a user