moved runtime data to jit

This commit is contained in:
debris 2016-01-09 00:55:17 +01:00
parent 4932720d58
commit 43c612fa89
4 changed files with 39 additions and 46 deletions

View File

@ -109,7 +109,6 @@ impl<'a> Executive<'a> {
fn create(&mut self) -> ExecutiveResult {
let address = self.params.address.clone();
//let new_address = contract_address(&address, &self.state.nonce(&address));
let new_address = self.params.address.clone();
self.state.inc_nonce(&address);

View File

@ -8,6 +8,43 @@ use util::bytes::*;
use util::sha3::*;
use evm;
/// Ethcore representation of evmjit runtime data.
pub struct RuntimeData {
pub gas: U256,
pub gas_price: U256,
pub call_data: Vec<u8>,
pub address: Address,
pub caller: Address,
pub origin: Address,
pub call_value: U256,
pub coinbase: Address,
pub difficulty: U256,
pub gas_limit: U256,
pub number: u64,
pub timestamp: u64,
pub code: Vec<u8>
}
impl RuntimeData {
pub fn new() -> RuntimeData {
RuntimeData {
gas: U256::zero(),
gas_price: U256::zero(),
call_data: vec![],
address: Address::new(),
caller: Address::new(),
origin: Address::new(),
call_value: U256::zero(),
coinbase: Address::new(),
difficulty: U256::zero(),
gas_limit: U256::zero(),
number: 0,
timestamp: 0,
code: vec![]
}
}
}
/// Should be used to convert jit types to ethcore
trait FromJit<T>: Sized {
fn from_jit(input: T) -> Self;
@ -94,7 +131,7 @@ impl IntoJit<evmjit::H256> for Address {
}
}
impl IntoJit<evmjit::RuntimeDataHandle> for evm::RuntimeData {
impl IntoJit<evmjit::RuntimeDataHandle> for RuntimeData {
fn into_jit(self) -> evmjit::RuntimeDataHandle {
let mut data = evmjit::RuntimeDataHandle::new();
assert!(self.gas <= U256::from(u64::max_value()), "evmjit gas must be lower than 2 ^ 64");
@ -268,7 +305,7 @@ impl evm::Evm for JitEvm {
// Dirty hack. This is unsafe, but we interact with ffi, so it's justified.
let ext_adapter: ExtAdapter<'static> = unsafe { ::std::mem::transmute(ExtAdapter::new(ext)) };
let mut ext_handle = evmjit::ExtHandle::new(ext_adapter);
let mut data = evm::RuntimeData::new();
let mut data = RuntimeData::new();
let params = ext.params();
data.gas = params.gas;
data.gas_price = params.gas_price;

View File

@ -1,7 +1,6 @@
//! Ethereum virtual machine.
pub mod ext;
pub mod runtime_data;
pub mod evm;
pub mod vmfactory;
pub mod logentry;
@ -12,7 +11,6 @@ mod jit;
pub use self::evm::{Evm, ReturnCode};
pub use self::ext::{Ext};
pub use self::runtime_data::RuntimeData;
pub use self::logentry::LogEntry;
pub use self::vmfactory::VmFactory;
pub use self::executive::Executive;

View File

@ -1,41 +0,0 @@
//! Immutable runtime data.
use util::hash::*;
use util::uint::*;
// call_data
pub struct RuntimeData {
pub gas: U256,
pub gas_price: U256,
pub call_data: Vec<u8>,
pub address: Address,
pub caller: Address,
pub origin: Address,
pub call_value: U256,
pub coinbase: Address,
pub difficulty: U256,
pub gas_limit: U256,
pub number: u64,
pub timestamp: u64,
pub code: Vec<u8>
}
impl RuntimeData {
pub fn new() -> RuntimeData {
RuntimeData {
gas: U256::zero(),
gas_price: U256::zero(),
call_data: vec![],
address: Address::new(),
caller: Address::new(),
origin: Address::new(),
call_value: U256::zero(),
coinbase: Address::new(),
difficulty: U256::zero(),
gas_limit: U256::zero(),
number: 0,
timestamp: 0,
code: vec![]
}
}
}