Skip to content

trie: no need to store preimage if not enabled #32012

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Jun 11, 2025

As the preimage will only be stored if t.preimages != nil, so no need to save them into local cache if not enabled, ref

if t.preimages != nil {
t.preimages.InsertPreimage(t.secKeyCache)
}

This will reduce the memory wasted to copy the bytes

@jsvisa jsvisa requested a review from rjl493456442 as a code owner June 11, 2025 13:36
Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

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

Unfortunately, the t.preimage will always be non-nil, as triedb does support the preimage interface.

We need to find an alternative approach to avoid caching preimages in the trie.

jsvisa added 3 commits June 12, 2025 22:54
Signed-off-by: jsvisa <[email protected]>
@jsvisa
Copy link
Contributor Author

jsvisa commented Jun 12, 2025

Unfortunately, the t.preimage will always be non-nil, as triedb does support the preimage interface.

just found the preimage was checked by type assert, and triedb always implement the preimageStore interface, so add another method PreimageEnabled() to explicitly indicate preimage is enabled or not.

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