go-ethereum/eth/tracers
Matthieu Vachon e0af166ffa Full OnGasConsumed loop and added GasChangeReason
With this change, the full gas loop of a transaction can be tracked going from initial balance (`gasLimit`) back down to 0.

I validated on my regression test suite that those conditions applied to all transactions I have:
- First `OnGasConsumed` is always going from 0 -> `trx.gasLimit`
- Last `OnGasConsumed` "new value" is always 0
- trx.gasLimit - last balance of last `OnGasConsumed` is equal to `trx.gasUsed`

The addition of `reason` make it possible for a logger to filter out unwanted signal, for example one could want to drop all OpCode related gas change and only cares about "transaction" level. The reason is also a good thing for visibility and for creating powerful debug tools for Ethereum transaction execution.

Also, I would like that we change the `OnGasConsumed` logic from `OnGasConsumed(actual, cost uint64, reason)` to `OnGasConsumed(old, new uint64, reason)`. With the new tracing I've done, we now have negative `cost` that needs to be passed around but the `cost` is `uint64` so it creates overflow. Everything works fine if you record the new/old value `gas-cost` as the final value goes back to a valid range. But it's weird for consumer that would log `cost` that it's `18127127187219...`. An alternative would be to accept a `int64` for the cost which is also valid, not full coverage theorically but I don't see why an operation would cost more than i64 max value. Maybe it make more sense than to have signature `OnGasConsumed(gas uint64, cost int64, reason)`, I'm fine with it also, I leave the decision to you.
2023-08-28 15:30:10 -04:00
..
internal/tracetest capture call validation errors 2023-07-27 21:57:40 +02:00
js emit err on tx validation failure 2023-07-26 20:07:13 +02:00
logger Full OnGasConsumed loop and added GasChangeReason 2023-08-28 15:30:10 -04:00
native Full OnGasConsumed loop and added GasChangeReason 2023-08-28 15:30:10 -04:00
api.go fix merge conflict 2023-07-27 14:41:47 +02:00
api_test.go capture call validation errors 2023-07-27 21:57:40 +02:00
noop.go Full OnGasConsumed loop and added GasChangeReason 2023-08-28 15:30:10 -04:00
printer.go Full OnGasConsumed loop and added GasChangeReason 2023-08-28 15:30:10 -04:00
tracers.go provide StateLogger for short-lived tracers 2023-06-28 18:00:44 +02:00
tracers_test.go all: remove debug-field from vm config (#27048) 2023-04-04 09:50:13 -04:00
tracker.go eth/traces: add state limit (#25812) 2022-10-06 10:48:04 +02:00
tracker_test.go eth/traces: add state limit (#25812) 2022-10-06 10:48:04 +02:00