Skip to content

Commit

Permalink
refactor(interpreter): simplify the logic of calc.new_cost()
Browse files Browse the repository at this point in the history
  • Loading branch information
IaroslavMazur committed Dec 30, 2023
1 parent cd19eec commit bb1c30f
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions crates/interpreter/src/gas/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,16 @@ fn xfer_cost(is_call_or_callcode: bool, transfers_value: bool) -> u64 {

#[inline]
fn new_cost<SPEC: Spec>(is_call_or_staticcall: bool, is_new: bool, transfers_value: bool) -> u64 {
if is_call_or_staticcall {
// EIP-161: State trie clearing (invariant-preserving alternative)
if SPEC::enabled(SPURIOUS_DRAGON) {
if transfers_value && is_new {
NEWACCOUNT
} else {
0
}
} else if is_new {
NEWACCOUNT
} else {
0
}
} else {
0
if !is_call_or_staticcall || !is_new {
return 0;
}

// EIP-161: State trie clearing (invariant-preserving alternative)
if SPEC::enabled(SPURIOUS_DRAGON) && !transfers_value {
return 0;
}

NEWACCOUNT
}

#[inline]
Expand Down

0 comments on commit bb1c30f

Please sign in to comment.