Rename BeaconStateTypes to EthSpec

This commit is contained in:
Paul Hauner 2019-05-10 14:47:09 +10:00
parent 75b310a078
commit ce8ebeccbc
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
60 changed files with 223 additions and 235 deletions

View File

@ -83,7 +83,7 @@ impl BlockProcessingOutcome {
}
}
pub struct BeaconChain<T: ClientDB + Sized, U: SlotClock, F: ForkChoice, B: BeaconStateTypes> {
pub struct BeaconChain<T: ClientDB + Sized, U: SlotClock, F: ForkChoice, B: EthSpec> {
pub block_store: Arc<BeaconBlockStore<T>>,
pub state_store: Arc<BeaconStateStore<T>>,
pub slot_clock: U,
@ -100,7 +100,7 @@ where
T: ClientDB,
U: SlotClock,
F: ForkChoice,
B: BeaconStateTypes,
B: EthSpec,
{
/// Instantiate a new Beacon Chain, from genesis.
pub fn from_genesis(

View File

@ -1,17 +1,17 @@
use serde_derive::Serialize;
use types::{BeaconBlock, BeaconState, BeaconStateTypes, Hash256};
use types::{BeaconBlock, BeaconState, EthSpec, Hash256};
/// Represents some block and it's associated state. Generally, this will be used for tracking the
/// head, justified head and finalized head.
#[derive(Clone, Serialize, PartialEq, Debug)]
pub struct CheckPoint<B: BeaconStateTypes> {
pub struct CheckPoint<B: EthSpec> {
pub beacon_block: BeaconBlock,
pub beacon_block_root: Hash256,
pub beacon_state: BeaconState<B>,
pub beacon_state_root: Hash256,
}
impl<B: BeaconStateTypes> CheckPoint<B> {
impl<B: EthSpec> CheckPoint<B> {
/// Create a new checkpoint.
pub fn new(
beacon_block: BeaconBlock,

View File

@ -11,7 +11,7 @@ use std::path::PathBuf;
use std::sync::Arc;
use tree_hash::TreeHash;
use types::test_utils::TestingBeaconStateBuilder;
use types::{BeaconBlock, ChainSpec, FewValidatorsStateTypes, FoundationStateTypes, Hash256};
use types::{BeaconBlock, ChainSpec, FewValidatorsEthSpec, FoundationEthSpec, Hash256};
//TODO: Correct this for prod
//TODO: Account for historical db
@ -22,8 +22,8 @@ pub fn initialise_beacon_chain(
BeaconChain<
DiskDB,
SystemTimeSlotClock,
BitwiseLMDGhost<DiskDB, FoundationStateTypes>,
FoundationStateTypes,
BitwiseLMDGhost<DiskDB, FoundationEthSpec>,
FoundationEthSpec,
>,
> {
// set up the db
@ -75,8 +75,8 @@ pub fn initialise_test_beacon_chain(
BeaconChain<
MemoryDB,
SystemTimeSlotClock,
BitwiseLMDGhost<MemoryDB, FewValidatorsStateTypes>,
FewValidatorsStateTypes,
BitwiseLMDGhost<MemoryDB, FewValidatorsEthSpec>,
FewValidatorsEthSpec,
>,
> {
let db = Arc::new(MemoryDB::open());

View File

@ -8,16 +8,16 @@ use slot_clock::TestingSlotClock;
use std::sync::Arc;
use tree_hash::TreeHash;
use types::*;
use types::{test_utils::TestingBeaconStateBuilder, BeaconStateTypes, FewValidatorsStateTypes};
use types::{test_utils::TestingBeaconStateBuilder, EthSpec, FewValidatorsEthSpec};
type TestingBeaconChain<B> =
BeaconChain<MemoryDB, TestingSlotClock, BitwiseLMDGhost<MemoryDB, FewValidatorsStateTypes>, B>;
BeaconChain<MemoryDB, TestingSlotClock, BitwiseLMDGhost<MemoryDB, FewValidatorsEthSpec>, B>;
pub struct TestingBeaconChainBuilder<B: BeaconStateTypes> {
pub struct TestingBeaconChainBuilder<B: EthSpec> {
state_builder: TestingBeaconStateBuilder<B>,
}
impl<B: BeaconStateTypes> TestingBeaconChainBuilder<B> {
impl<B: EthSpec> TestingBeaconChainBuilder<B> {
pub fn build(self, spec: &ChainSpec) -> TestingBeaconChain<B> {
let db = Arc::new(MemoryDB::open());
let block_store = Arc::new(BeaconBlockStore::new(db.clone()));
@ -44,7 +44,7 @@ impl<B: BeaconStateTypes> TestingBeaconChainBuilder<B> {
}
}
impl<B: BeaconStateTypes> From<TestingBeaconStateBuilder<B>> for TestingBeaconChainBuilder<B> {
impl<B: EthSpec> From<TestingBeaconStateBuilder<B>> for TestingBeaconChainBuilder<B> {
fn from(state_builder: TestingBeaconStateBuilder<B>) -> TestingBeaconChainBuilder<B> {
TestingBeaconChainBuilder { state_builder }
}

View File

@ -10,7 +10,7 @@ use std::path::PathBuf;
use types::multiaddr::Protocol;
use types::multiaddr::ToMultiaddr;
use types::Multiaddr;
use types::{BeaconStateTypes, ChainSpec, LighthouseTestnetStateTypes};
use types::{ChainSpec, EthSpec, LighthouseTestnetEthSpec};
/// Stores the client configuration for this Lighthouse instance.
#[derive(Debug, Clone)]
@ -35,7 +35,7 @@ impl Default for ClientConfig {
fs::create_dir_all(&data_dir)
.unwrap_or_else(|_| panic!("Unable to create {:?}", &data_dir));
let default_spec = LighthouseTestnetStateTypes::spec();
let default_spec = LighthouseTestnetEthSpec::spec();
let default_net_conf = NetworkConfig::new(default_spec.boot_nodes.clone());
Self {

View File

@ -6,17 +6,17 @@ use beacon_chain::{
slot_clock::{SlotClock, SystemTimeSlotClock},
};
use fork_choice::ForkChoice;
use types::{BeaconStateTypes, FewValidatorsStateTypes, FoundationStateTypes};
use types::{EthSpec, FewValidatorsEthSpec, FoundationEthSpec};
pub trait ClientTypes {
type DB: ClientDB + 'static;
type SlotClock: SlotClock + 'static;
type ForkChoice: ForkChoice + 'static;
type BeaconStateTypes: BeaconStateTypes + 'static;
type EthSpec: EthSpec + 'static;
fn initialise_beacon_chain(
config: &ClientConfig,
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes>;
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::EthSpec>;
}
pub struct StandardClientType;
@ -24,12 +24,12 @@ pub struct StandardClientType;
impl ClientTypes for StandardClientType {
type DB = DiskDB;
type SlotClock = SystemTimeSlotClock;
type ForkChoice = BitwiseLMDGhost<DiskDB, Self::BeaconStateTypes>;
type BeaconStateTypes = FoundationStateTypes;
type ForkChoice = BitwiseLMDGhost<DiskDB, Self::EthSpec>;
type EthSpec = FoundationEthSpec;
fn initialise_beacon_chain(
config: &ClientConfig,
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes> {
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::EthSpec> {
initialise::initialise_beacon_chain(&config.spec, Some(&config.db_name))
}
}
@ -39,12 +39,12 @@ pub struct TestingClientType;
impl ClientTypes for TestingClientType {
type DB = MemoryDB;
type SlotClock = SystemTimeSlotClock;
type ForkChoice = BitwiseLMDGhost<MemoryDB, Self::BeaconStateTypes>;
type BeaconStateTypes = FewValidatorsStateTypes;
type ForkChoice = BitwiseLMDGhost<MemoryDB, Self::EthSpec>;
type EthSpec = FewValidatorsEthSpec;
fn initialise_beacon_chain(
config: &ClientConfig,
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes> {
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::EthSpec> {
initialise::initialise_test_beacon_chain(&config.spec, None)
}
}

View File

@ -20,7 +20,7 @@ use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::runtime::TaskExecutor;
use tokio::timer::Interval;
use types::BeaconStateTypes;
use types::EthSpec;
type ArcBeaconChain<D, S, F, B> = Arc<BeaconChain<D, S, F, B>>;
@ -30,9 +30,9 @@ pub struct Client<T: ClientTypes> {
/// Configuration for the lighthouse client.
_config: ClientConfig,
/// The beacon chain for the running client.
_beacon_chain: ArcBeaconChain<T::DB, T::SlotClock, T::ForkChoice, T::BeaconStateTypes>,
_beacon_chain: ArcBeaconChain<T::DB, T::SlotClock, T::ForkChoice, T::EthSpec>,
/// Reference to the network service.
pub network: Arc<NetworkService<T::BeaconStateTypes>>,
pub network: Arc<NetworkService<T::EthSpec>>,
/// Signal to terminate the RPC server.
pub rpc_exit_signal: Option<Signal>,
/// Signal to terminate the slot timer.
@ -149,7 +149,7 @@ where
T: ClientDB,
U: SlotClock,
F: ForkChoice,
B: BeaconStateTypes,
B: EthSpec,
{
if let Some(genesis_height) = chain.slots_since_genesis() {
let result = chain.catchup_state();

View File

@ -2,7 +2,7 @@ use super::STATES_DB_COLUMN as DB_COLUMN;
use super::{ClientDB, DBError};
use ssz::decode;
use std::sync::Arc;
use types::{BeaconState, BeaconStateTypes, Hash256};
use types::{BeaconState, EthSpec, Hash256};
pub struct BeaconStateStore<T>
where
@ -19,7 +19,7 @@ impl<T: ClientDB> BeaconStateStore<T> {
Self { db }
}
pub fn get_deserialized<B: BeaconStateTypes>(
pub fn get_deserialized<B: EthSpec>(
&self,
hash: &Hash256,
) -> Result<Option<BeaconState<B>>, DBError> {

View File

@ -236,7 +236,7 @@ mod test {
#[test]
fn ssz_encoding() {
let original = PubsubMessage::Block(BeaconBlock::empty(&FoundationStateTypes::spec()));
let original = PubsubMessage::Block(BeaconBlock::empty(&FoundationEthSpec::spec()));
let encoded = ssz_encode(&original);

View File

@ -9,14 +9,13 @@ use beacon_chain::{
};
use eth2_libp2p::rpc::HelloMessage;
use types::{
Attestation, BeaconBlock, BeaconBlockBody, BeaconBlockHeader, BeaconStateTypes, Epoch, Hash256,
Slot,
Attestation, BeaconBlock, BeaconBlockBody, BeaconBlockHeader, Epoch, EthSpec, Hash256, Slot,
};
pub use beacon_chain::{BeaconChainError, BlockProcessingOutcome, InvalidBlock};
/// The network's API to the beacon chain.
pub trait BeaconChain<B: BeaconStateTypes>: Send + Sync {
pub trait BeaconChain<B: EthSpec>: Send + Sync {
fn get_spec(&self) -> &ChainSpec;
fn get_state(&self) -> RwLockReadGuard<BeaconState<B>>;
@ -70,7 +69,7 @@ where
T: ClientDB + Sized,
U: SlotClock,
F: ForkChoice,
B: BeaconStateTypes,
B: EthSpec,
{
fn get_spec(&self) -> &ChainSpec {
&self.spec

View File

@ -13,7 +13,7 @@ use slog::{debug, warn};
use std::collections::HashMap;
use std::sync::Arc;
use std::time::Instant;
use types::BeaconStateTypes;
use types::EthSpec;
/// Timeout for RPC requests.
// const REQUEST_TIMEOUT: Duration = Duration::from_secs(30);
@ -21,7 +21,7 @@ use types::BeaconStateTypes;
// const HELLO_TIMEOUT: Duration = Duration::from_secs(30);
/// Handles messages received from the network and client and organises syncing.
pub struct MessageHandler<B: BeaconStateTypes> {
pub struct MessageHandler<B: EthSpec> {
/// Currently loaded and initialised beacon chain.
_chain: Arc<BeaconChain<B>>,
/// The syncing framework.
@ -45,7 +45,7 @@ pub enum HandlerMessage {
PubsubMessage(PeerId, Box<PubsubMessage>),
}
impl<B: BeaconStateTypes> MessageHandler<B> {
impl<B: EthSpec> MessageHandler<B> {
/// Initializes and runs the MessageHandler.
pub fn spawn(
beacon_chain: Arc<BeaconChain<B>>,

View File

@ -13,10 +13,10 @@ use slog::{debug, info, o, trace};
use std::marker::PhantomData;
use std::sync::Arc;
use tokio::runtime::TaskExecutor;
use types::{BeaconStateTypes, Topic};
use types::{EthSpec, Topic};
/// Service that handles communication between internal services and the eth2_libp2p network service.
pub struct Service<B: BeaconStateTypes> {
pub struct Service<B: EthSpec> {
//libp2p_service: Arc<Mutex<LibP2PService>>,
_libp2p_exit: oneshot::Sender<()>,
network_send: crossbeam_channel::Sender<NetworkMessage>,
@ -24,7 +24,7 @@ pub struct Service<B: BeaconStateTypes> {
//message_handler_send: Sender<HandlerMessage>
}
impl<B: BeaconStateTypes> Service<B> {
impl<B: EthSpec> Service<B> {
pub fn new(
beacon_chain: Arc<BeaconChain<B>>,
config: &NetworkConfig,

View File

@ -5,7 +5,7 @@ use slog::{debug, error};
use std::sync::Arc;
use std::time::{Duration, Instant};
use tree_hash::TreeHash;
use types::{BeaconBlock, BeaconBlockBody, BeaconBlockHeader, BeaconStateTypes, Hash256, Slot};
use types::{BeaconBlock, BeaconBlockBody, BeaconBlockHeader, EthSpec, Hash256, Slot};
/// Provides a queue for fully and partially built `BeaconBlock`s.
///
@ -19,7 +19,7 @@ use types::{BeaconBlock, BeaconBlockBody, BeaconBlockHeader, BeaconStateTypes, H
/// `BeaconBlockBody` as the key.
/// - It is possible for multiple distinct blocks to have identical `BeaconBlockBodies`. Therefore
/// we cannot use a `HashMap` keyed by the root of `BeaconBlockBody`.
pub struct ImportQueue<B: BeaconStateTypes> {
pub struct ImportQueue<B: EthSpec> {
pub chain: Arc<BeaconChain<B>>,
/// Partially imported blocks, keyed by the root of `BeaconBlockBody`.
pub partials: Vec<PartialBeaconBlock>,
@ -29,7 +29,7 @@ pub struct ImportQueue<B: BeaconStateTypes> {
log: slog::Logger,
}
impl<B: BeaconStateTypes> ImportQueue<B> {
impl<B: EthSpec> ImportQueue<B> {
/// Return a new, empty queue.
pub fn new(chain: Arc<BeaconChain<B>>, stale_time: Duration, log: slog::Logger) -> Self {
Self {

View File

@ -9,7 +9,7 @@ use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;
use tree_hash::TreeHash;
use types::{Attestation, BeaconBlock, BeaconStateTypes, Epoch, Hash256, Slot};
use types::{Attestation, BeaconBlock, Epoch, EthSpec, Hash256, Slot};
/// The number of slots that we can import blocks ahead of us, before going into full Sync mode.
const SLOT_IMPORT_TOLERANCE: u64 = 100;
@ -88,7 +88,7 @@ impl From<HelloMessage> for PeerSyncInfo {
}
}
impl<B: BeaconStateTypes> From<&Arc<BeaconChain<B>>> for PeerSyncInfo {
impl<B: EthSpec> From<&Arc<BeaconChain<B>>> for PeerSyncInfo {
fn from(chain: &Arc<BeaconChain<B>>) -> PeerSyncInfo {
Self::from(chain.hello_message())
}
@ -103,7 +103,7 @@ pub enum SyncState {
}
/// Simple Syncing protocol.
pub struct SimpleSync<B: BeaconStateTypes> {
pub struct SimpleSync<B: EthSpec> {
/// A reference to the underlying beacon chain.
chain: Arc<BeaconChain<B>>,
/// A mapping of Peers to their respective PeerSyncInfo.
@ -116,7 +116,7 @@ pub struct SimpleSync<B: BeaconStateTypes> {
log: slog::Logger,
}
impl<B: BeaconStateTypes> SimpleSync<B> {
impl<B: EthSpec> SimpleSync<B> {
/// Instantiate a `SimpleSync` instance, with no peers and an empty queue.
pub fn new(beacon_chain: Arc<BeaconChain<B>>, log: &slog::Logger) -> Self {
let sync_logger = log.new(o!("Service"=> "Sync"));

View File

@ -9,15 +9,15 @@ use protos::services_grpc::AttestationService;
use slog::{error, info, trace, warn};
use ssz::{ssz_encode, Decodable};
use std::sync::Arc;
use types::{Attestation, BeaconStateTypes};
use types::{Attestation, EthSpec};
#[derive(Clone)]
pub struct AttestationServiceInstance<B: BeaconStateTypes> {
pub struct AttestationServiceInstance<B: EthSpec> {
pub chain: Arc<BeaconChain<B>>,
pub log: slog::Logger,
}
impl<B: BeaconStateTypes> AttestationService for AttestationServiceInstance<B> {
impl<B: EthSpec> AttestationService for AttestationServiceInstance<B> {
/// Produce the `AttestationData` for signing by a validator.
fn produce_attestation_data(
&mut self,

View File

@ -13,16 +13,16 @@ use slog::Logger;
use slog::{error, info, trace, warn};
use ssz::{ssz_encode, Decodable};
use std::sync::Arc;
use types::{BeaconBlock, BeaconStateTypes, Signature, Slot};
use types::{BeaconBlock, EthSpec, Signature, Slot};
#[derive(Clone)]
pub struct BeaconBlockServiceInstance<B: BeaconStateTypes> {
pub struct BeaconBlockServiceInstance<B: EthSpec> {
pub chain: Arc<BeaconChain<B>>,
pub network_chan: crossbeam_channel::Sender<NetworkMessage>,
pub log: Logger,
}
impl<B: BeaconStateTypes> BeaconBlockService for BeaconBlockServiceInstance<B> {
impl<B: EthSpec> BeaconBlockService for BeaconBlockServiceInstance<B> {
/// Produce a `BeaconBlock` for signing by a validator.
fn produce_beacon_block(
&mut self,

View File

@ -8,10 +8,10 @@ use beacon_chain::{
AttestationValidationError, BlockProductionError,
};
pub use beacon_chain::{BeaconChainError, BlockProcessingOutcome};
use types::{Attestation, AttestationData, BeaconBlock, BeaconStateTypes};
use types::{Attestation, AttestationData, BeaconBlock, EthSpec};
/// The RPC's API to the beacon chain.
pub trait BeaconChain<B: BeaconStateTypes>: Send + Sync {
pub trait BeaconChain<B: EthSpec>: Send + Sync {
fn get_spec(&self) -> &ChainSpec;
fn get_state(&self) -> RwLockReadGuard<BeaconState<B>>;
@ -39,7 +39,7 @@ where
T: ClientDB + Sized,
U: SlotClock,
F: ForkChoice,
B: BeaconStateTypes,
B: EthSpec,
{
fn get_spec(&self) -> &ChainSpec {
&self.spec

View File

@ -5,15 +5,15 @@ use protos::services::{Empty, Fork, NodeInfoResponse};
use protos::services_grpc::BeaconNodeService;
use slog::{trace, warn};
use std::sync::Arc;
use types::BeaconStateTypes;
use types::EthSpec;
#[derive(Clone)]
pub struct BeaconNodeServiceInstance<B: BeaconStateTypes> {
pub struct BeaconNodeServiceInstance<B: EthSpec> {
pub chain: Arc<BeaconChain<B>>,
pub log: slog::Logger,
}
impl<B: BeaconStateTypes> BeaconNodeService for BeaconNodeServiceInstance<B> {
impl<B: EthSpec> BeaconNodeService for BeaconNodeServiceInstance<B> {
/// Provides basic node information.
fn info(&mut self, ctx: RpcContext, _req: Empty, sink: UnarySink<NodeInfoResponse>) {
trace!(self.log, "Node info requested via RPC");

View File

@ -21,9 +21,9 @@ use protos::services_grpc::{
use slog::{info, o, warn};
use std::sync::Arc;
use tokio::runtime::TaskExecutor;
use types::BeaconStateTypes;
use types::EthSpec;
pub fn start_server<B: BeaconStateTypes>(
pub fn start_server<B: EthSpec>(
config: &RPCConfig,
executor: &TaskExecutor,
network_chan: crossbeam_channel::Sender<NetworkMessage>,

View File

@ -7,16 +7,16 @@ use protos::services_grpc::ValidatorService;
use slog::{trace, warn};
use ssz::decode;
use std::sync::Arc;
use types::{BeaconStateTypes, Epoch, RelativeEpoch};
use types::{Epoch, EthSpec, RelativeEpoch};
#[derive(Clone)]
pub struct ValidatorServiceInstance<B: BeaconStateTypes> {
pub struct ValidatorServiceInstance<B: EthSpec> {
pub chain: Arc<BeaconChain<B>>,
pub log: slog::Logger,
}
//TODO: Refactor Errors
impl<B: BeaconStateTypes> ValidatorService for ValidatorServiceInstance<B> {
impl<B: EthSpec> ValidatorService for ValidatorServiceInstance<B> {
/// For a list of validator public keys, this function returns the slot at which each
/// validator must propose a block, attest to a shard, their shard committee and the shard they
/// need to attest to.

View File

@ -11,7 +11,7 @@ use log::{debug, trace};
use std::collections::HashMap;
use std::marker::PhantomData;
use std::sync::Arc;
use types::{BeaconBlock, BeaconState, BeaconStateTypes, ChainSpec, Hash256, Slot, SlotHeight};
use types::{BeaconBlock, BeaconState, ChainSpec, EthSpec, Hash256, Slot, SlotHeight};
//TODO: Pruning - Children
//TODO: Handle Syncing
@ -54,7 +54,7 @@ pub struct BitwiseLMDGhost<T: ClientDB + Sized, B> {
_phantom: PhantomData<B>,
}
impl<T, B: BeaconStateTypes> BitwiseLMDGhost<T, B>
impl<T, B: EthSpec> BitwiseLMDGhost<T, B>
where
T: ClientDB + Sized,
{
@ -243,7 +243,7 @@ where
}
}
impl<T: ClientDB + Sized, B: BeaconStateTypes> ForkChoice for BitwiseLMDGhost<T, B> {
impl<T: ClientDB + Sized, B: EthSpec> ForkChoice for BitwiseLMDGhost<T, B> {
fn add_block(
&mut self,
block: &BeaconBlock,

View File

@ -11,7 +11,7 @@ use std::cmp::Ordering;
use std::collections::HashMap;
use std::marker::PhantomData;
use std::sync::Arc;
use types::{BeaconBlock, BeaconState, BeaconStateTypes, ChainSpec, Hash256, Slot, SlotHeight};
use types::{BeaconBlock, BeaconState, ChainSpec, EthSpec, Hash256, Slot, SlotHeight};
//TODO: Pruning - Children
//TODO: Handle Syncing
@ -54,7 +54,7 @@ pub struct OptimizedLMDGhost<T: ClientDB + Sized, B> {
_phantom: PhantomData<B>,
}
impl<T, B: BeaconStateTypes> OptimizedLMDGhost<T, B>
impl<T, B: EthSpec> OptimizedLMDGhost<T, B>
where
T: ClientDB + Sized,
{
@ -214,7 +214,7 @@ where
}
}
impl<T: ClientDB + Sized, B: BeaconStateTypes> ForkChoice for OptimizedLMDGhost<T, B> {
impl<T: ClientDB + Sized, B: EthSpec> ForkChoice for OptimizedLMDGhost<T, B> {
fn add_block(
&mut self,
block: &BeaconBlock,

View File

@ -9,7 +9,7 @@ use log::{debug, trace};
use std::collections::HashMap;
use std::marker::PhantomData;
use std::sync::Arc;
use types::{BeaconBlock, BeaconState, BeaconStateTypes, ChainSpec, Hash256, Slot};
use types::{BeaconBlock, BeaconState, ChainSpec, EthSpec, Hash256, Slot};
//TODO: Pruning and syncing
@ -26,7 +26,7 @@ pub struct SlowLMDGhost<T: ClientDB + Sized, B> {
_phantom: PhantomData<B>,
}
impl<T, B: BeaconStateTypes> SlowLMDGhost<T, B>
impl<T, B: EthSpec> SlowLMDGhost<T, B>
where
T: ClientDB + Sized,
{
@ -108,7 +108,7 @@ where
}
}
impl<T: ClientDB + Sized, B: BeaconStateTypes> ForkChoice for SlowLMDGhost<T, B> {
impl<T: ClientDB + Sized, B: EthSpec> ForkChoice for SlowLMDGhost<T, B> {
/// Process when a block is added
fn add_block(
&mut self,

View File

@ -26,8 +26,7 @@ use std::sync::Arc;
use std::{fs::File, io::prelude::*, path::PathBuf};
use types::test_utils::TestingBeaconStateBuilder;
use types::{
BeaconBlock, BeaconBlockBody, BeaconStateTypes, Eth1Data, FoundationStateTypes, Hash256,
Keypair, Slot,
BeaconBlock, BeaconBlockBody, Eth1Data, EthSpec, FoundationEthSpec, Hash256, Keypair, Slot,
};
use yaml_rust::yaml;
@ -85,7 +84,7 @@ fn test_yaml_vectors(
let test_cases = load_test_cases_from_yaml(yaml_file_path);
// default vars
let spec = FoundationStateTypes::spec();
let spec = FoundationEthSpec::spec();
let zero_hash = Hash256::zero();
let eth1_data = Eth1Data {
deposit_root: zero_hash.clone(),
@ -231,26 +230,26 @@ fn setup_inital_state(
// the fork choice instantiation
let fork_choice: Box<ForkChoice> = match fork_choice_algo {
ForkChoiceAlgorithm::OptimizedLMDGhost => {
let f: OptimizedLMDGhost<MemoryDB, FoundationStateTypes> =
let f: OptimizedLMDGhost<MemoryDB, FoundationEthSpec> =
OptimizedLMDGhost::new(block_store.clone(), state_store.clone());
Box::new(f)
}
ForkChoiceAlgorithm::BitwiseLMDGhost => {
let f: BitwiseLMDGhost<MemoryDB, FoundationStateTypes> =
let f: BitwiseLMDGhost<MemoryDB, FoundationEthSpec> =
BitwiseLMDGhost::new(block_store.clone(), state_store.clone());
Box::new(f)
}
ForkChoiceAlgorithm::SlowLMDGhost => {
let f: SlowLMDGhost<MemoryDB, FoundationStateTypes> =
let f: SlowLMDGhost<MemoryDB, FoundationEthSpec> =
SlowLMDGhost::new(block_store.clone(), state_store.clone());
Box::new(f)
}
ForkChoiceAlgorithm::LongestChain => Box::new(LongestChain::new(block_store.clone())),
};
let spec = FoundationStateTypes::spec();
let spec = FoundationEthSpec::spec();
let mut state_builder: TestingBeaconStateBuilder<FoundationStateTypes> =
let mut state_builder: TestingBeaconStateBuilder<FoundationEthSpec> =
TestingBeaconStateBuilder::from_single_keypair(num_validators, &Keypair::random(), &spec);
state_builder.build_caches(&spec).unwrap();
let (state, _keypairs) = state_builder.build();

View File

@ -16,8 +16,8 @@ use std::collections::{btree_map::Entry, hash_map, BTreeMap, HashMap, HashSet};
use std::marker::PhantomData;
use types::chain_spec::Domain;
use types::{
Attestation, AttestationData, AttesterSlashing, BeaconState, BeaconStateTypes, ChainSpec,
Deposit, Epoch, ProposerSlashing, Transfer, Validator, VoluntaryExit,
Attestation, AttestationData, AttesterSlashing, BeaconState, ChainSpec, Deposit, Epoch,
EthSpec, ProposerSlashing, Transfer, Validator, VoluntaryExit,
};
#[cfg(test)]
@ -26,7 +26,7 @@ const VERIFY_DEPOSIT_PROOFS: bool = false;
const VERIFY_DEPOSIT_PROOFS: bool = false; // TODO: enable this
#[derive(Default)]
pub struct OperationPool<T: BeaconStateTypes + Default> {
pub struct OperationPool<T: EthSpec + Default> {
/// Map from attestation ID (see below) to vectors of attestations.
attestations: RwLock<HashMap<AttestationId, Vec<Attestation>>>,
/// Map from deposit index to deposit data.
@ -54,7 +54,7 @@ struct AttestationId(Vec<u8>);
const DOMAIN_BYTES_LEN: usize = 8;
impl AttestationId {
fn from_data<T: BeaconStateTypes>(
fn from_data<T: EthSpec>(
attestation: &AttestationData,
state: &BeaconState<T>,
spec: &ChainSpec,
@ -65,7 +65,7 @@ impl AttestationId {
AttestationId(bytes)
}
fn compute_domain_bytes<T: BeaconStateTypes>(
fn compute_domain_bytes<T: EthSpec>(
epoch: Epoch,
state: &BeaconState<T>,
spec: &ChainSpec,
@ -85,7 +85,7 @@ impl AttestationId {
/// receive for including it in a block.
// TODO: this could be optimised with a map from validator index to whether that validator has
// attested in each of the current and previous epochs. Currently quadractic in number of validators.
fn attestation_score<T: BeaconStateTypes>(
fn attestation_score<T: EthSpec>(
attestation: &Attestation,
state: &BeaconState<T>,
spec: &ChainSpec,
@ -127,7 +127,7 @@ pub enum DepositInsertStatus {
Replaced(Box<Deposit>),
}
impl<T: BeaconStateTypes> OperationPool<T> {
impl<T: EthSpec> OperationPool<T> {
/// Create a new operation pool.
pub fn new() -> Self {
Self::default()
@ -501,7 +501,7 @@ impl<T: BeaconStateTypes> OperationPool<T> {
///
/// - Their `AttestationData` is equal.
/// - `attestation` does not contain any signatures that `PendingAttestation` does not have.
fn superior_attestation_exists_in_state<T: BeaconStateTypes>(
fn superior_attestation_exists_in_state<T: EthSpec>(
state: &BeaconState<T>,
attestation: &Attestation,
) -> bool {
@ -539,7 +539,7 @@ where
/// The keys in the map should be validator indices, which will be looked up
/// in the state's validator registry and then passed to `prune_if`.
/// Entries for unknown validators will be kept.
fn prune_validator_hash_map<T, F, B: BeaconStateTypes>(
fn prune_validator_hash_map<T, F, B: EthSpec>(
map: &mut HashMap<u64, T>,
prune_if: F,
finalized_state: &BeaconState<B>,
@ -666,7 +666,7 @@ mod tests {
}
// Create a random deposit (with a valid proof of posession)
fn make_deposit<T: BeaconStateTypes>(
fn make_deposit<T: EthSpec>(
rng: &mut XorShiftRng,
state: &BeaconState<T>,
spec: &ChainSpec,
@ -689,7 +689,7 @@ mod tests {
}
// Create `count` dummy deposits with sequential deposit IDs beginning from `start`.
fn dummy_deposits<T: BeaconStateTypes>(
fn dummy_deposits<T: EthSpec>(
rng: &mut XorShiftRng,
state: &BeaconState<T>,
spec: &ChainSpec,
@ -706,8 +706,8 @@ mod tests {
.collect()
}
fn test_state(rng: &mut XorShiftRng) -> (ChainSpec, BeaconState<FoundationStateTypes>) {
let spec = FoundationStateTypes::spec();
fn test_state(rng: &mut XorShiftRng) -> (ChainSpec, BeaconState<FoundationEthSpec>) {
let spec = FoundationEthSpec::spec();
let mut state = BeaconState::random_for_test(rng);
@ -722,10 +722,7 @@ mod tests {
/// Create a signed attestation for use in tests.
/// Signed by all validators in `committee[signing_range]` and `committee[extra_signer]`.
fn signed_attestation<
R: std::slice::SliceIndex<[usize], Output = [usize]>,
B: BeaconStateTypes,
>(
fn signed_attestation<R: std::slice::SliceIndex<[usize], Output = [usize]>, B: EthSpec>(
committee: &CrosslinkCommittee,
keypairs: &[Keypair],
signing_range: R,
@ -757,7 +754,7 @@ mod tests {
}
/// Test state for attestation-related tests.
fn attestation_test_state<B: BeaconStateTypes>(
fn attestation_test_state<B: EthSpec>(
num_committees: usize,
) -> (BeaconState<B>, Vec<Keypair>, ChainSpec) {
let spec = B::spec();
@ -774,11 +771,11 @@ mod tests {
state_builder.build_caches(&spec).unwrap();
let (state, keypairs) = state_builder.build();
(state, keypairs, FoundationStateTypes::spec())
(state, keypairs, FoundationEthSpec::spec())
}
/// Set the latest crosslink in the state to match the attestation.
fn fake_latest_crosslink<B: BeaconStateTypes>(
fn fake_latest_crosslink<B: EthSpec>(
att: &Attestation,
state: &mut BeaconState<B>,
spec: &ChainSpec,
@ -792,7 +789,7 @@ mod tests {
#[test]
fn test_attestation_score() {
let (ref mut state, ref keypairs, ref spec) =
attestation_test_state::<FoundationStateTypes>(1);
attestation_test_state::<FoundationEthSpec>(1);
let slot = state.slot - 1;
let committees = state
@ -824,7 +821,7 @@ mod tests {
#[test]
fn attestation_aggregation_insert_get_prune() {
let (ref mut state, ref keypairs, ref spec) =
attestation_test_state::<FoundationStateTypes>(1);
attestation_test_state::<FoundationEthSpec>(1);
let op_pool = OperationPool::new();
@ -890,7 +887,7 @@ mod tests {
#[test]
fn attestation_duplicate() {
let (ref mut state, ref keypairs, ref spec) =
attestation_test_state::<FoundationStateTypes>(1);
attestation_test_state::<FoundationEthSpec>(1);
let op_pool = OperationPool::new();
@ -917,7 +914,7 @@ mod tests {
#[test]
fn attestation_pairwise_overlapping() {
let (ref mut state, ref keypairs, ref spec) =
attestation_test_state::<FoundationStateTypes>(1);
attestation_test_state::<FoundationEthSpec>(1);
let op_pool = OperationPool::new();
@ -963,7 +960,7 @@ mod tests {
let big_step_size = 4;
let (ref mut state, ref keypairs, ref spec) =
attestation_test_state::<FoundationStateTypes>(big_step_size);
attestation_test_state::<FoundationEthSpec>(big_step_size);
let op_pool = OperationPool::new();

View File

@ -3,7 +3,7 @@ use types::{BeaconStateError as Error, *};
/// Exit the validator of the given `index`.
///
/// Spec v0.5.1
pub fn exit_validator<T: BeaconStateTypes>(
pub fn exit_validator<T: EthSpec>(
state: &mut BeaconState<T>,
validator_index: usize,
spec: &ChainSpec,

View File

@ -4,7 +4,7 @@ use types::{BeaconStateError as Error, *};
/// Slash the validator with index ``index``.
///
/// Spec v0.5.1
pub fn slash_validator<T: BeaconStateTypes>(
pub fn slash_validator<T: EthSpec>(
state: &mut BeaconState<T>,
validator_index: usize,
spec: &ChainSpec,

View File

@ -10,7 +10,7 @@ pub enum GenesisError {
/// Returns the genesis `BeaconState`
///
/// Spec v0.5.1
pub fn get_genesis_state<T: BeaconStateTypes>(
pub fn get_genesis_state<T: EthSpec>(
genesis_validator_deposits: &[Deposit],
genesis_time: u64,
genesis_eth1_data: Eth1Data,

View File

@ -40,7 +40,7 @@ const VERIFY_DEPOSIT_MERKLE_PROOFS: bool = false;
/// returns an error describing why the block was invalid or how the function failed to execute.
///
/// Spec v0.5.1
pub fn per_block_processing<T: BeaconStateTypes>(
pub fn per_block_processing<T: EthSpec>(
state: &mut BeaconState<T>,
block: &BeaconBlock,
spec: &ChainSpec,
@ -55,7 +55,7 @@ pub fn per_block_processing<T: BeaconStateTypes>(
/// returns an error describing why the block was invalid or how the function failed to execute.
///
/// Spec v0.5.1
pub fn per_block_processing_without_verifying_block_signature<T: BeaconStateTypes>(
pub fn per_block_processing_without_verifying_block_signature<T: EthSpec>(
state: &mut BeaconState<T>,
block: &BeaconBlock,
spec: &ChainSpec,
@ -70,7 +70,7 @@ pub fn per_block_processing_without_verifying_block_signature<T: BeaconStateType
/// returns an error describing why the block was invalid or how the function failed to execute.
///
/// Spec v0.5.1
fn per_block_processing_signature_optional<T: BeaconStateTypes>(
fn per_block_processing_signature_optional<T: EthSpec>(
mut state: &mut BeaconState<T>,
block: &BeaconBlock,
should_verify_block_signature: bool,
@ -100,7 +100,7 @@ fn per_block_processing_signature_optional<T: BeaconStateTypes>(
/// Processes the block header.
///
/// Spec v0.5.1
pub fn process_block_header<T: BeaconStateTypes>(
pub fn process_block_header<T: EthSpec>(
state: &mut BeaconState<T>,
block: &BeaconBlock,
spec: &ChainSpec,
@ -125,7 +125,7 @@ pub fn process_block_header<T: BeaconStateTypes>(
/// Verifies the signature of a block.
///
/// Spec v0.5.1
pub fn verify_block_signature<T: BeaconStateTypes>(
pub fn verify_block_signature<T: EthSpec>(
state: &BeaconState<T>,
block: &BeaconBlock,
spec: &ChainSpec,
@ -153,7 +153,7 @@ pub fn verify_block_signature<T: BeaconStateTypes>(
/// `state.latest_randao_mixes`.
///
/// Spec v0.5.1
pub fn process_randao<T: BeaconStateTypes>(
pub fn process_randao<T: EthSpec>(
state: &mut BeaconState<T>,
block: &BeaconBlock,
spec: &ChainSpec,
@ -184,7 +184,7 @@ pub fn process_randao<T: BeaconStateTypes>(
/// Update the `state.eth1_data_votes` based upon the `eth1_data` provided.
///
/// Spec v0.5.1
pub fn process_eth1_data<T: BeaconStateTypes>(
pub fn process_eth1_data<T: EthSpec>(
state: &mut BeaconState<T>,
eth1_data: &Eth1Data,
) -> Result<(), Error> {
@ -213,7 +213,7 @@ pub fn process_eth1_data<T: BeaconStateTypes>(
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.5.1
pub fn process_proposer_slashings<T: BeaconStateTypes>(
pub fn process_proposer_slashings<T: EthSpec>(
state: &mut BeaconState<T>,
proposer_slashings: &[ProposerSlashing],
spec: &ChainSpec,
@ -246,7 +246,7 @@ pub fn process_proposer_slashings<T: BeaconStateTypes>(
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.5.1
pub fn process_attester_slashings<T: BeaconStateTypes>(
pub fn process_attester_slashings<T: EthSpec>(
state: &mut BeaconState<T>,
attester_slashings: &[AttesterSlashing],
spec: &ChainSpec,
@ -304,7 +304,7 @@ pub fn process_attester_slashings<T: BeaconStateTypes>(
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.5.1
pub fn process_attestations<T: BeaconStateTypes>(
pub fn process_attestations<T: EthSpec>(
state: &mut BeaconState<T>,
attestations: &[Attestation],
spec: &ChainSpec,
@ -346,7 +346,7 @@ pub fn process_attestations<T: BeaconStateTypes>(
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.5.1
pub fn process_deposits<T: BeaconStateTypes>(
pub fn process_deposits<T: EthSpec>(
state: &mut BeaconState<T>,
deposits: &[Deposit],
spec: &ChainSpec,
@ -416,7 +416,7 @@ pub fn process_deposits<T: BeaconStateTypes>(
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.5.1
pub fn process_exits<T: BeaconStateTypes>(
pub fn process_exits<T: EthSpec>(
state: &mut BeaconState<T>,
voluntary_exits: &[VoluntaryExit],
spec: &ChainSpec,
@ -448,7 +448,7 @@ pub fn process_exits<T: BeaconStateTypes>(
/// an `Err` describing the invalid object or cause of failure.
///
/// Spec v0.5.1
pub fn process_transfers<T: BeaconStateTypes>(
pub fn process_transfers<T: EthSpec>(
state: &mut BeaconState<T>,
transfers: &[Transfer],
spec: &ChainSpec,

View File

@ -9,7 +9,7 @@ use types::*;
/// Returns `Ok(())` if the `Attestation` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.5.1
pub fn validate_attestation<T: BeaconStateTypes>(
pub fn validate_attestation<T: EthSpec>(
state: &BeaconState<T>,
attestation: &Attestation,
spec: &ChainSpec,
@ -18,7 +18,7 @@ pub fn validate_attestation<T: BeaconStateTypes>(
}
/// Like `validate_attestation` but doesn't run checks which may become true in future states.
pub fn validate_attestation_time_independent_only<T: BeaconStateTypes>(
pub fn validate_attestation_time_independent_only<T: EthSpec>(
state: &BeaconState<T>,
attestation: &Attestation,
spec: &ChainSpec,
@ -32,7 +32,7 @@ pub fn validate_attestation_time_independent_only<T: BeaconStateTypes>(
/// Returns `Ok(())` if the `Attestation` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.5.1
pub fn validate_attestation_without_signature<T: BeaconStateTypes>(
pub fn validate_attestation_without_signature<T: EthSpec>(
state: &BeaconState<T>,
attestation: &Attestation,
spec: &ChainSpec,
@ -45,7 +45,7 @@ pub fn validate_attestation_without_signature<T: BeaconStateTypes>(
///
///
/// Spec v0.5.1
fn validate_attestation_parametric<T: BeaconStateTypes>(
fn validate_attestation_parametric<T: EthSpec>(
state: &BeaconState<T>,
attestation: &Attestation,
spec: &ChainSpec,
@ -168,7 +168,7 @@ fn validate_attestation_parametric<T: BeaconStateTypes>(
/// match the current (or previous) justified epoch and root from the state.
///
/// Spec v0.5.1
fn verify_justified_epoch_and_root<T: BeaconStateTypes>(
fn verify_justified_epoch_and_root<T: EthSpec>(
attestation: &Attestation,
state: &BeaconState<T>,
spec: &ChainSpec,
@ -223,7 +223,7 @@ fn verify_justified_epoch_and_root<T: BeaconStateTypes>(
/// - A `validator_index` in `committee` is not in `state.validator_registry`.
///
/// Spec v0.5.1
fn verify_attestation_signature<T: BeaconStateTypes>(
fn verify_attestation_signature<T: EthSpec>(
state: &BeaconState<T>,
committee: &[usize],
a: &Attestation,

View File

@ -8,7 +8,7 @@ use types::*;
/// Returns `Ok(())` if the `AttesterSlashing` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.5.1
pub fn verify_attester_slashing<T: BeaconStateTypes>(
pub fn verify_attester_slashing<T: EthSpec>(
state: &BeaconState<T>,
attester_slashing: &AttesterSlashing,
should_verify_slashable_attestations: bool,
@ -42,7 +42,7 @@ pub fn verify_attester_slashing<T: BeaconStateTypes>(
/// Returns Ok(indices) if `indices.len() > 0`.
///
/// Spec v0.5.1
pub fn gather_attester_slashing_indices<T: BeaconStateTypes>(
pub fn gather_attester_slashing_indices<T: EthSpec>(
state: &BeaconState<T>,
attester_slashing: &AttesterSlashing,
spec: &ChainSpec,
@ -57,7 +57,7 @@ pub fn gather_attester_slashing_indices<T: BeaconStateTypes>(
/// Same as `gather_attester_slashing_indices` but allows the caller to specify the criteria
/// for determining whether a given validator should be considered slashed.
pub fn gather_attester_slashing_indices_modular<F, T: BeaconStateTypes>(
pub fn gather_attester_slashing_indices_modular<F, T: EthSpec>(
state: &BeaconState<T>,
attester_slashing: &AttesterSlashing,
is_slashed: F,

View File

@ -16,7 +16,7 @@ use types::*;
/// Note: this function is incomplete.
///
/// Spec v0.5.1
pub fn verify_deposit<T: BeaconStateTypes>(
pub fn verify_deposit<T: EthSpec>(
state: &BeaconState<T>,
deposit: &Deposit,
verify_merkle_branch: bool,
@ -47,7 +47,7 @@ pub fn verify_deposit<T: BeaconStateTypes>(
/// Verify that the `Deposit` index is correct.
///
/// Spec v0.5.1
pub fn verify_deposit_index<T: BeaconStateTypes>(
pub fn verify_deposit_index<T: EthSpec>(
state: &BeaconState<T>,
deposit: &Deposit,
) -> Result<(), Error> {
@ -68,7 +68,7 @@ pub fn verify_deposit_index<T: BeaconStateTypes>(
/// ## Errors
///
/// Errors if the state's `pubkey_cache` is not current.
pub fn get_existing_validator_index<T: BeaconStateTypes>(
pub fn get_existing_validator_index<T: EthSpec>(
state: &BeaconState<T>,
deposit: &Deposit,
) -> Result<Option<u64>, Error> {
@ -92,7 +92,7 @@ pub fn get_existing_validator_index<T: BeaconStateTypes>(
/// Verify that a deposit is included in the state's eth1 deposit root.
///
/// Spec v0.5.1
fn verify_deposit_merkle_proof<T: BeaconStateTypes>(
fn verify_deposit_merkle_proof<T: EthSpec>(
state: &BeaconState<T>,
deposit: &Deposit,
spec: &ChainSpec,

View File

@ -8,7 +8,7 @@ use types::*;
/// Returns `Ok(())` if the `Exit` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.5.1
pub fn verify_exit<T: BeaconStateTypes>(
pub fn verify_exit<T: EthSpec>(
state: &BeaconState<T>,
exit: &VoluntaryExit,
spec: &ChainSpec,
@ -17,7 +17,7 @@ pub fn verify_exit<T: BeaconStateTypes>(
}
/// Like `verify_exit` but doesn't run checks which may become true in future states.
pub fn verify_exit_time_independent_only<T: BeaconStateTypes>(
pub fn verify_exit_time_independent_only<T: EthSpec>(
state: &BeaconState<T>,
exit: &VoluntaryExit,
spec: &ChainSpec,
@ -26,7 +26,7 @@ pub fn verify_exit_time_independent_only<T: BeaconStateTypes>(
}
/// Parametric version of `verify_exit` that skips some checks if `time_independent_only` is true.
fn verify_exit_parametric<T: BeaconStateTypes>(
fn verify_exit_parametric<T: EthSpec>(
state: &BeaconState<T>,
exit: &VoluntaryExit,
spec: &ChainSpec,

View File

@ -8,7 +8,7 @@ use types::*;
/// Returns `Ok(())` if the `ProposerSlashing` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.5.1
pub fn verify_proposer_slashing<T: BeaconStateTypes>(
pub fn verify_proposer_slashing<T: EthSpec>(
proposer_slashing: &ProposerSlashing,
state: &BeaconState<T>,
spec: &ChainSpec,

View File

@ -11,7 +11,7 @@ use types::*;
/// Returns `Ok(())` if the `SlashableAttestation` is valid, otherwise indicates the reason for invalidity.
///
/// Spec v0.5.1
pub fn verify_slashable_attestation<T: BeaconStateTypes>(
pub fn verify_slashable_attestation<T: EthSpec>(
state: &BeaconState<T>,
slashable_attestation: &SlashableAttestation,
spec: &ChainSpec,

View File

@ -11,7 +11,7 @@ use types::*;
/// Note: this function is incomplete.
///
/// Spec v0.5.1
pub fn verify_transfer<T: BeaconStateTypes>(
pub fn verify_transfer<T: EthSpec>(
state: &BeaconState<T>,
transfer: &Transfer,
spec: &ChainSpec,
@ -20,7 +20,7 @@ pub fn verify_transfer<T: BeaconStateTypes>(
}
/// Like `verify_transfer` but doesn't run checks which may become true in future states.
pub fn verify_transfer_time_independent_only<T: BeaconStateTypes>(
pub fn verify_transfer_time_independent_only<T: EthSpec>(
state: &BeaconState<T>,
transfer: &Transfer,
spec: &ChainSpec,
@ -29,7 +29,7 @@ pub fn verify_transfer_time_independent_only<T: BeaconStateTypes>(
}
/// Parametric version of `verify_transfer` that allows some checks to be skipped.
fn verify_transfer_parametric<T: BeaconStateTypes>(
fn verify_transfer_parametric<T: EthSpec>(
state: &BeaconState<T>,
transfer: &Transfer,
spec: &ChainSpec,
@ -123,7 +123,7 @@ fn verify_transfer_parametric<T: BeaconStateTypes>(
/// Does not check that the transfer is valid, however checks for overflow in all actions.
///
/// Spec v0.5.1
pub fn execute_transfer<T: BeaconStateTypes>(
pub fn execute_transfer<T: EthSpec>(
state: &mut BeaconState<T>,
transfer: &Transfer,
spec: &ChainSpec,

View File

@ -33,7 +33,7 @@ pub type WinningRootHashSet = HashMap<u64, WinningRoot>;
/// returned, a state might be "half-processed" and therefore in an invalid state.
///
/// Spec v0.5.1
pub fn per_epoch_processing<T: BeaconStateTypes>(
pub fn per_epoch_processing<T: EthSpec>(
state: &mut BeaconState<T>,
spec: &ChainSpec,
) -> Result<(), Error> {
@ -90,7 +90,7 @@ pub fn per_epoch_processing<T: BeaconStateTypes>(
/// Maybe resets the eth1 period.
///
/// Spec v0.5.1
pub fn maybe_reset_eth1_period<T: BeaconStateTypes>(state: &mut BeaconState<T>, spec: &ChainSpec) {
pub fn maybe_reset_eth1_period<T: EthSpec>(state: &mut BeaconState<T>, spec: &ChainSpec) {
let next_epoch = state.next_epoch(spec);
let voting_period = spec.epochs_per_eth1_voting_period;
@ -112,7 +112,7 @@ pub fn maybe_reset_eth1_period<T: BeaconStateTypes>(state: &mut BeaconState<T>,
/// - `previous_justified_epoch`
///
/// Spec v0.5.1
pub fn update_justification_and_finalization<T: BeaconStateTypes>(
pub fn update_justification_and_finalization<T: EthSpec>(
state: &mut BeaconState<T>,
total_balances: &TotalBalances,
spec: &ChainSpec,
@ -182,7 +182,7 @@ pub fn update_justification_and_finalization<T: BeaconStateTypes>(
/// Also returns a `WinningRootHashSet` for later use during epoch processing.
///
/// Spec v0.5.1
pub fn process_crosslinks<T: BeaconStateTypes>(
pub fn process_crosslinks<T: EthSpec>(
state: &mut BeaconState<T>,
spec: &ChainSpec,
) -> Result<WinningRootHashSet, Error> {
@ -225,7 +225,7 @@ pub fn process_crosslinks<T: BeaconStateTypes>(
/// Finish up an epoch update.
///
/// Spec v0.5.1
pub fn finish_epoch_update<T: BeaconStateTypes>(
pub fn finish_epoch_update<T: EthSpec>(
state: &mut BeaconState<T>,
spec: &ChainSpec,
) -> Result<(), Error> {

View File

@ -33,7 +33,7 @@ impl std::ops::AddAssign for Delta {
/// Apply attester and proposer rewards.
///
/// Spec v0.5.1
pub fn apply_rewards<T: BeaconStateTypes>(
pub fn apply_rewards<T: EthSpec>(
state: &mut BeaconState<T>,
validator_statuses: &mut ValidatorStatuses,
winning_root_for_shards: &WinningRootHashSet,
@ -80,7 +80,7 @@ pub fn apply_rewards<T: BeaconStateTypes>(
/// attestation in the previous epoch.
///
/// Spec v0.5.1
fn get_proposer_deltas<T: BeaconStateTypes>(
fn get_proposer_deltas<T: EthSpec>(
deltas: &mut Vec<Delta>,
state: &mut BeaconState<T>,
validator_statuses: &mut ValidatorStatuses,
@ -121,7 +121,7 @@ fn get_proposer_deltas<T: BeaconStateTypes>(
/// Apply rewards for participation in attestations during the previous epoch.
///
/// Spec v0.5.1
fn get_justification_and_finalization_deltas<T: BeaconStateTypes>(
fn get_justification_and_finalization_deltas<T: EthSpec>(
deltas: &mut Vec<Delta>,
state: &BeaconState<T>,
validator_statuses: &ValidatorStatuses,
@ -262,7 +262,7 @@ fn compute_inactivity_leak_delta(
/// Calculate the deltas based upon the winning roots for attestations during the previous epoch.
///
/// Spec v0.5.1
fn get_crosslink_deltas<T: BeaconStateTypes>(
fn get_crosslink_deltas<T: EthSpec>(
deltas: &mut Vec<Delta>,
state: &BeaconState<T>,
validator_statuses: &ValidatorStatuses,
@ -296,7 +296,7 @@ fn get_crosslink_deltas<T: BeaconStateTypes>(
/// Returns the base reward for some validator.
///
/// Spec v0.5.1
fn get_base_reward<T: BeaconStateTypes>(
fn get_base_reward<T: EthSpec>(
state: &BeaconState<T>,
index: usize,
previous_total_balance: u64,
@ -313,7 +313,7 @@ fn get_base_reward<T: BeaconStateTypes>(
/// Returns the inactivity penalty for some validator.
///
/// Spec v0.5.1
fn get_inactivity_penalty<T: BeaconStateTypes>(
fn get_inactivity_penalty<T: EthSpec>(
state: &BeaconState<T>,
index: usize,
epochs_since_finality: u64,
@ -329,6 +329,6 @@ fn get_inactivity_penalty<T: BeaconStateTypes>(
/// Returns the epochs since the last finalized epoch.
///
/// Spec v0.5.1
fn epochs_since_finality<T: BeaconStateTypes>(state: &BeaconState<T>, spec: &ChainSpec) -> Epoch {
fn epochs_since_finality<T: EthSpec>(state: &BeaconState<T>, spec: &ChainSpec) -> Epoch {
state.current_epoch(spec) + 1 - state.finalized_epoch
}

View File

@ -4,7 +4,7 @@ use types::*;
/// Returns validator indices which participated in the attestation.
///
/// Spec v0.5.1
pub fn get_attestation_participants<T: BeaconStateTypes>(
pub fn get_attestation_participants<T: EthSpec>(
state: &BeaconState<T>,
attestation_data: &AttestationData,
bitfield: &Bitfield,

View File

@ -6,7 +6,7 @@ use types::*;
/// slot.
///
/// Spec v0.5.1
pub fn inclusion_distance<T: BeaconStateTypes>(
pub fn inclusion_distance<T: EthSpec>(
state: &BeaconState<T>,
attestations: &[&PendingAttestation],
validator_index: usize,
@ -19,7 +19,7 @@ pub fn inclusion_distance<T: BeaconStateTypes>(
/// Returns the slot of the earliest included attestation for some validator.
///
/// Spec v0.5.1
pub fn inclusion_slot<T: BeaconStateTypes>(
pub fn inclusion_slot<T: EthSpec>(
state: &BeaconState<T>,
attestations: &[&PendingAttestation],
validator_index: usize,
@ -32,7 +32,7 @@ pub fn inclusion_slot<T: BeaconStateTypes>(
/// Finds the earliest included attestation for some validator.
///
/// Spec v0.5.1
fn earliest_included_attestation<T: BeaconStateTypes>(
fn earliest_included_attestation<T: EthSpec>(
state: &BeaconState<T>,
attestations: &[&PendingAttestation],
validator_index: usize,

View File

@ -5,7 +5,7 @@ use types::{BeaconStateError as Error, *};
/// ``EJECTION_BALANCE``.
///
/// Spec v0.5.1
pub fn process_ejections<T: BeaconStateTypes>(
pub fn process_ejections<T: EthSpec>(
state: &mut BeaconState<T>,
spec: &ChainSpec,
) -> Result<(), Error> {

View File

@ -3,7 +3,7 @@ use types::*;
/// Process the exit queue.
///
/// Spec v0.5.1
pub fn process_exit_queue<T: BeaconStateTypes>(state: &mut BeaconState<T>, spec: &ChainSpec) {
pub fn process_exit_queue<T: EthSpec>(state: &mut BeaconState<T>, spec: &ChainSpec) {
let current_epoch = state.current_epoch(spec);
let eligible = |index: usize| {
@ -32,7 +32,7 @@ pub fn process_exit_queue<T: BeaconStateTypes>(state: &mut BeaconState<T>, spec:
/// Initiate an exit for the validator of the given `index`.
///
/// Spec v0.5.1
fn prepare_validator_for_withdrawal<T: BeaconStateTypes>(
fn prepare_validator_for_withdrawal<T: EthSpec>(
state: &mut BeaconState<T>,
validator_index: usize,
spec: &ChainSpec,

View File

@ -3,7 +3,7 @@ use types::{BeaconStateError as Error, *};
/// Process slashings.
///
/// Spec v0.5.1
pub fn process_slashings<T: BeaconStateTypes>(
pub fn process_slashings<T: EthSpec>(
state: &mut BeaconState<T>,
current_total_balance: u64,
spec: &ChainSpec,

View File

@ -8,9 +8,9 @@ use types::*;
fn runs_without_error() {
Builder::from_env(Env::default().default_filter_or("error")).init();
let spec = FewValidatorsStateTypes::spec();
let spec = FewValidatorsEthSpec::spec();
let mut builder: TestingBeaconStateBuilder<FewValidatorsStateTypes> =
let mut builder: TestingBeaconStateBuilder<FewValidatorsEthSpec> =
TestingBeaconStateBuilder::from_deterministic_keypairs(8, &spec);
let target_slot = (spec.genesis_epoch + 4).end_slot(spec.slots_per_epoch);

View File

@ -5,7 +5,7 @@ use types::*;
/// Peforms a validator registry update, if required.
///
/// Spec v0.5.1
pub fn update_registry_and_shuffling_data<T: BeaconStateTypes>(
pub fn update_registry_and_shuffling_data<T: EthSpec>(
state: &mut BeaconState<T>,
current_total_balance: u64,
spec: &ChainSpec,
@ -50,7 +50,7 @@ pub fn update_registry_and_shuffling_data<T: BeaconStateTypes>(
/// Returns `true` if the validator registry should be updated during an epoch processing.
///
/// Spec v0.5.1
pub fn should_update_validator_registry<T: BeaconStateTypes>(
pub fn should_update_validator_registry<T: EthSpec>(
state: &BeaconState<T>,
spec: &ChainSpec,
) -> Result<bool, BeaconStateError> {
@ -79,7 +79,7 @@ pub fn should_update_validator_registry<T: BeaconStateTypes>(
/// Note: Utilizes the cache and will fail if the appropriate cache is not initialized.
///
/// Spec v0.5.1
pub fn update_validator_registry<T: BeaconStateTypes>(
pub fn update_validator_registry<T: EthSpec>(
state: &mut BeaconState<T>,
current_total_balance: u64,
spec: &ChainSpec,
@ -134,7 +134,7 @@ pub fn update_validator_registry<T: BeaconStateTypes>(
/// Activate the validator of the given ``index``.
///
/// Spec v0.5.1
pub fn activate_validator<T: BeaconStateTypes>(
pub fn activate_validator<T: EthSpec>(
state: &mut BeaconState<T>,
validator_index: usize,
is_genesis: bool,

View File

@ -161,7 +161,7 @@ impl ValidatorStatuses {
/// - Total balances for the current and previous epochs.
///
/// Spec v0.5.1
pub fn new<T: BeaconStateTypes>(
pub fn new<T: EthSpec>(
state: &BeaconState<T>,
spec: &ChainSpec,
) -> Result<Self, BeaconStateError> {
@ -199,7 +199,7 @@ impl ValidatorStatuses {
/// `total_balances` fields.
///
/// Spec v0.5.1
pub fn process_attestations<T: BeaconStateTypes>(
pub fn process_attestations<T: EthSpec>(
&mut self,
state: &BeaconState<T>,
spec: &ChainSpec,
@ -265,7 +265,7 @@ impl ValidatorStatuses {
/// "winning" shard block root for the previous epoch.
///
/// Spec v0.5.1
pub fn process_winning_roots<T: BeaconStateTypes>(
pub fn process_winning_roots<T: EthSpec>(
&mut self,
state: &BeaconState<T>,
winning_roots: &WinningRootHashSet,
@ -316,7 +316,7 @@ fn is_from_epoch(a: &PendingAttestation, epoch: Epoch, spec: &ChainSpec) -> bool
/// the first slot of the given epoch.
///
/// Spec v0.5.1
fn has_common_epoch_boundary_root<T: BeaconStateTypes>(
fn has_common_epoch_boundary_root<T: EthSpec>(
a: &PendingAttestation,
state: &BeaconState<T>,
epoch: Epoch,
@ -332,7 +332,7 @@ fn has_common_epoch_boundary_root<T: BeaconStateTypes>(
/// the current slot of the `PendingAttestation`.
///
/// Spec v0.5.1
fn has_common_beacon_block_root<T: BeaconStateTypes>(
fn has_common_beacon_block_root<T: EthSpec>(
a: &PendingAttestation,
state: &BeaconState<T>,
) -> Result<bool, BeaconStateError> {

View File

@ -35,7 +35,7 @@ impl WinningRoot {
/// per-epoch processing.
///
/// Spec v0.5.1
pub fn winning_root<T: BeaconStateTypes>(
pub fn winning_root<T: EthSpec>(
state: &BeaconState<T>,
shard: u64,
spec: &ChainSpec,
@ -90,7 +90,7 @@ pub fn winning_root<T: BeaconStateTypes>(
/// Returns `true` if pending attestation `a` is eligible to become a winning root.
///
/// Spec v0.5.1
fn is_eligible_for_winning_root<T: BeaconStateTypes>(
fn is_eligible_for_winning_root<T: EthSpec>(
state: &BeaconState<T>,
a: &PendingAttestation,
shard: Shard,
@ -105,7 +105,7 @@ fn is_eligible_for_winning_root<T: BeaconStateTypes>(
/// Returns all indices which voted for a given crosslink. Does not contain duplicates.
///
/// Spec v0.5.1
fn get_attesting_validator_indices<T: BeaconStateTypes>(
fn get_attesting_validator_indices<T: EthSpec>(
state: &BeaconState<T>,
shard: u64,
crosslink_data_root: &Hash256,

View File

@ -11,7 +11,7 @@ pub enum Error {
/// Advances a state forward by one slot, performing per-epoch processing if required.
///
/// Spec v0.5.1
pub fn per_slot_processing<T: BeaconStateTypes>(
pub fn per_slot_processing<T: EthSpec>(
state: &mut BeaconState<T>,
spec: &ChainSpec,
) -> Result<(), Error> {
@ -26,10 +26,7 @@ pub fn per_slot_processing<T: BeaconStateTypes>(
Ok(())
}
fn cache_state<T: BeaconStateTypes>(
state: &mut BeaconState<T>,
spec: &ChainSpec,
) -> Result<(), Error> {
fn cache_state<T: EthSpec>(state: &mut BeaconState<T>, spec: &ChainSpec) -> Result<(), Error> {
let previous_slot_state_root = state.update_tree_hash_cache()?;
// Note: increment the state slot here to allow use of our `state_root` and `block_root`

View File

@ -67,7 +67,7 @@ pub enum Error {
)]
pub struct BeaconState<T>
where
T: BeaconStateTypes,
T: EthSpec,
{
// Misc
pub slot: Slot,
@ -140,7 +140,7 @@ where
pub tree_hash_cache: TreeHashCache,
}
impl<T: BeaconStateTypes> BeaconState<T> {
impl<T: EthSpec> BeaconState<T> {
/// Produce the first state of the Beacon Chain.
///
/// This does not fully build a genesis beacon state, it omits processing of initial validator

View File

@ -3,7 +3,7 @@ use fixed_len_vec::typenum::{Unsigned, U1024, U8, U8192};
use serde_derive::{Deserialize, Serialize};
use std::fmt::Debug;
pub trait BeaconStateTypes:
pub trait EthSpec:
'static + Default + Sync + Send + Clone + Debug + PartialEq + serde::de::DeserializeOwned
{
type ShardCount: Unsigned + Clone + Sync + Send + Debug + PartialEq;
@ -54,9 +54,9 @@ pub trait BeaconStateTypes:
///
/// Spec v0.5.1
#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize)]
pub struct FoundationStateTypes;
pub struct FoundationEthSpec;
impl BeaconStateTypes for FoundationStateTypes {
impl EthSpec for FoundationEthSpec {
type ShardCount = U1024;
type SlotsPerHistoricalRoot = U8192;
type LatestRandaoMixesLength = U8192;
@ -68,15 +68,15 @@ impl BeaconStateTypes for FoundationStateTypes {
}
}
pub type FoundationBeaconState = BeaconState<FoundationStateTypes>;
pub type FoundationBeaconState = BeaconState<FoundationEthSpec>;
/// Ethereum Foundation specifications, modified to be suitable for < 1000 validators.
///
/// Spec v0.5.1
#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize)]
pub struct FewValidatorsStateTypes;
pub struct FewValidatorsEthSpec;
impl BeaconStateTypes for FewValidatorsStateTypes {
impl EthSpec for FewValidatorsEthSpec {
type ShardCount = U8;
type SlotsPerHistoricalRoot = U8192;
type LatestRandaoMixesLength = U8192;
@ -88,15 +88,15 @@ impl BeaconStateTypes for FewValidatorsStateTypes {
}
}
pub type FewValidatorsBeaconState = BeaconState<FewValidatorsStateTypes>;
pub type FewValidatorsBeaconState = BeaconState<FewValidatorsEthSpec>;
/// Specifications suitable for a small-scale (< 1000 validators) lighthouse testnet.
///
/// Spec v0.5.1
#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize)]
pub struct LighthouseTestnetStateTypes;
pub struct LighthouseTestnetEthSpec;
impl BeaconStateTypes for LighthouseTestnetStateTypes {
impl EthSpec for LighthouseTestnetEthSpec {
type ShardCount = U8;
type SlotsPerHistoricalRoot = U8192;
type LatestRandaoMixesLength = U8192;
@ -108,4 +108,4 @@ impl BeaconStateTypes for LighthouseTestnetStateTypes {
}
}
pub type LighthouseTestnetBeaconState = BeaconState<LighthouseTestnetStateTypes>;
pub type LighthouseTestnetBeaconState = BeaconState<LighthouseTestnetEthSpec>;

View File

@ -28,7 +28,7 @@ pub struct EpochCache {
impl EpochCache {
/// Return a new, fully initialized cache.
pub fn initialized<T: BeaconStateTypes>(
pub fn initialized<T: EthSpec>(
state: &BeaconState<T>,
relative_epoch: RelativeEpoch,
spec: &ChainSpec,
@ -200,7 +200,7 @@ pub struct EpochCrosslinkCommitteesBuilder {
impl EpochCrosslinkCommitteesBuilder {
/// Instantiates a builder that will build for the `state`'s previous epoch.
pub fn for_previous_epoch<T: BeaconStateTypes>(
pub fn for_previous_epoch<T: EthSpec>(
state: &BeaconState<T>,
active_validator_indices: Vec<usize>,
spec: &ChainSpec,
@ -215,7 +215,7 @@ impl EpochCrosslinkCommitteesBuilder {
}
/// Instantiates a builder that will build for the `state`'s next epoch.
pub fn for_current_epoch<T: BeaconStateTypes>(
pub fn for_current_epoch<T: EthSpec>(
state: &BeaconState<T>,
active_validator_indices: Vec<usize>,
spec: &ChainSpec,
@ -233,7 +233,7 @@ impl EpochCrosslinkCommitteesBuilder {
///
/// Note: there are two possible epoch builds for the next epoch, one where there is a registry
/// change and one where there is not.
pub fn for_next_epoch<T: BeaconStateTypes>(
pub fn for_next_epoch<T: EthSpec>(
state: &BeaconState<T>,
active_validator_indices: Vec<usize>,
registry_change: bool,

View File

@ -1,11 +1,11 @@
#![cfg(test)]
use super::*;
use crate::beacon_state::FewValidatorsStateTypes;
use crate::beacon_state::FewValidatorsEthSpec;
use crate::test_utils::*;
use swap_or_not_shuffle::shuffle_list;
fn do_sane_cache_test<T: BeaconStateTypes>(
fn do_sane_cache_test<T: EthSpec>(
state: BeaconState<T>,
epoch: Epoch,
relative_epoch: RelativeEpoch,
@ -65,10 +65,7 @@ fn do_sane_cache_test<T: BeaconStateTypes>(
}
}
fn setup_sane_cache_test<T: BeaconStateTypes>(
validator_count: usize,
spec: &ChainSpec,
) -> BeaconState<T> {
fn setup_sane_cache_test<T: EthSpec>(validator_count: usize, spec: &ChainSpec) -> BeaconState<T> {
let mut builder =
TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(validator_count, spec);
@ -102,11 +99,11 @@ fn setup_sane_cache_test<T: BeaconStateTypes>(
#[test]
fn builds_sane_current_epoch_cache() {
let mut spec = FewValidatorsStateTypes::spec();
let mut spec = FewValidatorsEthSpec::spec();
spec.shard_count = 4;
let validator_count = (spec.shard_count * spec.target_committee_size) + 1;
let state: BeaconState<FewValidatorsStateTypes> =
let state: BeaconState<FewValidatorsEthSpec> =
setup_sane_cache_test(validator_count as usize, &spec);
do_sane_cache_test(
@ -122,11 +119,11 @@ fn builds_sane_current_epoch_cache() {
#[test]
fn builds_sane_previous_epoch_cache() {
let mut spec = FewValidatorsStateTypes::spec();
let mut spec = FewValidatorsEthSpec::spec();
spec.shard_count = 2;
let validator_count = (spec.shard_count * spec.target_committee_size) + 1;
let state: BeaconState<FewValidatorsStateTypes> =
let state: BeaconState<FewValidatorsEthSpec> =
setup_sane_cache_test(validator_count as usize, &spec);
do_sane_cache_test(
@ -142,11 +139,11 @@ fn builds_sane_previous_epoch_cache() {
#[test]
fn builds_sane_next_without_update_epoch_cache() {
let mut spec = FewValidatorsStateTypes::spec();
let mut spec = FewValidatorsEthSpec::spec();
spec.shard_count = 2;
let validator_count = (spec.shard_count * spec.target_committee_size) + 1;
let mut state: BeaconState<FewValidatorsStateTypes> =
let mut state: BeaconState<FewValidatorsEthSpec> =
setup_sane_cache_test(validator_count as usize, &spec);
state.validator_registry_update_epoch = state.slot.epoch(spec.slots_per_epoch);

View File

@ -1,6 +1,6 @@
#![cfg(test)]
use super::*;
use crate::beacon_state::FewValidatorsStateTypes;
use crate::beacon_state::FewValidatorsEthSpec;
use crate::test_utils::*;
ssz_tests!(FoundationBeaconState);
@ -11,7 +11,7 @@ cached_tree_hash_tests!(FoundationBeaconState);
/// 1. Using the cache before it's built fails.
/// 2. Using the cache after it's build passes.
/// 3. Using the cache after it's dropped fails.
fn test_cache_initialization<'a, T: BeaconStateTypes>(
fn test_cache_initialization<'a, T: EthSpec>(
state: &'a mut BeaconState<T>,
relative_epoch: RelativeEpoch,
spec: &ChainSpec,
@ -46,9 +46,9 @@ fn test_cache_initialization<'a, T: BeaconStateTypes>(
#[test]
fn cache_initialization() {
let spec = FewValidatorsStateTypes::spec();
let spec = FewValidatorsEthSpec::spec();
let builder: TestingBeaconStateBuilder<FewValidatorsStateTypes> =
let builder: TestingBeaconStateBuilder<FewValidatorsEthSpec> =
TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(16, &spec);
let (mut state, _keypairs) = builder.build();

View File

@ -22,7 +22,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
CachedTreeHash,
TestRandom,
)]
pub struct HistoricalBatch<T: BeaconStateTypes> {
pub struct HistoricalBatch<T: EthSpec> {
pub block_roots: FixedLenVec<Hash256, T::SlotsPerHistoricalRoot>,
pub state_roots: FixedLenVec<Hash256, T::SlotsPerHistoricalRoot>,
}
@ -31,7 +31,7 @@ pub struct HistoricalBatch<T: BeaconStateTypes> {
mod tests {
use super::*;
pub type FoundationHistoricalBatch = HistoricalBatch<FoundationStateTypes>;
pub type FoundationHistoricalBatch = HistoricalBatch<FoundationEthSpec>;
ssz_tests!(FoundationHistoricalBatch);
cached_tree_hash_tests!(FoundationHistoricalBatch);

View File

@ -12,7 +12,7 @@ pub struct TestingAttestationBuilder {
impl TestingAttestationBuilder {
/// Create a new attestation builder.
pub fn new<T: BeaconStateTypes>(
pub fn new<T: EthSpec>(
state: &BeaconState<T>,
committee: &[usize],
slot: Slot,

View File

@ -10,7 +10,7 @@ pub struct TestingAttestationDataBuilder {
impl TestingAttestationDataBuilder {
/// Configures a new `AttestationData` which attests to all of the same parameters as the
/// state.
pub fn new<T: BeaconStateTypes>(
pub fn new<T: EthSpec>(
state: &BeaconState<T>,
shard: u64,
slot: Slot,

View File

@ -82,7 +82,7 @@ impl TestingBeaconBlockBuilder {
///
/// Note: the signed messages of the split committees will be identical -- it would be possible
/// to aggregate these split attestations.
pub fn insert_attestations<T: BeaconStateTypes>(
pub fn insert_attestations<T: EthSpec>(
&mut self,
state: &BeaconState<T>,
secret_keys: &[&SecretKey],
@ -171,7 +171,7 @@ impl TestingBeaconBlockBuilder {
}
/// Insert a `Valid` deposit into the state.
pub fn insert_deposit<T: BeaconStateTypes>(
pub fn insert_deposit<T: EthSpec>(
&mut self,
amount: u64,
index: u64,
@ -193,7 +193,7 @@ impl TestingBeaconBlockBuilder {
}
/// Insert a `Valid` exit into the state.
pub fn insert_exit<T: BeaconStateTypes>(
pub fn insert_exit<T: EthSpec>(
&mut self,
state: &BeaconState<T>,
validator_index: u64,
@ -214,7 +214,7 @@ impl TestingBeaconBlockBuilder {
///
/// Note: this will set the validator to be withdrawable by directly modifying the state
/// validator registry. This _may_ cause problems historic hashes, etc.
pub fn insert_transfer<T: BeaconStateTypes>(
pub fn insert_transfer<T: EthSpec>(
&mut self,
state: &BeaconState<T>,
from: u64,

View File

@ -25,12 +25,12 @@ pub fn keypairs_path() -> PathBuf {
///
/// This struct should **never be used for production purposes.**
#[derive(Clone)]
pub struct TestingBeaconStateBuilder<T: BeaconStateTypes> {
pub struct TestingBeaconStateBuilder<T: EthSpec> {
state: BeaconState<T>,
keypairs: Vec<Keypair>,
}
impl<T: BeaconStateTypes> TestingBeaconStateBuilder<T> {
impl<T: EthSpec> TestingBeaconStateBuilder<T> {
/// Attempts to load validators from a file in `$HOME/.lighthouse/keypairs.raw_keypairs`. If
/// the file is unavailable, it generates the keys at runtime.
///

View File

@ -16,7 +16,7 @@ impl TestingPendingAttestationBuilder {
///
/// * The aggregation and custody bitfields will all be empty, they need to be set with
/// `Self::add_committee_participation`.
pub fn new<T: BeaconStateTypes>(
pub fn new<T: EthSpec>(
state: &BeaconState<T>,
shard: u64,
slot: Slot,

View File

@ -7,8 +7,7 @@ use std::fs::File;
use std::io::{Error, ErrorKind};
use std::path::PathBuf;
use types::{
BeaconStateTypes, ChainSpec, FewValidatorsStateTypes, FoundationStateTypes,
LighthouseTestnetStateTypes,
ChainSpec, EthSpec, FewValidatorsEthSpec, FoundationEthSpec, LighthouseTestnetEthSpec,
};
/// Stores the core configuration for this validator instance.
@ -34,7 +33,7 @@ impl Default for Config {
let server = "localhost:5051".to_string();
let spec = FoundationStateTypes::spec();
let spec = FoundationEthSpec::spec();
Self {
data_dir,
@ -68,9 +67,9 @@ impl Config {
if let Some(spec_str) = args.value_of("spec") {
info!(log, "Using custom spec: {:?}", spec_str);
config.spec = match spec_str {
"foundation" => FoundationStateTypes::spec(),
"few_validators" => FewValidatorsStateTypes::spec(),
"lighthouse_testnet" => LighthouseTestnetStateTypes::spec(),
"foundation" => FoundationEthSpec::spec(),
"few_validators" => FewValidatorsEthSpec::spec(),
"lighthouse_testnet" => LighthouseTestnetEthSpec::spec(),
// Should be impossible due to clap's `possible_values(..)` function.
_ => unreachable!(),
};