Generalize engine trait (#6591)
* move common forks and parameters to common params * port specs over to new format * fix RPC tests * parity-machine skeleton * remove block type * extract out ethereum-specific methods into EthereumMachine * beginning to integrate Machine into engines. dealing with stale transitions in Ethash * initial porting to machine * move block reward back into engine * abstract block reward logic * move last hash and DAO HF logic into machine * begin making engine function parameters generic * abstract epoch verifier and ethash block reward logic * instantiate special ethereummachine for ethash in spec * optional full verification in verify_block_family * re-instate tx_filter in a way that works for all engines * fix warnings * fix most tests, further generalize engine trait * uncomment nullengine, get ethcore tests compiling * fix warnings * update a bunch of specs * re-enable engine signer, validator set, and transition handler * migrate basic_authority engine * move last hashes into executedblock * port tendermint * make all ethcore tests pass * json-tests compilation * fix RPC tests: change in gas limit for new block changed PoW hash * fix minor grumbles * validate chainspecs * fix broken import * fix transaction verification for pre-homestead
This commit is contained in:
committed by
Gav Wood
parent
d8af9f4e7b
commit
bc167a211b
@@ -18,7 +18,6 @@ use std::sync::Arc;
|
||||
use super::test_common::*;
|
||||
use state::{Backend as StateBackend, State, Substate};
|
||||
use executive::*;
|
||||
use engines::Engine;
|
||||
use evm::{VMType, Finalize};
|
||||
use vm::{
|
||||
self, ActionParams, CallType, Schedule, Ext,
|
||||
@@ -34,6 +33,7 @@ use bytes::{Bytes, BytesRef};
|
||||
use trie;
|
||||
use rlp::RlpStream;
|
||||
use hash::keccak;
|
||||
use machine::EthereumMachine as Machine;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
struct CallCreate {
|
||||
@@ -57,22 +57,22 @@ impl From<ethjson::vm::Call> for CallCreate {
|
||||
|
||||
/// Tiny wrapper around executive externalities.
|
||||
/// Stores callcreates.
|
||||
struct TestExt<'a, T: 'a, V: 'a, B: 'a, E: 'a>
|
||||
where T: Tracer, V: VMTracer, B: StateBackend, E: Engine + ?Sized
|
||||
struct TestExt<'a, T: 'a, V: 'a, B: 'a>
|
||||
where T: Tracer, V: VMTracer, B: StateBackend
|
||||
{
|
||||
ext: Externalities<'a, T, V, B, E>,
|
||||
ext: Externalities<'a, T, V, B>,
|
||||
callcreates: Vec<CallCreate>,
|
||||
nonce: U256,
|
||||
sender: Address,
|
||||
}
|
||||
|
||||
impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> TestExt<'a, T, V, B, E>
|
||||
where T: Tracer, V: VMTracer, B: StateBackend, E: Engine + ?Sized
|
||||
impl<'a, T: 'a, V: 'a, B: 'a> TestExt<'a, T, V, B>
|
||||
where T: Tracer, V: VMTracer, B: StateBackend,
|
||||
{
|
||||
fn new(
|
||||
state: &'a mut State<B>,
|
||||
info: &'a EnvInfo,
|
||||
engine: &'a E,
|
||||
machine: &'a Machine,
|
||||
depth: usize,
|
||||
origin_info: OriginInfo,
|
||||
substate: &'a mut Substate,
|
||||
@@ -84,15 +84,15 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> TestExt<'a, T, V, B, E>
|
||||
let static_call = false;
|
||||
Ok(TestExt {
|
||||
nonce: state.nonce(&address)?,
|
||||
ext: Externalities::new(state, info, engine, depth, origin_info, substate, output, tracer, vm_tracer, static_call),
|
||||
ext: Externalities::new(state, info, machine, depth, origin_info, substate, output, tracer, vm_tracer, static_call),
|
||||
callcreates: vec![],
|
||||
sender: address,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for TestExt<'a, T, V, B, E>
|
||||
where T: Tracer, V: VMTracer, B: StateBackend, E: Engine + ?Sized
|
||||
impl<'a, T: 'a, V: 'a, B: 'a> Ext for TestExt<'a, T, V, B>
|
||||
where T: Tracer, V: VMTracer, B: StateBackend
|
||||
{
|
||||
fn storage_at(&self, key: &H256) -> vm::Result<H256> {
|
||||
self.ext.storage_at(key)
|
||||
@@ -231,7 +231,12 @@ fn do_json_test_for(vm_type: &VMType, json_data: &[u8]) -> Vec<String> {
|
||||
let mut state = get_temp_state();
|
||||
state.populate_from(From::from(vm.pre_state.clone()));
|
||||
let info = From::from(vm.env);
|
||||
let engine = TestEngine::new(1);
|
||||
let machine = {
|
||||
let mut machine = ::ethereum::new_frontier_test_machine();
|
||||
machine.set_schedule_creation_rules(Box::new(move |s, _| s.max_depth = 1));
|
||||
machine
|
||||
};
|
||||
|
||||
let params = ActionParams::from(vm.transaction);
|
||||
|
||||
let mut substate = Substate::new();
|
||||
@@ -245,7 +250,7 @@ fn do_json_test_for(vm_type: &VMType, json_data: &[u8]) -> Vec<String> {
|
||||
let mut ex = try_fail!(TestExt::new(
|
||||
&mut state,
|
||||
&info,
|
||||
&engine,
|
||||
&machine,
|
||||
0,
|
||||
OriginInfo::from(¶ms),
|
||||
&mut substate,
|
||||
|
||||
Reference in New Issue
Block a user