-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
cmd, core, eth: add issuance tracking and querying #24723
Conversation
Question is how @JustinDrake wants to consume the data.
So what would be preferrable?
And would you want the data as a subscription (json) or spat out in some csv form? |
@karalabe: Love it! :) My main suggestion would be to use precise terminology around issuance and supply. Issuance is newly issued ETH, whereas supply is issuance minus burned and self-destroyed ETH. Specific renaming suggestions:
Other renaming suggestions that I don't feel so strongly about:
@holiman: The |
Another quick comment: I noticed you added an |
// Issuance calculates the Ether issuance (or burn) across two state tries. In | ||
// normal mode of operation, the expectation is to calculate the issuance between | ||
// two consecutive blocks. | ||
func Issuance(block *types.Block, parent *types.Header, db *trie.Database, config *params.ChainConfig) (*big.Int, error) { |
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.
IMO this is not issuance, but "EtherDelta". Issuance is "how much is issued", which IMO should be mining-rewards.
This is how I think of the terms:
rewards
: mining rewardsburn
: 1559 burnissuance
:rewards
-burn
delta
:issuance
-destroyed ether
And the supply
is the delta
between empty-state
(before genesis) and chain head.
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.
IMO this is not issuance, but "EtherDelta". Issuance is "how much is issued", which IMO should be mining-rewards.
Similar comment here :) #24723 (comment)
the
delta
"delta" is a great word, probably better than "diff" or "change". I'll edit my comment above to use "delta".
subsidy = ethash.ConstantinopleBlockReward | ||
} | ||
} | ||
// Accumulate the rewards for inclded uncles |
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.
*included
(:
Had to rebase this to be able to run it past Gray Glacier. Most of it seemed straightforward, the one change I'd love some more experienced eyes on is how I adapted for #24750. The tries used to calculate the issuance for every block need an diff --git a/core/issuance/issuance.go b/core/issuance/issuance.go
index 67f75b87a..e6e0e2080 100644
--- a/core/issuance/issuance.go
+++ b/core/issuance/issuance.go
@@ -43,11 +43,11 @@ func Issuance(block *types.Block, parent *types.Header, db *trie.Database, confi
if block.ParentHash() != parent.Hash() {
return nil, fmt.Errorf("parent hash mismatch: have %s, want %s", block.ParentHash().Hex(), parent.Hash().Hex())
}
- src, err := trie.New(parent.Root, db)
+ src, err := trie.New(common.Hash{}, parent.Root, db)
if err != nil {
return nil, fmt.Errorf("failed to open source trie: %v", err)
}
- dst, err := trie.New(block.Root(), db)
+ dst, err := trie.New(common.Hash{}, block.Root(), db)
if err != nil {
return nil, fmt.Errorf("failed to open destination trie: %v", err)
} |
Mm, and minor comment (It's hard to not start concerning yourself with adjacent changes 😅 ), this PR removes the Thought I'd give the heads up in case it's helpful and anyone ever ends up trying to merge this PR 😊 . |
Closing in favour of the up-to-date-er |
To @JustinDrake
TL;DR
The PR introduces a new flag
--issuance
that makes Geth crawl and store the Ether issuance based on the state changes between blocks (i.e. the true value, not what the protocol says).The user can subscribe on the
eth_issuance
RPC endpoint from a block in the past to receive all historical and future issuance updates in real time. The returned issuance will not only include the state-crawled issuance, but also the block and uncle subsidy as specified by the protocol as well as the 1559 burn. In certain blocks there will be a tiny discrepancy due to the EVM being able to burn Ether via self destructs. This will also be returned on the API, but it's just the diff between the "measured" and "theoretical" issuance, there's no block tracing done to double check this.If the issuance was not calculated for a certain block (block was not executed due to snap sync), the
issuance
anddestructed
fields in the result will benull
, but the other header-calculable fields will be returned nonetheless.Note, running with issuance tracking will take a performance hit due to having to crawl parts of the trie that would have been left idle otherwise (EVM reads from snapshots), and also will take a disk hit since we need to store a big.Int value for each processed block. There will be no particular effort to optimize these further. This is the cost of issuance tracking.
Whilst the above will give you the issuance across blocks, it will not give you the total Ether supply, unless you full sync and accumulate the data from all blocks. To help with starting tracking from a snap synced node, the PR also introduces a command to crawl the total supply based on Geth's snapshots.