|
| 1 | +# Mainnet Deployment Runbook (Foundation Build) |
| 2 | + |
| 3 | +This runbook covers deploying `program-v2` (the no-fee foundation build) to the |
| 4 | +LazorKit mainnet program slot, and the binary swap back to `lazorkit-protocol` |
| 5 | +(the commercial build) at the end of the foundation contract. |
| 6 | + |
| 7 | +The same on-chain slot — `LazorjRFNavitUaBu5m3WaNPjU1maipvSW2rZfAFAKi` — hosts |
| 8 | +both binaries at different times. dApp integrators keep using one stable |
| 9 | +program ID through the transition; only the on-chain behavior changes when |
| 10 | +the binary is swapped. |
| 11 | + |
| 12 | +## Why this scheme |
| 13 | + |
| 14 | +- **Foundation contract** requires a no-profit deploy (no admin, no protocol |
| 15 | + fees). `program-v2` ships exactly that. |
| 16 | +- **Brand continuity** — the mainnet program ID was published before the |
| 17 | + foundation contract. Switching IDs would force every integrating dApp to |
| 18 | + redeploy and migrate their on-chain references. |
| 19 | +- **Reversibility** — Solana program upgrades replace the binary at a slot. |
| 20 | + The same upgrade authority can swap from `program-v2` → `lazorkit-protocol` |
| 21 | + in one transaction once the foundation contract ends. |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +- Solana CLI 3.0.4 (pinned in `Cargo.toml [workspace.metadata.cli]`). |
| 26 | +- The mainnet program **upgrade authority** — a multisig keypair held jointly |
| 27 | + by the foundation and the lazorkit team. (If a single key holds the |
| 28 | + authority, transition to multisig before deploy — losing it locks the slot.) |
| 29 | +- The mainnet program **address keypair** for `LazorjRFNavitUaBu5m3WaNPjU1maipvSW2rZfAFAKi` |
| 30 | + (only needed for the *initial* deploy; subsequent upgrades use the upgrade |
| 31 | + authority). |
| 32 | +- A funded mainnet wallet for rent + transaction fees (~5 SOL leaves room). |
| 33 | +- Audit sign-off on the exact source revision being deployed (see |
| 34 | + `docs/AUDIT_PREP.md` for the pre-tag checklist). |
| 35 | + |
| 36 | +## Initial deploy (program-v2 → mainnet slot) |
| 37 | + |
| 38 | +1. Verify the source matches the audit-frozen tag: |
| 39 | + |
| 40 | + ```bash |
| 41 | + git fetch --tags |
| 42 | + git checkout audit-frozen-vN # whatever tag was audited |
| 43 | + git status # must be clean |
| 44 | + ``` |
| 45 | + |
| 46 | +2. Confirm the workspace is on the right toolchain: |
| 47 | + |
| 48 | + ```bash |
| 49 | + cat Cargo.toml | grep -A1 'metadata.cli' # → solana = "3.0.4" |
| 50 | + solana --version # → must be 3.0.4 |
| 51 | + rustup show active-toolchain # matches rust-toolchain.toml |
| 52 | + ``` |
| 53 | + |
| 54 | +3. Build the mainnet binary: |
| 55 | + |
| 56 | + ```bash |
| 57 | + cd program |
| 58 | + cargo build-sbf --features mainnet |
| 59 | + cd .. |
| 60 | + ``` |
| 61 | + |
| 62 | +4. Verify the embedded program ID: |
| 63 | + |
| 64 | + ```bash |
| 65 | + solana-keygen pubkey target/deploy/lazorkit_program-keypair.json |
| 66 | + # → must print LazorjRFNavitUaBu5m3WaNPjU1maipvSW2rZfAFAKi |
| 67 | + ``` |
| 68 | + |
| 69 | + If the printed pubkey is anything else, the build picked up the wrong |
| 70 | + keypair. Replace `target/deploy/lazorkit_program-keypair.json` with the |
| 71 | + keypair file for `LazorjRF…` before deploying. **Do not deploy with a |
| 72 | + mismatched ID** — the binary's compile-time `crate::ID` reads from |
| 73 | + `assertions/src/lib.rs` (the `LazorjRF…` constant under the `mainnet` |
| 74 | + feature) and will fail every PDA derivation if loaded into a different |
| 75 | + slot. |
| 76 | + |
| 77 | +5. Record the binary hash for the release artifact: |
| 78 | + |
| 79 | + ```bash |
| 80 | + shasum -a 256 target/deploy/lazorkit_program.so |
| 81 | + # Compare against the hash published in the GitHub Release for this tag. |
| 82 | + ``` |
| 83 | + |
| 84 | +6. Deploy: |
| 85 | + |
| 86 | + ```bash |
| 87 | + solana program deploy target/deploy/lazorkit_program.so -u m \ |
| 88 | + --program-id <path/to/LazorjRF-keypair.json> \ |
| 89 | + --upgrade-authority <path/to/upgrade-authority.json> |
| 90 | + ``` |
| 91 | + |
| 92 | +7. Verify the deployed program: |
| 93 | + |
| 94 | + ```bash |
| 95 | + solana program show LazorjRFNavitUaBu5m3WaNPjU1maipvSW2rZfAFAKi -u m |
| 96 | + # Look for: ProgramData Address, Authority, Last Deployed In Slot, Data Len |
| 97 | + ``` |
| 98 | + |
| 99 | + The `Authority` line must match the multisig pubkey that should retain |
| 100 | + upgrade control. |
| 101 | + |
| 102 | +8. Smoke-test on-chain: |
| 103 | + |
| 104 | + - Create a wallet via the SDK pointing at the foundation flavor. |
| 105 | + - Verify no fee transfer occurs (compare lamport balances pre/post). |
| 106 | + - Run `solana account <walletPda>` and confirm the discriminator is `1`. |
| 107 | + |
| 108 | +## Subsequent upgrades (program-v2 patch deploy) |
| 109 | + |
| 110 | +For a routine upgrade of the foundation build (e.g., a security fix): |
| 111 | + |
| 112 | +```bash |
| 113 | +git checkout <new-audit-frozen-tag> |
| 114 | +cd program && cargo build-sbf --features mainnet && cd .. |
| 115 | +solana program deploy target/deploy/lazorkit_program.so -u m \ |
| 116 | + --program-id LazorjRFNavitUaBu5m3WaNPjU1maipvSW2rZfAFAKi \ |
| 117 | + --upgrade-authority <path/to/upgrade-authority.json> |
| 118 | +``` |
| 119 | + |
| 120 | +Document each upgrade in `CHANGELOG.md` and update the on-chain `security.txt` |
| 121 | +metadata via the next build (the macro embeds `GITHUB_SHA` automatically when |
| 122 | +built in CI). |
| 123 | + |
| 124 | +## Binary swap at contract end (program-v2 → lazorkit-protocol) |
| 125 | + |
| 126 | +When the foundation contract ends and the slot needs to host the commercial |
| 127 | +build again: |
| 128 | + |
| 129 | +1. In the **`lazorkit-protocol`** repo, check out the audit-frozen tag for |
| 130 | + the commercial build: |
| 131 | + |
| 132 | + ```bash |
| 133 | + cd ../lazorkit-protocol |
| 134 | + git checkout audit-frozen-commercial-vN |
| 135 | + ``` |
| 136 | + |
| 137 | +2. Build the commercial mainnet binary: |
| 138 | + |
| 139 | + ```bash |
| 140 | + cd program && cargo build-sbf --features mainnet && cd .. |
| 141 | + ``` |
| 142 | + |
| 143 | +3. Verify it embeds the same program ID (`LazorjRF…`): |
| 144 | + |
| 145 | + ```bash |
| 146 | + solana-keygen pubkey target/deploy/lazorkit_program-keypair.json |
| 147 | + ``` |
| 148 | + |
| 149 | +4. Deploy the upgrade. **No `--program-id` flag** — the slot already exists, |
| 150 | + we're upgrading it: |
| 151 | + |
| 152 | + ```bash |
| 153 | + solana program deploy target/deploy/lazorkit_program.so -u m \ |
| 154 | + --program-id LazorjRFNavitUaBu5m3WaNPjU1maipvSW2rZfAFAKi \ |
| 155 | + --upgrade-authority <path/to/upgrade-authority.json> |
| 156 | + ``` |
| 157 | + |
| 158 | +5. Initialise the protocol config (commercial-only instruction; no equivalent |
| 159 | + exists in the foundation build, so this is a fresh state): |
| 160 | + |
| 161 | + ```bash |
| 162 | + # Use the lazorkit-protocol SDK to send InitializeProtocol + InitializeTreasuryShard. |
| 163 | + # This step is only needed the first time the commercial build is on this |
| 164 | + # slot; subsequent upgrades preserve the existing ProtocolConfig PDA. |
| 165 | + ``` |
| 166 | + |
| 167 | +6. Smoke-test: |
| 168 | + |
| 169 | + - Create a wallet — the fee transfer to the treasury shard should succeed. |
| 170 | + - Verify the SDK consumer receives `protocolConfigPda` etc. without error. |
| 171 | + |
| 172 | +## Pre-existing wallet accounts across the swap |
| 173 | + |
| 174 | +Wallet, Vault, Authority, Session, and DeferredExec PDAs created under the |
| 175 | +foundation build remain valid and accessible under the commercial build — |
| 176 | +they all derive from the same program ID and the same seed schema, and the |
| 177 | +account-discriminator layout is identical between the two builds. |
| 178 | + |
| 179 | +What changes: |
| 180 | + |
| 181 | +- Fee accounts (`ProtocolConfig`, `FeeRecord`, `TreasuryShard`) start |
| 182 | + appearing once the commercial binary is live. Existing wallets continue to |
| 183 | + work; the fee is charged on subsequent `CreateWallet` / `Execute` / |
| 184 | + `ExecuteDeferred` calls if the SDK appends fee accounts. |
| 185 | +- Sessions created with action permissions under the foundation build remain |
| 186 | + enforced under the commercial build — action handling is identical. |
| 187 | +- The on-chain `security.txt` updates to advertise `lazorkit-protocol` as the |
| 188 | + source repo. Integrators querying it should re-fetch. |
| 189 | + |
| 190 | +## Rollback |
| 191 | + |
| 192 | +If a deployed upgrade misbehaves: |
| 193 | + |
| 194 | +```bash |
| 195 | +solana program deploy target/deploy/<previous-good-binary>.so -u m \ |
| 196 | + --program-id LazorjRFNavitUaBu5m3WaNPjU1maipvSW2rZfAFAKi \ |
| 197 | + --upgrade-authority <path/to/upgrade-authority.json> |
| 198 | +``` |
| 199 | + |
| 200 | +Solana program slots are upgrade-replaceable (so long as the upgrade |
| 201 | +authority hasn't been frozen). Keep the previous mainnet binary archived |
| 202 | +locally + in the GitHub Release for at least one audit cycle so a rollback |
| 203 | +is one command, not a rebuild. |
| 204 | + |
| 205 | +## Locking the upgrade authority |
| 206 | + |
| 207 | +After the post-contract swap to `lazorkit-protocol` is stable and you no |
| 208 | +longer want any further upgrades: |
| 209 | + |
| 210 | +```bash |
| 211 | +solana program set-upgrade-authority \ |
| 212 | + LazorjRFNavitUaBu5m3WaNPjU1maipvSW2rZfAFAKi \ |
| 213 | + --upgrade-authority <path/to/current-upgrade-authority.json> \ |
| 214 | + --final |
| 215 | +``` |
| 216 | + |
| 217 | +This is **irreversible**. Only do this after a long stability window and |
| 218 | +explicit foundation/team agreement — once finalised, the binary cannot be |
| 219 | +patched, security advisories included. |
0 commit comments