7.6 KiB
Solution: LP-0013 — Token Program Improvements: Authorities
Submitted by: bristinWild
Summary
This submission implements a complete mint authority model for the LEZ Token program. Fungible tokens can now be created with a designated mint authority that can mint additional supply, rotate control to a new key, or permanently revoke minting to fix the supply. A standalone lez-authority crate provides the reusable authority primitive as defined in RFP-001.
Demo Video
Link - https://www.youtube.com/watch?v=Q_uAv7xRD-c
Repository
- Repo: https://github.com/bristinWild/lez-programs (PR: https://github.com/logos-blockchain/lez-programs/pull/125)
- Fork: https://github.com/bristinWild/lez-programs
- Branch:
solution/lp-0013-authorities - Commit:
c2d259e - Key files:
lez-authority/src/lib.rs—Authoritytype +Ownabletrait (RFP-001)programs/token/core/src/lib.rs—TokenDefinition::Fungiblewithauthority: Authorityfieldprograms/token/src/mint.rs— authority-gatedMinthandler (self/external authority)programs/token/src/set_authority.rs—SetAuthorityhandler (rotation + revocation)programs/token/src/new_definition.rs—NewFungibleDefinitionwithmint_authority: Option<AccountId>programs/token/methods/guest/src/bin/token.rs— guest binary dispatch for all instructionsprograms/integration_tests/tests/token.rs— 17 integration tests including full rotation flowscripts/demo-full-flow.sh— end-to-end demo scriptscripts/examples/fixed_supply_token.sh— fixed supply examplescripts/examples/variable_supply_token.sh— variable supply + rotation exampledocs/LP-0013-README.md— architecture, CU costs, CLI usage, design docsartifacts/token-idl.json— regenerated IDL via SPEL framework
Approach
Authority Model
authority: Authority is embedded directly in TokenDefinition::Fungible via the lez-authority crate:
Authority(Some(key))— the key holder controls minting and can rotate/revokeAuthority(None)— supply is permanently fixed; minting is rejected deterministically
lez-authority Crate (RFP-001)
A standalone crate with zero dependency on any specific program or nssa_core. Provides:
Authority(Option<[u8; 32]>)newtype withauthority(),require(),rotate()Ownabletrait withrequire_owner,transfer_ownership,renounce_ownership
All logic is unit-tested independently (8 tests).
Instructions
| Instruction | Description |
|---|---|
NewFungibleDefinition |
Create token with optional mint authority (mint_authority: Option<AccountId>) |
Mint (updated) |
Authority-gated — self-authority (empty rest accounts) or external rotated authority (rest account) |
SetAuthority |
Rotate to new key (Some(key)) or revoke permanently (None) |
Authority Transfer (RFP-001)
The Mint and SetAuthority instructions support both self/PDA authority and external rotated authority passed as a rest account. After rotation, the new key can actually mint — proven by the token_rotate_authority_then_new_authority_can_mint integration test.
Atomicity
SetAuthority only mutates authority after all authorization checks pass. Unauthorized calls return before any write — prior authority is preserved. Structural guarantee via Authority::rotate().
Success Criteria Checklist
- Variable-size tokens via mint authority —
NewFungibleDefinitionsets authority at init;Mintchecks it - Minting by the authority — self-authority and external rotated-authority paths both supported and tested
- Authority rotation and revocation —
SetAuthoritywithSome(new_key)rotates; withNonerevokes permanently - Two example integrations —
scripts/examples/fixed_supply_token.shandscripts/examples/variable_supply_token.sh - Self-sufficient agnostic authority library (RFP-001) —
lez-authoritycrate, zero deps on token program or nssa - SDK/module — SPEL IDL + CLI integration; guest binary wired for all instructions
- IDL —
artifacts/token-idl.jsonregenerated via SPEL framework - Atomicity — structural guarantee in
Authority::rotate(), verified by unit tests - Deterministic rejection —
"Mint authority check failed: Revoked"on every revoked-authority mint attempt - CU costs — measured from LEZ sequencer execution logs on localnet:
NewFungibleDefinition~11ms,Mint~10ms,SetAuthority~8ms (execution time inside zkVM, measured via sequencer logs withRISC0_DEV_MODE=1; this reflects actual program execution cost independent of proof generation). Full ZK proof generation takes 3–10 minutes per tx withRISC0_DEV_MODE=0on Apple M-series hardware. LEZ devnet/testnet deployment pending public sequencer availability. - Integration tests — 17 tests in
programs/integration_tests/tests/token.rsagainst live sequencer (standalone mode), including full RFP-001 rotation flow - CI green — 60 unit tests + 17 integration tests passing
- README —
docs/LP-0013-README.mdwith deployment steps, CLI instructions, architecture, error codes - Demo script —
scripts/demo-full-flow.sh— reproducible against local LEZ sequencer withRISC0_DEV_MODE=0 - Recorded video demo — https://www.youtube.com/watch?v=Q_uAv7xRD-c (narrated,
RISC0_DEV_MODE=0terminal output visible)
FURPS Self-Assessment
Functionality
NewFungibleDefinition: creates fungible token withmint_authority: Option<AccountId>—Some= mintable,None= fixed supplyMint: self-authority (definition account is its own authority) or external rotated authority (rest account)SetAuthority: rotates toSome(new_key)or revokes toNone; authorization check enforces caller identity- Metadata fungibles carry a real
mint_authority— intentional and tested - AMM LP token authority correctly wired to pool PDA — all AMM tests pass unchanged
Usability
- Single embedded
authority: Authorityfield — minimal diff, easy to audit lez-authorityimportable by any LEZ program without token program dependencyartifacts/token-idl.jsonenables full SPEL CLI interactiondocs/LP-0013-README.mddocuments all flows with CLI examples and CU costs
Reliability
- Atomicity:
Authority::rotate()returnsErrbefore mutating — no partial writes possible - 13 dedicated authority unit tests cover all lifecycle cases
- 17 integration tests including full rotation flow at executor level
- All 60 unit tests + 17 integration tests pass
Performance
- Authority check in
Mint: singleOptionmatch — negligible overhead SetAuthority: single account read + write- CU costs (LEZ localnet,
RISC0_DEV_MODE=1):NewFungibleDefinition~11ms,Mint~10ms,SetAuthority~8ms
Supportability
- Demo script reproducible against local sequencer with
RISC0_DEV_MODE=0 docs/LP-0013-README.mddocuments deployment, CLI usage, architecture, error codes- PR #125 on
logos-blockchain/lez-programs— rebased onto upstream main
Supporting Materials
- PR: https://github.com/logos-blockchain/lez-programs/pull/125
- Architecture docs:
docs/LP-0013-README.md - Authority library:
lez-authority/src/lib.rs - SetAuthority handler:
programs/token/src/set_authority.rs - Mint handler:
programs/token/src/mint.rs - Demo script:
scripts/demo-full-flow.sh - Example scripts:
scripts/examples/ - Demo video: https://www.youtube.com/watch?v=Q_uAv7xRD-c
Terms & Conditions
By submitting this solution, I confirm that I have read and agree to the Terms & Conditions.