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

Redundant/Useless TrieDB instances #78

Open
hsyodyssey opened this issue Apr 13, 2022 · 0 comments
Open

Redundant/Useless TrieDB instances #78

hsyodyssey opened this issue Apr 13, 2022 · 0 comments

Comments

@hsyodyssey
Copy link

  • Since no functions in trie\database.go are used as the current middle layer for MT to submit data to Disk, all instances of TrieDB are theoretically useless.
  • Also, since the structure of MT nodes is different from that of the original MPT, the functions of reference counting in trie\database.go are invalid.

But there are still a lot of functions calls to trie\database.go in the codebase.

For example, in the core/blockchain.go , NewBlockChain function creates an instance of trie\database.go\Database. And this instance is called multiple times in the core/blockchain.go , such as:

triedb := bc.stateCache.TrieDB()

Even some function about reference counting of nodes is called, we can find it in this line: https://github.com/scroll-tech/go-ethereum/blob/zkrollup-smt/core/blockchain.go#L1243.

Fortunately, since MT has not submitted any data to this instance, its dirties array is always empty. Therefore, the relevant call is always a direct return, which is why the current code works without problems.

If we want to support both MPT and MT, these areas may need some attention.

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

No branches or pull requests

3 participants