-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
347 lines (337 loc) · 13.5 KB
/
Copy pathdocker-compose.yml
File metadata and controls
347 lines (337 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# Spec 16 BSVM developer devnet.
#
# One command: `docker compose up`.
#
# Brings up a BSV regtest node + auto-miner and a 3-node BSVM cluster
# (two provers + one follower) with the Hardhat default test accounts
# pre-funded. Chain ID 31337 matches the Hardhat / Foundry defaults so
# existing Solidity tooling points at http://localhost:8545 without
# reconfiguration.
#
# This file is the DEVELOPER-facing entry point. The Go test harness at
# `test/multinode/docker/docker-compose.yml` is a separate file with
# different chain ID (8453111), subnet, and ports — kept intentionally
# distinct so `docker compose up` (dev) and `go test` (CI) can run
# side-by-side on the same machine. See docker-compose.README.md.
#
# Prove modes (switch via BSVM_PROVE_MODE env var, default `mock`):
# mock — devkey covenant, SP1 mock runtime, sub-second "proofs".
# execute — devkey covenant, SP1 execute runtime, dual-EVM check runs.
# prove — production covenant (groth16-wa), real STARK proofs. Needs
# GPU; see docker-compose.proving.yml override.
networks:
bsvm-devnet:
name: bsvm-devnet
driver: bridge
ipam:
config:
- subnet: 172.60.0.0/24
x-bsvm-common: &bsvm-common
image: bsvm:devnet
init: true
restart: unless-stopped
networks:
- bsvm-devnet
environment: &bsvm-env
# Default to `execute` so `docker compose up` produces real BSV
# regtest activity: every node builds a FRI advance and races to
# submit it on-chain. `mock` (no broadcast) remains available via
# `BSVM_PROVE_MODE=mock docker compose up`.
BSVM_PROVE_MODE: ${BSVM_PROVE_MODE:-execute}
BSVM_CHAIN_ID: "31337"
BSVM_BSV_RPC: "http://devuser:devpass@bsv-regtest:18332"
# Regtest network string selects the BSV address prefix used by
# the fee wallet + enables the devnet auto-funding bootstrap.
BSVM_BSV_NETWORK: "regtest"
BSVM_EXPLORER: "true"
BSVM_LOG_LEVEL: info
BSVM_GENESIS_DIR: /shared/genesis
BSVM_BATCH_SIZE: "16"
BSVM_FLUSH_DELAY: "1s"
BSVM_GAS_PRICE: "1"
BSVM_DEPOSIT_CONFIRMATIONS: "1"
# Loosen the default 16-block cap so bsvm-sim can push continuous
# traffic without running into "speculative depth limit reached"
# during slow mock-proving windows. 512 blocks is ~8 minutes of
# buffer at a 1s flush delay — plenty for dev-loop driving.
BSVM_MAX_SPECULATIVE_DEPTH: "512"
depends_on:
bsv-regtest:
condition: service_healthy
services:
# ─── BSV Regtest Node ─────────────────────────────────────────────
bsv-regtest:
image: bitcoinsv/bitcoin-sv:latest
container_name: bsvm-bsv-regtest
networks:
- bsvm-devnet
command: >
bitcoind
-regtest
-server
-rpcuser=devuser
-rpcpassword=devpass
-rpcallowip=0.0.0.0/0
-rpcbind=0.0.0.0
-port=18444
-rpcport=18332
-txindex=1
-excessiveblocksize=1000000000
-maxstackmemoryusageconsensus=100000000
-maxstackmemoryusagepolicy=100000000
-maxscriptsizepolicy=0
-maxscriptnumlengthpolicy=0
-maxtxsizepolicy=0
-genesisactivationheight=1
-chronicleactivationheight=1
-minminingtxfee=0.00000001
-acceptnonstdtxn=1
ports:
# Host port 18335 → container 18332. Avoids collisions with other
# regtest instances already mapped to 18332 (e.g. runar integration
# tests). Internal devnet traffic uses the service name
# "bsv-regtest" on the bsvm-devnet network, so this external
# remap is only for the developer's CLI convenience.
- "18335:18332"
volumes:
- bsv-data:/root/.bitcoin
healthcheck:
test: ["CMD-SHELL", "bitcoin-cli -regtest -rpcuser=devuser -rpcpassword=devpass getblockchaininfo"]
interval: 3s
timeout: 2s
retries: 20
start_period: 5s
# ─── Auto-miner (mines a block every 10s) ─────────────────────────
bsv-miner:
image: bitcoinsv/bitcoin-sv:latest
container_name: bsvm-bsv-miner
networks:
- bsvm-devnet
depends_on:
bsv-regtest:
condition: service_healthy
entrypoint: ["/bin/sh", "-c"]
command:
- |
set -e
ADDR=$$(bitcoin-cli -regtest -rpcconnect=bsv-regtest \
-rpcuser=devuser -rpcpassword=devpass getnewaddress)
echo "bsv-miner: mining to $$ADDR"
# Mine 150 blocks up front so coinbase is mature before
# bsvm-init runs. Subsequent blocks arrive every 10 seconds
# so BSV tip keeps moving while nodes are running.
bitcoin-cli -regtest -rpcconnect=bsv-regtest \
-rpcuser=devuser -rpcpassword=devpass \
generatetoaddress 150 $$ADDR > /dev/null
echo "bsv-miner: 150 primer blocks mined"
while true; do
bitcoin-cli -regtest -rpcconnect=bsv-regtest \
-rpcuser=devuser -rpcpassword=devpass \
generatetoaddress 1 $$ADDR > /dev/null 2>&1 || true
sleep 10
done
# ─── Cluster Bootstrap (one-shot) ─────────────────────────────────
# Deploys the rollup covenant + genesis manifest to BSV in a single
# transaction. Writes the resulting txid to /shared/cluster/genesis.txid
# so the nodes can boot entirely from that one file — no shard.json,
# no genesis_alloc.json, just a 64-char txid. Runs to completion then
# exits. Idempotent: if the genesis.txid already references a live
# covenant tx on BSV, `bsvm deploy-shard` refuses to re-deploy.
bsvm-init:
image: bsvm:devnet
container_name: bsvm-init
networks:
- bsvm-devnet
environment:
BSVM_PROVE_MODE: ${BSVM_PROVE_MODE:-execute}
BSVM_BSV_RPC: "http://devuser:devpass@bsv-regtest:18332"
BSVM_BSV_NETWORK: "regtest"
BSVM_LOG_LEVEL: info
depends_on:
bsv-regtest:
condition: service_healthy
bsv-miner:
condition: service_started
volumes:
- cluster-shared:/shared/cluster
restart: "no"
entrypoint: ["/bin/sh", "-c"]
command:
- |
set -e
# Wait for bsv-miner to finish its 150-block primer so the
# first coinbase is mature (100+ confirmations) and
# sendtoaddress in deploy-shard can find spendable outputs.
echo "bsvm-init: waiting for BSV primer blocks (>=150)..."
for i in $$(seq 1 60); do
HEIGHT=$$(wget -qO- --post-data='{"jsonrpc":"1.0","id":"bsvm-init","method":"getblockcount","params":[]}' \
--header='Content-Type: application/json' \
http://devuser:devpass@bsv-regtest:18332/ 2>/dev/null \
| sed -n 's/.*"result":\([0-9]*\).*/\1/p')
if [ -n "$$HEIGHT" ] && [ "$$HEIGHT" -ge 150 ]; then
echo "bsvm-init: primer ready (height=$$HEIGHT)"
break
fi
echo "bsvm-init: primer not ready yet (height=$${HEIGHT:-?}, attempt $$i/60)"
sleep 1
done
bsvm deploy-shard \
--datadir /shared/cluster \
--bsv-rpc "$$BSVM_BSV_RPC" \
--bsv-network "$$BSVM_BSV_NETWORK" \
--prove-mode $${BSVM_PROVE_MODE:-execute} \
--governance single_key \
--prefund-accounts hardhat \
--chain-id 31337
TXID=$$(cat /shared/cluster/genesis.txid | tr -d '[:space:]')
echo "bsvm-init: deployed shard genesis txid=$$TXID"
# ─── Node 1: Prover (primary) ─────────────────────────────────────
node1:
<<: *bsvm-common
container_name: bsvm-node1
hostname: node1
environment:
<<: *bsvm-env
BSVM_NODE_NAME: node1
BSVM_RPC_PORT: "8545"
BSVM_P2P_PORT: "9945"
BSVM_ROLE: prover
BSVM_COINBASE: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
# Deterministic libp2p identity — matches peer IDs baked into the
# BSVM_PEERS lists of node2/node3 below. Seed is 32 bytes hex.
BSVM_P2P_SEED: "0000000000000000000000000000000000000000000000000000000000000001"
BSVM_PEERS: "/dns4/node2/tcp/9945/p2p/12D3KooWHdiAxVd8uMQR1hGWXccidmfCwLqcMpGwR6QcTP6QRMuD,/dns4/node3/tcp/9945/p2p/12D3KooWSCufgHzV4fCwRijfH2k3abrpAJxTKxEvN1FDuRXA2U9x"
ports:
- "8545:8545" # JSON-RPC (HTTP) — matches spec 16 banner
- "18546:8546" # JSON-RPC WebSocket
- "9945:9945" # libp2p P2P
volumes:
- node1-data:/data/bsvm
- cluster-shared:/shared/cluster:ro
depends_on:
bsv-regtest:
condition: service_healthy
bsvm-init:
condition: service_completed_successfully
entrypoint: ["/bin/sh", "-c"]
command:
- |
set -e
# Read the genesis covenant txid written by bsvm-init. That is
# the sole input needed to boot the shard — `bsvm run` fetches
# the covenant tx from BSV, parses the OP_RETURN manifest, and
# runs InitGenesis locally against the alloc it recovers.
TXID=$$(cat /shared/cluster/genesis.txid | tr -d '[:space:]')
echo "node: booting shard from genesis txid=$$TXID"
# node1 is the prover — it needs BSV RPC access to broadcast
# covenant advances. It also hands the raw genesis tx over P2P
# to any follower that asks (via --genesis-tx-file we let node1
# verify the bytes it will serve).
exec bsvm run \
--datadir /data/bsvm \
--genesis-txid $$TXID \
--genesis-tx-file /shared/cluster/genesis.tx \
--bsv-rpc "$$BSVM_BSV_RPC" \
--bsv-network "$$BSVM_BSV_NETWORK"
healthcheck:
test: ["CMD-SHELL", "wget -qO- --post-data='{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":1}' --header='Content-Type: application/json' http://localhost:8545 | grep -q result"]
interval: 5s
timeout: 3s
retries: 20
start_period: 300s
# ─── Node 2: Follower (no BSV RPC; syncs genesis via P2P) ─────────
node2:
<<: *bsvm-common
container_name: bsvm-node2
hostname: node2
environment:
<<: *bsvm-env
# Deliberately unset BSV_RPC so the follower path is exercised.
BSVM_BSV_RPC: ""
BSVM_NODE_NAME: node2
BSVM_RPC_PORT: "8545"
BSVM_P2P_PORT: "9945"
BSVM_ROLE: follower
BSVM_COINBASE: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
BSVM_P2P_SEED: "0000000000000000000000000000000000000000000000000000000000000002"
BSVM_PEERS: "/dns4/node1/tcp/9945/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp,/dns4/node3/tcp/9945/p2p/12D3KooWSCufgHzV4fCwRijfH2k3abrpAJxTKxEvN1FDuRXA2U9x"
ports:
- "8546:8545" # JSON-RPC (HTTP)
- "18548:8546" # JSON-RPC WebSocket
- "9946:9945" # libp2p P2P
volumes:
- node2-data:/data/bsvm
# Only the txid (public shard identifier) is read from the
# shared volume; no RPC access is configured for this follower.
- cluster-shared:/shared/cluster:ro
depends_on:
bsv-regtest:
condition: service_healthy
bsvm-init:
condition: service_completed_successfully
entrypoint: ["/bin/sh", "-c"]
command:
- |
set -e
TXID=$$(cat /shared/cluster/genesis.txid | tr -d '[:space:]')
echo "node: booting shard from genesis txid=$$TXID (follower; no BSV RPC)"
# No --bsv-rpc, no --genesis-tx-file — the follower asks
# its configured peers for the raw genesis tx, verifies by
# hashing, then boots.
exec bsvm run \
--datadir /data/bsvm \
--genesis-txid $$TXID
healthcheck:
test: ["CMD-SHELL", "wget -qO- --post-data='{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":1}' --header='Content-Type: application/json' http://localhost:8545 | grep -q result"]
interval: 5s
timeout: 3s
retries: 20
start_period: 300s
# ─── Node 3: Follower (no BSV RPC; syncs genesis via P2P) ─────────
node3:
<<: *bsvm-common
container_name: bsvm-node3
hostname: node3
environment:
<<: *bsvm-env
# No BSV RPC — follower syncs everything over P2P.
BSVM_BSV_RPC: ""
BSVM_NODE_NAME: node3
BSVM_RPC_PORT: "8545"
BSVM_P2P_PORT: "9945"
BSVM_ROLE: follower
BSVM_P2P_SEED: "0000000000000000000000000000000000000000000000000000000000000003"
BSVM_PEERS: "/dns4/node1/tcp/9945/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp,/dns4/node2/tcp/9945/p2p/12D3KooWHdiAxVd8uMQR1hGWXccidmfCwLqcMpGwR6QcTP6QRMuD"
ports:
- "8547:8545" # JSON-RPC (HTTP)
- "18550:8546" # JSON-RPC WebSocket
- "9947:9945" # libp2p P2P
volumes:
- node3-data:/data/bsvm
- cluster-shared:/shared/cluster:ro
depends_on:
bsv-regtest:
condition: service_healthy
bsvm-init:
condition: service_completed_successfully
entrypoint: ["/bin/sh", "-c"]
command:
- |
set -e
TXID=$$(cat /shared/cluster/genesis.txid | tr -d '[:space:]')
echo "node: booting shard from genesis txid=$$TXID (follower; no BSV RPC)"
exec bsvm run \
--datadir /data/bsvm \
--genesis-txid $$TXID
healthcheck:
test: ["CMD-SHELL", "wget -qO- --post-data='{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":1}' --header='Content-Type: application/json' http://localhost:8545 | grep -q result"]
interval: 5s
timeout: 3s
retries: 20
start_period: 300s
volumes:
bsv-data:
node1-data:
node2-data:
node3-data:
cluster-shared: