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

Ethcore crate split part 1 #6041

Merged
merged 3 commits into from
Jul 12, 2017
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
36 changes: 33 additions & 3 deletions Cargo.lock

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

7 changes: 3 additions & 4 deletions ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bloomchain = "0.1"
bn = { git = "https://github.com/paritytech/bn" }
byteorder = "1.0"
clippy = { version = "0.0.103", optional = true}
common-types = { path = "types" }
crossbeam = "0.2.9"
env_logger = "0.4"
ethabi = "2.0"
Expand All @@ -31,7 +32,7 @@ ethcore-util = { path = "../util" }
ethjson = { path = "../json" }
ethkey = { path = "../ethkey" }
ethstore = { path = "../ethstore" }
evmjit = { path = "../evmjit", optional = true }
evm = { path = "evm" }
futures = "0.1"
hardware-wallet = { path = "../hw" }
hyper = { git = "https://github.com/paritytech/hyper", default-features = false }
Expand All @@ -52,14 +53,12 @@ semver = "0.6"
stats = { path = "../util/stats" }
time = "0.1"
transient-hashmap = "0.4"
parity-wasm = "0.12"
wasm-utils = { git = "https://github.com/paritytech/wasm-utils" }

[dev-dependencies]
native-contracts = { path = "native_contracts", features = ["test_contracts"] }

[features]
jit = ["evmjit"]
jit = ["evm/jit"]
evm-debug = ["slow-blocks"]
evm-debug-tests = ["evm-debug"]
slow-blocks = [] # Use SLOW_TX_DURATION="50" (compile time!) to track transactions over 50ms
Expand Down
1 change: 0 additions & 1 deletion ethcore/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
extern crate ethcore_ipc_codegen;

fn main() {
ethcore_ipc_codegen::derive_binary("src/types/mod.rs.in").unwrap();
ethcore_ipc_codegen::derive_ipc_cond("src/client/traits.rs", cfg!(feature="ipc")).unwrap();
ethcore_ipc_codegen::derive_ipc_cond("src/snapshot/snapshot_service_trait.rs", cfg!(feature="ipc")).unwrap();
ethcore_ipc_codegen::derive_ipc_cond("src/client/chain_notify.rs", cfg!(feature="ipc")).unwrap();
Expand Down
23 changes: 23 additions & 0 deletions ethcore/evm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "evm"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]

[dependencies]
bit-set = "0.4"
byteorder = "1.0"
common-types = { path = "../types" }
ethcore-util = { path = "../../util" }
evmjit = { path = "../../evmjit", optional = true }
ethjson = { path = "../../json" }
lazy_static = "0.2"
log = "0.3"
rlp = { path = "../../util/rlp" }
parity-wasm = "0.12"
wasm-utils = { git = "https://github.com/paritytech/wasm-utils" }

[dev-dependencies]
rustc-hex = "1.0"

[features]
jit = ["evmjit"]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use util::{Address, Bytes, U256};
use util::hash::{H256};
use util::sha3::{Hashable, SHA3_EMPTY};
use ethjson;
use types::executed::CallType;

use {CallType};

use std::sync::Arc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern crate test;
use self::test::{Bencher, black_box};

use util::*;
use action_params::ActionParams;
use evm::action_params::ActionParams;
use evm::{self, Factory, VMType};
use evm::tests::FakeExt;

Expand Down
70 changes: 70 additions & 0 deletions ethcore/evm/src/call_type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//! EVM call types.

use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp};

/// The type of the call-like instruction.
#[derive(Debug, PartialEq, Clone)]
pub enum CallType {
/// Not a CALL.
None,
/// CALL.
Call,
/// CALLCODE.
CallCode,
/// DELEGATECALL.
DelegateCall,
/// STATICCALL
StaticCall,
}

impl Encodable for CallType {
fn rlp_append(&self, s: &mut RlpStream) {
let v = match *self {
CallType::None => 0u32,
CallType::Call => 1,
CallType::CallCode => 2,
CallType::DelegateCall => 3,
CallType::StaticCall => 4,
};
Encodable::rlp_append(&v, s);
}
}

impl Decodable for CallType {
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
rlp.as_val().and_then(|v| Ok(match v {
0u32 => CallType::None,
1 => CallType::Call,
2 => CallType::CallCode,
3 => CallType::DelegateCall,
4 => CallType::StaticCall,
_ => return Err(DecoderError::Custom("Invalid value of CallType item")),
}))
}
}

#[cfg(test)]
mod tests {
use rlp::*;
use super::CallType;

#[test]
fn encode_call_type() {
let ct = CallType::Call;

let mut s = RlpStream::new_list(2);
s.append(&ct);
assert!(!s.is_finished(), "List shouldn't finished yet");
s.append(&ct);
assert!(s.is_finished(), "List should be finished now");
s.out();
}

#[test]
fn should_encode_and_decode_call_type() {
let original = CallType::Call;
let encoded = encode(&original);
let decoded = decode(&encoded);
assert_eq!(original, decoded);
}
}
4 changes: 2 additions & 2 deletions ethcore/src/env_info.rs → ethcore/evm/src/env_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use std::cmp;
use std::sync::Arc;
use util::{U256, Address, H256, Hashable};
use header::BlockNumber;
use types::BlockNumber;
use ethjson;

/// Simple vector of hashes, should be at most 256 items large, can be smaller if being used
Expand Down Expand Up @@ -82,7 +82,7 @@ mod tests {
use ethjson;

#[test]
fn it_serializes_form_json() {
fn it_serializes_from_json() {
let env_info = EnvInfo::from(ethjson::vm::Env {
author: ethjson::hash::Address(Address::from_str("000000f00000000f000000000000f00000000f00").unwrap()),
number: ethjson::uint::Uint(U256::from(1_112_339)),
Expand Down
11 changes: 2 additions & 9 deletions ethcore/src/evm/evm.rs → ethcore/evm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use std::{ops, cmp, fmt};
use util::{U128, U256, U512, trie};
use action_params::ActionParams;
use evm::Ext;
use builtin;
use {Ext};

use super::wasm;

/// Evm errors.
Expand Down Expand Up @@ -77,12 +77,6 @@ impl From<Box<trie::TrieError>> for Error {
}
}

impl From<builtin::Error> for Error {
fn from(err: builtin::Error) -> Self {
Error::BuiltIn(err.0)
}
}

impl From<wasm::RuntimeError> for Error {
fn from(err: wasm::RuntimeError) -> Self {
Error::Wasm(format!("Runtime error: {:?}", err))
Expand All @@ -109,7 +103,6 @@ impl fmt::Display for Error {
/// A specialized version of Result over EVM errors.
pub type Result<T> = ::std::result::Result<T, Error>;


/// Return data buffer. Holds memory from a previous call and a slice into that memory.
#[derive(Debug)]
pub struct ReturnData {
Expand Down
7 changes: 4 additions & 3 deletions ethcore/src/evm/ext.rs → ethcore/evm/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
//! Interface for Evm externalities.

use util::*;
use evm::{self, Schedule, ReturnData};
use env_info::*;
use types::executed::CallType;
use call_type::CallType;
use env_info::EnvInfo;
use schedule::Schedule;
use evm::{self, ReturnData};

/// Result of externalities create function.
pub enum ContractCreateResult {
Expand Down
File renamed without changes.
Loading