This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* split out types into separate crate * split out evm into its own crate
- Loading branch information
Showing
108 changed files
with
805 additions
and
776 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.