-
Notifications
You must be signed in to change notification settings - Fork 5
Smartcontract: Add ResourceExtension and Foundation Commands for Managing #2377
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
2531292 to
b010de7
Compare
66a5e38 to
cb28d3e
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 implements ResourceExtension accounts for managing IP and ID allocations in the smart contract. It introduces a new on-chain account type with bitmap-based allocation tracking and provides Foundation-restricted CLI commands for resource management.
- Adds ResourceExtension account type with IpAllocator and IdAllocator for bitmap-based resource tracking
- Implements create/allocate/deallocate instructions with Foundation allowlist enforcement
- Adds CLI commands and SDK methods for resource management operations
Reviewed changes
Copilot reviewed 43 out of 44 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| smartcontract/programs/doublezero-serviceability/src/state/resource_extension.rs | Core ResourceExtension state implementation with owned and borrowed variants |
| smartcontract/programs/doublezero-serviceability/src/ip_allocator.rs | IP address allocation using bitmap for efficient subnet tracking |
| smartcontract/programs/doublezero-serviceability/src/id_allocator.rs | ID allocation using bitmap for numeric range tracking |
| smartcontract/programs/doublezero-serviceability/src/processors/resource/*.rs | Processor functions for create/allocate/deallocate operations |
| smartcontract/programs/doublezero-serviceability/tests/resource_extension_test.rs | Comprehensive integration tests for all ResourceType variants |
| smartcontract/sdk/rs/src/commands/resource/*.rs | SDK command implementations for resource operations |
| smartcontract/cli/src/resource/*.rs | CLI command implementations with validation |
| smartcontract/programs/doublezero-serviceability/src/pda.rs | PDA derivation functions for all ResourceType variants |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
smartcontract/programs/doublezero-serviceability/src/state/resource_extension.rs
Outdated
Show resolved
Hide resolved
smartcontract/programs/doublezero-serviceability/src/state/resource_extension.rs
Outdated
Show resolved
Hide resolved
smartcontract/programs/doublezero-serviceability/src/state/resource_extension.rs
Outdated
Show resolved
Hide resolved
smartcontract/programs/doublezero-serviceability/src/state/resource_extension.rs
Outdated
Show resolved
Hide resolved
smartcontract/programs/doublezero-serviceability/src/state/resource_extension.rs
Outdated
Show resolved
Hide resolved
smartcontract/programs/doublezero-serviceability/src/processors/resource/allocate.rs
Outdated
Show resolved
Hide resolved
smartcontract/programs/doublezero-serviceability/src/processors/resource/create.rs
Outdated
Show resolved
Hide resolved
smartcontract/programs/doublezero-serviceability/src/processors/resource/deallocate.rs
Outdated
Show resolved
Hide resolved
- Add integration tests covering CreateResource, AllocateResource, and DeallocateResource instructions - Add test helpers: get_resource_extension_data, wait_for_new_blockhash, setup_program_with_globalconfig - Add get_resource_extension() getter to AccountData - Fix test_allocation_prefix_range_check: use correct allocation_size values to trigger validation errors Covering: - Happy path: create, allocate, deallocate, full lifecycle - Security: foundation_allowlist enforcement - Errors: double allocation, duplicate create, nonexistent resource - DzPrefixBlock: device-specific allocation and PDA derivation
161bb5b to
b64d2f3
Compare
Summary of Changes
Testing Verification
Closes #2386
Closes #2387
Closes #2389
Closes #2390
Closes #2392
Closes #2393
Closes #2394
Closes #2395
Closes #2396
Closes #2397
Closes #2399