fix: Bidirection Object Storage for delegation#6681
fix: Bidirection Object Storage for delegation#6681Kassaking7 wants to merge 5 commits intoXRPLF:developfrom
Conversation
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
|
If only the most recent commit is unsigned, you can run:
If multiple commits are unsigned, you can run:
If you're new to commit signing, there are different ways to set it up: Sign commits with
|
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
98f7c62 to
ac6b4dd
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #6681 +/- ##
=======================================
Coverage 81.6% 81.6%
=======================================
Files 1010 1010
Lines 75992 76009 +17
Branches 7601 7599 -2
=======================================
+ Hits 62013 62032 +19
+ Misses 13979 13977 -2
🚀 New features to boost your workflow:
|
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
PeterChen13579
left a comment
There was a problem hiding this comment.
LGTM, feel free to implement the suggestion I have, if you want. I'm okay either way
|
Hi @bthomee , this PR is ready to merge. Thanks! |
ximinez
left a comment
There was a problem hiding this comment.
Unless I'm massively missing something, these changes need to be amendment gated.
There was a problem hiding this comment.
Pull request overview
Fixes cleanup of ltDELEGATE ledger entries when either the delegator or authorized (delegatee) account is deleted by making Delegate objects discoverable from both parties’ owner directories (mirroring the sfOwnerNode/sfDestinationNode pattern used by other bi-directional objects like Escrow).
Changes:
- Store
ltDELEGATEin both the delegator’s and authorized account’s owner directories and persist the authorized-side directory page insfDestinationNode. - Update
DelegateSet::deleteDelegateto remove the directory entry from both sides (and keep owner-count accounting on the delegator only). - Extend protocol-autogen schema/wrappers and add/expand unit tests to validate the new optional field and AccountDelete behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/libxrpl/tx/transactors/delegate/DelegateSet.cpp |
Inserts Delegate into both owner dirs and deletes from both using sfDestinationNode. |
include/xrpl/tx/transactors/delegate/DelegateSet.h |
Updates deleteDelegate signature to no longer require an explicit account parameter. |
src/libxrpl/tx/transactors/account/AccountDelete.cpp |
Uses updated deleteDelegate signature when sweeping ltDELEGATE from owner dirs. |
include/xrpl/protocol/detail/ledger_entries.macro |
Adds sfDestinationNode as an optional field of ltDELEGATE. |
include/xrpl/protocol_autogen/ledger_entries/Delegate.h |
Adds wrapper getter/has-check and builder setter for sfDestinationNode. |
src/tests/libxrpl/protocol_autogen/ledger_entries/DelegateTests.cpp |
Adds coverage for sfDestinationNode round-trip and absence when unset. |
src/test/app/Delegate_test.cpp |
Adds AccountDelete scenarios validating cleanup from both directories and reserve recovery. |
Comments suppressed due to low confidence (1)
src/libxrpl/tx/transactors/delegate/DelegateSet.cpp:78
- When updating an existing Delegate (sle already present) you only update sfPermissions. If this ledger entry was created by older code it may lack sfDestinationNode and may not be present in the authorized account’s owner directory, so deleting the authorized account would still leave a dangling Delegate in the delegator’s directory. Consider backfilling here: if sfDestinationNode is absent, dirInsert into keylet::ownerDir(authAccount), set sfDestinationNode, and update the SLE so the bidirectional cleanup works for pre-existing entries too.
sle->setFieldArray(sfPermissions, permissions);
ctx_.view().update(sle);
return tesSUCCESS;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This change is in |
That's what I missed. Thanks! LMK when the Copilot comments are addressed, and I'll merge. |
All comments addressed. Ready to merge. Thanks! |
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
High Level Overview of Change
When account A (the delegatee) is deleted, any Delegate ledger objects in other accounts' owner directories that reference A via sfAuthorize were not cleaned up, leaving dangling objects on-ledger.
This PR fixes the issue by storing the Delegate object in both the delegating account's (B) and the authorized account's (A) owner directories, mirroring the pattern used by EscrowCreate. When either party deletes their account, AccountDelete walks their owner directory, finds the ltDELEGATE entry, and deleteDelegate cleans up both sides.
Context of Change
API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)I conducted a local test using standalone mode. The core commands I had:
We can see that now we don't have delegate object for delegator after delegatee's account got deleted.