Skip to content

feat: improve logging of non-existing destinations for masternode payment#6740

Merged
PastaPastaPasta merged 1 commit intodashpay:developfrom
knst:feat-logs-destination
Jul 4, 2025
Merged

feat: improve logging of non-existing destinations for masternode payment#6740
PastaPastaPasta merged 1 commit intodashpay:developfrom
knst:feat-logs-destination

Conversation

@knst
Copy link
Collaborator

@knst knst commented Jul 3, 2025

Issue being fixed or feature implemented

In case if destination is invalid for cbtx, the logs are missing

What was done?

Improved logs for case if invalid destination

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

@knst knst added this to the 23 milestone Jul 3, 2025
@knst knst requested review from PastaPastaPasta and UdjinM6 July 3, 2025 17:36
@coderabbitai
Copy link

coderabbitai bot commented Jul 3, 2025

Walkthrough

The change updates the error handling logic in the CMNPaymentsProcessor::IsTransactionValid method within the masternode payments code. Specifically, when an expected masternode payment output is missing from the transaction outputs, the code now conditionally logs either the encoded destination (if extraction is successful) or the raw hexadecimal representation of the scriptPubKey (if extraction fails). This replaces a previous assertion failure with a more robust logging approach, ensuring that error messages are still generated even for unknown or non-standard scriptPubKeys. No public or exported entity declarations were altered.


📜 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 1083228 and e9f292d.

📒 Files selected for processing (1)
  • src/masternode/payments.cpp (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: kwvg
PR: dashpay/dash#6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: kwvg
PR: dashpay/dash#6718
File: test/functional/test_framework/test_framework.py:2102-2102
Timestamp: 2025-06-09T16:43:20.996Z
Learning: In the test framework consolidation PR (#6718), user kwvg prefers to limit functional changes to those directly related to MasternodeInfo, avoiding scope creep even for minor improvements like error handling consistency.
Learnt from: kwvg
PR: dashpay/dash#6529
File: src/wallet/rpcwallet.cpp:3002-3003
Timestamp: 2025-02-14T15:19:17.218Z
Learning: The `GetWallet()` function calls in `src/wallet/rpcwallet.cpp` are properly validated with null checks that throw appropriate RPC errors, making additional validation unnecessary.
Learnt from: kwvg
PR: dashpay/dash#6665
File: src/evo/providertx.h:82-82
Timestamp: 2025-06-06T11:53:09.094Z
Learning: In ProTx serialization code (SERIALIZE_METHODS), version checks should use hardcoded maximum flags (/*is_basic_scheme_active=*/true, /*is_extended_addr=*/true) rather than deployment-based flags. This is because serialization code should be able to deserialize any structurally valid ProTx up to the maximum version the code knows how to handle, regardless of current consensus validity. Validation code, not serialization code, is responsible for checking whether a ProTx version is consensus-valid based on deployment status.
src/masternode/payments.cpp (5)
Learnt from: kwvg
PR: dashpay/dash#6718
File: test/functional/test_framework/test_framework.py:2102-2102
Timestamp: 2025-06-09T16:43:20.996Z
Learning: In the test framework consolidation PR (#6718), user kwvg prefers to limit functional changes to those directly related to MasternodeInfo, avoiding scope creep even for minor improvements like error handling consistency.
Learnt from: kwvg
PR: dashpay/dash#6529
File: src/wallet/rpcwallet.cpp:3002-3003
Timestamp: 2025-02-14T15:19:17.218Z
Learning: The `GetWallet()` function calls in `src/wallet/rpcwallet.cpp` are properly validated with null checks that throw appropriate RPC errors, making additional validation unnecessary.
Learnt from: kwvg
PR: dashpay/dash#6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: kwvg
PR: dashpay/dash#6665
File: src/evo/providertx.h:82-82
Timestamp: 2025-06-06T11:53:09.094Z
Learning: In ProTx serialization code (SERIALIZE_METHODS), version checks should use hardcoded maximum flags (/*is_basic_scheme_active=*/true, /*is_extended_addr=*/true) rather than deployment-based flags. This is because serialization code should be able to deserialize any structurally valid ProTx up to the maximum version the code knows how to handle, regardless of current consensus validity. Validation code, not serialization code, is responsible for checking whether a ProTx version is consensus-valid based on deployment status.
Learnt from: kwvg
PR: dashpay/dash#6530
File: src/validation.cpp:360-362
Timestamp: 2025-01-14T08:37:16.955Z
Learning: The UpdateTransactionsFromBlock() method in txmempool.cpp takes parameters in the order: vHashUpdate, ancestor_size_limit, ancestor_count_limit. The size limit comes before the count limit.
🔇 Additional comments (1)
src/masternode/payments.cpp (1)

129-136: LGTM! Excellent improvement to error handling robustness.

This change effectively addresses the PR objective of improving logging for invalid destinations. The implementation:

  • Replaces potential assertion failures with graceful fallback logging
  • Handles both standard destinations (via EncodeDestination) and non-standard scriptPubKeys (via HexStr)
  • Maintains consistent error message format while providing more comprehensive information
  • Uses modern C++ structured binding for clean conditional logic

This defensive programming approach ensures that error logs are always generated, even for unknown or non-standard scriptPubKeys, which will improve debugging capabilities for masternode payment validation issues.

✨ 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

@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 e9f292d

Copy link
Collaborator

@kwvg kwvg left a comment

Choose a reason for hiding this comment

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

utACK e9f292d

@PastaPastaPasta PastaPastaPasta merged commit 094ceb9 into dashpay:develop Jul 4, 2025
55 of 57 checks passed
@knst knst deleted the feat-logs-destination branch July 5, 2025 13:26
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Jul 9, 2025
…s for masternode payment

e9f292d feat: improve logging of non-existing destinations for masternode payment (Konstantin Akimov)

Pull request description:

  ## Issue being fixed or feature implemented
  In case if destination is invalid for cbtx, the logs are missing

  ## What was done?
  Improved logs for case if invalid destination

  ## How Has This Been Tested?
  N/A

  ## Breaking Changes
  N/A

  ## Checklist:
  - [x] 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
  - [x] I have assigned this pull request to a milestone

ACKs for top commit:
  UdjinM6:
    utACK e9f292d
  kwvg:
    utACK e9f292d

Tree-SHA512: 990aadceff00bd964dbe9b8da292779ac15bba347688b655a64250c257b137511afdc6301010459c5d6287f3464922fffb5745789633dd690778e8c770d8095c
@UdjinM6 UdjinM6 modified the milestones: 23, 22.1.3 Jul 9, 2025
PastaPastaPasta added a commit that referenced this pull request Jul 10, 2025
9ec8e66 docs: add v22.1.3 release notes and archive v22.1.2 (pasta)
95c2a0e chore: bump version to v22.1.3 (pasta)
3345046 chore: update chainparams for v22.1.3 release (pasta)
1db850a Merge #6632: perf: versionbits avoid calculation which is not used (pasta)
4173e3c Merge #6739: docs: Fix broken links from translation instructions and a typo (pasta)
9eda785 Merge #6740: feat: improve logging of non-existing destinations for masternode payment (pasta)
47b6826 Merge #6744: fix: remove useless but alarming log record about spent information (pasta)

Pull request description:

  ## Issue being fixed or feature implemented
  Backports for a new version, v22.1.3

  ## What was done?
  See release notes

  ## How Has This Been Tested?

  ## Breaking Changes
  None

  ## Checklist:
  - [x] 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
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK 9ec8e66
  kwvg:
    utACK 9ec8e66

Tree-SHA512: 9e94b472c32f87c46d60fe53bcec59cb2ec1823e56cfbc2fe4a07d476e1c576c0d7f0c54115aeca902767651591556d68c8e81b81ac9bd12bc5291fa17f5a768
PastaPastaPasta added a commit that referenced this pull request Jul 15, 2025
9ec8e66 docs: add v22.1.3 release notes and archive v22.1.2 (pasta)
95c2a0e chore: bump version to v22.1.3 (pasta)
3345046 chore: update chainparams for v22.1.3 release (pasta)
1db850a Merge #6632: perf: versionbits avoid calculation which is not used (pasta)
4173e3c Merge #6739: docs: Fix broken links from translation instructions and a typo (pasta)
9eda785 Merge #6740: feat: improve logging of non-existing destinations for masternode payment (pasta)
47b6826 Merge #6744: fix: remove useless but alarming log record about spent information (pasta)

Pull request description:

  ## Issue being fixed or feature implemented

  ## What was done?

  ## How Has This Been Tested?

  ## 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)_

ACKs for top commit:
  PastaPastaPasta:
    utACK 2527ca5
  kwvg:
    utACK 2527ca5

Tree-SHA512: 3ecf4f26a816db6be797208ce5d519b8c3571a4aae832d8a1dcf41add4cc48d102459302e1777786b19f577c0a3222d77ce490e2301e73963d6021e2cdc2ad86
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.

4 participants