Fixing code compilation

This commit is contained in:
Tomusdrw 2016-01-16 02:25:08 +01:00
parent 689b1fd112
commit aef38a9abc
3 changed files with 10 additions and 9 deletions

View File

@ -215,7 +215,7 @@ pub struct Interpreter;
impl evm::Evm for Interpreter {
fn exec(&self, params: &ActionParams, ext: &mut evm::Ext) -> evm::Result {
let code = &params.code;
let code = &params.code.clone().unwrap();
let valid_jump_destinations = self.find_jump_destinations(&code);
let mut current_gas = params.gas.clone();
@ -653,9 +653,10 @@ impl Interpreter {
let big_id = stack.pop_back();
let id = big_id.low_u64() as usize;
let max = id.wrapping_add(32);
let bound = cmp::min(params.data.len(), max);
if id < bound && big_id < U256::from(params.data.len()) {
let mut v = params.data[id..bound].to_vec();
let data = params.data.clone().unwrap();
let bound = cmp::min(data.len(), max);
if id < bound && big_id < U256::from(data.len()) {
let mut v = data[id..bound].to_vec();
v.resize(32, 0);
stack.push(U256::from(&v[..]))
} else {
@ -663,7 +664,7 @@ impl Interpreter {
}
},
instructions::CALLDATASIZE => {
stack.push(U256::from(params.data.len()));
stack.push(U256::from(params.data.clone().unwrap().len()));
},
instructions::CODESIZE => {
stack.push(U256::from(code.len()));
@ -674,10 +675,10 @@ impl Interpreter {
stack.push(U256::from(len));
},
instructions::CALLDATACOPY => {
self.copy_data_to_memory(mem, stack, &params.data);
self.copy_data_to_memory(mem, stack, &params.data.clone().unwrap());
},
instructions::CODECOPY => {
self.copy_data_to_memory(mem, stack, &params.code);
self.copy_data_to_memory(mem, stack, &params.code.clone().unwrap());
},
instructions::EXTCODECOPY => {
let address = u256_to_address(&stack.pop_back());

View File

@ -103,7 +103,7 @@ fn test_stack_underflow() {
let mut params = ActionParams::new();
params.address = address.clone();
params.gas = U256::from(100_000);
params.code = code;
params.code = Some(code);
let mut ext = FakeExt::new();
let err = {

View File

@ -784,7 +784,7 @@ mod tests {
params.sender = sender.clone();
params.origin = sender.clone();
params.gas = U256::from(0x0186a0);
params.code = code.clone();
params.code = Some(code.clone());
params.value = U256::from_str("0de0b6b3a7640000").unwrap();
let mut state = State::new_temp();
state.add_balance(&sender, &U256::from_str("152d02c7e14af6800000").unwrap());