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
- 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
- InitChaosRequest
- Creates new ChaosRequest
- Transfers tokens to escrow
- Validates request parameters
- FinalizeChaosRequest
- Updates request status
- Releases/refunds tokens
- Stores results
- CreateProposal
- Creates new governance proposal
- Validates proposal parameters
- VoteOnProposal
- Records voter's choice
- Updates vote tally
- 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)
- 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
- ChaosRequest creation: Any verified user
- Finalization: AI engine only (signed proofs)
- Governance: Token holders with minimum stake
- Configuration: Multisig only
- Emergency operations: Multisig only
- Real-time transaction monitoring
- Anomaly detection
- Automated alerts for suspicious activity
- Regular security audits
- Incident response plan
- 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
- Failed requests refund tokens
- Partial completions refund proportionally
- Invalid states trigger pause and audit
- ChaosRequest: Pending -> InProgress -> Completed/Failed
- GovernanceProposal: Proposed -> Voting -> Approved/Rejected