reverted incorrect changes to externalities
This commit is contained in:
parent
01fcb9b445
commit
5998c16b17
@ -19,7 +19,8 @@ pub enum OutputPolicy<'a> {
|
|||||||
pub struct OriginInfo {
|
pub struct OriginInfo {
|
||||||
address: Address,
|
address: Address,
|
||||||
origin: Address,
|
origin: Address,
|
||||||
gas_price: U256
|
gas_price: U256,
|
||||||
|
value: U256
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OriginInfo {
|
impl OriginInfo {
|
||||||
@ -28,7 +29,11 @@ impl OriginInfo {
|
|||||||
OriginInfo {
|
OriginInfo {
|
||||||
address: params.address.clone(),
|
address: params.address.clone(),
|
||||||
origin: params.origin.clone(),
|
origin: params.origin.clone(),
|
||||||
gas_price: params.gas_price.clone()
|
gas_price: params.gas_price.clone(),
|
||||||
|
value: match params.value {
|
||||||
|
ActionValue::Transfer(val) => val,
|
||||||
|
ActionValue::Apparent(val) => val,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,7 +116,7 @@ impl<'a> Ext for Externalities<'a> {
|
|||||||
origin: self.origin_info.origin.clone(),
|
origin: self.origin_info.origin.clone(),
|
||||||
gas: *gas,
|
gas: *gas,
|
||||||
gas_price: self.origin_info.gas_price.clone(),
|
gas_price: self.origin_info.gas_price.clone(),
|
||||||
value: value.clone(),
|
value: ActionValue::Transfer(value.clone()),
|
||||||
code: Some(code.to_vec()),
|
code: Some(code.to_vec()),
|
||||||
data: None,
|
data: None,
|
||||||
};
|
};
|
||||||
@ -131,24 +136,29 @@ impl<'a> Ext for Externalities<'a> {
|
|||||||
|
|
||||||
fn call(&mut self,
|
fn call(&mut self,
|
||||||
gas: &U256,
|
gas: &U256,
|
||||||
address: &Address,
|
sender_address: &Address,
|
||||||
value: &U256,
|
receive_address: &Address,
|
||||||
|
value: Option<U256>,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
code_address: &Address,
|
code_address: &Address,
|
||||||
output: &mut [u8]) -> MessageCallResult {
|
output: &mut [u8]) -> MessageCallResult {
|
||||||
|
|
||||||
let params = ActionParams {
|
let mut params = ActionParams {
|
||||||
|
sender: sender_address.clone(),
|
||||||
|
address: receive_address.clone(),
|
||||||
|
value: ActionValue::Apparent(self.origin_info.value.clone()),
|
||||||
code_address: code_address.clone(),
|
code_address: code_address.clone(),
|
||||||
address: address.clone(),
|
|
||||||
sender: self.origin_info.address.clone(),
|
|
||||||
origin: self.origin_info.origin.clone(),
|
origin: self.origin_info.origin.clone(),
|
||||||
gas: *gas,
|
gas: *gas,
|
||||||
gas_price: self.origin_info.gas_price.clone(),
|
gas_price: self.origin_info.gas_price.clone(),
|
||||||
value: value.clone(),
|
|
||||||
code: self.state.code(code_address),
|
code: self.state.code(code_address),
|
||||||
data: Some(data.to_vec()),
|
data: Some(data.to_vec()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(value) = value {
|
||||||
|
params.value = ActionValue::Transfer(value);
|
||||||
|
}
|
||||||
|
|
||||||
let mut ex = Executive::from_parent(self.state, self.env_info, self.engine, self.depth);
|
let mut ex = Executive::from_parent(self.state, self.env_info, self.engine, self.depth);
|
||||||
|
|
||||||
match ex.call(params, self.substate, BytesRef::Fixed(output)) {
|
match ex.call(params, self.substate, BytesRef::Fixed(output)) {
|
||||||
@ -158,9 +168,10 @@ impl<'a> Ext for Externalities<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn extcode(&self, address: &Address) -> Bytes {
|
fn extcode(&self, address: &Address) -> Bytes {
|
||||||
self.state.code(address).unwrap_or(vec![])
|
self.state.code(address).unwrap_or_else(|| vec![])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(match_ref_pats)]
|
||||||
fn ret(&mut self, gas: &U256, data: &[u8]) -> Result<U256, evm::Error> {
|
fn ret(&mut self, gas: &U256, data: &[u8]) -> Result<U256, evm::Error> {
|
||||||
match &mut self.output {
|
match &mut self.output {
|
||||||
&mut OutputPolicy::Return(BytesRef::Fixed(ref mut slice)) => unsafe {
|
&mut OutputPolicy::Return(BytesRef::Fixed(ref mut slice)) => unsafe {
|
||||||
@ -204,7 +215,6 @@ impl<'a> Ext for Externalities<'a> {
|
|||||||
fn suicide(&mut self, refund_address: &Address) {
|
fn suicide(&mut self, refund_address: &Address) {
|
||||||
let address = self.origin_info.address.clone();
|
let address = self.origin_info.address.clone();
|
||||||
let balance = self.balance(&address);
|
let balance = self.balance(&address);
|
||||||
trace!("Suiciding {} -> {} (xfer: {})", address, refund_address, balance);
|
|
||||||
self.state.transfer_balance(&address, refund_address, &balance);
|
self.state.transfer_balance(&address, refund_address, &balance);
|
||||||
self.substate.suicides.insert(address);
|
self.substate.suicides.insert(address);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user