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

store/v2: remove auto migration and fix restore cmd #23568

Merged
merged 16 commits into from
Jan 31, 2025

Conversation

alpe
Copy link
Contributor

@alpe alpe commented Jan 31, 2025

Description

  • Merge main
  • Bugfixes

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...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

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...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Release Notes

  • Improvements

    • Removed auto migration functionality from store module
    • Enhanced store key retrieval capabilities
    • Simplified store initialization process
  • Bug Fixes

    • Fixed restore command in store module
    • Improved snapshot restoration handling
  • Chores

    • Updated dependency management in various modules
    • Removed migration-related code and test configurations
  • Testing

    • Enabled previously skipped system tests for snapshots and pruning
    • Refined test suite configurations

These changes focus on streamlining the store module's functionality and improving overall system reliability.

mmsqe and others added 11 commits January 14, 2025 14:24
* main: (61 commits)
  build(deps): Bump cosmossdk.io/x/tx from 1.0.1 to 1.1.0 (#23547)
  feat(client/v2): add map support (#23544)
  fix(db): Fix pebbleDB integration (#23552)
  build(deps): Bump buf.build/gen/go/cometbft/cometbft/protocolbuffers/go from 1.36.3-20241120201313-68e42a58b301.1 to 1.36.4-20241120201313-68e42a58b301.1 in /api (#23520)
  build(deps): Bump github.com/golang/glog from 1.2.3 to 1.2.4 in /tools/hubl (#23541)
  fix(x/tx): add an option to encode maps using amino json (ref #23513) (#23539)
  build(deps): Bump cosmossdk.io/collections from 1.0.0 to 1.1.0 (#23534)
  build(deps): Bump github.com/bytedance/sonic from 1.12.7 to 1.12.8 in /log (#23516)
  chore: fix changelog for `v0.52.0-rc.2` (#23502)
  build(deps): Bump google.golang.org/protobuf from 1.36.3 to 1.36.4 in /x/upgrade (#23512)
  chore(collections): bring in `protocodec` in collections directly (#23515)
  feat(x/tx): add an option to encode maps using amino json (#23513)
  fix(codec): provide legacy amino og type (#23504)
  chore: remove unecessary SDKGasMeter impl (#23503)
  refactor: replace `golang.org/x/exp` with stdlib (#23501)
  build(deps): Bump google.golang.org/grpc from 1.69.4 to 1.70.0 in /tools/cosmovisor (#23496)
  build(deps): Bump google.golang.org/grpc from 1.69.4 to 1.70.0 in /store (#23494)
  build(deps): Bump github.com/hashicorp/go-plugin from 1.6.2 to 1.6.3 in /store (#23493)
  ci: Fix Ci job target (#23500)
  feat(server/v2): add swagger server component (#23486)
  ...
Copy link
Contributor

coderabbitai bot commented Jan 31, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 golangci-lint (1.62.2)

level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package sqlite3: could not load export data: no export data for "github.com/bvinc/go-sqlite-lite/sqlite3""
level=error msg="Running error: can't run linter goanalysis_metalinter\nbuildir: failed to load package sqlite3: could not load export data: no export data for "github.com/bvinc/go-sqlite-lite/sqlite3""

📝 Walkthrough

Walkthrough

This pull request introduces significant changes to the Cosmos SDK's store and server modules, primarily focusing on removing migration-related functionality and simplifying the store management process. The modifications span multiple files across different packages, including runtime/v2, server/v2, and store/v2. Key changes include removing auto-migration logic, updating dependency management, and refactoring store initialization and snapshot restoration processes.

Changes

File Change Summary
runtime/v2/go.mod Added replace directive for cosmossdk.io/store/v2, added/removed several indirect dependencies
server/v2/commands.go Added new store-related commands: restore, prune, export
server/v2/store/commands.go Simplified pruning command by directly using s.store
server/v2/store/server.go Changed store field type from Backend to RootStore
store/v2/root/* Removed migration-related fields and logic across multiple files
store/v2/commitment/store.go Added version setting during node restoration
store/v2/root/builder.go Added GetStoreKeys() method to Builder interface

Sequence Diagram

sequenceDiagram
    participant Server
    participant RootStore
    participant CommitStore
    
    Server->>RootStore: Create with New()
    RootStore->>CommitStore: Initialize
    RootStore-->>Server: Return Store Instance
    
    Note over Server,RootStore: Migration logic removed
    Note over Server,RootStore: Simplified store initialization
Loading

Possibly related PRs

Suggested Labels

C:server/v2 appmanager, C:server/v2 cometbft

Suggested Reviewers

  • kocubinski
  • aljo242
  • julienrbrt
  • tac0turtle
  • testinginprod
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

This comment has been minimized.

Copy link
Contributor

@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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
store/v2/CHANGELOG.md (1)

29-29: Add blank lines around list items.

According to markdown best practices, list items should be surrounded by blank lines for better readability.

Apply this diff to fix the formatting:

 ### Improvements
+
 * [#23568](https://github.com/cosmos/cosmos-sdk/pull/23568) Remove auto migration and fix restore cmd
 * [#23013](https://github.com/cosmos/cosmos-sdk/pull/23013) Support memDB for sims
+
 ### Bug Fixes
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

29-29: Lists should be surrounded by blank lines
null

(MD032, blanks-around-lists)

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8eb6822 and 5ed53a4.

⛔ Files ignored due to path filters (1)
  • runtime/v2/go.sum is excluded by !**/*.sum
📒 Files selected for processing (17)
  • runtime/v2/go.mod (3 hunks)
  • server/v2/commands.go (1 hunks)
  • server/v2/store/commands.go (2 hunks)
  • server/v2/store/server.go (1 hunks)
  • server/v2/store/snapshot.go (2 hunks)
  • simapp/v2/go.mod (0 hunks)
  • store/v2/CHANGELOG.md (1 hunks)
  • store/v2/commitment/store.go (1 hunks)
  • store/v2/root/builder.go (2 hunks)
  • store/v2/root/factory.go (2 hunks)
  • store/v2/root/factory_test.go (0 hunks)
  • store/v2/root/migrate_test.go (1 hunks)
  • store/v2/root/store.go (1 hunks)
  • store/v2/root/store_mock_test.go (0 hunks)
  • store/v2/root/store_test.go (3 hunks)
  • store/v2/root/upgrade_test.go (2 hunks)
  • tests/systemtests/store_test.go (2 hunks)
💤 Files with no reviewable changes (3)
  • store/v2/root/factory_test.go
  • simapp/v2/go.mod
  • store/v2/root/store_mock_test.go
✅ Files skipped from review due to trivial changes (1)
  • store/v2/root/store.go
🧰 Additional context used
📓 Path-based instructions (12)
server/v2/commands.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

store/v2/root/factory.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

store/v2/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

store/v2/root/builder.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.

server/v2/store/snapshot.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

store/v2/root/upgrade_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"

tests/systemtests/store_test.go (3)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

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"

server/v2/store/server.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/store/commands.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

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"

🪛 markdownlint-cli2 (0.17.2)
store/v2/CHANGELOG.md

29-29: Lists should be surrounded by blank lines
null

(MD032, blanks-around-lists)

🪛 GitHub Actions: v2 core Tests
tests/systemtests/store_test.go

[error] TestAccountCreation failed: timeout waiting for node start: 45s

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: tests (00)
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (19)
store/v2/CHANGELOG.md (1)

29-29: LGTM! The changelog entry is well-formatted and clear.

The new entry follows the changelog format guidelines and provides a clear description of the changes.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

29-29: Lists should be surrounded by blank lines
null

(MD032, blanks-around-lists)

server/v2/store/server.go (1)

27-27: LGTM! Type change improves type safety

The change from Backend to RootStore provides better type safety and clearer intent about the required store implementation.

Also applies to: 30-30

tests/systemtests/store_test.go (2)

29-31: LGTM! Simplified snapshot restore directories

The change to only include application.db in restorable directories aligns with the store implementation changes.

🧰 Tools
🪛 GitHub Actions: v2 core Tests

[error] TestAccountCreation failed: timeout waiting for node start: 45s


65-66: Verify chain restart timing

The added chain restart and block wait improves test reliability, but might be related to the TestAccountCreation timeout in CI.

✅ Verification successful

Chain restart timing is consistent with codebase patterns

The added 2-block wait is consistent with similar patterns across the test suite, where tests commonly wait for 2-10 blocks after chain start. The system tests have a 15-minute CI timeout, which is more than sufficient for this operation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for similar timeout patterns in other test files
rg -A 5 "StartChain\(t\)" --type go | grep -B 5 "AwaitNBlocks"

Length of output: 2651


Script:

#!/bin/bash
# Search for TestAccountCreation implementation and timing patterns
rg -l "TestAccountCreation" --type go
rg "func TestAccountCreation" -A 10 --type go

# Look for test timeouts in CI configuration
fd "\.github|\.gitlab-ci" --type f | xargs rg "timeout|TIMEOUT"

Length of output: 66001

🧰 Tools
🪛 GitHub Actions: v2 core Tests

[error] TestAccountCreation failed: timeout waiting for node start: 45s

store/v2/root/builder.go (1)

28-29: LGTM! Well-implemented store keys accessor

The GetStoreKeys method is efficiently implemented with pre-allocated capacity and provides useful access to registered store keys.

Also applies to: 104-110

store/v2/root/factory.go (1)

117-117: LGTM! Successfully removed migration logic

The removal of migration logic simplifies the store creation process and aligns with the PR objectives. The code is now more focused and maintainable.

Also applies to: 142-142

store/v2/root/upgrade_test.go (2)

47-47: LGTM: Constructor call simplified

The removal of the last nil argument aligns with the simplified store initialization.


89-89: LGTM: Consistent constructor usage

The change maintains consistency with the earlier constructor call.

store/v2/root/migrate_test.go (1)

70-70: LGTM: Constructor call simplified

The change is consistent with the simplified store initialization pattern.

server/v2/store/commands.go (1)

Line range hint 48-61: LGTM: Simplified store access pattern

The changes improve the code by:

  1. Directly using the server's store instance instead of creating a new one
  2. Simplifying the error handling flow
  3. Reducing unnecessary object creation
server/v2/commands.go (1)

187-189: LGTM: Added store commands to app building requirements

The addition of store commands to appBuildingCommands ensures proper application initialization for store operations.

server/v2/store/snapshot.go (2)

45-48: LGTM! Simplified snapshot manager creation.

The code now directly uses s.store instead of creating a new root store, which simplifies the snapshot management process.


86-89: LGTM! Consistent with the snapshot manager creation changes.

The restore command follows the same pattern of using s.store directly.

store/v2/commitment/store.go (1)

566-568: LGTM! Fixed version handling during snapshot restoration.

Setting the version for nodes with version 0 ensures consistent versioning during snapshot restoration.

Run the following script to verify version handling in other snapshot-related code:

✅ Verification successful

✓ Version handling during snapshot restoration is correct

The version check and assignment for nodes with version 0 follows established patterns in the codebase for handling unset versions during snapshot restoration. This is consistent with similar version handling throughout the codebase, particularly in snapshot-related operations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other places where version 0 might be handled
ast-grep --pattern $'if $x.Version == 0 {
  $$$
}'

Length of output: 51


Script:

#!/bin/bash
# Search for Version field assignments and comparisons
rg "Version\s*(==|=)\s*\d+" -A 2

# Search for snapshot restoration related code with version handling
rg "snapshot|restore.*[Vv]ersion" -A 3

# Try alternative ast-grep pattern for version checks
ast-grep --pattern 'node.Version = $x'

Length of output: 78656

store/v2/root/store_test.go (3)

55-56: LGTM! Updated constructor call.

Removed unnecessary nil arguments from the New function call, reflecting the removal of migration-related parameters.


76-77: LGTM! Consistent constructor update.

The changes maintain consistency with the updated New function signature.


85-86: LGTM! Consistent constructor update.

The changes maintain consistency with the updated New function signature.

runtime/v2/go.mod (2)

28-29: LGTM! Added replace directive for local development.

The replace directive ensures the store/v2 module is resolved from the local path.


36-36: Verify new indirect dependencies.

Several new indirect dependencies have been added. Please ensure they are necessary and their versions are compatible.

Run the following script to check dependency compatibility:

Also applies to: 38-38, 50-50, 53-53, 65-65

✅ Verification successful

All dependencies verified and compatible

The go mod verify check passed successfully and all dependencies, including the new indirect ones, are properly versioned and compatible. No conflicts or issues were detected in the dependency graph.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential dependency conflicts
go mod verify
go mod graph | awk '{if ($1 !~ /@/ || $2 !~ /@/) print $0}'

Length of output: 265


Script:

#!/bin/bash
# First verify the file exists and check its content
if [ -f runtime/v2/go.mod ]; then
    echo "=== go.mod content ==="
    cat runtime/v2/go.mod
    echo -e "\n=== Checking dependencies ==="
    cd runtime/v2
    go mod verify
    echo -e "\n=== Dependency graph ==="
    go mod graph | awk '{if ($1 !~ /@/ || $2 !~ /@/) print $0}'
else
    echo "go.mod file not found at runtime/v2/go.mod"
fi

Length of output: 9775

store/v2/root/builder.go Fixed Show fixed Hide fixed
@tac0turtle tac0turtle added this pull request to the merge queue Jan 31, 2025
Merged via the queue into main with commit 9a92843 Jan 31, 2025
67 of 70 checks passed
@tac0turtle tac0turtle deleted the alex/marko/kill_migration branch January 31, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants