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

feat: enable KromaZKTrie by default #76

Merged
merged 2 commits into from
Feb 27, 2024

Conversation

jyc228
Copy link
Collaborator

@jyc228 jyc228 commented Feb 27, 2024

Summary by CodeRabbit

  • Refactor
    • Renamed ExperimentalZkTree to KromaZKTrie across various configurations and methods to reflect the new naming convention for ZK state trie usage.
  • New Features
    • Updated the boolean flag for ZK state trie usage to KromaZKTrie with a default value of true, enhancing user control over this feature.
  • Documentation
    • Modified usage descriptions for related flags to better reflect their updated functionalities.

Copy link

coderabbitai bot commented Feb 27, 2024

Walkthrough

The recent updates predominantly involve renaming the ExperimentalZkTrie configuration and related functionality to KromaZKTrie across various components of the codebase. This renaming affects flags, configuration structures, and logic pertaining to the Zero-Knowledge (ZK) state trie implementation, indicating a shift towards a more finalized or specific use case, possibly related to the Kroma project. The modifications span across command-line interfaces, utility flags, core blockchain logic, Ethereum back-end configurations, and trie database implementations.

Changes

Files Change Summary
cmd/geth/config.go, cmd/geth/main.go Renamed ExperimentalZkTree to KromaZKTrie in cfg.Eth and utils.ExperimentalZkTrie to utils.KromaZKTrie.
cmd/utils/flags.go Renamed the flag ExperimentalZkTrie to KromaZKTrie, updated Usage description, and added a default Value of true.
core/blockchain.go, core/state/database.go Renamed ExperimentalZkTrie to KromaZKTrie in CacheConfig and cachingDB structs, affecting ZK state trie logic.
eth/backend.go, eth/ethconfig/config.go Renamed ExperimentalZkTrie to KromaZKTrie in New function and Config struct, impacting Ethereum configuration.
internal/ethapi/api.go Modified newStateTrie method to check for IsKromaZK instead of IsZkStateTrie, affecting database logic flow.
trie/database.go, trie/merkle_trie.go Renamed ExperimentalZkTrie to KromaZKTrie in Config struct and updated method calls to IsKromaZK(), affecting trie implementation selection.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@jyc228 jyc228 requested a review from a team February 27, 2024 03:56
@jyc228 jyc228 self-assigned this Feb 27, 2024
@jyc228 jyc228 changed the title refac: rename ExperimentalZkTrie to KromaZkTrie feat: enable KromaZkTrie by default Feb 27, 2024
Copy link
Contributor

@kangsorang kangsorang left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@0xHansLee 0xHansLee left a comment

Choose a reason for hiding this comment

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

If you don't mind, let's use upper case for acronyms. It's preferred way in golang.
So, let's change KromaZkTrie to KromaZKTrie, all capitals.
FYI, let's see Initialisms in https://go.dev/wiki/CodeReviewComments.

Copy link
Contributor

@seolaoh seolaoh left a comment

Choose a reason for hiding this comment

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

LGTM, I agree with the above comment.

@jyc228
Copy link
Collaborator Author

jyc228 commented Feb 27, 2024

@0xHansLee
For now, I'll only reflect it in KromaZKTrie and not the rest.

@jyc228 jyc228 force-pushed the refac/rename-experimentalzktrie-to-kromazktrie branch from 7d34a63 to 0678bc2 Compare February 27, 2024 06:30
@jyc228 jyc228 changed the title feat: enable KromaZkTrie by default feat: enable KromaZKTrie by default Feb 27, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 348e72e and 0678bc2.
Files selected for processing (10)
  • cmd/geth/config.go (1 hunks)
  • cmd/geth/main.go (1 hunks)
  • cmd/utils/flags.go (1 hunks)
  • core/blockchain.go (1 hunks)
  • core/state/database.go (2 hunks)
  • eth/backend.go (1 hunks)
  • eth/ethconfig/config.go (1 hunks)
  • internal/ethapi/api.go (1 hunks)
  • trie/database.go (2 hunks)
  • trie/merkle_trie.go (1 hunks)
Additional comments: 13
trie/merkle_trie.go (1)
  • 83-83: The update from db.IsZkStateTrie() to db.IsKromaZK() aligns with the PR's objective to make KromaZKTrie the default trie implementation. Ensure that the Database interface and its implementations are correctly updated to include the IsKromaZK method for this condition to function as expected.
eth/ethconfig/config.go (1)
  • 193-193: Renaming ExperimentalZkTree to KromaZKTrie within the Config struct aligns with the PR's objective. Ensure that all references to the old field name are updated across the codebase to maintain consistency.
core/state/database.go (2)
  • 179-179: The update in the OpenTrie method to check for KromaZK aligns with the PR's objective. Ensure that the trie.Database interface and its implementations are correctly updated to include the IsKromaZK method for this condition to function as expected.
  • 200-200: The update in the OpenStorageTrie method to check for KromaZK aligns with the PR's objective. Ensure that the trie.Database interface and its implementations are correctly updated to include the IsKromaZK method for this condition to function as expected.
cmd/geth/config.go (1)
  • 193-193: The change to use KromaZKTrie as the default trie implementation is noted. Ensure that all references to the previous ExperimentalZkTree across the entire codebase have been updated accordingly to maintain consistency.
Verification successful

The search for any remaining references to ExperimentalZkTree did not yield any results, indicating that all necessary updates have likely been made to replace or remove references to ExperimentalZkTree in favor of KromaZKTrie. This supports the conclusion that the change has been properly integrated across the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any remaining references to `ExperimentalZkTree` which should have been replaced.
rg --type go 'ExperimentalZkTree'

Length of output: 33

trie/database.go (3)
  • 40-40: Renaming ExperimentalZkTrie to KromaZKTrie in the Config struct aligns with the new naming convention. Ensure this change is consistently applied across all relevant parts of the codebase.
  • 381-382: Replacing IsZkStateTrie with IsKromaZK reflects the updated naming convention. Verify that this new method is correctly used wherever trie type checks are performed.
  • 389-393: The SetBackend method correctly updates the KromaZKTrie configuration. Ensure that the logic here accurately reflects the intended behavior when switching trie backends, especially in the context of enabling or disabling the KromaZKTrie.
cmd/geth/main.go (1)
  • 160-160: Renaming utils.ExperimentalZkTrie to utils.KromaZKTrie aligns with the PR's objective to make KromaZKTrie the default trie implementation. This change is straightforward and seems correctly implemented in the context of the provided code. However, it's crucial to ensure that all references to the old ExperimentalZkTrie across the entire codebase are updated to KromaZKTrie to maintain consistency and avoid potential configuration errors or runtime issues.
Verification successful

The verification process did not find any remaining references to ExperimentalZkTrie in the Go files of the codebase, indicating that the renaming to KromaZKTrie has been successfully applied across the entire codebase. This aligns with the initial review comment's concern and suggests that the change has been implemented correctly and thoroughly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any remaining references to ExperimentalZkTrie in the codebase.
rg --type go 'ExperimentalZkTrie'
# Expecting no results, indicating all references have been updated.

Length of output: 33

eth/backend.go (1)
  • 211-211: The change from ExperimentalZkTrie to KromaZKTrie in the cacheConfig struct reflects the PR's objective to make KromaZKTrie the default state trie implementation. This update is consistent with the broader system updates and aligns with the PR's goals. However, ensure that all references to the old ExperimentalZkTrie field across the codebase are updated to KromaZKTrie to maintain consistency and avoid potential configuration errors.
cmd/utils/flags.go (1)
  • 1039-1043: The renaming of the flag from ExperimentalZkTrie to KromaZKTrie and the addition of a default value of true align with the PR's objective to make KromaZKTrie the default trie implementation. Ensure that all references to this flag in documentation, tests, and other parts of the codebase are updated accordingly to reflect this change. Additionally, verify that setting this flag to true by default does not introduce any unexpected behavior or conflicts with other configurations.
internal/ethapi/api.go (1)
  • 790-790: The change from checking IsZk() to IsKromaZK() in the newStateTrie function aligns with the PR's objective to transition to KromaZKTrie. However, ensure that all references and dependencies throughout the codebase are updated accordingly to prevent any inconsistencies or errors.
core/blockchain.go (1)
  • 151-162: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [24-25]

LGTM!

Comment on lines 151 to 162
SnapshotNoBuild bool // Whether the background generation is allowed
SnapshotWait bool // Wait for snapshot construction on startup. TODO(karalabe): This is a dirty hack for testing, nuke it

ExperimentalZkTrie bool // use ZkMerkleStateTrie instead of ZkTrie
KromaZKTrie bool // use ZkMerkleStateTrie instead of ZkTrie
}

// triedbConfig derives the configures for trie database.
func (c *CacheConfig) triedbConfig() *trie.Config {
config := &trie.Config{Preimages: c.Preimages, ExperimentalZkTrie: c.ExperimentalZkTrie}
config := &trie.Config{Preimages: c.Preimages, KromaZKTrie: c.KromaZKTrie}
if c.StateScheme == rawdb.HashScheme {
config.HashDB = &hashdb.Config{
CleanCacheSize: c.TrieCleanLimit * 1024 * 1024,
Copy link

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [14-14]

There is a TODO comment regarding missing tests.

Do you want me to generate the tests or open a GitHub issue to track this task?

Copy link
Contributor

@0xHansLee 0xHansLee left a comment

Choose a reason for hiding this comment

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

@0xHansLee
For now, I'll only reflect it in KromaZKTrie and not the rest.

Got it, thanks!

@jyc228 jyc228 changed the base branch from main to release/v0.4.4 February 27, 2024 07:51
@jyc228 jyc228 merged commit 88724d8 into release/v0.4.4 Feb 27, 2024
2 checks passed
@jyc228 jyc228 deleted the refac/rename-experimentalzktrie-to-kromazktrie branch February 27, 2024 07:54
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