-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
Supply delta live tracer #29347
Supply delta live tracer #29347
Conversation
This reverts commit bc983e2.
core/tracing/hooks.go
Outdated
@@ -214,6 +214,44 @@ const ( | |||
BalanceDecreaseSelfdestructBurn BalanceChangeReason = 14 | |||
) | |||
|
|||
// String returns a string representation of the reason. | |||
func (r BalanceChangeReason) String() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use https://pkg.go.dev/golang.org/x/tools/cmd/stringer to generate this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to solve the following error: ``` --- FAIL: TestSupplySelfdestruct (1.56s) testing.go:1231: TempDir RemoveAll cleanup: remove C:\Users\appveyor\AppData\Local\Temp\1\TestSupplySelfdestruct3803137642\001\supply.jsonl: The process cannot access the file because it is being used by another process. ```
Was expecting lumberjack.Rotate() to close the file
Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I was co-author :) I'll wait for others to chime in as well
core/tracing/hooks.go
Outdated
OnSkippedBlock SkippedBlockHook | ||
OnGenesisBlock GenesisBlockHook | ||
OnBlockchainInit BlockchainInitHook | ||
OnBlockchainTerminate BlockchainTerminateHook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@s1na what do you think of this name over "OnBlockchainEnd"?
Linking the reader here for visibility: https://github.com/ziogaschr/supply-tracer-parser |
Delta *big.Int `json:"delta"` | ||
Reward *big.Int `json:"reward"` | ||
Withdrawals *big.Int `json:"withdrawals"` | ||
Burn *big.Int `json:"burn"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
big.Int
marshals as json numbers. Which means that we're kind of limited to 53
bits, because of javascript. So better if we marshal it as hex-strings (or dec-strings for that matter).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So Delta is a signed number. The best thing I can think of is to add a new field for the sign.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like your idea @s1na, as supporting Negative numbers for hex isn't the nicest thing and also the consumers of the JSON will have to find a library that supports negative numbers as well.
Another suggestion might be if we use two different fields like DeltaInflation
and DeltaDeflation
(we have to think of better names) (thanks to @meowsbits for this suggestion)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of this? ziogaschr@3ac74bd#r142142290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@holiman @s1na I pushed some commits which change the output to the following after our discussion with @s1na.
We dropped the delta
, which could have negative numbers and we will let the consumer to do the calculations on their side.
{
"issuance": {
"genesisAlloc": "0x0", // omitempty
"reward": "0x0",
"withdrawals": "0x0"
},
"burn": {
"1559": "0x0",
"blob": "0x0",
"misc": "0x0"
},
"blockNumber": 1,
"hash": "0x54177b2adb754306d0d267f82537551c467201bf0c8509e60b77229b41c99e3a",
"parentHash": "0xaf41e72f748de317965454508c749f7e14dc4fe444cd07bca4c981c7e952364d"
}
This needs a rebase |
# Conflicts: # core/tracing/hooks.go
The new output becomes: ``` { "issuance": { "reward": 0, "withdrawals": 0 }, "burn": { "1559": 0, "blob": 0, "misc": 0 }, "blockNumber": 1, "hash": "0x", "parentHash": "0x" } ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 🙌 🙌
0x34a9c05b638020a07bb153bf624c8763bf8b4a86 |
Introduces the first built-in live tracer. The supply tracer tracks ETH supply changes across blocks and writes the output to disk. This will need to be enabled through CLI using the `--vmtrace supply` flag. Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
Introduces the first built-in live tracer. The supply tracer tracks ETH supply changes across blocks and writes the output to disk. This will need to be enabled through CLI using the `--vmtrace supply` flag. Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
This PR is based on #24723 by @karalabe / @holiman (and the successor #25662) and uses the live chain tracing with hooks implementation #29189 by @s1na.
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:
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:
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: