Skip to content

fix(drive-abci): don't panic on unsupported version error #2679

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

Open
wants to merge 1 commit into
base: v2.0-dev
Choose a base branch
from

Conversation

lklimek
Copy link
Contributor

@lklimek lklimek commented Jun 24, 2025

Issue being fixed or feature implemented

When Drive does not support new version during upgrade, it panics.
It means that some misbehaving proposer can propose a block that will panic the whole network.

Correct behavior is to reject such block proposal, and let Tenderdash handle the issue (eg. get proposal from another node).

What was done?

Changed panic to error, and added trace::error to display previous message to the user.

How Has This Been Tested?

Not tested

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of unsupported protocol versions by displaying a clear error message instead of causing the application to crash.
  • New Features
    • Added detailed error messaging when a required protocol version is not supported, including information about the maximum supported and requested versions.

@lklimek lklimek requested a review from QuantumExplorer as a code owner June 24, 2025 11:25
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

Walkthrough

A new error variant, ProtocolVersionNotSupported, was added to the ExecutionError enum to represent unsupported protocol versions. The control flow in block proposal execution was updated to return this error instead of panicking when an unsupported protocol version is encountered, enabling graceful error handling and logging.

Changes

File(s) Change Summary
packages/rs-drive-abci/src/error/execution.rs Added ProtocolVersionNotSupported variant to ExecutionError enum with fields for max supported and required versions.
packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs Replaced panic on unsupported protocol version with logging and returning the new error variant in a ValidationResult.

Sequence Diagram(s)

sequenceDiagram
    participant Platform
    participant Logger
    participant Caller

    Caller->>Platform: run_block_proposal(next_protocol_version)
    Platform->>Platform: Check if next_protocol_version is supported
    alt Supported
        Platform-->>Caller: Proceed with proposal execution
    else Not Supported
        Platform->>Logger: Log error with version details
        Platform-->>Caller: Return ValidationResult with ProtocolVersionNotSupported error
    end
Loading

Poem

A hop, a skip, a protocol check,
No more panics—errors now reflect!
If versions clash and can't proceed,
A gentle message plants the seed.
Upgrade, dear node, don't be distraught—
This rabbit’s patch brings panic to naught! 🐇✨

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

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 (2)
packages/rs-drive-abci/src/error/execution.rs (1)

55-63: Fix typo in comment and approve the new error variant.

The new ProtocolVersionNotSupported error variant is well-designed with clear field names and a helpful error message that guides users to upgrade. However, there's a typo in the comment.

-    /// We don't have the required protocol version. Most liekly the platform must be upgraded.
+    /// We don't have the required protocol version. Most likely the platform must be upgraded.
packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs (1)

84-84: Update comment to reflect the new non-panic behavior.

The comment states "We should panic if this node is not supported a new protocol version" but the code now returns an error instead of panicking. Update the comment to match the current implementation.

-            // We should panic if this node is not supported a new protocol version
+            // We should return an error if this node does not support the new protocol version
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 63beab6 and 0078462.

📒 Files selected for processing (2)
  • packages/rs-drive-abci/src/error/execution.rs (1 hunks)
  • packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs (3)
Learnt from: QuantumExplorer
PR: dashpay/platform#2215
File: packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs:119-120
Timestamp: 2024-10-06T16:18:07.994Z
Learning: In the `run_block_proposal` function in `packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs`, it's acceptable to pass `platform_state` to `perform_events_on_first_block_of_protocol_change`, even if `block_platform_state` has been updated.
Learnt from: QuantumExplorer
PR: dashpay/platform#2215
File: packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs:105-105
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In `run_block_proposal` in `packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs`, when retrieving `last_block_time_ms`, it's acceptable to use `platform_state` instead of `block_platform_state`, even after updating the protocol version.
Learnt from: QuantumExplorer
PR: dashpay/platform#2215
File: packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs:105-105
Timestamp: 2024-10-06T16:17:34.571Z
Learning: In `run_block_proposal` in `packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs`, when retrieving `last_block_time_ms`, it's acceptable to use `platform_state` instead of `block_platform_state`, even after updating the protocol version.
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (drive-abci) / Check each feature
  • GitHub Check: Rust packages (drive-abci) / Linting
  • GitHub Check: Rust packages (drive-abci) / Unused dependencies
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
🔇 Additional comments (1)
packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs (1)

86-102: Excellent graceful error handling implementation.

This change successfully addresses the core issue by:

  1. Preventing network-wide panics: Instead of panicking when an unsupported protocol version is encountered, the code now returns a controlled error
  2. Providing comprehensive logging: The error message includes software version and upgrade instructions
  3. Enabling proper upstream handling: Returns a ValidationResult that allows callers to handle the error appropriately
  4. Security improvement: Prevents misbehaving proposers from causing network-wide crashes

The implementation correctly constructs the ProtocolVersionNotSupported error with the required parameters and maintains consistency with the function's return type.

@lklimek lklimek changed the title chore(abci): don't panic on unsupported version error fix(drive-abci): don't panic on unsupported version error Jun 24, 2025
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.

1 participant