added suicide details
This commit is contained in:
parent
8ab56ea3d1
commit
77babe6226
@ -433,7 +433,7 @@ impl<'a> Executive<'a> {
|
|||||||
self.state.add_balance(&self.info.author, &fees_value);
|
self.state.add_balance(&self.info.author, &fees_value);
|
||||||
|
|
||||||
// perform suicides
|
// perform suicides
|
||||||
for address in &substate.suicides {
|
for (address, _) in &substate.suicides {
|
||||||
self.state.kill_account(address);
|
self.state.kill_account(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +262,13 @@ impl<'a, T, V> Ext for Externalities<'a, T, V> where T: 'a + Tracer, V: 'a + VMT
|
|||||||
trace!("Suiciding {} -> {} (xfer: {})", address, refund_address, balance);
|
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);
|
|
||||||
|
let details = SuicideDetails {
|
||||||
|
refund_address: refund_address.clone(),
|
||||||
|
value: balance,
|
||||||
|
};
|
||||||
|
|
||||||
|
self.substate.suicides.insert(address, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn schedule(&self) -> &Schedule {
|
fn schedule(&self) -> &Schedule {
|
||||||
|
@ -15,14 +15,25 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! Execution environment substate.
|
//! Execution environment substate.
|
||||||
use common::*;
|
use std::collections::HashMap;
|
||||||
|
use util::{Address, U256};
|
||||||
|
use log_entry::LogEntry;
|
||||||
|
|
||||||
|
/// Details of the commited suicide.
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
pub struct SuicideDetails {
|
||||||
|
/// Suicided contract heir.
|
||||||
|
pub refund_address: Address,
|
||||||
|
/// Balance of the contract just before suicide.
|
||||||
|
pub value: U256,
|
||||||
|
}
|
||||||
|
|
||||||
/// State changes which should be applied in finalize,
|
/// State changes which should be applied in finalize,
|
||||||
/// after transaction is fully executed.
|
/// after transaction is fully executed.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Substate {
|
pub struct Substate {
|
||||||
/// Any accounts that have suicided.
|
/// Any accounts that have suicided.
|
||||||
pub suicides: HashSet<Address>,
|
pub suicides: HashMap<Address, SuicideDetails>,
|
||||||
|
|
||||||
/// Any logs.
|
/// Any logs.
|
||||||
pub logs: Vec<LogEntry>,
|
pub logs: Vec<LogEntry>,
|
||||||
@ -37,12 +48,7 @@ pub struct Substate {
|
|||||||
impl Substate {
|
impl Substate {
|
||||||
/// Creates new substate.
|
/// Creates new substate.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Substate {
|
Substate::default()
|
||||||
suicides: Default::default(),
|
|
||||||
logs: Default::default(),
|
|
||||||
sstore_clears_count: Default::default(),
|
|
||||||
contracts_created: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merge secondary substate `s` into self, accruing each element correspondingly.
|
/// Merge secondary substate `s` into self, accruing each element correspondingly.
|
||||||
@ -56,8 +62,8 @@ impl Substate {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::Substate;
|
||||||
use common::*;
|
use log_entry::LogEntry;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn created() {
|
fn created() {
|
||||||
@ -68,19 +74,19 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn accrue() {
|
fn accrue() {
|
||||||
let mut sub_state = Substate::new();
|
let mut sub_state = Substate::new();
|
||||||
sub_state.contracts_created.push(address_from_u64(1u64));
|
sub_state.contracts_created.push(1u64.into());
|
||||||
sub_state.logs.push(LogEntry {
|
sub_state.logs.push(LogEntry {
|
||||||
address: address_from_u64(1u64),
|
address: 1u64.into(),
|
||||||
topics: vec![],
|
topics: vec![],
|
||||||
data: vec![]
|
data: vec![]
|
||||||
});
|
});
|
||||||
sub_state.sstore_clears_count = 5.into();
|
sub_state.sstore_clears_count = 5.into();
|
||||||
sub_state.suicides.insert(address_from_u64(10u64));
|
sub_state.suicides.insert(10u64.into(), Default::default());
|
||||||
|
|
||||||
let mut sub_state_2 = Substate::new();
|
let mut sub_state_2 = Substate::new();
|
||||||
sub_state_2.contracts_created.push(address_from_u64(2u64));
|
sub_state_2.contracts_created.push(2u64.into());
|
||||||
sub_state_2.logs.push(LogEntry {
|
sub_state_2.logs.push(LogEntry {
|
||||||
address: address_from_u64(1u64),
|
address: 1u64.into(),
|
||||||
topics: vec![],
|
topics: vec![],
|
||||||
data: vec![]
|
data: vec![]
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user