Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Allow single opcode stepping for EVM #9051

Merged
merged 23 commits into from
Aug 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3850eae
Feed in ActionParams on VM creation
sorpaas Jul 5, 2018
73f58ea
Fix ethcore after Vm interface change
sorpaas Jul 5, 2018
db4f030
Move informant inside Interpreter struct
sorpaas Jul 5, 2018
b3cbf24
Move do_trace to Interpreter struct
sorpaas Jul 5, 2018
3145fc5
Move all remaining exec variables to Interpreter struct
sorpaas Jul 5, 2018
b98129e
Refactor VM to allow single opcode step
sorpaas Jul 5, 2018
bb944c8
Fix all EVM tests
sorpaas Jul 5, 2018
9ea1409
Fix all wasm tests
sorpaas Jul 5, 2018
c8a3a54
Fix wasm runner tests
sorpaas Jul 5, 2018
5f0a419
Fix a check case where code length is zero
sorpaas Jul 5, 2018
e2bb546
Fix jsontests compile
sorpaas Jul 5, 2018
bb303d7
Fix cargo lock
sorpaas Jul 5, 2018
8578b20
Use match instead of expect
sorpaas Jul 17, 2018
9e8b23c
Use cheaper check reader.len() == 0 for the initial special case
sorpaas Jul 17, 2018
e6fb25b
Get rid of try_and_done! macro by using Result<(), ReturnType>
sorpaas Jul 17, 2018
151101a
Use Never instead of ()
sorpaas Jul 17, 2018
ee4a476
Merge branch 'master' of https://github.com/paritytech/parity into sp…
sorpaas Jul 24, 2018
1d1a319
Fix parity-bytes path
sorpaas Jul 24, 2018
45f715b
Bypass gasometer lifetime problem by borrow only for a instance
sorpaas Jul 24, 2018
21b8729
typo: missing {
sorpaas Jul 24, 2018
104f844
Fix ethcore test compile
sorpaas Jul 24, 2018
f936a56
Fix evm tests
sorpaas Jul 24, 2018
b165893
Merge branch 'master' of https://github.com/paritytech/parity into sp…
sorpaas Aug 3, 2018
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ethcore/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
bit-set = "0.4"
parity-bytes = { git = "https://github.com/paritytech/parity-common" }
ethereum-types = "0.3"
heapsize = "0.4"
lazy_static = "1.0"
Expand Down
6 changes: 6 additions & 0 deletions ethcore/evm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ impl Finalize for Result<GasLeft> {
}
}

impl Finalize for Error {
fn finalize<E: Ext>(self, _ext: E) -> Result<FinalizationResult> {
Err(self)
}
}

/// Cost calculation type. For low-gas usage we calculate costs using usize instead of U256
pub trait CostType: Sized + From<usize> + Copy
+ ops::Mul<Output=Self> + ops::Div<Output=Self> + ops::Add<Output=Self> +ops::Sub<Output=Self>
Expand Down
20 changes: 14 additions & 6 deletions ethcore/evm/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
//! Evm factory.
//!
use std::sync::Arc;
use vm::Vm;
use vm::{Vm, Schedule};
use ethereum_types::U256;
use super::vm::ActionParams;
use super::interpreter::SharedCache;
use super::vmtype::VMType;

Expand All @@ -32,12 +33,12 @@ pub struct Factory {
impl Factory {
/// Create fresh instance of VM
/// Might choose implementation depending on supplied gas.
pub fn create(&self, gas: &U256) -> Box<Vm> {
pub fn create(&self, params: ActionParams, schedule: &Schedule, depth: usize) -> Box<Vm> {
match self.evm {
VMType::Interpreter => if Self::can_fit_in_usize(gas) {
Box::new(super::interpreter::Interpreter::<usize>::new(self.evm_cache.clone()))
VMType::Interpreter => if Self::can_fit_in_usize(&params.gas) {
Box::new(super::interpreter::Interpreter::<usize>::new(params, self.evm_cache.clone(), schedule, depth))
} else {
Box::new(super::interpreter::Interpreter::<U256>::new(self.evm_cache.clone()))
Box::new(super::interpreter::Interpreter::<U256>::new(params, self.evm_cache.clone(), schedule, depth))
}
}
}
Expand Down Expand Up @@ -68,7 +69,14 @@ impl Default for Factory {

#[test]
fn test_create_vm() {
let _vm = Factory::default().create(&U256::zero());
use vm::Ext;
use vm::tests::FakeExt;
use bytes::Bytes;

let mut params = ActionParams::default();
params.code = Some(Arc::new(Bytes::default()));
let ext = FakeExt::new();
let _vm = Factory::default().create(params, ext.schedule(), ext.depth());
}

/// Create tests by injecting different VM factories
Expand Down
Loading