Skip to content

Latest commit

 

History

History
140 lines (118 loc) · 4.72 KB

File metadata and controls

140 lines (118 loc) · 4.72 KB

Tern - Limitations & Production Roadmap

Current Limitations

1. External Contract Dependencies

  • Problem: Contracts calling other contracts (e.g., contract-call? 'SP...arkadiko-dao) fail on testnet if those contracts don't exist
  • Current: We detect and warn about dependencies, but can't resolve them
  • Production Solution:
    • Dependency graph builder - identify all contracts that need migration
    • Batch migration - migrate dependency tree in correct order
    • Mock contract generator - create stub contracts for testing
    • Mainnet fork simulation (like Foundry's anvil for EVM)

2. Wallet Security

  • Problem: Using seed phrase in .env is insecure
  • Current: Server-side signing with environment variable
  • Production Solution:
    • Integrate Leather/Xverse wallet connect
    • Client-side transaction signing
    • Hardware wallet support (Ledger)
    • Multi-sig support for team deployments

3. State Replication

  • Problem: Migrated contracts start with empty state
  • Current: Side-by-side comparison + manual replication via Contract Explorer (call read functions on original, use values to call write functions on migrated)
  • Production Solution:
    • State snapshot export from original contract
    • Init function generator based on contract analysis
    • State replay engine - replay historical transactions
    • Map bulk-initialization helper
    • Principal address mapping (mainnet → testnet equivalents)

4. Original Contract Management

  • Problem: Original contract may hold assets (STX, tokens, NFTs)
  • Current: No interaction with original contract
  • Production Solution:
    • Dual-contract explorer (mainnet + testnet side by side)
    • Asset inventory viewer (tokens, NFTs, STX balance)
    • Migration plan for assets (requires owner action on mainnet)
    • Pause/deprecation helper for original contract
    • Redirect/proxy pattern implementation

5. Live Migration Path

  • Problem: No safe path for contracts with real users/assets
  • Current: Only testnet deployment
  • Production Solution:
    • Staged migration workflow:
      1. Deploy to testnet → Test
      2. Deploy to mainnet (new address)
      3. Migration period (both contracts active)
      4. Asset migration tools
      5. Original contract deprecation
    • User notification system
    • Liquidity migration helpers

6. Testing & Validation

  • Problem: Limited validation before deployment
  • Current: Syntax validation only
  • Production Solution:
    • Unit test generation for migrated functions
    • Invariant testing (state properties that should hold)
    • Fuzzing support
    • Integration test scaffolding
    • CI/CD pipeline integration

7. Version Control & History

  • Problem: No record of migrations
  • Current: One-shot migration, no history
  • Production Solution:
    • Migration history with timestamps
    • Diff snapshots for each migration
    • Rollback support (redeploy previous version)
    • Git integration for contract versioning
    • Team collaboration features

8. Network Support

  • Problem: Limited to mainnet→testnet flow
  • Current: Hardcoded networks
  • Production Solution:
    • Custom network support (devnet, mocknet)
    • Cross-network deployment
    • Network-specific configurations
    • Testnet faucet integration

Feature Comparison

Feature Current (Hackathon) Production Ready
Migration Analysis AI-powered AI + Static analysis
Deployment Testnet only Any network
Wallet Seed phrase Wallet connect
Dependencies Warning only Auto-resolve
State Compare only Full replication
Testing Manual Automated suite
Security Basic Audit-grade
History None Full versioning

Security Considerations

Current Risks (Hackathon Demo)

  1. Seed phrase in environment - never use with real funds
  2. No transaction simulation - unexpected behavior possible
  3. No post-conditions - assets could be lost
  4. Server-side signing - key exposure risk

Production Security Requirements

  1. Client-side signing only
  2. Hardware wallet support
  3. Transaction simulation mandatory
  4. Post-condition builder
  5. Audit trail logging
  6. Rate limiting and abuse prevention

Recommended MVP Improvements (Post-Hackathon)

Phase 1: Security

  • Wallet connect integration (Leather/Xverse)
  • Remove seed phrase dependency
  • Transaction simulation

Phase 2: Dependencies

  • Dependency graph visualization
  • Mock contract generator
  • Batch migration support

Phase 3: State Management

  • State export/import
  • Init function generator
  • Principal mapping

Phase 4: Production

  • Mainnet deployment support
  • Migration history
  • Team collaboration