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 optional argument to ignore ChainLocks for reconsiderblocks RPC #6501

Merged
merged 1 commit into from
Jan 11, 2025

Conversation

knst
Copy link
Collaborator

@knst knst commented Dec 20, 2024

Issue being fixed or feature implemented

More general way to implement #6500 which can be merged to develop.

What was done?

It allows removing BLOCK_CONFLICT_CHAINLOCK flag via ResetBlockFailureFlags

How Has This Been Tested?

N/A

Breaking Changes

N/A

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 made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

Copy link

coderabbitai bot commented Dec 20, 2024

Walkthrough

The pull request introduces modifications across multiple source files to enhance the blockchain RPC functionality and block validation process. The primary focus is on adding a new boolean parameter, ignore_chainlocks, to the reconsiderblock method, allowing users to specify whether to ignore existing chainlocks during the block reconsideration process.

The changes span four key files:

  • src/rpc/blockchain.cpp: The reconsiderblock function has been updated to include the ignore_chainlocks parameter, affecting how block failure flags are reset.
  • src/rpc/client.cpp: A new entry has been added to the vRPCConvertParams array to support the conversion of the ignore_chainlocks parameter.
  • src/validation.cpp: The ResetBlockFailureFlags method in the CChainState class has been modified to conditionally handle chainlock conflicts based on the new ignore_chainlocks parameter.
  • src/validation.h: The method signature for ResetBlockFailureFlags has been updated to include the ignore_chainlocks parameter.

These modifications provide more granular control over block validation and reconsideration processes, maintaining the existing code structure while introducing new capabilities for handling block states and RPC interactions.

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1cb44ab and 64817da.

📒 Files selected for processing (4)
  • src/rpc/blockchain.cpp (3 hunks)
  • src/rpc/client.cpp (1 hunks)
  • src/validation.cpp (3 hunks)
  • src/validation.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/rpc/client.cpp
  • src/validation.h
  • src/validation.cpp
🔇 Additional comments (3)
src/rpc/blockchain.cpp (3)

2128-2129: LGTM! Parameter definition is clear and well-documented.

The new ignore_chainlocks parameter is properly defined with:

  • Appropriate type (BOOL)
  • Sensible default value (false)
  • Clear description of its purpose

2141-2141: LGTM! Parameter parsing is correct.

The parameter parsing follows best practices:

  • Proper null check for optional parameter
  • Correct boolean value extraction

2150-2150: LGTM! Parameter is used appropriately.

The ignore_chainlocks parameter is correctly passed to ResetBlockFailureFlags to control chainlock behavior.


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.

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

@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: 2

🧹 Nitpick comments (1)
src/validation.cpp (1)

3413-3414: LGTM! Consider adding documentation for the new parameter.

The new ignore_chainlocks parameter is a good addition. Consider adding documentation to explain when this parameter should be set to true/false.

Add documentation like:

/**
 * Reset the validation state of a block and its descendants.
 * @param pindex The block index to start from
 * @param ignore_chainlocks If true, also clear BLOCK_CONFLICT_CHAINLOCK flags
 */
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ad7a373 and 80cd381.

📒 Files selected for processing (4)
  • src/rpc/blockchain.cpp (3 hunks)
  • src/rpc/client.cpp (1 hunks)
  • src/validation.cpp (3 hunks)
  • src/validation.h (1 hunks)
🔇 Additional comments (4)
src/rpc/blockchain.cpp (2)

2128-2128: Looks good: Parameter definition aligns with the updated functionality.
The new parameter "nochainlocks" has a clear default (false) and an explanatory description.


2150-2150: Integration with ResetBlockFailureFlags is consistent.
Once the parameter index mismatch is corrected, passing “ignore_chainlocks” here directly aligns with the updated method signature.

src/rpc/client.cpp (1)

78-78: Consistent addition of "nochainlocks" parameter.
This correctly registers the second parameter (index = 1) for JSON conversion. Ensure the caller in blockchain.cpp references this same index to avoid mismatched parameters.

src/validation.h (1)

716-716: Straightforward extension to ResetBlockFailureFlags.
Providing a default of false for "ignore_chainlocks" is a safe choice, preserving existing behavior unless explicitly overridden. The concurrency annotation (EXCLUSIVE_LOCKS_REQUIRED) helps ensure proper synchronization.

src/rpc/blockchain.cpp Outdated Show resolved Hide resolved
src/validation.cpp Outdated Show resolved Hide resolved
@knst knst force-pushed the reconsider-reset-cl branch from 80cd381 to 1cb44ab Compare December 20, 2024 19:13
src/validation.cpp Outdated Show resolved Hide resolved
@knst knst force-pushed the reconsider-reset-cl branch 3 times, most recently from d5f0049 to b7f1d6b Compare December 20, 2024 19:20
src/rpc/blockchain.cpp Outdated Show resolved Hide resolved
src/rpc/blockchain.cpp Outdated Show resolved Hide resolved
src/rpc/client.cpp Outdated Show resolved Hide resolved
@knst knst force-pushed the reconsider-reset-cl branch from b7f1d6b to 64817da Compare December 23, 2024 10:30
@thephez thephez added the RPC Some notable changes to RPC params/behaviour/descriptions label Dec 23, 2024
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK 64817da

@knst knst requested a review from PastaPastaPasta December 27, 2024 07:40
@knst knst added this to the 22.1 milestone Dec 27, 2024
Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK 64817da

@PastaPastaPasta PastaPastaPasta merged commit 8debe7b into dashpay:develop Jan 11, 2025
23 checks passed
@knst knst deleted the reconsider-reset-cl branch January 14, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RPC Some notable changes to RPC params/behaviour/descriptions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants