Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -177,8 +176,7 @@ pub type PendingTransitionStore<'a> = Fn(H256) -> Option<epoch::PendingTransitio
/// Proof dependent on state.
pub trait StateDependentProof<M: Machine>: Send + Sync {
/// Generate a proof, given the state.
// TODO: make this into an &M::StateContext
fn generate_proof<'a>(&self, state: &<M as Localized<'a>>::StateContext) -> Result<Vec<u8>, String>;
fn generate_proof<'a>(&self, state: &machine::Call) -> Result<Vec<u8>, 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.
Expand Down Expand Up @@ -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<M: Machine> {
/// Cannot determine until more data is passed.
Unsure(M::AuxiliaryRequest),
Unsure(AuxiliaryRequest),
/// No epoch change.
No,
/// The epoch will change, with proof.
Expand Down Expand Up @@ -310,7 +308,7 @@ pub trait Engine<M: Machine>: 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: &<M as Localized<'a>>::StateContext) -> Result<Vec<u8>, String> { Ok(Vec::new()) }
fn genesis_epoch_data<'a>(&self, _header: &Header, _state: &machine::Call) -> Result<Vec<u8>, 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
Expand All @@ -321,7 +319,7 @@ pub trait Engine<M: Machine>: 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: <M as Localized<'a>>::AuxiliaryData)
fn signals_epoch_end<'a>(&self, _header: &Header, _aux: AuxiliaryData<'a>)
-> EpochChange<M>
{
EpochChange::No
Expand Down
7 changes: 0 additions & 7 deletions ethcore/src/machine/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
16 changes: 1 addition & 15 deletions ethcore/src/machine/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}