legitimate-patterns-research.md
1 # Legitimate User Patterns Research 2 3 **Status**: Phase 2 - Research queries for Gemini execution 4 **Priority**: P0-P3 patterns across 6 categories 5 6 ## Research Queries for Gemini 7 8 ### Query 1: Blockchain Governance Voting Patterns 9 **Search**: "blockchain governance voting patterns production deployment real-world" 10 **Focus**: 11 - Typical voting participation rates 12 - Proposal lifecycle (draft → vote → timelock → execute) 13 - Quorum requirements 14 - Delegation patterns 15 - Abstention vs active voting 16 17 **Expected patterns**: 18 - PT-L-001: Basic proposal voting (create → vote → result) 19 - PT-L-002: Delegated voting 20 - PT-L-003: Time-locked governance execution 21 - PT-L-004: Governance parameter updates 22 23 ### Query 2: Cross-Chain Bridge Testing Methodology 24 **Search**: "cross-chain bridge testing patterns atomic swaps lock mint methodology" 25 **Focus**: 26 - Lock/mint workflows 27 - Burn/unlock patterns 28 - Atomic swap mechanics 29 - Finality requirements 30 - Timeout handling 31 32 **Expected patterns**: 33 - PT-L-010: Basic lock→mint→burn→unlock flow 34 - PT-L-011: Multi-step cross-chain coordination 35 - PT-L-012: Cross-chain atomicity verification 36 - PT-L-013: Finality waiting patterns 37 38 ### Query 3: DEX Integration Test Scenarios 39 **Search**: "DEX integration testing orderbook matching AMM liquidity provider patterns" 40 **Focus**: 41 - Order placement and matching 42 - Market vs limit orders 43 - Partial fills 44 - Order cancellation 45 - Liquidity provision 46 47 **Expected patterns**: 48 - PT-L-020: Spot market order execution 49 - PT-L-021: Limit order placement and fill 50 - PT-L-022: Order cancellation 51 - PT-L-023: Liquidity pool operations 52 - PT-L-024: Slippage handling 53 54 ### Query 4: zkSNARK Testing Patterns 55 **Search**: "zkSNARK testing patterns privacy blockchain shielded transactions proof generation" 56 **Focus**: 57 - Proof generation workflows 58 - Verification patterns 59 - Privacy-preserving transfers 60 - Address recycling 61 - Mixing strategies 62 63 **Expected patterns**: 64 - PT-L-030: Shielded transfer (generate proof → submit) 65 - PT-L-031: Address recycling for privacy 66 - PT-L-032: Batch proof generation 67 - PT-L-033: Privacy set mixing 68 69 ### Query 5: BFT Consensus Testing 70 **Search**: "BFT consensus testing patterns validator participation block attestation" 71 **Focus**: 72 - Block proposal patterns 73 - Attestation signing 74 - Validator rotation 75 - Reward claiming 76 - Slashing conditions 77 78 **Expected patterns**: 79 - PT-L-040: Validator block proposal 80 - PT-L-041: Block attestation 81 - PT-L-042: Reward claiming 82 - PT-L-043: Validator registration/deregistration 83 84 ### Query 6: Perpetuals Trading Patterns 85 **Search**: "perpetual futures trading patterns leverage liquidation funding rate" 86 **Focus**: 87 - Position opening (long/short) 88 - Leverage management 89 - Position closing 90 - Liquidation triggers 91 - Funding rate payments 92 93 **Expected patterns**: 94 - PT-L-050: Open perpetual position 95 - PT-L-051: Close position (profit/loss) 96 - PT-L-052: Liquidation avoidance 97 - PT-L-053: Funding rate optimization 98 99 ## Documented Patterns (Based on Best Practices) 100 101 ### Category 1: Governance Workflows (P0-P1) 102 103 #### PT-L-001: Basic Proposal Lifecycle (P0) 104 **Description**: Complete governance proposal flow from creation to execution 105 **Steps**: 106 1. Create proposal with valid parameters 107 2. Wait for voting period start 108 3. Cast vote (yes/no/abstain) 109 4. Wait for voting period end 110 5. Wait for timelock 111 6. Execute proposal 112 113 **Test coverage**: 114 - Valid proposal formats 115 - Timelock enforcement 116 - Vote counting 117 - Execution success 118 119 #### PT-L-002: Delegated Voting (P1) 120 **Description**: Delegate voting power to another address 121 **Steps**: 122 1. Delegate tokens to representative 123 2. Representative votes on behalf 124 3. Verify vote weight includes delegated power 125 4. Undelegate after proposal 126 127 #### PT-L-003: Joint Alpha/Delta Governance (P0) 128 **Description**: Proposals that affect both chains 129 **Steps**: 130 1. Create proposal on Alpha 131 2. Proposal automatically mirrored to Delta 132 3. Vote on both chains 133 4. Execution requires quorum on both 134 5. State changes propagate via IPC 135 136 ### Category 2: Cross-Chain Coordination (P0) 137 138 #### PT-L-010: Lock/Mint/Burn/Unlock Flow (P0) 139 **Description**: Full cross-chain asset transfer cycle 140 **Steps**: 141 1. Lock AX on Alpha (generate unlock_id) 142 2. Wait for Alpha finality (3 blocks) 143 3. IPC message to Delta 144 4. Mint sAX on Delta (same amount) 145 5. Verify sAX balance 146 6. [Later] Burn sAX on Delta 147 7. IPC message to Alpha 148 8. Unlock AX on Alpha 149 150 **Success criteria**: 151 - Atomicity: no double-spend 152 - Conservation: total supply unchanged 153 - Finality: irreversible after confirmed 154 155 #### PT-L-011: Concurrent Cross-Chain Operations (P1) 156 **Description**: Multiple users performing cross-chain transfers simultaneously 157 **Steps**: 158 1. 100 bots lock AX on Alpha (different amounts) 159 2. Verify all IPC messages sent 160 3. Verify all sAX minted on Delta 161 4. Check total locked = total minted 162 163 ### Category 3: Trading Lifecycle (P0-P1) 164 165 #### PT-L-020: Spot Market Order (P0) 166 **Description**: Basic market order execution 167 **Steps**: 168 1. Query orderbook for pair (e.g., AX/DX) 169 2. Place market buy order 170 3. Verify immediate fill (or best available) 171 4. Check balance updated 172 5. Verify trade appears in history 173 174 #### PT-L-021: Limit Order Lifecycle (P0) 175 **Description**: Place, partial fill, cancel flow 176 **Steps**: 177 1. Place limit buy order below market price 178 2. Wait for partial fill (50%) 179 3. Verify balance updated for filled portion 180 4. Cancel remaining order 181 5. Verify order removed from book 182 183 #### PT-L-022: Liquidity Provider Operations (P1) 184 **Description**: Add/remove liquidity to AMM pool 185 **Steps**: 186 1. Approve token spending 187 2. Add liquidity (AX + DX) 188 3. Receive LP tokens 189 4. Wait for trading fees to accumulate 190 5. Remove liquidity 191 6. Verify fee rewards received 192 193 ### Category 4: Privacy Operations (P1-P2) 194 195 #### PT-L-030: Shielded Transfer (P1) 196 **Description**: Private AlphaVM transfer using ZK proofs 197 **Steps**: 198 1. Generate proof for transfer (amount, recipient) 199 2. Submit shielded transaction 200 3. Wait for proof verification (can be slow) 201 4. Verify transaction confirmed 202 5. Recipient verifies balance (off-chain) 203 204 **Constraints**: 205 - Proof generation: 5-10 seconds 206 - Verification: <1 second on-chain 207 208 #### PT-L-031: Address Recycling (P2) 209 **Description**: Rotate receiving addresses for privacy 210 **Steps**: 211 1. Generate new stealth address 212 2. Publish address to recipient (off-chain) 213 3. Receive transfer to new address 214 4. Never reuse address 215 216 ### Category 5: Validator Participation (P0-P1) 217 218 #### PT-L-040: Validator Block Proposal (P0) 219 **Description**: Propose a block as validator 220 **Steps**: 221 1. Verify validator is in active set 222 2. Wait for turn (round-robin or random) 223 3. Collect transactions from mempool 224 4. Build block with valid header 225 5. Propose block to network 226 6. Collect attestations (>2/3 stake) 227 7. Finalize block 228 229 #### PT-L-041: Continuous Block Attestation (P0) 230 **Description**: Attest to blocks proposed by others 231 **Steps**: 232 1. Monitor for new block proposals 233 2. Verify block validity 234 3. Sign attestation 235 4. Broadcast attestation 236 5. Track attestation rewards 237 238 #### PT-L-042: Rewards Claiming (P1) 239 **Description**: Claim accumulated validator rewards 240 **Steps**: 241 1. Query pending rewards 242 2. Submit claim transaction 243 3. Verify rewards credited to balance 244 4. Optional: re-stake rewards 245 246 ### Category 6: Time-Dependent Operations (P1-P2) 247 248 #### PT-L-060: Auction Participation (P2) 249 **Description**: Vickrey auction for name service 250 **Steps**: 251 1. Commit phase: Submit hash(bid, salt) 252 2. Wait for commit period end 253 3. Reveal phase: Submit (bid, salt) 254 4. Wait for reveal period end 255 5. Auction resolution: highest bidder wins 256 6. Refund losing bids 257 258 ## Alpha/Delta-Specific Mappings 259 260 ### Alpha Chain 261 - Governance: Native GID tokens, 7-day timelock 262 - Privacy: AlphaVM shielded transfers (Groth16) 263 - Validator: BFT consensus, 80 validators 264 - Cross-chain: Lock AX → emit IPC event 265 266 ### Delta Chain 267 - DEX: Orderbook + AMM hybrid 268 - Perpetuals: Up to 20x leverage 269 - Oracles: Median of 7 price feeds 270 - Cross-chain: Mint sAX ← receive IPC event 271 272 ## Priority Matrix 273 274 | Pattern | Priority | Complexity | Alpha/Delta | Test Duration | 275 |---------|----------|------------|-------------|---------------| 276 | PT-L-001 | P0 | Medium | Both | 2-3 min | 277 | PT-L-010 | P0 | High | Both | 1-2 min | 278 | PT-L-020 | P0 | Low | Delta | 10-30 sec | 279 | PT-L-021 | P0 | Medium | Delta | 30-60 sec | 280 | PT-L-030 | P1 | High | Alpha | 10-15 sec | 281 | PT-L-040 | P0 | High | Both | 1-2 min | 282 283 ## Implementation Notes 284 285 1. **All P0 patterns must be implemented in Phase 2** 286 2. **P1 patterns should be implemented if time permits** 287 3. **P2-P3 patterns are optional enhancements** 288 4. **Each pattern needs**: 289 - Behavior trait implementation 290 - Pre/post-condition checks 291 - Unit scenario YAML 292 - Integration test 293 294 ## Next Steps 295 296 1. Execute Gemini research queries to validate/expand patterns 297 2. Implement behaviors for all P0 patterns (Tasks #10-11) 298 3. Create unit scenarios for each pattern 299 4. Verify behaviors with integration tests