Skip to content

test: add migration integration test #150

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

Merged
merged 27 commits into from
Jun 26, 2025
Merged

test: add migration integration test #150

merged 27 commits into from
Jun 26, 2025

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Jun 23, 2025

Closes #77 (#77 (comment))

Summary by CodeRabbit

  • New Features

    • Introduced an automated migration test workflow for transitioning from a Cosmos SDK chain to a Rollkit-based chain, including verification of blocks, transactions, and balances before and after migration.
    • Added support for initializing the chain from a minimal migration genesis file, enabling smoother migrations to Rollkit.
  • Refactor

    • Improved migration command to generate a minimal Rollkit genesis file and handle multiple Rollkit stores.
    • Unified genesis file handling to support both standard and migration-based startups.
    • Enhanced integration test reliability by switching block count detection from log parsing to direct blockchain queries.
  • Chores

    • Updated dependency declarations for improved clarity.

Copy link

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

Copy link
Contributor

coderabbitai bot commented Jun 23, 2025

"""

Walkthrough

This update introduces a GitHub Actions workflow for automated migration testing from a Cosmos SDK chain to Rollkit, refactors the migration command to generate a minimal Rollkit genesis and handle multiple stores, and updates node startup logic to support migration genesis files. Additional minor dependency and struct updates are included.

Changes

File(s) Change Summary
.github/workflows/migration_test.yml Adds a comprehensive GitHub Actions workflow to test migration from Cosmos SDK to Rollkit, including chain setup, migration, transaction validation, and robust cleanup.
.github/workflows/integration_test.yml Changes block counting logic from log-based heuristic to querying current block height via CLI JSON output for more accurate block detection.
go.mod Moves github.com/celestiaorg/go-header from indirect to direct dependency.
pkg/rpc/core/status.go Removes the ProposerPriority field from cmttypes.Validator struct initialization for genesis validator creation.
server/migration_cmd.go Refactors and extends the migration command: renames it, adds detailed description, introduces a minimal Rollkit genesis struct and file creation, loads multiple Rollkit stores, improves error handling, and updates migration logic to initialize additional stores and generate a migration genesis file.
server/start.go Refactors node initialization to support loading a minimal Rollkit migration genesis file, adds helper functions for migration genesis loading and conversion, and unifies genesis handling for both migration and standard startup paths.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant CosmosSDK Chain
    participant Rollkit Chain
    participant DA Node

    GitHub Actions->>CosmosSDK Chain: Scaffold, build, initialize, start
    GitHub Actions->>CosmosSDK Chain: Send transactions, verify state
    GitHub Actions->>CosmosSDK Chain: Stop chain
    GitHub Actions->>Rollkit Chain: Add Rollkit, rebuild
    GitHub Actions->>Rollkit Chain: Run migration command (generate minimal genesis, migrate stores)
    GitHub Actions->>DA Node: Start DA node
    GitHub Actions->>Rollkit Chain: Start migrated chain
    GitHub Actions->>Rollkit Chain: Send transactions, verify state
    GitHub Actions->>Rollkit Chain: Query old blocks/transactions
Loading
sequenceDiagram
    participant MigrationCmd
    participant CometBFT State
    participant Rollkit Stores
    participant Genesis File

    MigrationCmd->>CometBFT State: Load blockstore and state
    MigrationCmd->>Rollkit Stores: Initialize multiple stores (rollkit, abci exec, header sync, data sync)
    MigrationCmd->>Rollkit Stores: Migrate blocks and state
    MigrationCmd->>Genesis File: Generate minimal Rollkit migration genesis file
Loading

Assessment against linked issues

Objective Addressed Explanation
Enable smooth migration from CometBFT to Rollkit (#77)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

  • feat(server): add migration command #113: Refactors and extends the migration command, adding support for multiple Rollkit stores, minimal genesis generation, and improved error handling—directly related to the migration logic updated in this PR.

  • ci: add tx test in integration test #87: Adds transaction test steps in integration workflows; related at the level of CI testing of transactions but modifies different workflows than this PR.

Suggested reviewers

  • tac0turtle

Poem

A bunny hopped from chain to chain,
Migrating blocks with gentle gain.
Genesis files, now light and neat,
Rollkit’s rhythm skips a beat.
From Cosmos roots to Rollkit heights,
The test runs through the starry nights—
🐇 All systems go, the future’s bright!
"""

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

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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.

