Skip to content

Latest commit

 

History

History
95 lines (82 loc) · 3.23 KB

FORMAL_SPEC.md

File metadata and controls

95 lines (82 loc) · 3.23 KB

GlitchGremlinProgram Formal Specification

1. Overview

The GlitchGremlinProgram is a Solana program that provides Chaos-as-a-Service (CaaS) functionality. It handles:

  • Chaos request lifecycle management
  • Token escrow and fee management
  • Governance integration
  • Result storage and reporting

2. Core Components

2.1 Accounts

  • ChaosRequest: Stores request details and status
    • Fields: owner, amount, status, params, result_ref
  • EscrowAccount: Holds tokens during chaos testing
    • Fields: amount, chaos_request, expiry
  • GovernanceProposal: Manages community chaos campaigns
    • Fields: id, proposer, description, target_program, votes

2.2 Instructions

  1. InitChaosRequest
    • Creates new ChaosRequest
    • Transfers tokens to escrow
    • Validates request parameters
  2. FinalizeChaosRequest
    • Updates request status
    • Releases/refunds tokens
    • Stores results
  3. CreateProposal
    • Creates new governance proposal
    • Validates proposal parameters
  4. VoteOnProposal
    • Records voter's choice
    • Updates vote tally

3. Security Model

3.1 Privileged Operations

  • Program upgrade (multisig controlled, 3/5 signatures)
  • Fee structure modification (governance controlled, 7 day timelock)
  • Escrow release authority (PDA controlled with signed proofs)
  • Governance parameter changes (governance controlled, 3 day timelock)
  • Emergency pause (multisig controlled, 2/3 signatures)

3.2 Rate Limiting

  • Max requests: 10 per minute per user
  • Max tokens escrowed: 1M GLITCH per request
  • Minimum request duration: 60 seconds
  • Maximum request duration: 3600 seconds
  • Minimum time between requests: 2 seconds
  • Maximum concurrent requests: 10 per user
  • Governance proposals: 1 per day per user
  • Voting cooldown: 1 hour between votes

3.3 Access Control

  • ChaosRequest creation: Any verified user
  • Finalization: AI engine only (signed proofs)
  • Governance: Token holders with minimum stake
  • Configuration: Multisig only
  • Emergency operations: Multisig only

3.4 Monitoring and Alerts

  • Real-time transaction monitoring
  • Anomaly detection
  • Automated alerts for suspicious activity
  • Regular security audits
  • Incident response plan

4. Error Handling

4.1 Error Codes

  • InsufficientFundsError (1001): Caller lacks required tokens
  • InvalidProgramError (1002): Target program address invalid
  • RequestTimeoutError (1003): Chaos request exceeded duration
  • InvalidInstructionError (1004): Malformed instruction data
  • UnauthorizedAccessError (1005): Invalid signer or authority
  • RateLimitExceededError (1006): Request threshold exceeded
  • InvalidProposalError (1007): Malformed governance proposal
  • VotingPeriodEndedError (1008): Attempt to vote after deadline
  • InsufficientStakeError (1009): Not enough tokens staked
  • ProposalExecutionError (1010): Failed to execute proposal
  • StakeLockedError (1011): Attempt to unstake before lockup period
  • DelegationError (1012): Invalid delegation attempt
  • RewardCalculationError (1013): Error in reward calculation

4.2 Error Recovery

  • Failed requests refund tokens
  • Partial completions refund proportionally
  • Invalid states trigger pause and audit

5. State Transitions

  • ChaosRequest: Pending -> InProgress -> Completed/Failed
  • GovernanceProposal: Proposed -> Voting -> Approved/Rejected