vm ext create function uses u256 instead of u64

This commit is contained in:
debris 2016-01-13 22:29:49 +01:00
parent 48e74e5874
commit 6f17b7b44b
5 changed files with 11 additions and 11 deletions

View File

@ -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<Address>), Error>;
fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> Result<(U256, Option<Address>), Error>;
/// Message call.
///

View File

@ -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()

View File

@ -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<Address>), evm::Error> {
fn create(&mut self, _gas: &U256, _value: &U256, _code: &[u8]) -> result::Result<(U256, Option<Address>), evm::Error> {
unimplemented!();
}

View File

@ -349,10 +349,10 @@ impl<'a> Ext for Externalities<'a> {
}
}
fn create(&mut self, gas: u64, value: &U256, code: &[u8]) -> Result<(u64, Option<Address>), evm::Error> {
fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> Result<(U256, Option<Address>), 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(&params, self.substate).map(|gas_left| (gas_left.low_u64(), Some(address)))
ex.create(&params, 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<u64, evm::Error> {

View File

@ -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<Address>), evm::Error> {
fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> Result<(U256, Option<Address>), 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)))