Base automatically changed from julien/migration to main June 24, 2025 08:45
@julienrbrt julienrbrt force-pushed the julien/migration-2 branch from ce72557 to b15457e Compare June 24, 2025 09:20
@julienrbrt julienrbrt marked this pull request as ready for review June 25, 2025 20:44
@julienrbrt julienrbrt requested a review from a team as a code owner June 25, 2025 20:44
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

♻️ Duplicate comments (1)
server/migration_cmd.go (1)

374-378: TODO is already tracked by maintainer.

As noted in the existing comment, this will be logged as a separate issue.

🧹 Nitpick comments (2)
server/start.go (1)

650-672: Consider extracting the genesis filename as a shared constant.

The hardcoded filename "rollkit_genesis.json" appears both here and in the migration command. Consider defining it as a shared constant to ensure consistency.

-const rollkitGenesisFilename = "rollkit_genesis.json"
+const RollkitGenesisFilename = "rollkit_genesis.json"

Then update both files to use this shared constant.

.github/workflows/migration_test.yml (1)

63-63: Remove trailing spaces.

YAMLlint detected trailing spaces on these lines.

-            ATTEMPT=$((ATTEMPT+1))
-            
+            ATTEMPT=$((ATTEMPT+1))
+
-            fi
-            
+            fi
+

Also applies to: 70-70, 233-233, 240-240

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c5a41d and 918d73d.

📒 Files selected for processing (5)
  • .github/workflows/migration_test.yml (1 hunks)
  • go.mod (1 hunks)
  • pkg/rpc/core/status.go (1 hunks)
  • server/migration_cmd.go (8 hunks)
  • server/start.go (10 hunks)
🧰 Additional context used
🧠 Learnings (1)
server/migration_cmd.go (1)
Learnt from: julienrbrt
PR: rollkit/go-execution-abci#113
File: server/migration_cmd.go:231-231
Timestamp: 2025-06-20T13:20:04.030Z
Learning: In the rollkit migration command (server/migration_cmd.go), InitialHeight is correctly set to LastBlockHeight because the Rollkit chain is technically a new chain that starts where the CometBFT chain ended, ensuring continuity during migration.
🪛 YAMLlint (1.37.1)
.github/workflows/migration_test.yml

[error] 63-63: trailing spaces

(trailing-spaces)


[error] 70-70: trailing spaces

(trailing-spaces)


[error] 233-233: trailing spaces

(trailing-spaces)


[error] 240-240: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: Test with Rollkit Chain
  • GitHub Check: Test Migration from Cosmos SDK to Rollkit
🔇 Additional comments (10)
go.mod (1)

18-18: LGTM!

The dependency change is correct - github.com/celestiaorg/go-header is now directly imported in server/migration_cmd.go for the header and data sync stores, so it should be a direct dependency.

pkg/rpc/core/status.go (1)

56-59: LGTM!

Removing ProposerPriority aligns with Rollkit's single-sequencer model and the simplified validator representation used in the minimal genesis format.

server/start.go (2)

331-380: Well-structured genesis loading with dual-source support.

The implementation elegantly handles both migration and normal startup scenarios. The manually constructed app genesis for RPC compatibility is a good solution.


674-686: LGTM!

Clean conversion from CometBFT genesis to Rollkit genesis format.

.github/workflows/migration_test.yml (2)

175-175: Address the TODO before merging.

