Skip to content

core/state, trie: add period to node encoding#560

Open
weiihann wants to merge 12 commits intogballet:archival-state-expiryfrom
weiihann:archive-expiry/trie-node
Open

core/state, trie: add period to node encoding#560
weiihann wants to merge 12 commits intogballet:archival-state-expiryfrom
weiihann:archive-expiry/trie-node

Conversation

@weiihann
Copy link
Collaborator

@weiihann weiihann commented Jan 20, 2026

No description provided.

@weiihann weiihann requested a review from gballet as a code owner January 20, 2026 08:03
Copy link
Owner

@gballet gballet left a comment

Choose a reason for hiding this comment

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

Almost there, but I am bringing your attention to a few points. Might be ok to ignore all of them while this is a prototype, but ideally I'd like to merge some code if it's possible.

tr.Update(key, result.vals[i])
}
_, nodes := tr.Commit(false)
_, nodes := tr.Commit(false, 0)
Copy link
Owner

Choose a reason for hiding this comment

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

this is going to be a problem, because it means that we can't generate the snapshot after period 0 or periods will be wrong. I guess it's ok for the test, but it means that we can't merge into master

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm from how I see it, it might not be a problem. The node set is used purely as a temporary in-memory hash->blob lookup table for the resolver. The nodes are never written to the disk, so the period value is irrelevant.

trie/trie.go Outdated
nodes := trienode.NewNodeSet(t.owner)
for _, path := range paths {
nodes.AddNode(path, trienode.NewDeletedWithPrev(t.prevalueTracer.Get(path)))
nodes.AddNode(path, trienode.NewDeletedWithPrev(t.prevalueTracer.Get(path), period))
Copy link
Owner

Choose a reason for hiding this comment

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

not that this is incorrect, but it poses a tough question: if a piece of the state is accessed and then reorged, and not touched in the new fork, should it be resurrected?

no, because it is not part of the official history, and so a fullsync would get the block wrong. But this might be tricky, because we need to save the period history of each nodes, or at least the previous one.

This is only important if this becomes in-protocol of course. Otherwise, I can think of a few tricks so that it doesn't matter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For out-of-protocol, I think falsely resurrecting nodes due to reorgs is acceptable.

Yes we have to deal with this if it's in-protocol. But we have more problems to deal with if it's a solution where we have to add metadata to every single trie node.

So I'd keep this in mind and leave it for now.

@weiihann weiihann force-pushed the archive-expiry/trie-node branch from 0e9bced to 668fc8e Compare January 26, 2026 10:45
@weiihann weiihann requested a review from gballet January 26, 2026 12:46
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.

2 participants