mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: some trace statediff improvements (#5033)
This commit is contained in:
@ -577,6 +577,11 @@ where
|
|||||||
DB: DatabaseRef,
|
DB: DatabaseRef,
|
||||||
{
|
{
|
||||||
for (addr, changed_acc) in account_diffs.into_iter() {
|
for (addr, changed_acc) in account_diffs.into_iter() {
|
||||||
|
// if the account was selfdestructed and created during the transaction, we can ignore it
|
||||||
|
if changed_acc.is_selfdestructed() && changed_acc.is_created() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
let addr = *addr;
|
let addr = *addr;
|
||||||
let entry = state_diff.entry(addr).or_default();
|
let entry = state_diff.entry(addr).or_default();
|
||||||
|
|
||||||
@ -592,6 +597,19 @@ where
|
|||||||
} else {
|
} else {
|
||||||
// account already exists, we need to fetch the account from the db
|
// account already exists, we need to fetch the account from the db
|
||||||
let db_acc = db.basic(addr)?.unwrap_or_default();
|
let db_acc = db.basic(addr)?.unwrap_or_default();
|
||||||
|
|
||||||
|
// check if the account was changed at all
|
||||||
|
// NOTE: changed storage values are set by the the
|
||||||
|
// `CallTraceNode::parity_update_state_diff`
|
||||||
|
if entry.storage.is_empty() &&
|
||||||
|
db_acc == changed_acc.info &&
|
||||||
|
!changed_acc.is_selfdestructed()
|
||||||
|
{
|
||||||
|
// clear the entry if the account was not changed
|
||||||
|
state_diff.remove(&addr);
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
entry.balance = if db_acc.balance == changed_acc.info.balance {
|
entry.balance = if db_acc.balance == changed_acc.info.balance {
|
||||||
Delta::Unchanged
|
Delta::Unchanged
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -82,6 +82,30 @@ pub enum Delta<T> {
|
|||||||
Changed(ChangedType<T>),
|
Changed(ChangedType<T>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === impl Delta ===
|
||||||
|
|
||||||
|
impl<T> Delta<T> {
|
||||||
|
/// Returns true if the value is unchanged
|
||||||
|
pub fn is_unchanged(&self) -> bool {
|
||||||
|
matches!(self, Delta::Unchanged)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns true if the value is added
|
||||||
|
pub fn is_added(&self) -> bool {
|
||||||
|
matches!(self, Delta::Added(_))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns true if the value is removed
|
||||||
|
pub fn is_removed(&self) -> bool {
|
||||||
|
matches!(self, Delta::Removed(_))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns true if the value is changed
|
||||||
|
pub fn is_changed(&self) -> bool {
|
||||||
|
matches!(self, Delta::Changed(_))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct AccountDiff {
|
pub struct AccountDiff {
|
||||||
|
|||||||
Reference in New Issue
Block a user