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

One simple question about zk_trie_impl #1

Open
hsyodyssey opened this issue Nov 9, 2022 · 7 comments
Open

One simple question about zk_trie_impl #1

hsyodyssey opened this issue Nov 9, 2022 · 7 comments

Comments

@hsyodyssey
Copy link

hsyodyssey commented Nov 9, 2022

Hi, may I ask what the purpose of this line in TryUpdate function is?

The value of dbKeyRootNode is not changed in TryUpdate process . So this function call will always insert the KV with the same Key into the DB, right?

Please correct me if I have a misunderstanding.

@shu-unifra
Copy link

The value of dbKeyRootNode is (DBEntryTypeRoot+mt.rootKey) and mt.rootKey is changed in TryUpdate, so......

@hsyodyssey
Copy link
Author

hsyodyssey commented Nov 17, 2022

The value of dbKeyRootNode is (DBEntryTypeRoot+mt.rootKey) and mt.rootKey is changed in TryUpdate, so......

Yeah, but the Key of dbKeyRootNode is constant (dbKeyRootNode = []byte("currentroot")), right? The function directly inserts KVs with the same Key (sure different Value) to underlying database.

My question is, if more than one zkTries exist at the same time, will there be conflict or overwriting in their Root updates?

@shu-unifra
Copy link

The value of dbKeyRootNode is (DBEntryTypeRoot+mt.rootKey) and mt.rootKey is changed in TryUpdate, so......

Yeah, but the Key of dbKeyRootNode is constant (dbKeyRootNode = []byte("currentroot")), right? The function directly insert KVs with the same Key (sure different Value) to underlying database.

My question is, if more than one zkTries exist at the same time, will there be conflict or overwriting in their Root updates?

OK, I got your question, but I don't know why~

@hsyodyssey
Copy link
Author

Haha, there seems to be no conflict problem encountered now. So I'm curious if there are other mechanisms to avoid read conflicts.

@hsyodyssey
Copy link
Author

Having understood that, I think I know why there is no conflict at the current codebase.

@shu-unifra
Copy link

Having understood that, I think I know why there is no conflict at the current codebase.

Can you tell me about it please?

@hsyodyssey
Copy link
Author

Having understood that, I think I know why there is no conflict at the current codebase.

Can you tell me about it please?

Basically, I think this function call is redundant since it just inserts a KV with a constant key. There is no other function to query this KV and the Root value of each contract's Storage Trie does not point to this KV. Therefore, this function call is just writing continuously and does not cause any conflicts. Maybe could optimize this area in the future 😊.

@29988122 29988122 reopened this Mar 29, 2023
noel2004 pushed a commit that referenced this issue Apr 2, 2024
fix trie node and add a few node related tests
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