Skip to content

Conversation

@elitegreg
Copy link
Contributor

@elitegreg elitegreg commented Dec 9, 2025

Summary of Changes

  • Adds ResourceExtension to the smartcontract. This account tracks either IP or ID resources using a bitmap.
  • Adds create/allocate/deallocate/get SDK methods for ResourceExtension
  • Adds create/allocate/deallocate/get CLI commands for ResourceExtension (Foundation allowlist only)

Testing Verification

  • Added new unit tests
  • Tested with a test solana instance manually from the command line

Closes #2386
Closes #2387
Closes #2389
Closes #2390
Closes #2392
Closes #2393
Closes #2394
Closes #2395
Closes #2396
Closes #2397
Closes #2399

@elitegreg elitegreg force-pushed the gm/ip_allocation branch 2 times, most recently from 2531292 to b010de7 Compare December 16, 2025 07:27
@elitegreg elitegreg changed the title [WIP] Resource Extension Smartcontract: Add ResourceExtension and Foundation Commands for Managing Dec 23, 2025
@elitegreg elitegreg requested a review from Copilot December 23, 2025 18:13
@elitegreg elitegreg marked this pull request as ready for review December 23, 2025 18:15
Copy link

Copilot AI left a 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.

elitegreg and others added 10 commits December 23, 2025 21:08
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment