-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
refactor(store/v2): Store v2 supports create state at version 0 #20643
Conversation
This reverts commit 214605b.
WalkthroughWalkthroughThe changes across several test files aim to adjust the versioning logic from starting at Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 8
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (6)
- store/v2/commitment/store.go (7 hunks)
- store/v2/commitment/store_test_suite.go (2 hunks)
- store/v2/migration/manager_test.go (2 hunks)
- store/v2/root/migrate_test.go (3 hunks)
- store/v2/root/store.go (2 hunks)
- store/v2/root/store_test.go (8 hunks)
Files not summarized due to errors (1)
- store/v2/commitment/store.go: Error: Server error. Please try again later.
Files skipped from review due to trivial changes (1)
- store/v2/migration/manager_test.go
Additional context used
Path-based instructions (5)
store/v2/commitment/store_test_suite.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.store/v2/root/migrate_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"store/v2/root/store_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"store/v2/root/store.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.store/v2/commitment/store.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (8)
store/v2/commitment/store_test_suite.go (1)
Line range hint
36-104
: Changes align with the PR's objective to support versioning starting from 0. Ensure snapshot functionality is correctly handling the new version range.store/v2/root/migrate_test.go (2)
52-52
: Changes correctly adjust the versioning to start from 0, aligning with the PR's objective. Verify that the migration setup handles the new version range correctly.
Line range hint
94-134
: Changes correctly adjust the versioning to start from 0 in the migration tests, ensuring comprehensive coverage from the initial version. Verify that the migration process handles the new version range correctly.store/v2/root/store_test.go (5)
Line range hint
92-104
: Changes correctly adjust the versioning to start from 0 in the query tests, aligning with the PR's objective. Verify that the query functionality handles the new version range correctly.
150-153
: Changes correctly adjust the versioning to start from 0 in the proof tests, ensuring comprehensive coverage from the initial version. Verify that the proof functionality handles the new version range correctly.
Line range hint
275-296
: Changes correctly adjust the versioning to start from 0 in the state at tests, ensuring comprehensive coverage from the initial version. Verify that the state at functionality handles the new version range correctly.
120-130
: Changes correctly adjust the versioning to start from 0 in the fallback tests, ensuring comprehensive coverage from the initial version. Verify that the fallback functionality handles the new version range correctly.Verification successful
Let's directly run the Go test suite for the
store/v2/root/store_test.go
file to verify the fallback functionality.
Since the
go
command is not available, let's inspect theTestGetFallback
function directly to ensure it correctly tests the fallback functionality.
Let's use
rg
to search for theTestGetFallback
function and display its surrounding lines to inspect the implementation.
Let's search for all function definitions in the
store/v2/root/store_test.go
file to confirm the presence ofTestGetFallback
.
Let's search for the
TestGetFallback
function and display its surrounding lines to inspect the implementation.
Let's use
rg
to search for theTestGetFallback
function with a simpler pattern and display its surrounding lines.
The
TestGetFallback
function is correctly implemented to test the fallback functionality starting from version 0. It ensures that the fallback mechanism works as expected by querying for a key and verifying the result.
- The function creates a changeset and commits it to the state commitment.
- It then queries for the key and checks if the fallback to the state commitment is successful.
- It also tests querying a non-existent key to ensure proper handling.
This confirms that the fallback functionality is tested comprehensively from the initial version.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify fallback functionality handles the new version range correctly. # Test: Run the fallback test and check for errors. rg --type go $'TestGetFallback' store/v2/root/store_test.go --exec go test {}Length of output: 487
Script:
#!/bin/bash # Description: Run the Go test suite for the store_test.go file to verify fallback functionality. # Locate the store_test.go file and run the tests. go test ./store/v2/root/store_test.goLength of output: 109
Script:
#!/bin/bash # Description: Retrieve the implementation of the TestGetFallback function from the store_test.go file. # Locate the TestGetFallback function in the store_test.go file. ast-grep --lang go --pattern $'func TestGetFallback($_) { $$$ }' store/v2/root/store_test.goLength of output: 95
Script:
#!/bin/bash # Description: Search for the TestGetFallback function and display its surrounding lines. # Locate the TestGetFallback function and display 20 lines before and after its occurrence. rg 'func TestGetFallback' -A 20 -B 20 store/v2/root/store_test.goLength of output: 67
Script:
#!/bin/bash # Description: Search for all function definitions in the store_test.go file to confirm the presence of TestGetFallback. # Locate all function definitions in the store_test.go file. rg 'func ' store/v2/root/store_test.goLength of output: 666
Script:
#!/bin/bash # Description: Search for the TestGetFallback function and display its surrounding lines. # Locate the TestGetFallback function and display 20 lines before and after its occurrence. rg 'func (s \*RootStoreTestSuite) TestGetFallback' -A 20 -B 20 store/v2/root/store_test.goLength of output: 92
Script:
#!/bin/bash # Description: Search for the TestGetFallback function and display its surrounding lines. # Locate the TestGetFallback function and display 20 lines before and after its occurrence. rg 'TestGetFallback' -A 20 -B 20 store/v2/root/store_test.goLength of output: 1404
Line range hint
166-180
: Changes correctly adjust the versioning to start from 0 in the load version tests, ensuring comprehensive coverage from the initial version. Verify that the load version functionality handles the new version range correctly.Verification successful
The
TestLoadVersion
function is present in thestore/v2/root/store_test.go
file and its implementation correctly handles the new version range by writing and committing changesets starting from version 0. It also ensures the latest version is correct and attempts to load a non-existent version to check for errors.
store/v2/root/store_test.go
, lines 163-169: The function writes and commits changesets starting from version 0.store/v2/root/store_test.go
, lines 170-176: The function ensures the latest version is correct.store/v2/root/store_test.go
, lines 177-179: The function attempts to load a non-existent version and checks for errors.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify load version functionality handles the new version range correctly. # Test: Run the load version test and check for errors. rg --type go $'TestLoadVersion' store/v2/root/store_test.go --exec go test {}Length of output: 487
Script:
#!/bin/bash # Description: Run the Go tests in the store/v2/root/store_test.go file to verify the load version functionality. # Locate the store_test.go file and run the tests. fd store_test.go --exec go test {}Length of output: 684
Script:
#!/bin/bash # Description: Extract the implementation of the TestLoadVersion function from the store/v2/root/store_test.go file. # Locate the store_test.go file and extract the TestLoadVersion function implementation. fd store_test.go --exec ast-grep --lang go --pattern $'func TestLoadVersion($_) { $$$ }' {}Length of output: 96
Script:
#!/bin/bash # Description: Search for the TestLoadVersion function definition and extract the surrounding lines from the store/v2/root/store_test.go file. # Locate the store_test.go file and search for the TestLoadVersion function definition. fd store_test.go --exec rg --context 20 'func TestLoadVersion' {}Length of output: 69
Script:
#!/bin/bash # Description: Search for all function definitions in the store/v2/root/store_test.go file. # Locate the store_test.go file and search for all function definitions. fd store_test.go --exec rg --type go --pattern '^func ' {}Length of output: 7890
Script:
#!/bin/bash # Description: Search for all function definitions in the store/v2/root/store_test.go file. # Locate the store_test.go file and search for all function definitions. fd store_test.go --exec rg '^func ' {}Length of output: 10446
Script:
#!/bin/bash # Description: Extract the implementation of the TestLoadVersion function from the store/v2/root/store_test.go file. # Locate the store_test.go file and extract the lines surrounding the TestLoadVersion function definition. fd store_test.go --exec rg --context 20 'func (s *RootStoreTestSuite) TestLoadVersion' {}Length of output: 93
Script:
#!/bin/bash # Description: Extract the implementation of the TestLoadVersion function from the store/v2/root/store_test.go file. # Locate the store_test.go file and extract the TestLoadVersion function implementation. fd store_test.go --exec ast-grep --lang go --pattern $'func (s *RootStoreTestSuite) TestLoadVersion($_) { $$$ }' {}Length of output: 120
Script:
#!/bin/bash # Description: Search for the TestLoadVersion function definition and extract the surrounding lines from the store/v2/root/store_test.go file. # Locate the store_test.go file and search for the TestLoadVersion function definition. fd store_test.go --exec rg --context 20 'TestLoadVersion' {}Length of output: 1378
// since iavl still start version at 1 | ||
// TODO: revert this after iavl support create state at version 0 | ||
treeVer := version + 1 | ||
|
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.
Update the version adjustment logic for proof generation.
- // since iavl still start version at 1
- // TODO: revert this after iavl support create state at version 0
- treeVer := version + 1
+ // Adjusted to start at version 0 as per new requirements
+ treeVer := version
Similar to the previous comment, this change is necessary to ensure consistency across all methods that handle versioning. Confirm that all dependent components are compatible with this versioning change.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// since iavl still start version at 1 | |
// TODO: revert this after iavl support create state at version 0 | |
treeVer := version + 1 | |
// Adjusted to start at version 0 as per new requirements | |
treeVer := version |
// since iavl start at version 1 instead of 0 | ||
// TODO: revert this after iavl support create state at version 0 | ||
treeVer := targetVersion + 1 | ||
|
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.
Adjust the versioning logic to start at 0.
- // since iavl start at version 1 instead of 0
- // TODO: revert this after iavl support create state at version 0
- treeVer := targetVersion + 1
+ // Adjusted to start at version 0 as per new requirements
+ treeVer := targetVersion
This change aligns with the PR's objective to support creating state at version 0. Ensure that the iavl
library is updated to support this change before removing the TODO comment.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// since iavl start at version 1 instead of 0 | |
// TODO: revert this after iavl support create state at version 0 | |
treeVer := targetVersion + 1 | |
// Adjusted to start at version 0 as per new requirements | |
treeVer := targetVersion |
// since iavl still start at version 1 instead of 0 | ||
// TODO: revert this after iavl support create state at version 0 | ||
treeVer := version + 1 | ||
|
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.
Correct the versioning in the Get
method.
- // since iavl still start at version 1 instead of 0
- // TODO: revert this after iavl support create state at version 0
- treeVer := version + 1
+ // Adjusted to start at version 0 as per new requirements
+ treeVer := version
Ensure that the Get
method correctly interacts with the adjusted versioning system. This change is crucial for maintaining the integrity of data retrieval operations.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// since iavl still start at version 1 instead of 0 | |
// TODO: revert this after iavl support create state at version 0 | |
treeVer := version + 1 | |
// Adjusted to start at version 0 as per new requirements | |
treeVer := version |
// since iavl start at version 1 instead of 0 | ||
// TODO: revert this after iavl support create state at version 0 | ||
treeVer := version + 1 | ||
|
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.
Modify the pruning logic to accommodate the new versioning system.
- // since iavl start at version 1 instead of 0
- // TODO: revert this after iavl support create state at version 0
- treeVer := version + 1
+ // Adjusted to start at version 0 as per new requirements
+ treeVer := version
This adjustment ensures that the pruning process is consistent with the new versioning system. Verify that this change does not affect the integrity of the pruning process.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// since iavl start at version 1 instead of 0 | |
// TODO: revert this after iavl support create state at version 0 | |
treeVer := version + 1 | |
// Adjusted to start at version 0 as per new requirements | |
treeVer := version |
// since iavl still start at version 1 instead of 0 | ||
// TODO: revert this after iavl support create state at version 0 | ||
treeVer := version + 1 | ||
|
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.
Revise the restore logic to align with the new versioning system.
- // since iavl still start at version 1 instead of 0
- // TODO: revert this after iavl support create state at version 0
- treeVer := version + 1
+ // Adjusted to start at version 0 as per new requirements
+ treeVer := version
Ensure that the restore functionality is compatible with the new versioning system. This is critical for maintaining data consistency during state restoration.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// since iavl still start at version 1 instead of 0 | |
// TODO: revert this after iavl support create state at version 0 | |
treeVer := version + 1 | |
// Adjusted to start at version 0 as per new requirements | |
treeVer := version |
// since iavl start at version 1 instead of 0 | ||
treeVer := version + 1 | ||
|
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.
Update the snapshot versioning logic.
- // since iavl start at version 1 instead of 0
- treeVer := version + 1
+ // Adjusted to start at version 0 as per new requirements
+ treeVer := version
This change is necessary to ensure that snapshots are correctly handled under the new versioning system. It's important to test this thoroughly to avoid any issues with snapshot integrity.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// since iavl start at version 1 instead of 0 | |
treeVer := version + 1 | |
// Adjusted to start at version 0 as per new requirements | |
treeVer := version |
@@ -72,7 +72,7 @@ func New( | |||
) (store.RootStore, error) { | |||
return &Store{ | |||
logger: logger.With("module", "root_store"), | |||
initialVersion: 1, | |||
initialVersion: 0, |
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.
Tip
Codebase Verification
No tests were found that verify the initial version being set to 0. Please add a test to ensure the initial version is correctly set to 0 in the store initialization.
store/v2/root/store.go
:initialVersion: 0
Analysis chain
Changes correctly set the initial version to 0 in the store's constructor, aligning with the PR's objective. Verify that the store initialization handles the new initial version correctly.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify store initialization handles the new initial version correctly.
# Test: Check the initial version after store creation.
rg --type go $'New' store/v2/root/store.go --exec go test {}
Length of output: 470
Script:
#!/bin/bash
# Description: Locate the New function and search for relevant tests.
# Step 1: Locate the New function in store/v2/root/store.go
echo "Locating the New function in store/v2/root/store.go"
ast-grep --lang go --pattern $'func New($_) $_' store/v2/root/store.go
# Step 2: Search for tests that verify the initial version of the store
echo "Searching for tests that verify the initial version of the store"
rg --type go 'initialVersion' --tests
Length of output: 793
Script:
#!/bin/bash
# Description: Locate the New function and search for relevant tests.
# Step 1: Locate the New function in store/v2/root/store.go
echo "Locating the New function in store/v2/root/store.go"
ast-grep --lang go --pattern $'func New($_) $_' store/v2/root/store.go
# Step 2: Search for test files that might contain tests for the initialVersion
echo "Searching for test files that might contain tests for the initialVersion"
rg --type go 'initialVersion'
Length of output: 2117
Script:
#!/bin/bash
# Description: Extract and review the relevant test from store/rootmulti/store_test.go
# Step 1: Extract the test that checks the initial version in store/rootmulti/store_test.go
echo "Extracting the test that checks the initial version in store/rootmulti/store_test.go"
rg --type go 'initialVersion' store/rootmulti/store_test.go
Length of output: 288
Script:
#!/bin/bash
# Description: Search for other tests that might check the initial version being set to 0.
# Step 1: Search for tests that check the initial version being set to 0
echo "Searching for tests that check the initial version being set to 0"
rg --type go 'initialVersion.*0' --tests
Length of output: 615
Script:
#!/bin/bash
# Description: Search for other tests that might check the initial version being set to 0.
# Step 1: Search for test files that might contain tests for the initial version
echo "Searching for test files that might contain tests for the initial version"
rg --type go 'initialVersion.*0'
Length of output: 296
if s.lastCommitInfo == nil { | ||
version = 0 | ||
} else { | ||
version = previousHeight + 1 | ||
} | ||
|
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.
Tip
Codebase Verification
The test cases in store/rootmulti/store_test.go
do reference lastCommitInfo
and verify its version after committing. However, there is no explicit test case that checks the behavior when lastCommitInfo
is nil.
To ensure comprehensive coverage, a new test case should be added to verify the behavior of writeSC
when lastCommitInfo
is nil.
- Add a test case to
store/rootmulti/store_test.go
to verify the behavior whenlastCommitInfo
is nil.
Analysis chain
Changes correctly handle the case where lastCommitInfo
is nil by starting from version 0 in the writeSC
method, ensuring that the store correctly handles the new initial version. Verify that the writeSC functionality handles the new version range correctly.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify writeSC functionality handles the new version range correctly.
# Test: Check the behavior of writeSC when `lastCommitInfo` is nil.
rg --type go $'writeSC' store/v2/root/store.go --exec go test {}
Length of output: 474
Script:
#!/bin/bash
# Step 1: Search for the `writeSC` function definition in the codebase.
ast-grep --lang go --pattern 'func writeSC($_, $_) $_'
# Step 2: Identify test files that include tests for `writeSC`.
rg 'writeSC' --type go --glob '*_test.go'
Length of output: 98
Script:
#!/bin/bash
# Step 1: Search for the `writeSC` function definition with a broader pattern.
ast-grep --lang go --pattern 'func writeSC($$$) $_'
# Step 2: Search for any references to `lastCommitInfo` in test files.
rg 'lastCommitInfo' --type go --glob '*_test.go'
Length of output: 605
Script:
#!/bin/bash
# Extract relevant test cases from store/rootmulti/store_test.go that reference lastCommitInfo.
rg -A 10 'lastCommitInfo' store/rootmulti/store_test.go
Length of output: 1132
Description
ref: #20443
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit