Skip to content

Conversation

shazam8253
Copy link
Contributor

No description provided.

@gballet gballet self-requested a review August 11, 2025 07:34
@rjl493456442
Copy link
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
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.

@@ -253,7 +257,7 @@ func (t *StateTrie) GetKey(shaKey []byte) []byte {
}

// 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
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
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.

@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
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