diff --git a/crates/evm/src/gas.cairo b/crates/evm/src/gas.cairo index e975f6f7e..7d7c63e80 100644 --- a/crates/evm/src/gas.cairo +++ b/crates/evm/src/gas.cairo @@ -32,7 +32,7 @@ const CODEDEPOSIT: u128 = 200; const SSTORE_SET: u128 = 20000; const SSTORE_RESET: u128 = 5000; -const REFUND_SSTORE_CLEARS: u128 = 15000; +const REFUND_SSTORE_CLEARS: u128 = 4800; const TRANSACTION_ZERO_DATA: u128 = 4; const TRANSACTION_NON_ZERO_DATA_INIT: u128 = 16; diff --git a/scripts/gas_debug_call.py b/scripts/gas_debug_call.py new file mode 100644 index 000000000..c3cda12ae --- /dev/null +++ b/scripts/gas_debug_call.py @@ -0,0 +1,43 @@ +import re + + +def process_logs(logs): + current_address = None + previous_gas = None + accumulated_gas = 0 + + pattern = re.compile(r"Address (\d+), gas left in call (\d+)") + + for line in logs.split("\n"): + match = pattern.search(line) + if match: + address, gas_left = match.groups() + gas_left = int(gas_left) + + if address != current_address: + if current_address is not None: + print( + f"Total gas used for {hex(int(current_address))}: {accumulated_gas}" + ) + current_address = address + previous_gas = gas_left + accumulated_gas = 0 + else: + gas_used = previous_gas - gas_left + accumulated_gas += gas_used + print( + f"Gas used in step for {hex(int(current_address))}: {gas_used} (Total: {accumulated_gas})" + ) + previous_gas = gas_left + + if current_address is not None: + print(f"Total gas used for {hex(int(current_address))}: {accumulated_gas}") + + +# Example usage +logs = """ +Address 1169201309864722334562947866173026415724746034380, gas left in call 79978528 +Address 1169201309864722334562947866173026415724746034380, gas left in call 79978525 +""" + +process_logs(logs)