Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ethcore/engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use machine::{
Machine,
executed_block::ExecutedBlock,
};
use vm::{EnvInfo, Schedule, CallType, ActionValue};
use vm::{EnvInfo, Schedule, ActionType, ActionValue};

use crate::signer::EngineSigner;

Expand Down Expand Up @@ -82,7 +82,7 @@ pub fn default_system_or_code_call<'a>(machine: &'a Machine, block: &'a mut Exec
Some(ActionValue::Apparent(U256::zero())),
U256::max_value(),
Some(data),
Some(CallType::StaticCall),
Some(ActionType::StaticCall),
)
},
};
Expand Down
29 changes: 19 additions & 10 deletions ethcore/evm/src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use ethereum_types::{U256, U512, H256, Address, BigEndianHash};


use vm::{
self, ActionParams, ParamsType, ActionValue, CallType, MessageCallResult,
self, ActionParams, ParamsType, ActionValue, ActionType, MessageCallResult,
ContractCreateResult, CreateContractAddress, ReturnData, GasLeft, Schedule,
TrapKind, TrapError
};
Expand Down Expand Up @@ -133,8 +133,8 @@ struct InterpreterParams {
pub value: ActionValue,
/// Input data.
pub data: Option<Bytes>,
/// Type of call
pub call_type: CallType,
/// Type of action
pub action_type: ActionType,
/// Param types encoding
pub params_type: ParamsType,
}
Expand All @@ -152,7 +152,7 @@ impl From<ActionParams> for InterpreterParams {
gas_price: params.gas_price,
value: params.value,
data: params.data,
call_type: params.call_type,
action_type: params.action_type,
params_type: params.params_type,
}
}
Expand Down Expand Up @@ -532,7 +532,9 @@ impl<Cost: CostType> Interpreter<Cost> {
let init_size = self.stack.pop_back();
let address_scheme = match instruction {
instructions::CREATE => CreateContractAddress::FromSenderAndNonce,
instructions::CREATE2 => CreateContractAddress::FromSenderSaltAndCodeHash(BigEndianHash::from_uint(&self.stack.pop_back())),
instructions::CREATE2 => CreateContractAddress::FromSenderSaltAndCodeHash(
BigEndianHash::from_uint(&self.stack.pop_back())
),
_ => unreachable!("instruction can only be CREATE/CREATE2 checked above; qed"),
};

Expand All @@ -553,7 +555,14 @@ impl<Cost: CostType> Interpreter<Cost> {

let contract_code = self.mem.read_slice(init_off, init_size);

let create_result = ext.create(&create_gas.as_u256(), &endowment, contract_code, &self.params.code_version, address_scheme, true);
let create_result = ext.create(
&create_gas.as_u256(),
&endowment,
contract_code,
&self.params.code_version,
address_scheme,
true,
);
return match create_result {
Ok(ContractCreateResult::Created(address, gas_left)) => {
self.stack.push(address_to_u256(address));
Expand Down Expand Up @@ -607,14 +616,14 @@ impl<Cost: CostType> Interpreter<Cost> {
return Err(vm::Error::MutableCallInStaticContext);
}
let has_balance = ext.balance(&self.params.address)? >= value.expect("value set for all but delegate call; qed");
(&self.params.address, &code_address, has_balance, CallType::Call)
(&self.params.address, &code_address, has_balance, ActionType::Call)
},
instructions::CALLCODE => {
let has_balance = ext.balance(&self.params.address)? >= value.expect("value set for all but delegate call; qed");
(&self.params.address, &self.params.address, has_balance, CallType::CallCode)
(&self.params.address, &self.params.address, has_balance, ActionType::CallCode)
},
instructions::DELEGATECALL => (&self.params.sender, &self.params.address, true, CallType::DelegateCall),
instructions::STATICCALL => (&self.params.address, &code_address, true, CallType::StaticCall),
instructions::DELEGATECALL => (&self.params.sender, &self.params.address, true, ActionType::DelegateCall),
instructions::STATICCALL => (&self.params.address, &code_address, true, ActionType::StaticCall),
_ => panic!(format!("Unexpected instruction {:?} in CALL branch.", instruction))
};

Expand Down
2 changes: 1 addition & 1 deletion ethcore/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mod instructions;
mod tests;

pub use vm::{
Schedule, CleanDustMode, EnvInfo, CallType, ActionParams, Ext,
Schedule, CleanDustMode, EnvInfo, ActionType, ActionParams, Ext,
ContractCreateResult, MessageCallResult, CreateContractAddress,
GasLeft, ReturnData
};
Expand Down
49 changes: 25 additions & 24 deletions ethcore/executive-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ mod tests {
test_helpers::{get_temp_state, get_temp_state_db}
};
use ethtrie;
use evm::CallType;
use machine::Machine;
use pod::{self, PodAccount, PodState};
use rustc_hex::FromHex;
Expand Down Expand Up @@ -324,6 +323,7 @@ mod tests {
value: 100.into(),
gas: 77412.into(),
init: vec![96, 16, 128, 96, 12, 96, 0, 57, 96, 0, 243, 0, 96, 0, 53, 84, 21, 96, 9, 87, 0, 91, 96, 32, 53, 96, 0, 53, 85],
creation_method: Some(trace::CreationMethod::Create),
}),
result: trace::Res::Create(trace::CreateResult {
gas_used: U256::from(3224),
Expand Down Expand Up @@ -381,6 +381,7 @@ mod tests {
value: 100.into(),
gas: 78792.into(),
init: vec![91, 96, 0, 86],
creation_method: Some(trace::CreationMethod::Create),
}),
result: trace::Res::FailedCreate(TraceError::OutOfGas),
subtraces: 0
Expand Down Expand Up @@ -419,7 +420,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(3),
Expand Down Expand Up @@ -460,7 +461,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(0),
Expand Down Expand Up @@ -501,7 +502,7 @@ mod tests {
value: 0.into(),
gas: 79_000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(3000),
Expand Down Expand Up @@ -543,7 +544,7 @@ mod tests {
value: 0.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(3_721), // in post-eip150
Expand Down Expand Up @@ -587,7 +588,7 @@ mod tests {
value: 0.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: 724.into(), // in post-eip150
Expand All @@ -602,7 +603,7 @@ mod tests {
value: 0.into(),
gas: 4096.into(),
input: vec![],
call_type: CallType::CallCode,
call_type: Some(trace::CallType::CallCode),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: 3.into(),
Expand Down Expand Up @@ -646,7 +647,7 @@ mod tests {
value: 0.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(736), // in post-eip150
Expand All @@ -661,7 +662,7 @@ mod tests {
value: 0.into(),
gas: 32768.into(),
input: vec![],
call_type: CallType::DelegateCall,
call_type: Some(trace::CallType::DelegateCall),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: 18.into(),
Expand Down Expand Up @@ -702,7 +703,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::FailedCall(TraceError::OutOfGas),
subtraces: 0,
Expand Down Expand Up @@ -744,7 +745,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(69),
Expand All @@ -759,7 +760,7 @@ mod tests {
value: 0.into(),
gas: 78934.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(3),
Expand Down Expand Up @@ -801,7 +802,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(31761),
Expand All @@ -816,7 +817,7 @@ mod tests {
value: 69.into(),
gas: 2300.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult::default()),
}];
Expand Down Expand Up @@ -855,7 +856,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(31761),
Expand Down Expand Up @@ -898,7 +899,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(79_000),
Expand All @@ -913,7 +914,7 @@ mod tests {
value: 0.into(),
gas: 78934.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::FailedCall(TraceError::OutOfGas),
}];
Expand Down Expand Up @@ -954,7 +955,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(135),
Expand All @@ -969,7 +970,7 @@ mod tests {
value: 0.into(),
gas: 78934.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(69),
Expand All @@ -984,7 +985,7 @@ mod tests {
value: 0.into(),
gas: 78868.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(3),
Expand Down Expand Up @@ -1029,7 +1030,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(79_000),
Expand All @@ -1044,7 +1045,7 @@ mod tests {
value: 0.into(),
gas: 78934.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::FailedCall(TraceError::OutOfGas),
}, FlatTrace {
Expand All @@ -1055,7 +1056,7 @@ mod tests {
to: Address::from_low_u64_be(0xc),
value: 0.into(),
gas: 78868.into(),
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
input: vec![],
}),
result: trace::Res::Call(trace::CallResult {
Expand Down Expand Up @@ -1099,7 +1100,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: CallType::Call,
call_type: Some(trace::CallType::Call),
}),
result: trace::Res::Call(trace::CallResult {
gas_used: 3.into(),
Expand Down
Loading