Question regarding example
e25519r opened this issue · comments
Hello, I was checking out revm and the block traces example.
When I'm summing up the gas_cost
of all ops (with a custom Inspector) using a transaction with no calls e.g. WETH.deposit()
results to the correct gas usage. initial=21064
, instructions=23974
equals expected=45038
for example tx=0x5f0dc1793698b53725b424499ab01d40f3b20b2052faf00851a0d57beed56352
.
fn step_end(&mut self, interp: &mut Interpreter, _context: &mut EvmContext<DB>) {
let remaining = core::mem::replace(&mut self.remaining, interp.gas.remaining());
self.total += = remaining.saturating_sub(self.remaining);
}
Although, when trying transactions that use (DELEGATECALL
, CALL
...) the total gas is way higher. initial=23208
, instructions=687946
while expected=126582
for example tx=0x2ff4cc105b52a29f5e2f105918c86c2bee14e9e2297d6331365a7efe8c14dada
.
I was creating some triggers on JUMPDEST/RETURN,STOP
etc or others with context.journaled_state.depth
and even if the total
was significantly closer, it was never exact.
What would be the best way to get a precise measurement?
Thanks!
Ok, having the json
traces showed better whats going on 👍