The workflow currently uses a specific commit hash. Ensure this is updated to use the main branch once PR #209 is merged.


1-373: Excellent end-to-end migration test coverage!

This workflow provides comprehensive testing of the migration process, including chain initialization, transaction verification, and post-migration state consistency checks.

server/migration_cmd.go (4)

41-59: Well-designed minimal genesis structure.

The rollkitMigrationGenesis struct contains exactly the essential information needed for post-migration startup, keeping the genesis file minimal and focused.


64-73: Improved command naming and documentation.

The rename to rollkit-migrate is more concise, and the detailed description clearly explains the migration process.


309-343: Comprehensive store loading with proper isolation.

The multi-store approach properly separates concerns and uses prefix transforms for namespace isolation. Good addition of metrics for the sync stores.


102-104: Excellent error handling improvements.

The consistent use of error wrapping with descriptive messages and proper resource cleanup with errors.Join follows Go best practices.

Also applies to: 117-118, 122-123, 150-151, 208-208

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: 4

🧹 Nitpick comments (1)
.github/workflows/migration_test.yml (1)

63-63: Remove trailing whitespace to satisfy YAML-lint

The CI already flags these lines; deleting the stray spaces keeps the workflow lint-clean.

Also applies to: 70-70, 233-233, 240-240

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 918d73d and 2f14b3a.

📒 Files selected for processing (1)
  • .github/workflows/migration_test.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/migration_test.yml

[error] 63-63: trailing spaces

(trailing-spaces)


[error] 70-70: trailing spaces

(trailing-spaces)


[error] 233-233: trailing spaces

(trailing-spaces)


[error] 240-240: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: lint / golangci-lint
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: Test Migration from Cosmos SDK to Rollkit
  • GitHub Check: Test with Rollkit Chain
🔇 Additional comments (2)
.github/workflows/migration_test.yml (2)

297-299: Arithmetic relies on all-numeric strings

gmd query bank balances … | jq '.balances[0].amount' returns a JSON string.
If the amount ever contains non-numeric characters (e.g. "0" vs "\"0\""), Bash arithmetic expansion will fail.

Add explicit coercion:

