diff --git a/src/evm/ext.rs b/src/evm/ext.rs index 7a11412a9..71fcf2696 100644 --- a/src/evm/ext.rs +++ b/src/evm/ext.rs @@ -25,7 +25,7 @@ pub trait Ext { /// If contract creation is successfull, return gas_left and contract address, /// If depth is too big or transfer value exceeds balance, return None /// Otherwise return appropriate `Error`. - fn create(&mut self, gas: u64, value: &U256, code: &[u8]) -> Result<(u64, Option
), Error>; + fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> Result<(U256, Option
), Error>; /// Message call. /// diff --git a/src/evm/jit.rs b/src/evm/jit.rs index cf7280f70..71789ef2a 100644 --- a/src/evm/jit.rs +++ b/src/evm/jit.rs @@ -209,9 +209,9 @@ impl<'a> evmjit::Ext for ExtAdapter<'a> { init_size: u64, address: *mut evmjit::H256) { unsafe { - match self.ext.create(*io_gas, &U256::from_jit(&*endowment), slice::from_raw_parts(init_beg, init_size as usize)) { + match self.ext.create(&U256::from(*io_gas), &U256::from_jit(&*endowment), slice::from_raw_parts(init_beg, init_size as usize)) { Ok((gas_left, opt)) => { - *io_gas = gas_left; + *io_gas = gas_left.low_u64(); *address = match opt { Some(addr) => addr.into_jit(), _ => Address::new().into_jit() diff --git a/src/evm/tests.rs b/src/evm/tests.rs index 4a50fcdba..4de68bc37 100644 --- a/src/evm/tests.rs +++ b/src/evm/tests.rs @@ -42,7 +42,7 @@ impl Ext for FakeExt { self.blockhashes.get(number).unwrap_or(&H256::new()).clone() } - fn create(&mut self, _gas: u64, _value: &U256, _code: &[u8]) -> result::Result<(u64, Option
), evm::Error> { + fn create(&mut self, _gas: &U256, _value: &U256, _code: &[u8]) -> result::Result<(U256, Option
), evm::Error> { unimplemented!(); } diff --git a/src/executive.rs b/src/executive.rs index da21e35a7..b10baa795 100644 --- a/src/executive.rs +++ b/src/executive.rs @@ -349,10 +349,10 @@ impl<'a> Ext for Externalities<'a> { } } - fn create(&mut self, gas: u64, value: &U256, code: &[u8]) -> Result<(u64, Option
), evm::Error> { + fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> Result<(U256, Option
), evm::Error> { // if balance is insufficient or we are to deep, return if self.state.balance(&self.params.address) < *value || self.depth >= self.schedule.stack_limit { - return Ok((gas, None)); + return Ok((*gas, None)); } // create new contract address @@ -363,7 +363,7 @@ impl<'a> Ext for Externalities<'a> { address: address.clone(), sender: self.params.address.clone(), origin: self.params.origin.clone(), - gas: U256::from(gas), + gas: *gas, gas_price: self.params.gas_price.clone(), value: value.clone(), code: code.to_vec(), @@ -372,7 +372,7 @@ impl<'a> Ext for Externalities<'a> { let mut ex = Executive::from_parent(self.state, self.info, self.engine, self.depth); ex.state.inc_nonce(&self.params.address); - ex.create(¶ms, self.substate).map(|gas_left| (gas_left.low_u64(), Some(address))) + ex.create(¶ms, self.substate).map(|gas_left| (gas_left, Some(address))) } fn call(&mut self, gas: u64, call_gas: u64, receive_address: &Address, value: &U256, data: &[u8], code_address: &Address, output: &mut [u8]) -> Result { diff --git a/src/tests/executive.rs b/src/tests/executive.rs index 5c47939c0..7e2b7ecfd 100644 --- a/src/tests/executive.rs +++ b/src/tests/executive.rs @@ -71,7 +71,7 @@ impl<'a> Ext for TestExt<'a> { self.ext.blockhash(number) } - fn create(&mut self, gas: u64, value: &U256, code: &[u8]) -> Result<(u64, Option
), evm::Error> { + fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> Result<(U256, Option
), evm::Error> { // in call and create we need to check if we exited with insufficient balance or max limit reached. // in case of reaching max depth, we should store callcreates. Otherwise, ignore. let res = self.ext.create(gas, value, code); @@ -82,7 +82,7 @@ impl<'a> Ext for TestExt<'a> { self.callcreates.push(CallCreate { data: code.to_vec(), destination: address.clone(), - _gas_limit: U256::from(gas), + _gas_limit: *gas, value: *value }); Ok((gas_left, Some(address))) @@ -94,7 +94,7 @@ impl<'a> Ext for TestExt<'a> { data: code.to_vec(), // TODO: address is not stored here? destination: Address::new(), - _gas_limit: U256::from(gas), + _gas_limit: *gas, value: *value }); Ok((gas_left, Some(address)))