|
| 1 | +# VeriSphere Core — Ops System (Reproducible Setup + Deploy) |
| 2 | + |
| 3 | +This document is the **authoritative, versioned** runbook for setting up a fresh machine to **build, test, and deploy** the `VeriSphereVSP/core` repository. |
| 4 | + |
| 5 | +> **Goal:** A new machine can be provisioned and produce the same results (builds/tests/deploys) with minimal drift. |
| 6 | +
|
| 7 | +--- |
| 8 | + |
| 9 | +## 1. Supported environment |
| 10 | + |
| 11 | +- OS: **Debian/Ubuntu** (tested on Debian 10+ / Ubuntu 20.04+) |
| 12 | +- Shell: bash |
| 13 | +- Toolchain: **Foundry** (forge/anvil/cast) pinned |
| 14 | +- Git: required |
| 15 | +- Node/Python: **not required** for core itself (only for surrounding infra) |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## 2. Repo layout assumptions |
| 20 | + |
| 21 | +This doc assumes: |
| 22 | + |
| 23 | +- Repo root is `~/verisphere/core` |
| 24 | +- Contracts are in `src/` |
| 25 | +- Tests are in `test/` |
| 26 | +- Deployment scripts are in `script/`: |
| 27 | + - `DeployDev.s.sol` |
| 28 | + - `DeployTestnet.s.sol` |
| 29 | + - `DeployMainnet.s.sol` |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## 3. Required system packages |
| 34 | + |
| 35 | +```bash |
| 36 | +sudo apt update |
| 37 | +sudo apt install -y build-essential curl git jq ca-certificates |
| 38 | +``` |
| 39 | + |
| 40 | +Optional but useful: |
| 41 | + |
| 42 | +```bash |
| 43 | +sudo apt install -y make unzip |
| 44 | +``` |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## 4. Install Foundry (pinned) |
| 49 | + |
| 50 | +Foundry is the **only supported** Solidity toolchain for this repo. |
| 51 | + |
| 52 | +1) Install Foundry: |
| 53 | + |
| 54 | +```bash |
| 55 | +curl -L https://foundry.paradigm.xyz | bash |
| 56 | +``` |
| 57 | + |
| 58 | +2) Load your shell configuration (or open a new terminal): |
| 59 | + |
| 60 | +```bash |
| 61 | +source ~/.bashrc |
| 62 | +``` |
| 63 | + |
| 64 | +3) Pin Foundry to a specific version: |
| 65 | + |
| 66 | +> Replace `FOUNDRY_VERSION_TAG` with the pinned tag you want to standardize on, e.g. `nightly-<date>` or a stable release tag. |
| 67 | +
|
| 68 | +```bash |
| 69 | +foundryup |
| 70 | +# Example pin (if you use nightlies): |
| 71 | +# foundryup -v nightly-2024-12-01 |
| 72 | +``` |
| 73 | + |
| 74 | +4) Verify: |
| 75 | + |
| 76 | +```bash |
| 77 | +forge --version |
| 78 | +cast --version |
| 79 | +anvil --version |
| 80 | +``` |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## 5. Clone and install dependencies |
| 85 | + |
| 86 | +```bash |
| 87 | +mkdir -p ~/verisphere |
| 88 | +cd ~/verisphere |
| 89 | +git clone https://github.com/VeriSphereVSP/core.git |
| 90 | +cd core |
| 91 | +``` |
| 92 | + |
| 93 | +Install forge libraries (if repo uses submodules / forge install): |
| 94 | + |
| 95 | +```bash |
| 96 | +forge install |
| 97 | +``` |
| 98 | + |
| 99 | +If the repo already vendors libraries under `lib/`, you may not need this step. |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## 6. Build and test |
| 104 | + |
| 105 | +Clean build: |
| 106 | + |
| 107 | +```bash |
| 108 | +cd ~/verisphere/core |
| 109 | +forge clean |
| 110 | +forge build |
| 111 | +``` |
| 112 | + |
| 113 | +Run tests: |
| 114 | + |
| 115 | +```bash |
| 116 | +forge test -vv |
| 117 | +``` |
| 118 | + |
| 119 | +If you want gas reports: |
| 120 | + |
| 121 | +```bash |
| 122 | +forge test --gas-report |
| 123 | +``` |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +## 7. Local dev chain (optional) |
| 128 | + |
| 129 | +Run a local chain: |
| 130 | + |
| 131 | +```bash |
| 132 | +anvil |
| 133 | +``` |
| 134 | + |
| 135 | +In a new terminal, you can deploy to the local chain: |
| 136 | + |
| 137 | +```bash |
| 138 | +export RPC_URL=http://127.0.0.1:8545 |
| 139 | +export PRIVATE_KEY=<anvil_private_key> |
| 140 | +forge script script/DeployDev.s.sol:DeployDev --rpc-url "$RPC_URL" --private-key "$PRIVATE_KEY" --broadcast -vvvv |
| 141 | +``` |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +## 8. Deployments |
| 146 | + |
| 147 | +### 8.1 Environment variables |
| 148 | + |
| 149 | +You will need: |
| 150 | + |
| 151 | +- `RPC_URL` (Avalanche Fuji / Mainnet / local Anvil) |
| 152 | +- `PRIVATE_KEY` (deployer key for that environment) |
| 153 | + |
| 154 | +Example: |
| 155 | + |
| 156 | +```bash |
| 157 | +export RPC_URL="https://api.avax-test.network/ext/bc/C/rpc" # Fuji |
| 158 | +export PRIVATE_KEY="0x...." |
| 159 | +``` |
| 160 | + |
| 161 | +### 8.2 Deploy to Dev |
| 162 | + |
| 163 | +Use when: |
| 164 | +- local/anvil, internal devnets, or ephemeral deployments |
| 165 | + |
| 166 | +```bash |
| 167 | +forge script script/DeployDev.s.sol:DeployDev --rpc-url "$RPC_URL" --private-key "$PRIVATE_KEY" --broadcast -vvvv |
| 168 | +``` |
| 169 | + |
| 170 | +### 8.3 Deploy to Testnet (Fuji) |
| 171 | + |
| 172 | +Use when: |
| 173 | +- public Fuji deployments |
| 174 | + |
| 175 | +```bash |
| 176 | +forge script script/DeployTestnet.s.sol:DeployTestnet --rpc-url "$RPC_URL" --private-key "$PRIVATE_KEY" --broadcast -vvvv |
| 177 | +``` |
| 178 | + |
| 179 | +### 8.4 Deploy to Mainnet |
| 180 | + |
| 181 | +Use when: |
| 182 | +- production deploy with governance/multisig handoffs |
| 183 | + |
| 184 | +```bash |
| 185 | +forge script script/DeployMainnet.s.sol:DeployMainnet --rpc-url "$RPC_URL" --private-key "$PRIVATE_KEY" --broadcast -vvvv |
| 186 | +``` |
| 187 | + |
| 188 | +--- |
| 189 | + |
| 190 | +## 9. Operational practices (recommended) |
| 191 | + |
| 192 | +### 9.1 Key management |
| 193 | + |
| 194 | +- Never commit private keys. |
| 195 | +- Prefer hardware wallets or secure key stores for mainnet. |
| 196 | +- For CI, use repository secrets and ephemeral deploy keys. |
| 197 | + |
| 198 | +### 9.2 Deterministic deploy notes |
| 199 | + |
| 200 | +- Every redeploy produces **new addresses**. |
| 201 | +- Your UI/backend should treat the deployment as **versioned**: |
| 202 | + - persist deployed addresses per environment (dev/testnet/mainnet) |
| 203 | + - publish a human-readable deployment manifest |
| 204 | + |
| 205 | +### 9.3 Deployment manifests |
| 206 | + |
| 207 | +Recommended output (copy/paste from forge logs into a checked-in file): |
| 208 | + |
| 209 | +- `deployments/dev.json` |
| 210 | +- `deployments/fuji.json` |
| 211 | +- `deployments/mainnet.json` |
| 212 | + |
| 213 | +Include: |
| 214 | +- chainId |
| 215 | +- deployer |
| 216 | +- block number |
| 217 | +- contract addresses |
| 218 | +- git commit hash |
| 219 | + |
| 220 | +--- |
| 221 | + |
| 222 | +## 10. Troubleshooting |
| 223 | + |
| 224 | +### 10.1 “Unable to resolve imports” |
| 225 | + |
| 226 | +- Run `forge install` |
| 227 | +- Check `foundry.toml` remappings |
| 228 | +- Ensure `lib/` exists and is populated |
| 229 | + |
| 230 | +### 10.2 Tests revert unexpectedly |
| 231 | + |
| 232 | +- Re-run with full traces: |
| 233 | + |
| 234 | +```bash |
| 235 | +forge test -vvvv |
| 236 | +``` |
| 237 | + |
| 238 | +### 10.3 RPC issues |
| 239 | + |
| 240 | +- Verify URL is correct and reachable |
| 241 | +- Some providers rate-limit; try another endpoint |
| 242 | + |
| 243 | +--- |
| 244 | + |
| 245 | +## 11. Where to store this file |
| 246 | + |
| 247 | +Place this document in the **core repo**: |
| 248 | + |
| 249 | +``` |
| 250 | +core/ops/VERISPHERE_CORE_OPS_SYSTEM.md |
| 251 | +``` |
| 252 | + |
| 253 | +Commit it so any new machine can reproduce the setup. |
| 254 | + |
| 255 | +--- |
| 256 | + |
| 257 | +## 12. Updating this ops system |
| 258 | + |
| 259 | +Any future task that changes: |
| 260 | +- repo structure |
| 261 | +- build process |
| 262 | +- deployment scripts |
| 263 | +- required env vars |
| 264 | + |
| 265 | +…must include a corresponding update to this document. |
| 266 | + |
0 commit comments