diff --git a/ops/arcade-escrow-deployments.md b/ops/arcade-escrow-deployments.md new file mode 100644 index 00000000..d4e44772 --- /dev/null +++ b/ops/arcade-escrow-deployments.md @@ -0,0 +1,55 @@ +# ArcadeEscrow — deployments + +Deployment record for [`src/arcade/ArcadeEscrow.sol`](../src/arcade/ArcadeEscrow.sol). + +## Mainnet (ZKsync Era, chain 324) + +| Contract | Address | Verified | +|---|---|---| +| `ArcadeEscrow` | [`0x661A48370275F10A7f95a86E408B568C08eFeef0`](https://explorer.zksync.io/address/0x661A48370275F10A7f95a86E408B568C08eFeef0#contract) | yes | + +- Deployed 2026-11-02 in tx [`0x1d6735dd…4f52`](https://explorer.zksync.io/tx/0x1d6735ddd6d6a8e5335f251668dc6df89ff755316bef69dc0a609507081a4f52) from `0x49dDBe122B410d4C4A5b1A77030903e6CD391c62`, which holds no role. +- Token: L2 NODL `0xBD4372e44c5eE654dd838304006E1f0f69983154`. +- Admin (`DEFAULT_ADMIN_ROLE`): `0x5e097AC1BCF81E7Ff2657045F72cAa6cF06486C9`, the 2-of-4 Safe. +- Oracle (`ORACLE_ROLE`): `0x7b0d247131B0A40D66baF289C3d424a3d4123fcD`, arcade-forge's settlement key. Its private key is in GCP Secret Manager as `arcade-escrow-oracle-private-key` (project `nodle-network-production`). It is a separate key from mission-control's `oracle_private_key`. + +| Parameter | Value | +|---|---| +| `minDeposit` | 200 NODL | +| `maxCharge` | 20,000 NODL | +| `quota` / `period` | 2,000,000 NODL / 1 day | +| `withdrawDelay` | 1 hour | +| `MAX_WITHDRAW_DELAY` | 7 days (constant) | +| `ADMIN_DELAY` | 8 days (constant) | + +Granting `ORACLE_ROLE`, raising `maxCharge` or the quota, and shortening the period go through `scheduleChange` → `executeChange` after `ADMIN_DELAY`. Lowering limits, revoking the oracle and pausing are immediate Safe transactions. + +### Gas sponsorship + +The oracle pays no gas: its transactions to the escrow use the general flow of `BondTreasuryPaymaster` [`0xb253528104D8C23eE14647410deDf70A9092bfFE`](https://explorer.zksync.io/address/0xb253528104D8C23eE14647410deDf70A9092bfFE). The paymaster checks only that the sender is a whitelisted user and the destination a whitelisted contract, so this needs one Safe transaction, which holds `WHITELIST_ADMIN_ROLE`: + +- `addWhitelistedContracts([ArcadeEscrow])` +- `addWhitelistedUsers([oracle])` + +Import [`safe/arcade-escrow-paymaster-whitelist.json`](safe/arcade-escrow-paymaster-whitelist.json) in the Safe Transaction Builder. No bond allowance is needed: the oracle never calls `consumeSponsoredBond`. + +Whitelisting is shared across the paymaster's lists: the oracle can also send sponsored transactions to the other whitelisted contracts, and existing whitelisted users can call the escrow (for example `deposit`) without gas. + +A sponsored `charge` should cost about what mission-control's `Payment.pay` does, ~0.000006 ETH. On 2026-11-02 the paymaster held 0.0859 ETH and had spent 0.0004 ETH in the previous 30 days, so it needs no top-up yet. Its NODL balance funds swarm bonds only. + +## Deploy and verify + +```bash +CONFIRM_MAINNET=YES DEPLOYER_PRIVATE_KEY=0x… \ +N_TOKEN_ADDR=0xBD4372e44c5eE654dd838304006E1f0f69983154 \ +N_ARCADE_ADMIN=0x5e097AC1BCF81E7Ff2657045F72cAa6cF06486C9 \ +N_ARCADE_ORACLE=0x7b0d247131B0A40D66baF289C3d424a3d4123fcD \ +N_ARCADE_QUOTA=2000000000000000000000000 \ +N_ARCADE_MIN_DEPOSIT=200000000000000000000 \ +N_ARCADE_MAX_CHARGE=20000000000000000000000 \ + ops/deploy_arcade_escrow_zksync.sh mainnet --broadcast +``` + +```bash +python3 ops/verify_zksync_contracts.py --broadcast broadcast/DeployArcadeEscrow.s.sol/324/run-latest.json --verifier-url https://zksync2-mainnet-explorer.zksync.io/contract_verification +``` diff --git a/ops/deploy_arcade_escrow_zksync.sh b/ops/deploy_arcade_escrow_zksync.sh new file mode 100755 index 00000000..e77f62a7 --- /dev/null +++ b/ops/deploy_arcade_escrow_zksync.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# Deploys the immutable ArcadeEscrow contract on zkSync (Sepolia or mainnet) with forge --zksync. +# zksolc cannot compile the L1-only SwarmRegistryL1Upgradeable (EXTCODECOPY), so the L1-only +# files are moved aside for the compile and restored on exit, exactly as +# ops/deploy_collection_factory_zksync.sh and ops/upgrade_collection_factory_zksync.sh do. +# +# Usage: +# DEPLOYER_PRIVATE_KEY=0x… N_TOKEN_ADDR=0x… N_ARCADE_ADMIN=0x… N_ARCADE_ORACLE=0x… \ +# N_ARCADE_QUOTA=… N_ARCADE_MIN_DEPOSIT=… N_ARCADE_MAX_CHARGE=… \ +# ops/deploy_arcade_escrow_zksync.sh [--broadcast] +# +# Amounts are in wei. See script/DeployArcadeEscrow.s.sol for the optional N_ARCADE_PERIOD and +# N_ARCADE_WITHDRAW_DELAY. +# +# Without --broadcast the script simulates only. The broadcast JSON lands in +# broadcast/DeployArcadeEscrow.s.sol//run-latest.json; verify afterwards with +# python3 ops/verify_zksync_contracts.py --broadcast . +set -euo pipefail +cd "$(dirname "$0")/.." + +NETWORK="${1:-}"; BROADCAST="${2:-}" +case "$BROADCAST" in + ""|--broadcast) ;; + *) echo "usage: $0 [--broadcast] (second argument must be exactly --broadcast or omitted)"; exit 1 ;; +esac +case "$NETWORK" in + testnet) RPC_URL="${L2_RPC:-https://sepolia.era.zksync.dev}" ;; + mainnet) RPC_URL="${L2_RPC:-https://mainnet.era.zksync.io}" ;; + *) echo "usage: $0 [--broadcast]"; exit 1 ;; +esac +: "${DEPLOYER_PRIVATE_KEY:?}" "${N_TOKEN_ADDR:?}" "${N_ARCADE_ADMIN:?}" "${N_ARCADE_ORACLE:?}" +: "${N_ARCADE_QUOTA:?}" "${N_ARCADE_MIN_DEPOSIT:?}" "${N_ARCADE_MAX_CHARGE:?}" +[[ "$DEPLOYER_PRIVATE_KEY" == 0x* ]] || export DEPLOYER_PRIVATE_KEY="0x${DEPLOYER_PRIVATE_KEY}" +if [[ "$NETWORK" == "mainnet" && "$BROADCAST" == "--broadcast" && "${CONFIRM_MAINNET:-}" != "YES" ]]; then + echo "mainnet broadcast requires CONFIRM_MAINNET=YES"; exit 1 +fi + +L1_BACKUP_DIR="/tmp/rollup-l1-backup-arcade-escrow" +restore_l1_contracts() { + [ -d "$L1_BACKUP_DIR" ] || return 0 + [ -f "$L1_BACKUP_DIR/SwarmRegistryL1Upgradeable.sol" ] && mv "$L1_BACKUP_DIR/SwarmRegistryL1Upgradeable.sol" src/swarms/ + [ -f "$L1_BACKUP_DIR/SwarmRegistryL1.t.sol" ] && mv "$L1_BACKUP_DIR/SwarmRegistryL1.t.sol" test/ + [ -d "$L1_BACKUP_DIR/upgrade-demo" ] && mv "$L1_BACKUP_DIR/upgrade-demo" test/ + [ -f "$L1_BACKUP_DIR/DeploySwarmUpgradeable.s.sol" ] && mv "$L1_BACKUP_DIR/DeploySwarmUpgradeable.s.sol" script/ + [ -f "$L1_BACKUP_DIR/UpgradeSwarm.s.sol" ] && mv "$L1_BACKUP_DIR/UpgradeSwarm.s.sol" script/ + rm -rf "$L1_BACKUP_DIR" + echo "L1-only contracts restored" +} +move_l1_contracts() { + [ -d "$L1_BACKUP_DIR" ] && restore_l1_contracts + mkdir -p "$L1_BACKUP_DIR" + [ -f src/swarms/SwarmRegistryL1Upgradeable.sol ] && mv src/swarms/SwarmRegistryL1Upgradeable.sol "$L1_BACKUP_DIR/" + [ -f test/SwarmRegistryL1.t.sol ] && mv test/SwarmRegistryL1.t.sol "$L1_BACKUP_DIR/" + [ -d test/upgrade-demo ] && mv test/upgrade-demo "$L1_BACKUP_DIR/" + [ -f script/DeploySwarmUpgradeable.s.sol ] && mv script/DeploySwarmUpgradeable.s.sol "$L1_BACKUP_DIR/" + [ -f script/UpgradeSwarm.s.sol ] && mv script/UpgradeSwarm.s.sol "$L1_BACKUP_DIR/" + echo "L1-only contracts moved aside for the zksync compile" +} +trap restore_l1_contracts EXIT +move_l1_contracts + +echo "network=$NETWORK rpc=$RPC_URL admin=$N_ARCADE_ADMIN oracle=$N_ARCADE_ORACLE broadcast=${BROADCAST:-no}" +forge script script/DeployArcadeEscrow.s.sol --rpc-url "$RPC_URL" --zksync --skip test ${BROADCAST:+--broadcast --slow} diff --git a/ops/safe/arcade-escrow-paymaster-whitelist.json b/ops/safe/arcade-escrow-paymaster-whitelist.json new file mode 100644 index 00000000..3ed45454 --- /dev/null +++ b/ops/safe/arcade-escrow-paymaster-whitelist.json @@ -0,0 +1,27 @@ +{ + "version": "1.0", + "chainId": "324", + "createdAt": 1793595600000, + "meta": { + "name": "ArcadeEscrow: sponsor oracle gas via BondTreasuryPaymaster", + "description": "Whitelist ArcadeEscrow 0x661A48370275F10A7f95a86E408B568C08eFeef0 as a destination and the arcade-forge oracle 0x7b0d247131B0A40D66baF289C3d424a3d4123fcD as a user on BondTreasuryPaymaster 0xb253528104D8C23eE14647410deDf70A9092bfFE.", + "txBuilderVersion": "1.18.0", + "createdFromSafeAddress": "0x5e097AC1BCF81E7Ff2657045F72cAa6cF06486C9" + }, + "transactions": [ + { + "to": "0xb253528104D8C23eE14647410deDf70A9092bfFE", + "value": "0", + "data": "0x25daffef00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000661a48370275f10a7f95a86e408b568c08efeef0", + "contractMethod": null, + "contractInputsValues": null + }, + { + "to": "0xb253528104D8C23eE14647410deDf70A9092bfFE", + "value": "0", + "data": "0x6496d3fc000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000007b0d247131b0a40d66baf289c3d424a3d4123fcd", + "contractMethod": null, + "contractInputsValues": null + } + ] +} diff --git a/ops/verify_zksync_contracts.py b/ops/verify_zksync_contracts.py index 22044813..2d7deca0 100755 --- a/ops/verify_zksync_contracts.py +++ b/ops/verify_zksync_contracts.py @@ -190,7 +190,9 @@ def apply_remappings(std_json: dict) -> int: pairs.sort(key=lambda x: -len(x[0])) source_keys = set(std_json["sources"].keys()) # Whole-statement match: imports may span lines (`import {A, B} from\n "@openzeppelin/..."`). - pattern = re.compile(r'(\bimport\b[^;]*?["\'])([^"\'.][^"\']*)(["\'])', re.S) + # The path excludes `;` and newlines, so a skipped relative import (`"../X.sol";`) cannot match + # from its closing quote into the next statement and swallow that statement's opening quote. + pattern = re.compile(r'(\bimport\b[^;]*?["\'])([^"\'.;\n][^"\';\n]*)(["\'])', re.S) changed = 0 def rewrite(m: "re.Match[str]") -> str: