Skip to content
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

trie : use trie.NewStackTrie instead of new(trie.Trie) #22246

Merged
merged 2 commits into from
Feb 2, 2021

Conversation

ucwong
Copy link
Contributor

@ucwong ucwong commented Jan 28, 2021

No description provided.

@fjl
Copy link
Contributor

fjl commented Jan 28, 2021

@holiman @karalabe: I just noticed, through this PR, that we added the hasher parameter in 87c0ba9. I think it would be better to remove this parameter again and let NewBlock handle this internally.

@ucwong
Copy link
Contributor Author

ucwong commented Jan 28, 2021

@holiman @karalabe: I just noticed, through this PR, that we added the hasher parameter in 87c0ba9. I think it would be better to remove this parameter again and let NewBlock handle this internally.

It will cause import cycle for this stacktrie_test.go file
https://github.com/ethereum/go-ethereum/blob/master/trie/stacktrie_test.go#L12

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

Yes, makes definite sense to me

@holiman
Copy link
Contributor

holiman commented Jan 29, 2021

@holiman @karalabe: I just noticed, through this PR, that we added the hasher parameter in 87c0ba9. I think it would be better to remove this parameter again and let NewBlock handle this internally.

I'd love to get rid of it, but if so we need to solve the import cycle problem. ISTR it's not just tests, but other things that are hard to solve

@karalabe
Copy link
Member

Stack trie assume we insert sorted keys, right? Are we sure all these use cases do that?

@holiman
Copy link
Contributor

holiman commented Jan 29, 2021

Stack trie assume we insert sorted keys, right? Are we sure all these use cases do that?

Yes, it does. However, all these usecases, unless I've missed something, is used (eventually) to feed into DeriveSha, which (nowadays) ensure that the keys are sorted.

If I missed something, then that would be bad :/

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM. This PR changes to use stackTrie in places that either directly call into DeriveSha, or types.NewBlock, where the hasher is only used for call into DeriveSha.

@holiman holiman added this to the 1.10.0 milestone Feb 2, 2021
@holiman holiman merged commit 83e4c49 into ethereum:master Feb 2, 2021
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