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: set defaults for --v2-upgrade-height #4091

Merged
merged 10 commits into from
Dec 9, 2024

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Dec 6, 2024

Closes #3995

If a user specifies the --v2-upgrade-height flag then it takes precedence over any defaults. If the user doesn't specify a --v2-upgrade-height flag and the chainID is arabica-11, mocha-4, or celestia then the v2 upgrade height is set to the block height that was coordinated on those chains.

See: https://docs.celestia.org/how-to-guides/network-upgrade-process#lemongrass-network-upgrade

Testing

  1. ./scripts/single-node.sh doesn't set a v2 upgrade height
  2. ./arabica.sh if we remove the --v2-upgrade-height flag in the script, gets defaulted correctly
  3. ./arabica.sh if we override the --v2-upgrade-height flag in the script, that gets used

@rootulp rootulp self-assigned this Dec 6, 2024
@rootulp rootulp marked this pull request as ready for review December 6, 2024 22:05
@rootulp rootulp requested a review from a team as a code owner December 6, 2024 22:05
@rootulp rootulp requested review from staheri14, ninabarbakadze, rach-id and evan-forbes and removed request for a team and staheri14 December 6, 2024 22:05
Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request enhance the startCmd function in the cmd/celestia-appd package by adding logic to set default upgrade heights based on the ChainID. New constants for MochaChainID and MainnetChainID are introduced in the appconsts package, along with corresponding upgrade heights for different chains. The modifications ensure that the command operates correctly while integrating these new constants and logic.

Changes

File Path Change Summary
cmd/celestia-appd/cmd/start.go Enhanced startCmd to set default upgrade heights based on ChainID. Added import for appconsts.
pkg/appconsts/chain_ids.go Added constants MochaChainID with value "mocha-4" and MainnetChainID with value "celestia".
pkg/appconsts/upgrade_heights.go Introduced constants for upgrade heights: ArabicaUpgradeHeightV2 (1751707), MochaUpgradeHeightV2 (2585031), and MainnetUpgradeHeightV2 (2371495).

Assessment against linked issues

Objective Addressed Explanation
Include v2 upgrade heights for arabica, mocha, and mainnet (3995)

Possibly related PRs

Suggested labels

required

Suggested reviewers

  • cmwaters
  • evan-forbes
  • ninabarbakadze
  • staheri14
  • rach-id

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7b12947 and 8d02c3f.

📒 Files selected for processing (1)
  • cmd/celestia-appd/cmd/start.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/celestia-appd/cmd/start.go

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

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

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

🧹 Outside diff range and nitpick comments (1)
cmd/celestia-appd/cmd/start.go (1)

121-133: Consider adding unit tests for chain ID handling

The chain ID handling logic would benefit from unit tests to ensure correct behavior across different networks and edge cases.

Would you like me to help create unit tests for this functionality?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f11a169 and 7b12947.

📒 Files selected for processing (3)
  • cmd/celestia-appd/cmd/start.go (2 hunks)
  • pkg/appconsts/chain_ids.go (1 hunks)
  • pkg/appconsts/upgrade_heights.go (1 hunks)
🔇 Additional comments (3)
pkg/appconsts/chain_ids.go (1)

5-6: LGTM: Chain ID constants are well-defined

The new chain ID constants follow the existing naming convention and correctly define the identifiers for Mocha and Mainnet networks.

pkg/appconsts/upgrade_heights.go (1)

4-12: LGTM: Upgrade heights are well-documented

The upgrade height constants are clearly documented and properly defined for each network. However, let's verify these heights against any network documentation or announcements.

✅ Verification successful

Let me search for more specific references to these upgrade heights.


Upgrade heights are verified and consistently used across the codebase

