Skip to content

Conversation

@rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Aug 13, 2025

This PR is the first step in the trienode history series.

It introduces the nodeWithOrigin struct in the path database, which tracks the original
values of dirty nodes to support trienode history construction.

Note, the original value is always empty in this PR, so it won't break the existing journal
for encoding and decoding. But the compatibility of journal should be handled in the
following PR.

}
}
}
for _, addr := range deletes {
Copy link
Member Author

@rjl493456442 rjl493456442 Aug 13, 2025

Choose a reason for hiding this comment

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

Apply trie insert/update before deletions to avoid loading siblings of deleted nodes within fullNode.

deletes = append(deletes, tkey)
} else {
err = st.Update(tkey.Bytes(), val)
err := st.Update(tkey.Bytes(), val)
Copy link
Member Author

Choose a reason for hiding this comment

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

Apply trie insert/update before deletions to avoid loading siblings of deleted nodes within fullNode.

return err
}
// Short circuit if the origins are not tracked
if len(s.nodeOrigin) == 0 {
Copy link
Member Author

Choose a reason for hiding this comment

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

The original values are not encoded into the journal if they are not provided.

@rjl493456442 rjl493456442 added this to the 1.16.4 milestone Sep 1, 2025
@fjl fjl removed the status:triage label Sep 2, 2025

// sanitize checks the provided user configurations and changes anything that's
// unreasonable or unworkable.
func (c *Config) sanitize() *Config {
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we should sanitize the state history flag as well? Limit it to 90k or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

No no, state history is not only for deep reorg resilience, but also the data for historical state.

Normally people will choose to keep the full history since the genesis with statehistory=0.

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

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

SGTM

func (s *nodeSetWithOrigin) hasOrigin(r *rlp.Stream) (bool, error) {
kind, _, err := r.Kind()
if err != nil {
if errors.Is(err, io.EOF) {
Copy link
Member

Choose a reason for hiding this comment

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

You could add a comment here that error being EOF means that we have a legacy nodeSet without origin

Copy link
Member Author

Choose a reason for hiding this comment

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

I can add it in a following PR, to not lose your approval :)

@rjl493456442 rjl493456442 merged commit 902ec5b into ethereum:master Sep 5, 2025
5 of 6 checks passed
Sahil-4555 pushed a commit to Sahil-4555/go-ethereum that referenced this pull request Oct 12, 2025
ethereum#32418)

This PR is the first step in the trienode history series.

It introduces the `nodeWithOrigin` struct in the path database, which tracks
the original values of dirty nodes to support trienode history construction.

Note, the original value is always empty in this PR, so it won't break the 
existing journal for encoding and decoding. The compatibility of journal 
should be handled in the following PR.
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