SPB Git

Repository Public

SP-WALLET-DEPLOYMENT.md 8.8 KB 127 lines markdown

1# SP Wallet NEXT — deployment23**Executed so far (2026-11-20, on the owner's explicit go-ahead for each):**4- 00:05 ET — stage 2, API + web: `main` = `30467db` on M2M32c. Backups `~/backups/sp-wallet/pre-next-20261120-0005.dump`,5  `dist-pre-next-20261120-0005.tgz`, `.commit` (851e2fa). After restart: migration applied, 19 proposals and the 282-entry6  audit chain unchanged, 251 balances read, snapshots recorded, locks unchanged.7- 00:08 ET — stage 3, signer on m6ma (review list S1–S12 approved): bundle of `30467db` (sha256 `af7b818f87dbfc9e…`,8  identical on the laptop and on the API node). Before the swap the new binary loaded a copy of the real state (same key id,9  same journal head, journal intact). Key id unchanged `spw-ab7cac49ffebb919`; start line shows the allowlist;10  `policy.json` untouched. Backups on m6ma `*.bak-next-20261120`; key-free state copy taken off the node.11- Not yet: stage 0 (off-node backup schedule), stage 5 (cool-down / cap values), stage 6 (native builds), and the first12  real operations of §7 — no real signature has gone through the new signer yet.1314Stages 0, 5 and 6 are not executed. Each stage needs the owner's explicit go-ahead.1516## 1. Environments1718| Environment | What it is | Used for |19|---|---|---|20| Development | laptop worktree, per-run test databases (`services/api/test/test-db.ts`), throwaway signer, scripted chains | unit, integration and contract tests |21| Fork / dev stack | `scripts/dev-stack.sh` and `SPWalletCore/Scripts/dev-stack.sh`: local API + throwaway signer, broadcast off or a local anvil fork with fake funds | browser and native end-to-end runs, the macOS self-test |22| **Pre-production rehearsal** | `scripts/rehearse-next.mts`: the NEXT server on a **restored copy of the production database**, read-only against the real chains, with a stub signer that answers status and nothing else (no key exists in the process, broadcast off, no agent / venue / alert worker) | migration on real data, real-chain reads, timings |23| Production | M2M32c (API, web, Postgres), m6ma (signer), BHS64 (gateway) | — |2425There is no permanent staging host: a second signer with real keys must not exist, and a staging stack with other keys26would read other addresses. The rehearsal gives the part that matters — real data, real networks — without a key.2728**Rehearsal results (2026-11-19, dump of 03:20):** migration 1.2 s, idempotent; proposals and audit chain byte-identical;29one-in-flight index created; 21 deposits classified (16 external, 5 internal); every new route answered 200; the signer30stub received only `GET /status`. Findings fixed before release: 19 s cold portfolio read, 88 s deposit scan, value31snapshots made unusable by one unreadable network, Litecoin balance unavailable when one of its two sources is down.3233## 2. Order of release (progressive)3435| Stage | What | Depends on | Reversible by |36|---|---|---|---|37| 0 | Backups: new `scripts/backup.sh` + `scripts/restore-test.sh` on M2M32c; off-node copy (`SPW_BACKUP_REMOTE`) | owner: destination node | restoring the old script |38| 1 | Rehearsal on the dump of the day | — | — |39| 2 | **API + web** (`next` → `main`) on M2M32c | stage 1 green | `git checkout` previous commit + rebuild + restart; the schema is additive (see §5) |40| 3 | **Signer bundle** on m6ma (review list S1–S12, `SP-WALLET-SECURITY.md`) | owner's approval of the list; same window as stage 2 or right after | previous `signer.mjs` (see §5) |41| 4 | Watch 24 h (§6) | — | — |42| 5 | Optional policy keys on the signer: passkey cool-down, vault-return cap | owner's values | removing the keys |43| 6 | macOS build (notarised) and iOS build (TestFlight) | stages 2–3 live (the apps need the new routes; they degrade when a route is missing) | previous builds keep working: the API is additive |4445Between stages 2 and 3 everything works except adding or revoking a passkey (the new API asks the signer for a route the46old signer does not have: an error, nothing is added). Native apps 1.0 keep working after stage 3 except "add a passkey"47(they fail locally, before any prompt) until stage 6.4849## 3. Stage 2 — API and web5051On the laptop: `git push origin next:main` (after the owner's go-ahead). On M2M32c, in `~/apps/sp-wallet`:5253```54scripts/backup.sh && scripts/restore-test.sh              # a dump that restores, taken now55pg_dump -Fc "$DATABASE_URL" > ~/backups/sp-wallet/pre-next-$(date +%Y%m%d-%H%M).dump56tar czf ~/backups/sp-wallet/dist-pre-next-$(date +%Y%m%d-%H%M).tgz dist57git pull --ff-only && pnpm install --frozen-lockfile58node scripts/build.mjs && (cd apps/web && node_modules/.bin/vite build)   # never restart before the web build ends59# restart keeping the whole PM2 environment (re-export it from `pm2 jlist`, then):60pm2 restart sp-wallet --update-env61```6263New optional environment: `SPW_BACKUP_REMOTE` (backup job), `SPW_COMMIT` is not needed (the build reads git).64Nothing existing is renamed. The migration runs at start (1.2 s on the rehearsal).6566Checks right after: `/api/v1/health/live` 200; start-up capability line unchanged; `GET /api/v1/openapi.json` (session)67answers; the worker loops `reconcile`, `deposits`, `balances`, `snapshots`, `events-prune` report in « État du système »;68one `portfolio_snapshots` row within 10 minutes; no `proposals_one_in_flight not created` warning in the log.6970## 4. Stage 3 — signer7172Pre-checks on m6ma: `pm2 env` shows `SPW_SIGNER_ALLOW_IPS` set (the new binary refuses to start otherwise);73no transfer in flight (`select count(*) from proposals where state in ('approved','signed','broadcast')` = 0);74no quoting mandate active.7576```77cd ~/apps/sp-wallet-signer && cp signer.mjs signer.mjs.bak-next78cp ~/sp-wallet-signer-data/state.json ~/sp-wallet-signer-data/state.json.bak-next      # for inspection only: never restore it (§5)79cp ~/sp-wallet-signer-data/policy.json ~/sp-wallet-signer-data/policy.json.bak-next80# from the laptop: scp dist/signer.mjs m6ma:apps/sp-wallet-signer/      (policy.json is NOT deleted, NOT edited)81pm2 restart sp-wallet-signer && node signer.mjs status          # key id must stay spw-ab7cac49ffebb91982```8384Checks: the start line shows `allowed-sources=<API node>`; the web Security Center lists the passkey from the signer with85no mismatch; `node signer.mjs backup-state ~/signer-state-$(date +%Y%m%d).tar` works (copy it off the node).86Then, with the owner at the keyboard: `node signer.mjs verify-recovery` (checks the paper phrase without showing anything).8788## 5. Rollback8990**API / web.** `git checkout <previous commit>`, rebuild, restart. The schema changes are additive (new columns, tables and91one partial unique index); the previous code runs on the new schema. Two things the previous code does not know:92- rows in state `dropped`: the old state machine has no such state. Before rolling back:93  `update proposals set state = 'failed' where state = 'dropped'` (they read as failed in the old vocabulary anyway);94- `replaced` rows are final again for the old code (no re-check): nothing to do.9596**Signer.** Put `signer.mjs.bak-next` back and restart. First remove `newCredentialCooldownSec` / `maxVaultReturnsPerDay`97from `policy.json` if stage 5 added them (the old binary refuses unknown keys). **Never restore `state.json.bak-next`**: it98would bring back passkeys revoked since. The old binary ignores the new state fields.99100**Database.** Restoring the pre-release dump is the last resort (it loses what happened since): only on the owner's101decision, with the signer halted.102103**Triggers for a rollback:** a transfer shown in a state the chain contradicts; the signer refusing valid approvals; a104worker loop failing repeatedly; the audit chain reported broken.105106## 6. Monitoring after release107108- « État du système » (`/monitor`): worker loops, endpoint health, signer reachable.109- New alerts: `transfer.dropped`, `transfer.replaced`, `transfer.expired`, `transfer.recovered` (critical),110  `security.credential_mismatch` (critical), `security.passkey_revoked`.111- Logs on M2M32c: `[worker] reconcile …` lines; `native <network>: scan bound reached` is normal on busy addresses.112- Daily: `scripts/restore-test.sh` on the night's dump (to be scheduled with the backup job).113114## 7. First real operations (owner)115116A simulated or fork test is not proof on a real chain. After release, in this order, each for a small amount:1171. a send on Base, then on **Arbitrum in ETH** (the gas-limit fix, never exercised on the real network);1182. a receive in native coin on an EVM network (detection is new);1193. add a second passkey from the web, see it in the Security Center, revoke it;1204. open the macOS and iOS apps: the dashboard matches the web figure for figure; a send made on one appears on the others121   without reloading.122123## 8. Not part of this release124125APNs push (owner decision), intentional replacement of a stuck transaction (new signing rule), restore of a signer from126the phrase (`import-recovery`), disk encryption / firewall changes on m6ma (owner decision).127
Files main
Menu

Theme