-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat: enable KromaZKTrie by default #78
Changes from all commits
49d2c85
c20a086
7c8e6c0
88724d8
9317a3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -787,7 +787,7 @@ func (s *BlockChainAPI) GetProof(ctx context.Context, address common.Address, st | |||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
func (s *BlockChainAPI) newStateTrie(id *trie.ID, db *trie.Database) (state.Trie, error) { | ||||||||||||||||||
if db.IsZkStateTrie() { | ||||||||||||||||||
if db.IsKromaZK() { | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition The method + if err != nil {
+ return nil, fmt.Errorf("unsupported trie type: %v", err)
+ } Committable suggestion
Suggested change
The use of In the + log.Debug("Creating new state trie", "type", "KromaZK") Committable suggestion
Suggested change
The method |
||||||||||||||||||
return trie.NewZkMerkleStateTrie(id.Root, db) | ||||||||||||||||||
} | ||||||||||||||||||
if db.IsZk() { | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package trie | ||
|
||
import ( | ||
zkt "github.com/kroma-network/zktrie/types" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/trie/zk" | ||
) | ||
|
||
// File for defining an iterator key and managing key <-> iterator key conversion functions. | ||
// | ||
// NodeIterator.LeafKey must satisfy the following characteristics | ||
// ``` | ||
// preordertraversal(tree).filter(x -> x is leaf).map(x -> x.leafKey) == sort(leafKeys) | ||
// ``` | ||
// Since Trie satisfies this condition, functions that utilize it do not require any additional code (e.g. snapsync). | ||
// However, zktrie does not, so unless we introduce a new key concept, we need to modify the core source code quite a bit. | ||
// Therefore, we introduced the concept of iteratorKey, which satisfies the above condition, and implemented functions to convert key and iteratorKey. | ||
|
||
func BytesToZkIteratorKey(data []byte) common.Hash { | ||
return common.BigToHash(zk.NewTreePathFromBytes(data).ToBigInt()) | ||
} | ||
|
||
func ZkIteratorKeyToZkHash(key common.Hash) zkt.Hash { | ||
return *zk.NewTreePathFromHashBig(key).ToZkHash() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
TODO
comment regarding adding tests should be addressed to ensure the reliability and correctness of the code.Would you like me to help generate tests for this functionality?