Skip to content

core, miner, trie: add metrics tracking state trie depth#32388

Merged
rjl493456442 merged 14 commits intoethereum:masterfrom
shazam8253:triedepth
Aug 22, 2025
Merged

core, miner, trie: add metrics tracking state trie depth#32388
rjl493456442 merged 14 commits intoethereum:masterfrom
shazam8253:triedepth

Conversation

@shazam8253
Copy link
Copy Markdown
Contributor

No description provided.

@gballet gballet self-requested a review August 11, 2025 07:34
@rjl493456442
Copy link
Copy Markdown
Member

rjl493456442 commented Aug 11, 2025

Any particular reason for making this PR?

We always construct a nodeset containing all the dirty nodes after commit, you can extract the
information you want from there?

// NodeSet contains a set of nodes collected during the commit operation.
// Each node is keyed by path. It's not thread-safe to use.
type NodeSet struct {
	Owner   common.Hash
	Leaves  []*leaf
	Nodes   map[string]*Node
	updates int // the count of updated and inserted nodes
	deletes int // the count of deleted nodes
}

If you need the statistics of accessed nodes, you can use Witness API to obtain all the nodes
have been resolved. You probably need to modify the API a bit by exposing the trie node path
as well.

@shazam8253
Copy link
Copy Markdown
Contributor Author

The reason for making this PR is for Guillaume's BloatNet project to bloat state and see growth of state trie. Needed to provide new metrics in prometheus so that Pari could parse the data and give it to a researcher.

Comment thread trie/secure_trie.go

// Witness returns a set containing all trie nodes that have been accessed.
func (t *StateTrie) Witness() map[string]struct{} {
func (t *StateTrie) Witness() map[string][]byte {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that Gary okay'd this. I wonder what the ram usage impact will be though. We'll have to check that... with metrics 😁

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe Gary changed this so that everything is tracked in stats now, but would be curious to see how much it impacts memory.

Comment thread trie/trie.go Outdated
Comment thread trie/trie.go Outdated
@rjl493456442 rjl493456442 marked this pull request as ready for review August 22, 2025 06:35
@rjl493456442 rjl493456442 changed the title trie/metrics: adding in metrics for depth of state trie core, miner, trie: add metrics tracking state trie depth Aug 22, 2025
@rjl493456442 rjl493456442 merged commit e965623 into ethereum:master Aug 22, 2025
7 of 11 checks passed
@rjl493456442 rjl493456442 added this to the 1.16.3 milestone Aug 22, 2025
rjl493456442 pushed a commit that referenced this pull request Sep 1, 2025
Filtering for leaf nodes was missing from #32388, which means that even
the root done was reported, which made little sense for the bloatnet
data processing we want to do.
gballet added a commit to gballet/go-ethereum that referenced this pull request Sep 11, 2025
)

Co-authored-by: shantichanal <158101918+shantichanal@users.noreply.github.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
gballet added a commit to gballet/go-ethereum that referenced this pull request Sep 11, 2025
Filtering for leaf nodes was missing from ethereum#32388, which means that even
the root done was reported, which made little sense for the bloatnet
data processing we want to do.
Sahil-4555 pushed a commit to Sahil-4555/go-ethereum that referenced this pull request Oct 12, 2025
Filtering for leaf nodes was missing from ethereum#32388, which means that even
the root done was reported, which made little sense for the bloatnet
data processing we want to do.
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.

4 participants