Add Altair tests to op pool (#2723)

## Issue Addressed

NA

## Proposed Changes

Adds some more testing for Altair to the op pool. Credits to @michaelsproul for some appropriated efforts here.

## Additional Info

NA


Co-authored-by: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
Paul Hauner
2021-10-16 05:07:23 +00:00
parent cfafe7ba3a
commit a7b675460d
6 changed files with 100 additions and 74 deletions

View File

@@ -2761,7 +2761,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
state.latest_block_header().canonical_root()
};
let (proposer_slashings, attester_slashings) = self.op_pool.get_slashings(&state);
let (proposer_slashings, attester_slashings, voluntary_exits) =
self.op_pool.get_slashings_and_exits(&state, &self.spec);
let eth1_data = eth1_chain.eth1_data_for_block_production(&state, &self.spec)?;
let deposits = eth1_chain
@@ -2821,7 +2822,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let slot = state.slot();
let proposer_index = state.get_beacon_proposer_index(state.slot(), &self.spec)? as u64;
let voluntary_exits = self.op_pool.get_voluntary_exits(&state, &self.spec).into();
// Closure to fetch a sync aggregate in cases where it is required.
let get_sync_aggregate = || -> Result<SyncAggregate<_>, BlockProductionError> {
@@ -2853,7 +2853,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
attester_slashings: attester_slashings.into(),
attestations,
deposits,
voluntary_exits,
voluntary_exits: voluntary_exits.into(),
},
}),
BeaconState::Altair(_) => {
@@ -2871,7 +2871,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
attester_slashings: attester_slashings.into(),
attestations,
deposits,
voluntary_exits,
voluntary_exits: voluntary_exits.into(),
sync_aggregate,
},
})

View File

@@ -26,6 +26,7 @@ use slot_clock::TestingSlotClock;
use state_processing::state_advance::complete_state_advance;
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
use store::{config::StoreConfig, BlockReplay, HotColdDB, ItemStore, LevelDB, MemoryStore};
@@ -126,11 +127,8 @@ pub fn test_spec<E: EthSpec>() -> ChainSpec {
FORK_NAME_ENV_VAR, e
)
});
let fork = match fork_name.as_str() {
"base" => ForkName::Base,
"altair" => ForkName::Altair,
other => panic!("unknown FORK_NAME: {}", other),
};
let fork = ForkName::from_str(fork_name.as_str())
.unwrap_or_else(|()| panic!("unknown FORK_NAME: {}", fork_name));
fork.make_genesis_spec(E::default_spec())
} else {
E::default_spec()