diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index e7be7bebb..5e451b5e4 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -49,13 +49,12 @@ use spec::CommonParams; use types::transaction::{self, UnverifiedTransaction, SignedTransaction}; use ethkey::{Signature}; -use machine::{Machine, LocalizedMachine as Localized}; +use machine::{self, Machine, AuxiliaryRequest, AuxiliaryData}; use ethereum_types::{H256, U256, Address}; use unexpected::{Mismatch, OutOfBounds}; use bytes::Bytes; use types::ancestry_action::AncestryAction; use block::ExecutedBlock; -use machine; /// Default EIP-210 contract code. /// As defined in https://github.com/ethereum/EIPs/pull/210 @@ -177,8 +176,7 @@ pub type PendingTransitionStore<'a> = Fn(H256) -> Option: Send + Sync { /// Generate a proof, given the state. - // TODO: make this into an &M::StateContext - fn generate_proof<'a>(&self, state: &>::StateContext) -> Result, String>; + fn generate_proof<'a>(&self, state: &machine::Call) -> Result, String>; /// Check a proof generated elsewhere (potentially by a peer). // `engine` needed to check state proofs, while really this should // just be state machine params. @@ -218,7 +216,7 @@ impl<'a, M: Machine> ConstructedVerifier<'a, M> { /// Results of a query of whether an epoch change occurred at the given block. pub enum EpochChange { /// Cannot determine until more data is passed. - Unsure(M::AuxiliaryRequest), + Unsure(AuxiliaryRequest), /// No epoch change. No, /// The epoch will change, with proof. @@ -310,7 +308,7 @@ pub trait Engine: Sync + Send { fn verify_block_external(&self, _header: &Header) -> Result<(), M::Error> { Ok(()) } /// Genesis epoch data. - fn genesis_epoch_data<'a>(&self, _header: &Header, _state: &>::StateContext) -> Result, String> { Ok(Vec::new()) } + fn genesis_epoch_data<'a>(&self, _header: &Header, _state: &machine::Call) -> Result, String> { Ok(Vec::new()) } /// Whether an epoch change is signalled at the given header but will require finality. /// If a change can be enacted immediately then return `No` from this function but @@ -321,7 +319,7 @@ pub trait Engine: Sync + Send { /// Return `Yes` or `No` when the answer is definitively known. /// /// Should not interact with state. - fn signals_epoch_end<'a>(&self, _header: &Header, _aux: >::AuxiliaryData) + fn signals_epoch_end<'a>(&self, _header: &Header, _aux: AuxiliaryData<'a>) -> EpochChange { EpochChange::No diff --git a/ethcore/src/machine/impls.rs b/ethcore/src/machine/impls.rs index 4cb052b9f..90d410c70 100644 --- a/ethcore/src/machine/impls.rs +++ b/ethcore/src/machine/impls.rs @@ -430,8 +430,6 @@ pub enum AuxiliaryRequest { impl super::Machine for EthereumMachine { type EngineClient = ::client::EngineClient; - type AuxiliaryRequest = AuxiliaryRequest; - type AncestryAction = ::types::ancestry_action::AncestryAction; type Error = Error; @@ -444,11 +442,6 @@ impl super::Machine for EthereumMachine { } } -impl<'a> super::LocalizedMachine<'a> for EthereumMachine { - type StateContext = Call<'a>; - type AuxiliaryData = AuxiliaryData<'a>; -} - // Try to round gas_limit a bit so that: // 1) it will still be in desired range // 2) it will be a nearest (with tendency to increase) multiple of PARITY_GAS_LIMIT_DETERMINANT diff --git a/ethcore/src/machine/traits.rs b/ethcore/src/machine/traits.rs index 4d4004bff..1523885e0 100644 --- a/ethcore/src/machine/traits.rs +++ b/ethcore/src/machine/traits.rs @@ -21,13 +21,9 @@ use ethereum_types::{U256, Address}; use block::ExecutedBlock; /// Generalization of types surrounding blockchain-suitable state machines. -pub trait Machine: for<'a> LocalizedMachine<'a> { +pub trait Machine: Send + Sync { /// A handle to a blockchain client for this machine. type EngineClient: ?Sized; - /// A description of needed auxiliary data. - type AuxiliaryRequest; - /// Actions taken on ancestry blocks when commiting a new block. - type AncestryAction; /// Errors which can occur when querying or interacting with the machine. type Error; @@ -39,13 +35,3 @@ pub trait Machine: for<'a> LocalizedMachine<'a> { /// Increment the balance of an account in the state of the live block. fn add_balance(&self, live: &mut ExecutedBlock, address: &Address, amount: &U256) -> Result<(), Self::Error>; } - -/// Machine-related types localized to a specific lifetime. -// TODO: this is a workaround for a lack of associated type constructors in the language. -pub trait LocalizedMachine<'a>: Sync + Send { - /// Definition of auxiliary data associated to a specific block. - type AuxiliaryData: 'a; - /// A context providing access to the state in a controlled capacity. - /// Generally also provides verifiable proofs. - type StateContext: ?Sized + 'a; -}