|
| 1 | +# Deployment Strategy |
| 2 | + |
| 3 | +This document outlines the branching and deployment strategy for Solidity contracts in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +We use a **promotion-based deployment model** where code flows from development through testnet to mainnet via pull requests. This ensures clear traceability of what code is deployed where. |
| 8 | + |
| 9 | +``` |
| 10 | +feature/* ────────────────┐ |
| 11 | + ▼ |
| 12 | + main (deployment-ready) |
| 13 | + │ |
| 14 | + ▼ PR (testnet deployment) |
| 15 | + deployed/testnet ──► tag: deploy/testnet/YYYY-MM-DD |
| 16 | + │ |
| 17 | + ▼ PR (mainnet deployment) |
| 18 | + deployed/mainnet ──► tag: deploy/mainnet/YYYY-MM-DD |
| 19 | +``` |
| 20 | + |
| 21 | +## Key Principles |
| 22 | + |
| 23 | +1. **Work in feature branches.** All development happens in `feature/*` branches. Merge to `main` only when the work is complete. |
| 24 | + |
| 25 | +2. **`main` is always deployable.** If code isn't ready for deployment, it stays in a feature branch. This also means code in `main` must be audited. |
| 26 | + |
| 27 | +3. **`deployed/*` branches are append-only.** They only move forward via PRs, merging everything accumulated. This keeps history clean and ensures testnet accurately previews what will go to mainnet. Exception: emergency hotfixes. |
| 28 | + |
| 29 | +4. **Tag every deployment.** Each merge to a deployment branch creates a tag (e.g., `deploy/mainnet/2026-04-16`) as an immutable historical record. |
| 30 | + |
| 31 | +5. **Backport hotfixes.** If you fix something directly on a deployment branch, merge that fix back to `main` to prevent regression. |
| 32 | + |
| 33 | +## Branches |
| 34 | + |
| 35 | +| Branch | Purpose | Contains | |
| 36 | +|--------|---------|----------| |
| 37 | +| `feature/*` | Active development | Work-in-progress, not yet deployment-ready | |
| 38 | +| `main` | Development head | Latest **deployment-ready** code | |
| 39 | +| `deployed/testnet` | Testnet deployment tracking | Exactly what's deployed on Arbitrum Sepolia | |
| 40 | +| `deployed/mainnet` | Mainnet deployment tracking | Exactly what's deployed on Arbitrum One | |
| 41 | + |
| 42 | +### Finding deployed code |
| 43 | + |
| 44 | +To see exactly what code is running on a network: |
| 45 | + |
| 46 | +```bash |
| 47 | +# What's on mainnet? |
| 48 | +git checkout deployed/mainnet |
| 49 | + |
| 50 | +# What's on testnet? |
| 51 | +git checkout deployed/testnet |
| 52 | + |
| 53 | +# What's pending deployment (in main but not yet on mainnet)? |
| 54 | +git diff deployed/mainnet..main |
| 55 | +``` |
| 56 | + |
| 57 | +## Tags |
| 58 | + |
| 59 | +Each deployment automatically creates a tag for historical reference: |
| 60 | + |
| 61 | +- `deploy/testnet/YYYY-MM-DD` — Testnet deployment snapshots |
| 62 | +- `deploy/mainnet/YYYY-MM-DD` — Mainnet deployment snapshots |
| 63 | + |
| 64 | +List all deployment tags: |
| 65 | + |
| 66 | +```bash |
| 67 | +git tag -l "deploy/*" |
| 68 | +``` |
| 69 | + |
| 70 | +## Workflows |
| 71 | + |
| 72 | +### Feature Development |
| 73 | + |
| 74 | +Features are developed in feature branches and merged to `main` when complete. |
| 75 | + |
| 76 | +``` |
| 77 | +feature/new-stuff ──PR──► main |
| 78 | +``` |
| 79 | + |
| 80 | +### Testnet Deployment |
| 81 | + |
| 82 | +When ready to deploy to testnet: |
| 83 | + |
| 84 | +1. Create a PR from `main` to `deployed/testnet` |
| 85 | +2. Review and merge the PR |
| 86 | +3. Create tag `deploy/testnet/YYYY-MM-DD` |
| 87 | +4. Deploy the contracts to Arbitrum Sepolia |
| 88 | + |
| 89 | +``` |
| 90 | +main ──PR──► deployed/testnet ──► tag: deploy/testnet/YYYY-MM-DD |
| 91 | +``` |
| 92 | + |
| 93 | +### Mainnet Deployment |
| 94 | + |
| 95 | +When ready to deploy to mainnet (typically after testnet validation and audit): |
| 96 | + |
| 97 | +1. Create a PR from `deployed/testnet` to `deployed/mainnet` |
| 98 | +2. Review and merge the PR |
| 99 | +3. Create tag `deploy/mainnet/YYYY-MM-DD` |
| 100 | +4. Deploy the contracts to Arbitrum One |
| 101 | + |
| 102 | +``` |
| 103 | +deployed/testnet ──PR──► deployed/mainnet ──► tag: deploy/mainnet/YYYY-MM-DD |
| 104 | +``` |
| 105 | + |
| 106 | +### Emergency Hotfix |
| 107 | + |
| 108 | +For critical mainnet issues that cannot wait for the normal flow: |
| 109 | + |
| 110 | +1. Branch from `deployed/mainnet` |
| 111 | +2. Apply the fix |
| 112 | +3. PR directly to `deployed/mainnet` |
| 113 | +4. Tag and deploy |
| 114 | +5. **Backport the fix to `main`** to prevent regression |
| 115 | + |
| 116 | +``` |
| 117 | +deployed/mainnet ◄── hotfix/critical-fix |
| 118 | + │ |
| 119 | + ├──► tag: deploy/mainnet/YYYY-MM-DD |
| 120 | + │ |
| 121 | + └──► PR to main (backport) |
| 122 | +``` |
| 123 | + |
| 124 | +## Auto-tagging |
| 125 | + |
| 126 | +A GitHub Action (`.github/workflows/deployment-tag.yml`) automatically creates deployment tags when PRs are merged to deployment branches. No manual tagging is required. |
0 commit comments