Skip to content

Conversation

@sonhv0212
Copy link
Contributor

Reference: ethereum/go-ethereum#29347

This PR adds a live tracer which stores the supply delta of each block during import of a block.
For finding the supply for the whole chain, a fresh sync has to be started.

The tracer output for a single block is:

{
  "issuance": {
    "genesisAlloc": "0x0",
    "reward": "0x0",
    "withdrawals": "0x0"
  },
  "burn": {
    "eip1559": "0x0",
    "blob": "0x0",
    "misc": "0x0"
  },
  "blockNumber": 1,
  "hash": "0x54177b2adb754306d0d267f82537551c467201bf0c8509e60b77229b41c99e3a",
  "parentHash": "0xaf41e72f748de317965454508c749f7e14dc4fe444cd07bca4c981c7e952364d"
}

For using this tracer the CLI flag --vmtrace supply has to be set. Additional options for the tracer can be set as --vmtrace.config '{"path": "/tmp/supply_logs/"}'.

Currently the following options are supported:

path        Path to the directory where the tracer logs will be stored
maxSize     MaxSize is the maximum size in megabytes of the tracer log file before it gets rotated. It defaults to 100 megabytes.

The output of this tracer is stored in log rotated JSONL files in the configured directory, those exported files have to be analysed with another tool.

Example tracer output:

