Skip to content

Commit

Permalink
add delta value to gas changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Aug 6, 2024
1 parent 284f984 commit 4354db9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions blocks/evm/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ CREATE TABLE IF NOT EXISTS gas_changes
-- gas change --
old_value UInt64,
new_value UInt64,
delta_value DEFAULT '' COMMENT 'Int128',
reason LowCardinality(String),
reason_code UInt32,
ordinal UInt64,
Expand Down
3 changes: 3 additions & 0 deletions blocks/evm/src/gas_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub fn gas_change_reason_to_string(reason: i32) -> String {
pub fn insert_gas_change(tables: &mut DatabaseChanges, clock: &Clock, gas_change: &GasChange, transaction: &TransactionTrace, trace: &Call) {
let old_value = gas_change.old_value;
let new_value = gas_change.new_value;
let delta_value = new_value as i128 - old_value as i128;

let reason = gas_change_reason_to_string(gas_change.reason);
let reason_code = gas_change.reason;
let ordinal = gas_change.ordinal;
Expand All @@ -54,6 +56,7 @@ pub fn insert_gas_change(tables: &mut DatabaseChanges, clock: &Clock, gas_change
.change("reason_code", ("", reason_code.to_string().as_str()))
.change("old_value", ("", old_value.to_string().as_str()))
.change("new_value", ("", new_value.to_string().as_str()))
.change("delta_value", ("", delta_value.to_string().as_str()))
.change("ordinal", ("", ordinal.to_string().as_str()));

insert_timestamp(row, clock, false);
Expand Down

0 comments on commit 4354db9

Please sign in to comment.