Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Revert "[Trace] Distinguish between create and create2 (#11311)" (#…
Browse files Browse the repository at this point in the history
…11427)

This reverts commit 87e1080.
  • Loading branch information
dvdplm authored Jan 30, 2020
1 parent bf44f02 commit 5d4993b
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 290 deletions.
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, ActionType, ActionValue};
use vm::{EnvInfo, Schedule, CallType, 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(ActionType::StaticCall),
Some(CallType::StaticCall),
)
},
};
Expand Down
29 changes: 10 additions & 19 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, ActionType, MessageCallResult,
self, ActionParams, ParamsType, ActionValue, CallType, 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 action
pub action_type: ActionType,
/// Type of call
pub call_type: CallType,
/// 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,
action_type: params.action_type,
call_type: params.call_type,
params_type: params.params_type,
}
}
Expand Down Expand Up @@ -532,9 +532,7 @@ 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 @@ -555,14 +553,7 @@ 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 @@ -616,14 +607,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, ActionType::Call)
(&self.params.address, &code_address, has_balance, CallType::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, ActionType::CallCode)
(&self.params.address, &self.params.address, has_balance, CallType::CallCode)
},
instructions::DELEGATECALL => (&self.params.sender, &self.params.address, true, ActionType::DelegateCall),
instructions::STATICCALL => (&self.params.address, &code_address, true, ActionType::StaticCall),
instructions::DELEGATECALL => (&self.params.sender, &self.params.address, true, CallType::DelegateCall),
instructions::STATICCALL => (&self.params.address, &code_address, true, CallType::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, ActionType, ActionParams, Ext,
Schedule, CleanDustMode, EnvInfo, CallType, ActionParams, Ext,
ContractCreateResult, MessageCallResult, CreateContractAddress,
GasLeft, ReturnData
};
Expand Down
49 changes: 24 additions & 25 deletions ethcore/executive-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ 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 @@ -323,7 +324,6 @@ 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,7 +381,6 @@ 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 @@ -420,7 +419,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(3),
Expand Down Expand Up @@ -461,7 +460,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(0),
Expand Down Expand Up @@ -502,7 +501,7 @@ mod tests {
value: 0.into(),
gas: 79_000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(3000),
Expand Down Expand Up @@ -544,7 +543,7 @@ mod tests {
value: 0.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(3_721), // in post-eip150
Expand Down Expand Up @@ -588,7 +587,7 @@ mod tests {
value: 0.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: 724.into(), // in post-eip150
Expand All @@ -603,7 +602,7 @@ mod tests {
value: 0.into(),
gas: 4096.into(),
input: vec![],
call_type: Some(trace::CallType::CallCode),
call_type: CallType::CallCode,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: 3.into(),
Expand Down Expand Up @@ -647,7 +646,7 @@ mod tests {
value: 0.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(736), // in post-eip150
Expand All @@ -662,7 +661,7 @@ mod tests {
value: 0.into(),
gas: 32768.into(),
input: vec![],
call_type: Some(trace::CallType::DelegateCall),
call_type: CallType::DelegateCall,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: 18.into(),
Expand Down Expand Up @@ -703,7 +702,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::FailedCall(TraceError::OutOfGas),
subtraces: 0,
Expand Down Expand Up @@ -745,7 +744,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(69),
Expand All @@ -760,7 +759,7 @@ mod tests {
value: 0.into(),
gas: 78934.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(3),
Expand Down Expand Up @@ -802,7 +801,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(31761),
Expand All @@ -817,7 +816,7 @@ mod tests {
value: 69.into(),
gas: 2300.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult::default()),
}];
Expand Down Expand Up @@ -856,7 +855,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(31761),
Expand Down Expand Up @@ -899,7 +898,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(79_000),
Expand All @@ -914,7 +913,7 @@ mod tests {
value: 0.into(),
gas: 78934.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::FailedCall(TraceError::OutOfGas),
}];
Expand Down Expand Up @@ -955,7 +954,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(135),
Expand All @@ -970,7 +969,7 @@ mod tests {
value: 0.into(),
gas: 78934.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(69),
Expand All @@ -985,7 +984,7 @@ mod tests {
value: 0.into(),
gas: 78868.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(3),
Expand Down Expand Up @@ -1030,7 +1029,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: U256::from(79_000),
Expand All @@ -1045,7 +1044,7 @@ mod tests {
value: 0.into(),
gas: 78934.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::FailedCall(TraceError::OutOfGas),
}, FlatTrace {
Expand All @@ -1056,7 +1055,7 @@ mod tests {
to: Address::from_low_u64_be(0xc),
value: 0.into(),
gas: 78868.into(),
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
input: vec![],
}),
result: trace::Res::Call(trace::CallResult {
Expand Down Expand Up @@ -1100,7 +1099,7 @@ mod tests {
value: 100.into(),
gas: 79000.into(),
input: vec![],
call_type: Some(trace::CallType::Call),
call_type: CallType::Call,
}),
result: trace::Res::Call(trace::CallResult {
gas_used: 3.into(),
Expand Down
Loading

0 comments on commit 5d4993b

Please sign in to comment.