{"delta":320000001000000000000000000,"reward":0,"withdrawals":0,"burn":0,"blockNumber":0,"hash":"0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}
{"delta":2000000000000000000,"reward":2000000000000000000,"withdrawals":0,"burn":0,"blockNumber":1,"hash":"0x696d95da6726a67afd5be2a37d3883e9be8008491b30d5bd1069ea5922fa2a41","parentHash":"0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9"}
{"delta":2000000000000000000,"reward":2000000000000000000,"withdrawals":0,"burn":0,"blockNumber":2,"hash":"0x89b977ffab1052f5f6f778e4680354a8a1a1e0f623db9b2f20beba9f36f68721","parentHash":"0x696d95da6726a67afd5be2a37d3883e9be8008491b30d5bd1069ea5922fa2a41"}
{"delta":2000000000000000000,"reward":2000000000000000000,"withdrawals":0,"burn":0,"blockNumber":3,"hash":"0x1970908e724ac37efbb0b3bf9f77ebdf04e1ccb3f9da1463bec00252cb3a701f","parentHash":"0x89b977ffab1052f5f6f778e4680354a8a1a1e0f623db9b2f20beba9f36f68721"}

@sonhv0212 sonhv0212 merged commit 23e560b into ronin-chain:evm-tracer-struct May 19, 2025
1 of 2 checks passed
chiphamskymavis pushed a commit that referenced this pull request Jul 1, 2025
* eth/tracer/live: add supply live tracer

* eth/tracers: fix supply live tracer test

* core: Close all tracers when stop blockchain

* eth/tracers: fix supply live tracer test
sonhv0212 added a commit that referenced this pull request Aug 11, 2025
* eth/tracer/live: add supply live tracer

* eth/tracers: fix supply live tracer test

* core: Close all tracers when stop blockchain

* eth/tracers: fix supply live tracer test
trantienduchn pushed a commit that referenced this pull request Sep 3, 2025
* eth/tracer/live: add supply live tracer

* eth/tracers: fix supply live tracer test

* core: Close all tracers when stop blockchain

* eth/tracers: fix supply live tracer test
trantienduchn added a commit that referenced this pull request Sep 3, 2025
* all: remove Message interface

* core: renaming isFake to skipAccountChecks

* all: expose message fields to remove getter func

* simulate: call apply message for short

* light: remove unused callmsg struct

* core: refactor TransactionToMessage to use NewMessage constructor

* ci: update job name in EVM tests

* core: enhance TransactionToMessage to include ExpiredTime field

* core: update NewMessage constructor to include SetCodeAuthorizations

* core: rename TransactionToMessage function for clarity

* core: update TransactionToMessage to utilize SetCodeAuthorizations

* core/tracing: add hooks for live tracing of block processing and transaction execution

* core: add VM new tracing support with new configuration options

* core/state: add tracing hook to state db and state object (#73)

* core/state: add tracing hook to state db

* core/state: add tracing hook to state object

* workflows: enable unit test

* core/state: add BalanceChangeReason to state db and state object (#74)

* core/state: add BalanceChangeReason to state object

* core/state: add BalanceChangeReason to StateDB.AddBalance

* core/state: add BalanceChangeReason to StateDB.SubBalance

* core/state: add BalanceChangeReason to StateDB.SetBalance

* core: state transition, processor, evm support live tracer (#75)

* core/vm: add VMError

* core/vm: use live tracer in EVMInterpreter.Run

* core: add live tracer to applyTransaction

* core: add live tracer to state transition flow

* core/vm: run precompiled contract with live tracer

* core/vm/runtime: add live tracer for runtime execution

* core: blockchain supports live tracer (#77)

* all: replace the older tracer by live tracer (#78)

* core/vm: remove usages of older tracer from interpreter

* core: remove usages of older tracer from state transition

* core/vm: remove usages of older tracer from evm

* core/vm: remove usages of older tracer from instructions

* all: replace the older tracer by live tracer

* eth/tracer/logger,internal/ethapi: update access list tracer

* all: replace LiveTracer by Tracer

* all: support calltracer2

* eth/tracer/internal/tracetest: fix test

* core, tests: add missing usages of live tracer in blockchain and statetest (#83)

* core: set logger for blockchain

* tests: state test supports live tracer

* eth/tracer/live: add supply live tracer (#84)

* eth/tracer/live: add supply live tracer

* eth/tracers: fix supply live tracer test

* core: Close all tracers when stop blockchain

* eth/tracers: fix supply live tracer test

* core, eth/tracers: move chainconfig to tracers and some refactors (#86)

* core, eth/tracers: move chainconfig to tracers

* eth/tracer/live: add noop live tracer

* core/tracers/live: rename supply to supplyTracer

* cmd/utils, eth/tracers: set default tracer config to empty object

* evm: remove EVMLogger interface (#91)

* core: minor cleanup in stateDB and Call (#96)

* core/vm/runtime: call OnTxStart before prepare state DB in Call

* core/state: simplify state selfdestruct

* core/vm: update gas usage to use Tracer instead of LiveTracer in EIP-7702 gas call variant

* eth/tracers/internal/tracetest: disable KotaroBlock in pre-Cancun tests

* core/vm/runtime: fix type error

* core/tracing: extends tracing.Hooks with OnSystemCallStartV2 (#30786)

This PR extends the Hooks interface with a new method,
`OnSystemCallStartV2`, which takes `VMContext` as its parameter.

Motivation

By including `VMContext` as a parameter, the `OnSystemCallStartV2` hook
achieves parity with the `OnTxStart` hook in terms of provided insights.
This alignment simplifies the inner tracer logic, enabling consistent
handling of state changes and internal calls within the same framework.

---------

Co-authored-by: Sina Mahmoodi <[email protected]>

* core: capture on gas change when applying eip-7623

Ref PR: ethereum/go-ethereum#30946

* all: remove Message interface

* core/state: add BalanceChangeReason to state db and state object (#74)

* core/state: add BalanceChangeReason to state object

* core/state: add BalanceChangeReason to StateDB.AddBalance

* core/state: add BalanceChangeReason to StateDB.SubBalance

* core/state: add BalanceChangeReason to StateDB.SetBalance

* core: state transition, processor, evm support live tracer (#75)

* core/vm: add VMError

* core/vm: use live tracer in EVMInterpreter.Run

* core: add live tracer to applyTransaction

* core: add live tracer to state transition flow

* core/vm: run precompiled contract with live tracer

* core/vm/runtime: add live tracer for runtime execution

* all: replace the older tracer by live tracer (#78)

* core/vm: remove usages of older tracer from interpreter

* core: remove usages of older tracer from state transition

* core/vm: remove usages of older tracer from evm

* core/vm: remove usages of older tracer from instructions

* all: replace the older tracer by live tracer

* eth/tracer/logger,internal/ethapi: update access list tracer

* all: replace LiveTracer by Tracer

* all: support calltracer2

* eth/tracer/internal/tracetest: fix test

* internal/ethapi: eth_multicall (#27720)

This is a successor PR to #25743. This PR is based on a new iteration of
the spec: ethereum/execution-apis#484.

`eth_multicall` takes in a list of blocks, each optionally overriding
fields like number, timestamp, etc. of a base block. Each block can
include calls. At each block users can override the state. There are
extra features, such as:

- Include ether transfers as part of the logs
- Overriding precompile codes with evm bytecode
- Redirecting accounts to another address

This PR includes the following breaking changes:

- Block override fields of eth_call and debug_traceCall have had the
following fields renamed
  - `coinbase` -> `feeRecipient`
  - `random` -> `prevRandao`
  - `baseFee` -> `baseFeePerGas`

---------

Co-authored-by: Gary Rong <[email protected]>
Co-authored-by: Martin Holst Swende <[email protected]>

* core/vm: init precompile logic, update tests

* core/vm: init precompile logic, update tests

* gethclient: update block overwrite json

* ethapi: move validation from ToMessage to CallDefault

* ethapi: remove un-used fee logic

* ci: try enable test report

* internal/ethapi/api: for simulated calls, set gaspool to max value if global gascap is 0 (#30474)

In #27720, we introduced RPC global gas cap. A value of `0` means an unlimited gas cap. However, this was not the case for simulated calls. This PR fixes the behaviour.

* core/types: remove redundance hashes

* ethapi: correct simulate blocktime to 3s

* ethapi: add tests for simulate

* genesis: support nil balance when init genesis

* eth/api: remove err unmarshal block rpc

* simulate: apply evm txcontext, fix state hook

* internal/ethapi: fix simulate tests related to gas, base fee (#95)

* internal/ethapi: fix simulate tests related to gas, base fee

* ethapi: fix simulate validation tests

* ethapi: pass nonce to message

---------

Co-authored-by: chiphamskymavis <[email protected]>

* core: remove redundant receipt bloom

* eth: lower blob basefee for gasestimator

* eth, internal: remove err in transaction to msg func

* core: remove receipt generator

* simulate: skip system transactions during simulation when signTxFn is unavailable (#110)

* ethapi: update gas used values in simulation tests for accuracy

* ci: trigger build nightly for simulate

* eth: Fix movePrecompileToAddress ignored on debug_traceCall (#114)

* eth/tracers: set logger hooks for stateDB (#115)

* eth/tracers: set logger hooks for stateDB

* core/state: ensure logger is included in StateDB copy

* cmd: add vm trace flags

* eth: add tracer initialization

* cmd: init live tracer

* internal/ethapi: remove hard code timeout

* ci: revert custom actions

* ci: revert custom trigger condition

* ethapi: remove duplicated code

* consensus,ethapi: remove skip system tx when simulate, remove unused allLogs, changed from engine FinalizeAndAssemble to manual types.NewBlock

* ci: trigger build nightly for simulate

* internal/ethapi: process EIP-2935 in simulation

* ci: revert build nightly

* internal/ethapi: use skipChecks in applyMessage()

* internal/ethapi: use vmConfig

* eth/gasestimator: use gasLimit

* internal/ethapi: fix test fails

* internal/ethapi: resolve comments

---------

Co-authored-by: sonhv0212 <[email protected]>
Co-authored-by: Sina Mahmoodi <[email protected]>
Co-authored-by: Gary Rong <[email protected]>
Co-authored-by: Martin Holst Swende <[email protected]>
Co-authored-by: jwasinger <[email protected]>
Co-authored-by: Tran Tien Duc <[email protected]>
Co-authored-by: TuDo1403 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants