Skip to content

feat(rfp-002): add spel-freeze-authority library and sample program#213

Draft
bristinWild wants to merge 4 commits into
logos-co:mainfrom
bristinWild:feat/rfp-002-freeze-authority
Draft

feat(rfp-002): add spel-freeze-authority library and sample program#213
bristinWild wants to merge 4 commits into
logos-co:mainfrom
bristinWild:feat/rfp-002-freeze-authority

Conversation

@bristinWild
Copy link
Copy Markdown

Implements RFP-002: Freeze Authority Library for LEZ programs.

What's included

spel-freeze-authority crate

  • FreezeState - core freeze primitive with program-level and account-level freeze
  • check_interaction() - single call gates any instruction
  • freeze_program() / unfreeze_program() - emergency circuit breaker
  • freeze_account() / unfreeze_account() - per-account freeze
  • set_freeze_authority() - admin-controlled rotation and revocation
  • 11 unit tests covering all 7 hard functionality requirements

spel-freeze-authority-sample - reference program

  • initialize - creates config PDA with admin + freeze authority
  • interact - normal instruction gated by check_interaction()
  • freeze_program / unfreeze_program - freeze authority only
  • freeze_account / unfreeze_account - freeze authority only
  • set_freeze_authority - admin only (rotate or revoke)
  • 9 integration tests

Authority Hierarchy

AdminAuthority (spel-admin-authority, RFP-001)
└── FreezeAuthority (spel-freeze-authority, RFP-002)
├── freeze_program() / unfreeze_program()
├── freeze_account(account_id)
└── unfreeze_account(account_id)

Test results

  • spel-freeze-authority: 11 tests ✅
  • spel-freeze-authority-sample: 9 tests ✅
  • Full workspace: all existing tests pass, 0 regressions ✅

Related

bristinWild added 4 commits May 20, 2026 02:35
- Add spel-admin-authority crate with AdminState core primitive
  - assert_admin(), transfer_admin(), revoke_admin() operations
  - Atomic mutations — state only changes after all checks pass
  - 9 unit tests covering all authority lifecycle scenarios
- Add spel-admin-authority-sample SPEL program demonstrating integration
  - initialize: creates config PDA, sets admin authority
  - set_config_value: admin-gated privileged instruction
  - transfer_admin: rotate authority to new key
  - revoke_admin: permanently revoke (irreversible)
  - 8 integration tests covering all 4 instructions + error cases
- Full workspace compiles clean, 17 tests passing

Addresses RFP-001: Admin Authority Library
- Add require_admin proc macro attribute to spel-framework-macros
- #[lez_program] now detects #[require_admin(config)] on instructions
  and injects AdminConfig::assert_admin() check before handler body runs
- Add AdminConfig to spel-admin-authority library (re-exported in sample)
- Update sample program to use #[require_admin(config)] annotation
- Full workspace: all tests passing, 0 failures

Usage:
  #[instruction]
  #[require_admin(config)]
  pub fn set_config_value(
      #[account(mut, pda = literal("config"))]
      config: AccountWithMetadata,
      #[account(signer)]
      admin: AccountWithMetadata,
      new_value: u64,
  ) -> SpelResult { ... }  // admin check injected automatically
- FreezeState with program-level and account-level freeze
- freeze_program/unfreeze_program — circuit breaker for entire program
- freeze_account/unfreeze_account — per-account freeze
- check_interaction() — single call gates any instruction
- set_freeze_authority() — admin-controlled rotation and revocation
- 11 unit tests for FreezeState
- 9 integration tests in sample program
- Full workspace: 0 failures

Addresses RFP-002: Freeze Authority Library
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant