|
| 1 | +# VeiledBatch - Production Deployment Checklist |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This document outlines all steps required to deploy VeiledBatch Hook to production. The system combines Uniswap v4 Hooks, Fhenix FHE, and EigenLayer AVS for confidential batch auctions. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 🔧 Prerequisites (Actions YOU Must Take) |
| 10 | + |
| 11 | +### 1. **Network Setup** |
| 12 | + |
| 13 | +| Task | Status | Notes | |
| 14 | +| --------------------------------------------------- | -------- | ----------------------------------- | |
| 15 | +| [ ] Deploy to Fhenix Helium Testnet first | Required | FHE precompiles only work on Fhenix | |
| 16 | +| [ ] Get Fhenix testnet ETH from faucet | Required | https://faucet.fhenix.zone | |
| 17 | +| [ ] Verify FHE precompile at address(128) is active | Required | Test with simple encrypt/decrypt | |
| 18 | + |
| 19 | +**Fhenix Network Details:** |
| 20 | + |
| 21 | +- Helium Testnet RPC: `https://api.helium.fhenix.zone` |
| 22 | +- Chain ID: `8008135` |
| 23 | +- Block Explorer: `https://explorer.helium.fhenix.zone` |
| 24 | + |
| 25 | +### 2. **EigenLayer AVS Registration** |
| 26 | + |
| 27 | +| Task | Status | Notes | |
| 28 | +| ------------------------------------ | -------- | ------------------ | |
| 29 | +| [ ] Create AVS on EigenLayer testnet | Required | Use eigenlayer-cli | |
| 30 | +| [ ] Register your AVS metadata | Required | Upload to IPFS | |
| 31 | +| [ ] Configure slashing conditions | Optional | For mainnet | |
| 32 | +| [ ] Set up at least 2 operator nodes | Required | For quorum | |
| 33 | + |
| 34 | +**Commands:** |
| 35 | + |
| 36 | +```bash |
| 37 | +# Install EigenLayer CLI |
| 38 | +npm install -g @eigenlayer/cli |
| 39 | + |
| 40 | +# Register AVS |
| 41 | +eigenlayer avs register --name "VeiledBatch" --network holesky |
| 42 | +``` |
| 43 | + |
| 44 | +### 3. **Operator Node Setup** |
| 45 | + |
| 46 | +Each operator needs: |
| 47 | +| Component | Purpose | |
| 48 | +|-----------|---------| |
| 49 | +| [ ] Kubernetes/Docker environment | Run operator node | |
| 50 | +| [ ] BLS key pair generated | For signature aggregation | |
| 51 | +| [ ] Stake deposited to EigenLayer | Minimum 0.1 ETH for testnet | |
| 52 | +| [ ] TEE enclave (optional) | For enhanced FHE security | |
| 53 | + |
| 54 | +**Operator Registration Process:** |
| 55 | + |
| 56 | +```solidity |
| 57 | +// 1. Generate BLS keypair offline |
| 58 | +// 2. Call registerOperator with pubkey hash |
| 59 | +hook.registerOperator{value: 0.1 ether}(pubkeyHash); |
| 60 | +``` |
| 61 | + |
| 62 | +### 4. **Frontend Requirements** |
| 63 | + |
| 64 | +| Task | Status | Notes | |
| 65 | +| ----------------------------------- | -------- | ------------------------- | |
| 66 | +| [ ] Install Fhenix SDK | Required | `npm install fhenix-sdk` | |
| 67 | +| [ ] Initialize Fhenix client | Required | See code below | |
| 68 | +| [ ] Implement intent encryption | Required | Before submitting to hook | |
| 69 | +| [ ] Handle sealed output decryption | Required | For viewing your intents | |
| 70 | + |
| 71 | +**Frontend Integration Example:** |
| 72 | + |
| 73 | +```typescript |
| 74 | +import { FhenixClient, EncryptedUint128 } from "fhenix-sdk"; |
| 75 | + |
| 76 | +// Initialize client |
| 77 | +const client = new FhenixClient({ provider: window.ethereum }); |
| 78 | + |
| 79 | +// Encrypt intent before swap |
| 80 | +async function encryptIntent( |
| 81 | + amount: bigint, |
| 82 | + zeroForOne: boolean, |
| 83 | + slippage: number |
| 84 | +) { |
| 85 | + const encAmount = await client.encrypt_uint128(amount); |
| 86 | + const encDirection = await client.encrypt_bool(zeroForOne); |
| 87 | + const encSlippage = await client.encrypt_uint32(slippage); |
| 88 | + const encMaxPrice = await client.encrypt_uint64(0n); // Or actual limit |
| 89 | + |
| 90 | + return ethers.utils.defaultAbiCoder.encode( |
| 91 | + ["bytes", "bytes", "bytes", "bytes"], |
| 92 | + [encAmount, encDirection, encSlippage, encMaxPrice] |
| 93 | + ); |
| 94 | +} |
| 95 | + |
| 96 | +// Submit via swap |
| 97 | +const hookData = await encryptIntent(1000000n, true, 50); |
| 98 | +await swapRouter.swap(poolKey, swapParams, hookData); |
| 99 | +``` |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## 📋 Smart Contract Deployment |
| 104 | + |
| 105 | +### Step 1: Deploy Hook |
| 106 | + |
| 107 | +```bash |
| 108 | +# Set environment variables |
| 109 | +export PRIVATE_KEY=<your_key> |
| 110 | +export FHENIX_RPC=https://api.helium.fhenix.zone |
| 111 | + |
| 112 | +# Deploy |
| 113 | +forge script script/DeployProduction.s.sol --rpc-url $FHENIX_RPC --broadcast |
| 114 | +``` |
| 115 | + |
| 116 | +### Step 2: Verify Contracts |
| 117 | + |
| 118 | +```bash |
| 119 | +forge verify-contract <ADDRESS> VeiledBatchHook \ |
| 120 | + --chain-id 8008135 \ |
| 121 | + --constructor-args $(cast abi-encode "constructor(address)" <POOL_MANAGER>) |
| 122 | +``` |
| 123 | + |
| 124 | +### Step 3: Configure Hook |
| 125 | + |
| 126 | +```solidity |
| 127 | +// After deployment: |
| 128 | +// 1. No additional setup needed - hook is self-contained |
| 129 | +// 2. Operators register themselves |
| 130 | +// 3. Users start submitting encrypted intents |
| 131 | +``` |
| 132 | + |
| 133 | +--- |
| 134 | + |
| 135 | +## 🔐 Security Considerations |
| 136 | + |
| 137 | +### Before Mainnet |
| 138 | + |
| 139 | +| Check | Status | Priority | |
| 140 | +| ----------------------------------------- | ------ | -------- | |
| 141 | +| [ ] Formal verification of FHE operations | P0 | Critical | |
| 142 | +| [ ] Audit of slashing conditions | P0 | Critical | |
| 143 | +| [ ] BLS signature aggregation audit | P0 | Critical | |
| 144 | +| [ ] Reentrancy analysis | P0 | Critical | |
| 145 | +| [ ] Gas optimization review | P1 | High | |
| 146 | +| [ ] Operator collusion prevention | P1 | High | |
| 147 | +| [ ] Emergency pause mechanism testing | P1 | High | |
| 148 | + |
| 149 | +### Known Limitations |
| 150 | + |
| 151 | +1. **Decryption Latency**: FHE decrypt operations are slow (~500ms per value) |
| 152 | +2. **Gas Costs**: Encrypted operations are gas-intensive |
| 153 | +3. **Network Dependency**: Only works on Fhenix-compatible networks |
| 154 | +4. **Operator Trust**: Operators can see decrypted data during processing |
| 155 | + |
| 156 | +--- |
| 157 | + |
| 158 | +## 📊 Monitoring Setup |
| 159 | + |
| 160 | +### Recommended Metrics |
| 161 | + |
| 162 | +```javascript |
| 163 | +// Monitor these events |
| 164 | +VeiledBatchHook.on("EncryptedIntentSubmitted", logIntent); |
| 165 | +VeiledBatchHook.on("BatchFinalized", logBatch); |
| 166 | +VeiledBatchHook.on("BatchProcessed", logProcess); |
| 167 | +VeiledBatchHook.on("OperatorSlashed", alertSlash); |
| 168 | +``` |
| 169 | + |
| 170 | +### Dashboard Requirements |
| 171 | + |
| 172 | +| Metric | Alert Threshold | |
| 173 | +| ------------------------------ | ---------------- | |
| 174 | +| Batch size before finalization | > 90 intents | |
| 175 | +| Time to batch finalization | > 45 seconds | |
| 176 | +| Operator response time | > 5 minutes | |
| 177 | +| Fallback execution rate | > 50% of intents | |
| 178 | +| Gas per intent | > 500k gas | |
| 179 | + |
| 180 | +--- |
| 181 | + |
| 182 | +## 🚀 Deployment Order |
| 183 | + |
| 184 | +### Testnet (Do First) |
| 185 | + |
| 186 | +1. [ ] Deploy to Fhenix Helium |
| 187 | +2. [ ] Register 2+ test operators |
| 188 | +3. [ ] Submit test encrypted intents |
| 189 | +4. [ ] Verify batch processing |
| 190 | +5. [ ] Test fallback mechanism |
| 191 | +6. [ ] Load test with 100 intents |
| 192 | + |
| 193 | +### Mainnet Checklist |
| 194 | + |
| 195 | +1. [ ] Complete security audit |
| 196 | +2. [ ] Deploy with timelock admin |
| 197 | +3. [ ] Set up multisig ownership |
| 198 | +4. [ ] Gradual operator onboarding |
| 199 | +5. [ ] Monitor for 2 weeks minimum |
| 200 | +6. [ ] Full launch |
| 201 | + |
| 202 | +--- |
| 203 | + |
| 204 | +## 🛠️ Troubleshooting |
| 205 | + |
| 206 | +### Common Issues |
| 207 | + |
| 208 | +**"FHE decrypt failed"** |
| 209 | + |
| 210 | +- Ensure you're on Fhenix network |
| 211 | +- Check precompile at address(128) is active |
| 212 | +- Verify encrypted handles are valid |
| 213 | + |
| 214 | +**"Invalid signature"** |
| 215 | + |
| 216 | +- Verify operator is registered |
| 217 | +- Check BLS key matches registration |
| 218 | +- Ensure message hash matches |
| 219 | + |
| 220 | +**"Batch not finalized"** |
| 221 | + |
| 222 | +- Wait for timeout (30 seconds) |
| 223 | +- Or wait for MAX_BATCH_SIZE (100 intents) |
| 224 | +- Or call forceFinalizeBatch (owner only) |
| 225 | + |
| 226 | +--- |
| 227 | + |
| 228 | +## 📞 Support Resources |
| 229 | + |
| 230 | +- Fhenix Discord: https://discord.gg/fhenix |
| 231 | +- EigenLayer Docs: https://docs.eigenlayer.xyz |
| 232 | +- Uniswap v4 Docs: https://docs.uniswap.org/contracts/v4/overview |
| 233 | + |
| 234 | +--- |
| 235 | + |
| 236 | +## File Structure (Production) |
| 237 | + |
| 238 | +``` |
| 239 | +VeiledBatch/ |
| 240 | +├── src/ |
| 241 | +│ ├── VeiledBatchHook.sol # Main production hook |
| 242 | +│ └── avs/ |
| 243 | +│ └── VeiledBatchAVSOperator.sol # Operator logic |
| 244 | +├── script/ |
| 245 | +│ └── DeployProduction.s.sol # Production deploy |
| 246 | +├── operator/ # To be created |
| 247 | +│ ├── Dockerfile |
| 248 | +│ ├── src/ |
| 249 | +│ │ ├── main.rs # Rust operator |
| 250 | +│ │ ├── fhe.rs # FHE operations |
| 251 | +│ │ └── bls.rs # BLS signatures |
| 252 | +│ └── Cargo.toml |
| 253 | +└── frontend/ # To be created |
| 254 | + ├── src/ |
| 255 | + │ ├── hooks/useFhenix.ts |
| 256 | + │ └── components/SwapForm.tsx |
| 257 | + └── package.json |
| 258 | +``` |
| 259 | + |
| 260 | +--- |
| 261 | + |
| 262 | +**Status**: Week 3 Implementation Complete |
| 263 | +**Next Steps**: |
| 264 | + |
| 265 | +1. Deploy to Fhenix Helium testnet |
| 266 | +2. Set up operator infrastructure |
| 267 | +3. Build frontend with Fhenix SDK |
| 268 | +4. Run integration tests |
0 commit comments