-
Notifications
You must be signed in to change notification settings - Fork 6
Resource Extension: Manage account creation/removal #2650
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
base: main
Are you sure you want to change the base?
Conversation
25baf16 to
1e80b28
Compare
1e80b28 to
e1db85e
Compare
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.
Pull request overview
This PR enhances resource management in the smart contract by automating the creation and removal of resource accounts during device lifecycle operations. The changes ensure that resource accounts (such as TunnelIds and DzPrefixBlock) are properly managed when devices are activated, updated, or closed.
Changes:
- Modified
SetGlobalConfig,ActivateDevice,UpdateDevice, andCloseAccountDeviceinstructions to automatically create/update/close associated resource accounts - Added a new
CloseResourceinstruction and CLI command for manual resource cleanup - Updated SDK commands to handle resource account management
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| smartcontract/sdk/rs/src/commands/resource/mod.rs | Added closeaccount module export |
| smartcontract/sdk/rs/src/commands/resource/closeaccount.rs | New command to close resource accounts |
| smartcontract/sdk/rs/src/commands/globalconfig/set.rs | Updated to create global resource accounts during config setup |
| smartcontract/sdk/rs/src/commands/device/update.rs | Added resource account creation when updating device prefixes |
| smartcontract/sdk/rs/src/commands/device/activate.rs | Modified to create resource accounts during device activation |
| smartcontract/sdk/rs/src/commands/device/closeaccount.rs | Enhanced to close associated resource accounts when closing device |
| smartcontract/programs/doublezero-serviceability/src/processors/resource/mod.rs | Updated resource creation logic to support optional associated accounts and account resizing |
| smartcontract/programs/doublezero-serviceability/src/processors/resource/closeaccount.rs | New processor for closing resource accounts |
| smartcontract/programs/doublezero-serviceability/src/processors/globalconfig/set.rs | Integrated resource account creation into global config setup |
| smartcontract/programs/doublezero-serviceability/src/processors/device/activate.rs | Added resource account creation during device activation |
| smartcontract/programs/doublezero-serviceability/src/processors/device/update.rs | Implemented resource account creation/update when modifying device prefixes |
| smartcontract/programs/doublezero-serviceability/src/processors/device/closeaccount.rs | Added resource account cleanup during device closure |
| smartcontract/programs/doublezero-serviceability/src/instructions.rs | Added CloseResource instruction variant |
| smartcontract/programs/doublezero-serviceability/src/error.rs | Added ImmutableField error and reordered error codes |
| smartcontract/programs/doublezero-serviceability/src/entrypoint.rs | Integrated new instruction handlers |
| smartcontract/cli/src/resource/close.rs | New CLI command for closing resources |
| smartcontract/cli/src/doublezerocommand.rs | Added close_resource trait method |
| client/doublezero/src/main.rs | Integrated close resource command |
| Various test files | Updated tests to include resource account management |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
smartcontract/programs/doublezero-serviceability/src/processors/resource/closeaccount.rs
Outdated
Show resolved
Hide resolved
|
@elitegreg I've opened a new pull request, #2655, to work on those changes. Once the pull request is ready, I'll request review from you. |
…s/resource/closeaccount.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
## Summary of Changes * Restored original error code mappings (codes 2-6) in `From<DoubleZeroError> for ProgramError` and `From<u32> for DoubleZeroError` implementations * The previous implementation reordered these mappings, which would cause deployed clients to misinterpret error codes returned by the smart contract * Preserved the new `ImmutableField` error variant at code 68 **Corrected mappings:** ```rust // Before (breaking) 2 => InvalidExchangePubkey 3 => InvalidDevicePubkey 4 => InvalidLocationPubkey 5 => InvalidDeviceAPubkey 6 => InvalidDeviceZPubkey // After (backward compatible) 2 => InvalidLocationPubkey 3 => InvalidExchangePubkey 4 => InvalidDeviceAPubkey 5 => InvalidDeviceZPubkey 6 => InvalidDevicePubkey ``` ## Testing Verification * Verified error enum round-trip conversion with `test_error_enum_conversions` <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/malbeclabs/doublezero/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. skip-changelog --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: elitegreg <3893730+elitegreg@users.noreply.github.com>
Summary of Changes
Testing Verification
Closes #2623
Closes #2624
Closes #2625