The upgrade heights are verified through multiple sources in the codebase:

  • The heights are consistently used in network startup scripts (scripts/*.sh)
  • They are referenced in the blocketa tool as example heights
  • The values are properly documented and used in the network upgrade process as evidenced by ADR-018 and release notes
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any documentation validating these upgrade heights

# Look for upgrade height references in markdown files
rg -A 2 "upgrade.*height|v2.*height" --type md

Length of output: 10636


Script:

#!/bin/bash
# Search for specific upgrade heights in the entire codebase
rg -A 2 "1751707|2585031|2371495"

Length of output: 1681

cmd/celestia-appd/cmd/start.go (1)

17-17: LGTM: Required import added

The appconsts package import is correctly added to access the chain ID and upgrade height constants.

Comment on lines 121 to 133
switch clientCtx.ChainID {
case appconsts.ArabicaChainID:
serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.ArabicaUpgradeHeightV2, appconsts.ArabicaChainID))
serverCtx.Viper.SetDefault(UpgradeHeightFlag, appconsts.ArabicaUpgradeHeightV2)
case appconsts.MochaChainID:
serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.MochaUpgradeHeightV2, appconsts.MochaChainID))
serverCtx.Viper.SetDefault(UpgradeHeightFlag, appconsts.MochaUpgradeHeightV2)
case appconsts.MainnetChainID:
serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.MainnetChainID, appconsts.MainnetChainID))
serverCtx.Viper.SetDefault(UpgradeHeightFlag, appconsts.MainnetUpgradeHeightV2)
default:
serverCtx.Logger.Info(fmt.Sprintf("No default value exists for the v2 upgrade height when the chainID is %v", clientCtx.ChainID))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect log messages and improve code structure

There are several issues in the chain ID handling logic:

  1. In the MochaChainID case, the log message swaps the upgrade height and chain ID values
  2. In the MainnetChainID case, the log message uses MainnetChainID twice instead of MainnetUpgradeHeightV2
  3. Consider extracting the upgrade height flag string to a constant

Apply these fixes:

 switch clientCtx.ChainID {
 case appconsts.ArabicaChainID:
     serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.ArabicaChainID, appconsts.ArabicaUpgradeHeightV2))
     serverCtx.Viper.SetDefault(UpgradeHeightFlag, appconsts.ArabicaUpgradeHeightV2)
 case appconsts.MochaChainID:
-    serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.MochaUpgradeHeightV2, appconsts.MochaChainID))
+    serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.MochaChainID, appconsts.MochaUpgradeHeightV2))
     serverCtx.Viper.SetDefault(UpgradeHeightFlag, appconsts.MochaUpgradeHeightV2)
 case appconsts.MainnetChainID:
-    serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.MainnetChainID, appconsts.MainnetChainID))
+    serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.MainnetChainID, appconsts.MainnetUpgradeHeightV2))
     serverCtx.Viper.SetDefault(UpgradeHeightFlag, appconsts.MainnetUpgradeHeightV2)

Consider extracting the upgrade height flag to a constant:

+const upgradeHeightFlagName = "v2-upgrade-height"
+
 switch clientCtx.ChainID {
 case appconsts.ArabicaChainID:
     serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.ArabicaChainID, appconsts.ArabicaUpgradeHeightV2))
-    serverCtx.Viper.SetDefault(UpgradeHeightFlag, appconsts.ArabicaUpgradeHeightV2)
+    serverCtx.Viper.SetDefault(upgradeHeightFlagName, appconsts.ArabicaUpgradeHeightV2)

Committable suggestion skipped: line range outside the PR's diff.

@celestia-bot celestia-bot requested a review from a team December 7, 2024 00:24
@rootulp rootulp requested a review from rach-id December 8, 2024 21:13
Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

Thanks for making this change 👍

@rootulp rootulp changed the title feat: include v2 upgrade height for supported networks feat: set defaults for --v2-upgrade-height Dec 9, 2024
@rootulp rootulp merged commit 818026a into celestiaorg:main Dec 9, 2024
30 checks passed
rootulp added a commit to rootulp/celestia-app that referenced this pull request Dec 9, 2024
Closes celestiaorg#3995

If a user specifies the `--v2-upgrade-height` flag then it takes
precedence over any defaults. If the user doesn't specify a
`--v2-upgrade-height` flag and the chainID is `arabica-11`, `mocha-4`,
or `celestia` then the v2 upgrade height is set to the block height that
was coordinated on those chains.

See:
https://docs.celestia.org/how-to-guides/network-upgrade-process#lemongrass-network-upgrade

## Testing

1. `./scripts/single-node.sh` doesn't set a v2 upgrade height
2. `./arabica.sh` if we remove the `--v2-upgrade-height` flag in the
script, gets defaulted correctly
3. `./arabica.sh` if we override the `--v2-upgrade-height` flag in the
script, that gets used
rootulp added a commit to rootulp/celestia-app that referenced this pull request Dec 9, 2024
Closes celestiaorg#3995

If a user specifies the `--v2-upgrade-height` flag then it takes
precedence over any defaults. If the user doesn't specify a
`--v2-upgrade-height` flag and the chainID is `arabica-11`, `mocha-4`,
or `celestia` then the v2 upgrade height is set to the block height that
was coordinated on those chains.

See:
https://docs.celestia.org/how-to-guides/network-upgrade-process#lemongrass-network-upgrade

## Testing

1. `./scripts/single-node.sh` doesn't set a v2 upgrade height
2. `./arabica.sh` if we remove the `--v2-upgrade-height` flag in the
script, gets defaulted correctly
3. `./arabica.sh` if we override the `--v2-upgrade-height` flag in the
script, that gets used
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.

Consider including v2 upgrade heights in binary for common networks
4 participants