Program ID
Overview
The Registry program serves three primary functions:- Protocol Configuration: Stores network parameters, epoch settings, and fees
- Forester Coordination: Manages forester registration, work tracking, and rewards
- Access Control: Wraps Account Compression instructions with eligibility checks
Key Features
Protocol Config
Network-wide settings and parameters
Forester Epochs
Time-based registration and work tracking
Wrapper Instructions
Access-controlled tree operations
Rent Management
Compressible config accounts
Account Types
Protocol Config PDA
Stores global protocol configuration.Protocol authority that can update config
PDA bump seed
Configuration parameters:
genesis_slot: Protocol start slotactive_phase_length: Slots per active phaseregistration_phase_length: Slots for forester registrationreport_work_phase_length: Slots for work reportingnetwork_fee: Base network fee in lamportsslot_length: Seconds per slot
[b"protocol_config_pda_v1", authority]
Source: programs/registry/src/protocol_config/state.rs
Forester Epoch PDA
Tracks forester registration and work for an epoch.Forester authority
Epoch number
Work units completed this epoch
Work breakdown per tree
Slot when forester registered
Whether epoch is finalized
[b"forester_epoch_pda", authority, epoch.to_le_bytes()]
Source: programs/registry/src/epoch/state.rs
Compressible Config
Configuration for compressible token accounts (rent management).Address that sponsored the rent
State: Active, Deprecated, or Inactive
Authority that can claim rent back
Incentive paid for compression (in lamports)
Incentive paid for decompression
Duration accounts must stay decompressed (in slots)
Counter for deriving unique config addresses
[b"compressible_config", rent_sponsor, counter.to_le_bytes()]
Source: program-libs/compressible/src/config.rs
Core Instructions
Protocol Configuration
initialize_protocol_config
initialize_protocol_config
Initializes the protocol config PDA. Can only be called once.Accounts:
authority(signer): Protocol authorityprotocol_config_pda(writable): PDA to initializesystem_program
bump: PDA bump seedprotocol_config: Configuration parameters
- Must be signed by program account keypair during deployment
- Can only be initialized once
programs/registry/src/protocol_config/initialize.rsupdate_protocol_config
update_protocol_config
Updates protocol configuration.Accounts:
authority(signer): Current protocol authorityprotocol_config_pda(writable): Config to updatenew_authority: Optional new authority
protocol_config: New configuration (optional)
- Cannot change
genesis_slot - Cannot change
active_phase_length(would break epoch calculations)
programs/registry/src/protocol_config/update.rsForester Management
register_epoch
register_epoch
Registers a forester for the current epoch.Accounts:
authority(signer): Forester authorityforester_epoch_pda(writable): PDA to createprotocol_config_pda: Protocol configsystem_program
- Calculates current epoch from slot and config
- Checks registration is during registration phase
- Creates forester epoch PDA for this epoch
- Must be called during registration phase
- One registration per epoch per forester
programs/registry/src/epoch/register_epoch.rsreport_work
report_work
Reports work completed by a forester (called by wrapper instructions).Accounts:
forester_epoch_pda(writable): Forester’s epoch PDAtree_account: Tree work was performed on
work_units: Amount of work to record
- Validates epoch is active
- Increments
total_work - Updates
work_by_treefor the specific tree
programs/registry/src/epoch/report_work.rsfinalize_registration
finalize_registration
Finalizes a forester’s epoch registration for rewards.Accounts:
authority(signer): Forester authorityforester_epoch_pda(writable): Epoch PDA to finalizeprotocol_config_pda: Protocol config
- Must be called during report work phase
- Can only finalize once per epoch
programs/registry/src/epoch/finalize_registration.rsCompressible Config Management
create_compressible_config_counter
create_compressible_config_counter
Creates a counter account for generating unique config addresses.Accounts:
rent_sponsor(signer): Sponsor who will own configscounter_account(writable): Counter PDA to createsystem_program
[b"compressible_config_counter", rent_sponsor]Source: programs/registry/src/compressible/create_config_counter.rscreate_compressible_config
create_compressible_config
Creates a new compressible config.Accounts:
rent_sponsor(signer): Config ownercounter_account(writable): Counter to incrementcompressible_config(writable): Config to createsystem_program
config_data: Configuration (rent authority, incentives, slot length)
- Increments counter
- Derives config PDA with new counter value
- Initializes config with provided data
programs/registry/src/compressible/create_config.rsupdate_compressible_config
update_compressible_config
Updates an existing compressible config.Accounts:
rent_sponsor(signer): Config ownercompressible_config(writable): Config to update
config_state: New state (Active, Deprecated, Inactive)rent_authority: Optional new rent authoritycompression_incentive: Optional new compression incentivedecompression_incentive: Optional new decompression incentiveslot_length: Optional new slot length
programs/registry/src/compressible/update_config.rsWrapper Instructions (Access Control)
These instructions wrap Account Compression operations with forester eligibility checks.Wrapper Pattern
Wrapper Pattern
All wrapper instructions follow the same pattern:
- Load account - Deserialize target account metadata
- Check forester - Validate authority and track work
- Execute CPI - Call Account Compression with PDA signer
batch_append
batch_append
Wraps Account Compression’s
batch_append with access control.Work Units: Based on batch size from queue metadataSource: programs/registry/src/account_compression_cpi/batch_append.rsbatch_nullify
batch_nullify
Wraps
batch_nullify with forester eligibility check.Work Units: Based on batch sizeSource: programs/registry/src/account_compression_cpi/batch_nullify.rsbatch_update_address_tree
batch_update_address_tree
Wraps batched address tree updates.Source:
programs/registry/src/account_compression_cpi/batch_update_address_tree.rsnullify
nullify
Wraps single leaf nullification.Work Units:
DEFAULT_WORK_V1 constantSource: programs/registry/src/account_compression_cpi/nullify.rsupdate_address_merkle_tree
update_address_merkle_tree
Wraps single address insertion.Work Units:
DEFAULT_WORK_V1 constantSource: programs/registry/src/account_compression_cpi/update_address_tree.rsrollover_state_merkle_tree_and_queue
rollover_state_merkle_tree_and_queue
Wraps state tree rollover.Source:
programs/registry/src/account_compression_cpi/rollover_state_tree.rsrollover_batched_state_merkle_tree
rollover_batched_state_merkle_tree
Wraps batched state tree rollover.Source:
programs/registry/src/account_compression_cpi/rollover_batched_state_tree.rsrollover_batched_address_merkle_tree
rollover_batched_address_merkle_tree
Wraps batched address tree rollover.Source:
programs/registry/src/account_compression_cpi/rollover_batched_address_tree.rsinitialize_batched_state_merkle_tree
initialize_batched_state_merkle_tree
Wraps batched state tree initialization.Source:
programs/registry/src/account_compression_cpi/initialize_batched_state_tree.rsinitialize_batched_address_merkle_tree
initialize_batched_address_merkle_tree
Wraps batched address tree initialization.Source:
programs/registry/src/account_compression_cpi/initialize_batched_address_tree.rsmigrate_state
migrate_state
Wraps state migration between trees.Source:
programs/registry/src/account_compression_cpi/migrate_state.rsCompressible Token Operations
compress_and_close
compress_and_close
Wraps Compressed Token’s compress and close operation.Process:
- Validates compressible config is not inactive
- Executes compression via CPI
- Handles rent distribution
programs/registry/src/compressible/compress_and_close.rsclaim
claim
Wraps Compressed Token’s claim instruction.Requirements:
- Config must not be inactive
- Account must be compressible
programs/registry/src/compressible/claim.rswithdraw_funding_pool
withdraw_funding_pool
Wraps Compressed Token’s withdraw funding pool instruction.Source:
programs/registry/src/compressible/withdraw_funding_pool.rsForester Eligibility System
Epoch Phases
Each epoch consists of three phases:- Registration Phase: Foresters register for the epoch
- Active Phase: Foresters perform work on trees
- Report Work Phase: Foresters finalize registration and receive rewards
Work Tracking
Work is tracked per operation:| Operation | Work Units |
|---|---|
| Batch append | Batch size |
| Batch nullify | Batch size |
| Batch address update | Batch size |
| Single nullify | DEFAULT_WORK_V1 (1) |
| Single address update | DEFAULT_WORK_V1 (1) |
| Tree rollover | DEFAULT_WORK_V1 (1) |
Eligibility Check
Thecheck_forester function validates operations:
With Forester PDA:
- Validates epoch registration
- Checks authority matches registered forester
- Tracks work units
- Requires network fee payment
- Checks authority matches tree’s designated forester
- No work tracking
- No network fee required
Usage Examples
Registering as a Forester
Creating a Compressible Config
Error Codes
| Code | Name | Description |
|---|---|---|
| 5000 | InvalidEpoch | Epoch number invalid for current slot |
| 5001 | InvalidPhase | Operation not allowed in current phase |
| 5002 | ForesterNotRegistered | Forester not registered for epoch |
| 5003 | InvalidSigner | Signer doesn’t match expected authority |
| 5004 | AlreadyFinalized | Epoch already finalized |
| 5005 | InvalidNetworkFee | Network fee payment incorrect |
| 5006 | InvalidConfigUpdate | Config update violates constraints |
| 5007 | ForesterDefined | Tree has forester but none provided |
| 5008 | ForesterUndefined | Tree has no forester but one provided |
| 5009 | CompressibleConfigInactive | Config state is inactive |
programs/registry/src/errors.rs
Source Code
View the full source code on GitHub:Next Steps
Run a Forester
Learn how to run a forester node
Programs Overview
Back to programs overview