Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracing: pass *tracing.Hooks around instead of vm.Config #2846

Conversation

maoueh
Copy link
Contributor

@maoueh maoueh commented Jan 7, 2025

Description

Passing *tracing.Hooks makes the intent clearer and ensure the applyTransaction controls the creation of the vm.Config.

Follow-up of #2772.

Rationale

#2772 (comment).

Passing `*tracing.Hooks` makes the intent clearer and ensure the `applyTransaction`
controls the creationg of the `vm.Config`.
@zzzckck
Copy link
Collaborator

zzzckck commented Jan 8, 2025

@maoueh may I know how would you use these new tracer hook interface?

	OnSystemTxStart           OnSystemTxStartHook
	OnSystemTxEnd             OnSystemTxEndHook
	OnSystemTxFixIntrinsicGas OnSystemTxFixIntrinsicGasHook

Seems like #2772 only effect live tracer, which only contain 2 tracer type: noop and supply, neither integrated with these 3 hooks yet.
I tried the supply tracer:

./bsc -- --config ./config.toml  --syncmode full --vmtrace supply --vmtrace.jsonconfig '{"path":"./liveTracerSupply", "maxSize":100}'

Here is the output in file: liveTracerSupply

{"issuance":{"genesisAlloc":"0xa56fa5b99019a5c8000000"},"blockNumber":0,"hash":"0x6d3c66c5357ec91d5c43af47e234a939b22557cbb552dc45bebbceeed90fbe34","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}
{"blockNumber":1,"hash":"0xd0bc67b50915467ada963c35ee00950f664788e47da8139d8c178653171034f1","parentHash":"0x6d3c66c5357ec91d5c43af47e234a939b22557cbb552dc45bebbceeed90fbe34"}
{"blockNumber":2,"hash":"0xc2d18d5a59d65da573f70c4d30448482418894e018b0d189db24ea4fd02d7aa1","parentHash":"0xd0bc67b50915467ada963c35ee00950f664788e47da8139d8c178653171034f1"}
{"blockNumber":3,"hash":"0x59f703c6a9c6c81b5523529e191ac77eb37b2a0646be51bfb6ae97a707130e09","parentHash":"0xc2d18d5a59d65da573f70c4d30448482418894e018b0d189db24ea4fd02d7aa1"}
{"blockNumber":4,"hash":"0xbd1bdaf8a8f5c00c464df2856a9e2ef23b8dcc906e6490d3cd295ebb5eb124c3","parentHash":"0x59f703c6a9c6c81b5523529e191ac77eb37b2a0646be51bfb6ae97a707130e09"}
...

@maoueh
Copy link
Contributor Author

maoueh commented Jan 8, 2025

@zzzckck We have a FirehoseTracer implementation (https://github.com/streamingfast/go-ethereum/blob/firehose-fh3.0/eth/tracers/firehose.go#L72) which leverages the Live Tracing API now offered in Geth 1.14. That powers our Firehose/Substreams services (https://docs.substreams.dev) as part of The Graph Foundation.

The FirehoseTracer link above is for Ethereum Mainnet, now that BSC bumped to Geth 1.14, our BSC nodes will be soon powered with it, I plan to work on that in the next few weeks.

Historically we maintained our own tracing API inside Geth node directly and for forks like BSC and Polygon, last year we contributed back to Geth directly working up with their team to revamp the tracing API to trace all state changes using live tracer that traces blocks as the node synchronize with the network.

You can see for example how current production BSC older tracer is tracing system transactions: https://github.com/streamingfast/go-ethereum/blob/release/bsc-1.x-fh2.5/consensus/parlia/parlia.go#L1970-L1973.

About the live tracer supply specifically, I can't seems to find back the source of it, but AFAIK it does hook OnTxStart/OnTxEnd which is now enabled for system transaction. The supply tracer tracks balance changes, was there any balance changes happening in the system transactions within the blocks you shown?

@zzzckck
Copy link
Collaborator

zzzckck commented Jan 9, 2025

@zzzckck We have a FirehoseTracer implementation (https://github.com/streamingfast/go-ethereum/blob/firehose-fh3.0/eth/tracers/firehose.go#L72) which leverages the Live Tracing API now offered in Geth 1.14. That powers our Firehose/Substreams services (https://docs.substreams.dev) as part of The Graph Foundation.

The FirehoseTracer link above is for Ethereum Mainnet, now that BSC bumped to Geth 1.14, our BSC nodes will be soon powered with it, I plan to work on that in the next few weeks.

Historically we maintained our own tracing API inside Geth node directly and for forks like BSC and Polygon, last year we contributed back to Geth directly working up with their team to revamp the tracing API to trace all state changes using live tracer that traces blocks as the node synchronize with the network.

You can see for example how current production BSC older tracer is tracing system transactions: https://github.com/streamingfast/go-ethereum/blob/release/bsc-1.x-fh2.5/consensus/parlia/parlia.go#L1970-L1973.

About the live tracer supply specifically, I can't seems to find back the source of it, but AFAIK it does hook OnTxStart/OnTxEnd which is now enabled for system transaction. The supply tracer tracks balance changes, was there any balance changes happening in the system transactions within the blocks you shown?

noted, thank you for your statement.
I just tried the supply tracer to learn how to use the live tracer feature, I run it locally to sync from genesis for only 2K+ blocks. supply tracer only printed the blockNumber, hash and parentHash in my env. I checked the code, it is as expected, so I am ok with it. Maybe it is not that useful for BSC, as the Issuance and Burn mechanism is different on BSC.

@zzzckck zzzckck merged commit b912401 into bnb-chain:develop Jan 9, 2025
7 checks passed
@maoueh
Copy link
Contributor Author

maoueh commented Jan 9, 2025

Maybe it is not that useful for BSC

I could try to find out who uses supply tracer as I followed the development on the supply tracer PR.

as the Issuance and Burn mechanism is different on BSC

But they are still traced no and should emit OnBalanceChange. Is Issuance and Burn done in the Parlia consensus engine? I can double check that.

@maoueh maoueh deleted the fix/parlia-system-tx-tracing-pass-tracer-around branch January 9, 2025 14:31
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.

3 participants