-          EXPECTED_BOB_BALANCE=$((BOB_BALANCE_BEFORE - 4000 + 1000))
+          EXPECTED_BOB_BALANCE=$((10#${BOB_BALANCE_BEFORE} - 4000 + 1000))

(or use bc for clarity).


335-337: --type=height is no longer a valid flag

Latest Cosmos-SDK CLIs accept --height <n> or positional <height>.
Please confirm this actually works; otherwise the old-block queries will always return the latest block.

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: 3

♻️ Duplicate comments (3)
.github/workflows/migration_test.yml (3)

29-31: Pipe-to-bash Ignite installer – risk already discussed

Same unpinned curl … | bash pattern that was addressed in previous reviews. No further action if you’re comfortable with the trade-off.


39-50: gmd still assumed to be on PATH after ignite chain build

Earlier feedback noted that ignite chain build drops the binary in ./build without exporting it. Subsequent gmd … invocations in this step will fail on a clean runner.


335-339: Duplicated misuse of --type=height

Same issue as earlier: replace with positional height argument.

🧹 Nitpick comments (2)
.github/workflows/migration_test.yml (2)

60-63: Trailing whitespace flagged by YAML-lint

Lines 63 (blank line) contain stray spaces, breaking strict linters.


71-73: Height polling uses unnecessary tail -n +2

gmd query block --output json already emits pure JSON; trimming the first line is unnecessary and will break if the CLI output format changes.

-            BLOCKS_FOUND=$(gmd query block --output json | tail -n +2 | jq -r '.header.height')
+            BLOCKS_FOUND=$(gmd query block --output json | jq -r '.header.height')
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f14b3a and e1784fc.

📒 Files selected for processing (2)
  • .github/workflows/integration_test.yml (1 hunks)
  • .github/workflows/migration_test.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/migration_test.yml

[error] 63-63: trailing spaces

(trailing-spaces)


[error] 70-70: trailing spaces

(trailing-spaces)


[error] 233-233: trailing spaces

(trailing-spaces)


[error] 240-240: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Test with Rollkit Chain
  • GitHub Check: Test Migration from Cosmos SDK to Rollkit
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: lint / golangci-lint

@julienrbrt julienrbrt enabled auto-merge (squash) June 26, 2025 08:07
@julienrbrt julienrbrt requested a review from randygrok June 26, 2025 08:07
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: 1

♻️ Duplicate comments (1)
server/migration_cmd.go (1)

374-381: Verify validator handling aligns with migration requirements.

The code enforces exactly one validator during migration, which may be overly restrictive. The TODO comment references issue #164 for multi-validator support.

Verify if the single validator requirement is appropriate for all migration scenarios:

#!/bin/bash
# Check if there are other references to validator handling in migration context
rg -A 5 -B 5 "validator.*migration|migration.*validator" --type go
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1784fc and 758778d.

📒 Files selected for processing (1)
  • server/migration_cmd.go (8 hunks)
🧰 Additional context used
🧠 Learnings (1)
server/migration_cmd.go (1)
Learnt from: julienrbrt
PR: rollkit/go-execution-abci#113
File: server/migration_cmd.go:231-231
Timestamp: 2025-06-20T13:20:04.030Z
Learning: In the rollkit migration command (server/migration_cmd.go), InitialHeight is correctly set to LastBlockHeight because the Rollkit chain is technically a new chain that starts where the CometBFT chain ended, ensuring continuity during migration.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Test with Rollkit Chain
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: lint / golangci-lint
  • GitHub Check: Test Migration from Cosmos SDK to Rollkit
🔇 Additional comments (9)
server/migration_cmd.go (9)

40-47: LGTM! Well-structured migration genesis struct.

The rollkitMigrationGenesis struct appropriately represents the minimal data needed for Rollkit migration, with proper JSON tags and essential fields.


49-59: LGTM! Clean conversion method.

The ToRollkitGenesis method correctly converts the migration genesis to a full Rollkit genesis using the appropriate constructor.


64-74: LGTM! Improved command documentation.

The command rename to "rollkit-migrate" and enhanced documentation clearly explain the migration process and expected outcomes.


96-99: LGTM! Comprehensive store management.

The new rollkitStores struct and loadRollkitStores function provide a clean abstraction for managing multiple Rollkit stores with proper initialization and key transforms.

Also applies to: 302-343


101-104: LGTM! Proper state preservation.

Saving the CometBFT state to the ABCI exec store before migration ensures state continuity and proper error handling.


154-164: LGTM! Proper sync store initialization.

The logic to initialize header and data sync stores with the first migrated block's data is correct and ensures proper state synchronization.


202-205: LGTM! Proper height tracking.

Setting the last height in the Rollkit store after migration ensures continuity and proper block height tracking.


392-400: LGTM! Proper JSON marshalling and file creation.

The use of cmtjson.MarshalIndent ensures compatibility with CometBFT genesis format, and the file creation includes proper error handling and permissions.


405-416: LGTM! Robust file existence checking.

The fileExists helper function properly handles both non-existence and other errors, providing clear error messages.

@julienrbrt julienrbrt merged commit 7194b52 into main Jun 26, 2025
11 checks passed
@julienrbrt julienrbrt deleted the julien/migration-2 branch June 26, 2025 10:48
alpe added a commit that referenced this pull request Jun 26, 2025
* main:
  test: add migration integration test + fix migration command (#150)
  build(deps): update to latest rollkit (#159)
  build(deps): bump rollkit to latest (#153)
  feat(server): add migration command (#113)
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.

[Feature Request]: Ensure CometBFT migration to Rollkit can be done smoothly
2 participants