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!: add a delay between quorum and upgrade height #3560

Merged
merged 26 commits into from
Jun 20, 2024

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Jun 12, 2024

Closes #3552

Testing

Manually tested the new CLI commands by staring single node script and then:

$ celestia-appd query signal upgrade
no upgrade is pending.

$ celestia-appd tx signal signal 3 --from $VALIDATOR --fees $DEFAULT_FEES --broadcast-mode $BROADCAST_MODE --yes

$ celestia-appd tx signal try-upgrade  --from $VALIDATOR --fees $DEFAULT_FEES --broadcast-mode $BROADCAST_MODE --yes

$ celestia-appd query signal upgrade
upgrade is pending to app version 3 at height 151345.

@rootulp rootulp self-assigned this Jun 12, 2024
@rootulp rootulp marked this pull request as ready for review June 13, 2024 20:30
@rootulp rootulp requested a review from a team as a code owner June 13, 2024 20:30
@rootulp rootulp requested review from ramin, rach-id, cmwaters and evan-forbes and removed request for a team, ramin and rach-id June 13, 2024 20:30
Copy link
Contributor

coderabbitai bot commented Jun 13, 2024

Walkthrough

Walkthrough

The recent changes introduce a delay mechanism for network upgrades and enhancements to the signal module. Key improvements include adding context-based conditional checks for version upgrading, integrating new query methods, and providing better error handling and unit test coverage to ensure robust upgrade processing.

Changes

File Change Summary
app/app.go Modified EndBlocker to include a context parameter ctx in the ShouldUpgrade call.
app/module/configurator_test.go Updated TestConfigurator to pass config.Codec to signal.NewKeeper.
proto/celestia/signal/v1/query.proto Added import for upgrade.proto, new RPC method GetUpgrade, and related message types.
proto/celestia/signal/v1/upgrade.proto Defined Upgrade message with app_version and upgrade_height fields.
x/signal/cli/cli_test.go Added TestCmdGetUpgrade to test the new CmdGetUpgrade function.
x/signal/cli/query.go Introduced CmdGetUpgrade command in GetQueryCmd function.
x/signal/integration_test.go Enhanced TestUpgradeIntegration with additional upgrade checks and validation logic.
x/signal/keeper.go Added DefaultUpgradeHeightDelay, new methods for managing upgrades, and updated TryUpgrade.
x/signal/keeper_test.go Enhanced tests for upgrade scenarios, added imports, and updated function calls in test cases.
x/signal/types/errors.go Introduced ErrUpgradePending and ErrInvalidUpgradeVersion errors.
x/signal/types/keys.go Added UpgradeKey and FirstSignalKey for managing upgrade information in the signal store.

Sequence Diagram

sequenceDiagram
    participant User
    participant SignalModule
    participant UpgradeScheduler
    User->>SignalModule: MsgTryUpgrade
    SignalModule->>UpgradeScheduler: Validate Upgrade
    UpgradeScheduler-->>SignalModule: Schedule Upgrade (with delay)
    SignalModule-->>User: Acknowledge Upgrade
Loading

Assessment against linked issues

Objective Addressed Explanation
Add a delay between MsgTryUpgrade and upgrade height (#3552)
Ensure signals and future cranks are no-ops during upgrade delay period (#3552)
Ensure proper error handling for invalid upgrade variations (#3552)

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9184493 and 8e9c37d.

Files selected for processing (2)
  • x/signal/keeper_test.go (11 hunks)
  • x/signal/types/keys.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • x/signal/keeper_test.go
  • x/signal/types/keys.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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

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

@celestia-bot celestia-bot requested a review from a team June 13, 2024 20:31
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.

Given the upgrade process now spans across multiple heights we need to be aware of node crashes, thus the signal keeper will need to persist the upgrade height and the quorum version to state.

I think it would also be helpful if we expose a grpc query for that upgrade height so users are able to know when exactly that upgrade height is.

@rootulp rootulp marked this pull request as draft June 14, 2024 14:51
rootulp added 10 commits June 14, 2024 14:15
Breaks TestResetTally I think because the current keeper iterates over
all keys and values and delete them. I think we want to find a way to
constrain the keys and values that validator signals are in. Or separate
those signals from the key used to persist the upgrade.
@rootulp rootulp requested a review from cmwaters June 17, 2024 14:29
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

Comment on lines 15 to 18
// DefaultUpgradeHeightDelay is the number of blocks after a quorum has been
// reached that the chain should upgrade to the new version. Assuming a
// block interval of 12 seconds, this is 48 hours.
const DefaultUpgradeHeightDelay = int64(3 * 7 * 24 * 60 * 60 / 12) // 3 weeks * 7 days * 24 hours * 60 minutes * 60 seconds / 12 seconds per block = 151,200 blocks.
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify the calculation of DefaultUpgradeHeightDelay.

Consider adding a comment to explain the calculation of DefaultUpgradeHeightDelay in more detail, especially how the block interval and total time are used to derive the number of blocks.

// DefaultUpgradeHeightDelay calculates the number of blocks needed for a 3-week delay, assuming a block interval of 12 seconds.
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.

Suggested change
// DefaultUpgradeHeightDelay is the number of blocks after a quorum has been
// reached that the chain should upgrade to the new version. Assuming a
// block interval of 12 seconds, this is 48 hours.
const DefaultUpgradeHeightDelay = int64(3 * 7 * 24 * 60 * 60 / 12) // 3 weeks * 7 days * 24 hours * 60 minutes * 60 seconds / 12 seconds per block = 151,200 blocks.
// DefaultUpgradeHeightDelay calculates the number of blocks needed for a 3-week delay, assuming a block interval of 12 seconds.
const DefaultUpgradeHeightDelay = int64(3 * 7 * 24 * 60 * 60 / 12) // 3 weeks * 7 days * 24 hours * 60 minutes * 60 seconds / 12 seconds per block = 151,200 blocks.

@rootulp rootulp marked this pull request as draft June 17, 2024 19:11
@rootulp rootulp marked this pull request as ready for review June 17, 2024 19:11
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

Comment on lines +15 to +18
// DefaultUpgradeHeightDelay is the number of blocks after a quorum has been
// reached that the chain should upgrade to the new version. Assuming a block
// interval of 12 seconds, this is 7 days.
const DefaultUpgradeHeightDelay = int64(7 * 24 * 60 * 60 / 12) // 7 days * 24 hours * 60 minutes * 60 seconds / 12 seconds per block = 50,400 blocks.
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify the calculation of DefaultUpgradeHeightDelay.

Consider adding a comment to explain the calculation of DefaultUpgradeHeightDelay in more detail, especially how the block interval and total time are used to derive the number of blocks.

// DefaultUpgradeHeightDelay calculates the number of blocks needed for a 7-day delay, assuming a block interval of 12 seconds.
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.

Suggested change
// DefaultUpgradeHeightDelay is the number of blocks after a quorum has been
// reached that the chain should upgrade to the new version. Assuming a block
// interval of 12 seconds, this is 7 days.
const DefaultUpgradeHeightDelay = int64(7 * 24 * 60 * 60 / 12) // 7 days * 24 hours * 60 minutes * 60 seconds / 12 seconds per block = 50,400 blocks.
// DefaultUpgradeHeightDelay calculates the number of blocks needed for a 7-day delay, assuming a block interval of 12 seconds.
const DefaultUpgradeHeightDelay = int64(7 * 24 * 60 * 60 / 12) // 7 days * 24 hours * 60 minutes * 60 seconds / 12 seconds per block = 50,400 blocks.

cmwaters
cmwaters previously approved these changes Jun 18, 2024
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.

Perfect, thanks

x/signal/integration_test.go Show resolved Hide resolved
@rootulp rootulp requested review from ninabarbakadze and removed request for ramin June 18, 2024 14:28
@celestia-bot celestia-bot requested a review from a team June 18, 2024 19:56
Copy link
Collaborator

@staheri14 staheri14 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'd defer to other reviewers for the final approval.

x/signal/types/keys.go Outdated Show resolved Hide resolved
x/signal/keeper_test.go Outdated Show resolved Hide resolved
x/signal/keeper.go Show resolved Hide resolved
@celestia-bot celestia-bot requested a review from a team June 19, 2024 19:42
@rootulp rootulp requested review from cmwaters and staheri14 June 19, 2024 19:47
Copy link
Collaborator

@staheri14 staheri14 left a comment

Choose a reason for hiding this comment

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

LGTM!

@rootulp rootulp merged commit 97af2fe into celestiaorg:main Jun 20, 2024
32 checks passed
@rootulp rootulp deleted the rp/delay-upgrade-height branch June 20, 2024 19:04
@coderabbitai coderabbitai bot mentioned this pull request Oct 28, 2024
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.

Add a delay between MsgTryUpgrade and upgrade height
3 participants