Skip to content

Commit

Permalink
Fix account creation reversion in decoder processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Aug 8, 2024
1 parent 3f20a79 commit 7576e05
Show file tree
Hide file tree
Showing 3 changed files with 370 additions and 4 deletions.
17 changes: 13 additions & 4 deletions trace_decoder/src/decoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,19 @@ impl ProcessedBlockTrace {
)?;

let updated_account_bytes = rlp::encode(&account);
trie_state
.state
.insert(val_k, updated_account_bytes.to_vec())
.map_err(TraceParsingError::from)?;
if *updated_account_bytes == EMPTY_ACCOUNT_BYTES_RLPED {
// If the account is still empty, this means we reverted its creation.
// We then need to remove it from the state trie.
trie_state
.state
.delete(val_k)
.map_err(TraceParsingError::from)?;
} else {
trie_state
.state
.insert(val_k, updated_account_bytes.to_vec())
.map_err(TraceParsingError::from)?;
}
}

Ok(out)
Expand Down
Loading

0 comments on commit 7576e05

Please sign in to comment.