The Registry program manages Light Protocol’s configuration, coordinates forester operations, and wraps Account Compression instructions with access control for decentralized tree maintenance.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Lightprotocol/light-protocol/llms.txt
Use this file to discover all available pages before exploring further.
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
Forester Epochs
Wrapper Instructions
Rent Management
Account Types
Protocol Config PDA
Stores global protocol configuration.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.[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).[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
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
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
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
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
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
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
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
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
- 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
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
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
programs/registry/src/account_compression_cpi/batch_update_address_tree.rsnullify
nullify
DEFAULT_WORK_V1 constantSource: programs/registry/src/account_compression_cpi/nullify.rsupdate_address_merkle_tree
update_address_merkle_tree
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
programs/registry/src/account_compression_cpi/rollover_state_tree.rsrollover_batched_state_merkle_tree
rollover_batched_state_merkle_tree
programs/registry/src/account_compression_cpi/rollover_batched_state_tree.rsrollover_batched_address_merkle_tree
rollover_batched_address_merkle_tree
programs/registry/src/account_compression_cpi/rollover_batched_address_tree.rsinitialize_batched_state_merkle_tree
initialize_batched_state_merkle_tree
programs/registry/src/account_compression_cpi/initialize_batched_state_tree.rsinitialize_batched_address_merkle_tree
initialize_batched_address_merkle_tree
programs/registry/src/account_compression_cpi/initialize_batched_address_tree.rsmigrate_state
migrate_state
programs/registry/src/account_compression_cpi/migrate_state.rsCompressible Token Operations
compress_and_close
compress_and_close
- Validates compressible config is not inactive
- Executes compression via CPI
- Handles rent distribution
programs/registry/src/compressible/compress_and_close.rsclaim
claim
- Config must not be inactive
- Account must be compressible
programs/registry/src/compressible/claim.rswithdraw_funding_pool
withdraw_funding_pool
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