-
Notifications
You must be signed in to change notification settings - Fork 39
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
fix(drive): more than one key was returned when expecting only one result #2421
Conversation
WalkthroughThe pull request introduces modifications across three files in the Dash Drive repository, focusing on transaction handling, error logging, and identity credit withdrawal transitions. The changes include updating the Changes
Possibly related PRs
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (1)
packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/transformer.rs (1)
46-107
: Consider enhancing the test coverage.While the test effectively validates the basic functionality with multiple transfer keys, it would be beneficial to explicitly verify that only one key is actually used in the withdrawal process.
Consider adding assertions to verify:
- Which key was selected
- That only one key was used in the process
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/rs-drive-abci/src/abci/handler/check_tx.rs
(1 hunks)packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/transformer.rs
(1 hunks)packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/v0/transformer.rs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
- GitHub Check: Rust packages (drive) / Formatting
- GitHub Check: Rust packages (dash-sdk) / Tests
- GitHub Check: Rust packages (dash-sdk) / Check each feature
- GitHub Check: Rust packages (drive-abci) / Check each feature
- GitHub Check: Rust packages (dash-sdk) / Unused dependencies
- GitHub Check: Rust packages (dash-sdk) / Linting
- GitHub Check: Rust packages (drive-abci) / Tests
- GitHub Check: Rust packages (drive-abci) / Linting
- GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
- GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
- GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
- GitHub Check: Build JS packages / Build JS
🔇 Additional comments (4)
packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/v0/transformer.rs (3)
96-98
: LGTM! This change directly addresses the core issue.The modification to limit the key request to one result aligns perfectly with the PR's objective of preventing multiple withdrawal keys from being returned.
Line range hint
109-134
: Well-structured fallback mechanism for handling disabled keys.The implementation gracefully handles the case where the first key is disabled by:
- Checking up to 5 additional keys
- Using reverse iteration to find the most recent non-disabled key
- Providing clear error messages when no valid keys are found
180-180
: Good improvement in error handling.Replacing
unwrap()
with the?
operator is a better practice as it properly propagates errors instead of panicking.packages/rs-drive-abci/src/abci/handler/check_tx.rs (1)
154-158
: Improved error logging and memory efficiency.Two good improvements here:
- Using
&tx
avoids unnecessary copying when hashing- Adding the encoded transaction to error logs will help with debugging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix is good, well done.
Issue being fixed or feature implemented
#2418
What was done?
unwrap
to?
How Has This Been Tested?
Added an integration test
Breaking Changes
Since this error is happening on check tx we shouldn't have such transitions in the chain
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Tests