feat: add undelegating flag and fix COW sync issues#21
Conversation
WalkthroughIntroduces support for an undelegating flag on account data structures. Adds the UNDELEGATING_FLAG_INDEX constant, implements getter and setter methods for the flag, extends debug output to include the undelegating state, and provides test coverage for the new functionality. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (2)
🔇 Additional comments (11)
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. Comment |
Summary by CodeRabbit
New Features
Tests
Adds support for an undelegating flag and fixes copy-on-write (COW) synchronization issues in the Account implementation:
undelegatingflag (index 4) withset_undelegating()andundelegating()methodsDetails
Undelegating Flag
Added a new account state flag for tracking delegation transitions. The flag is persisted with the same mechanism as other flags (executable, delegated, privileged, compressed) and includes both accessor and mutator methods.
COW Synchronization Fixes
Fixed several places in the code where borrowed accounts were being modified without triggering copy-on-write operations:
set_executable(): Now callsacc.cow()before modifying flags on borrowed accountstruncate_data(): Now callsacc.cow()before modifying data length on borrowed accountsspare_data_capacity_mut(): Now callsacc.cow()at the beginning for borrowed accountsThese fixes ensure that any modifications to borrowed accounts properly create a local copy before changes are applied, maintaining data consistency.
Testing
Added test coverage for the undelegating flag including: