feat: shared regtest env with .env auto-discovery#1
Conversation
Defines the approach for making arkade-regtest the single source of truth for regtest infrastructure across ts-sdk, boltz-swap, and dotnet-sdk via git submodules with .env overrides.
- Clarify .env discovery as "base + overlay" not "first found wins" - Specify ARKD_IMAGE override mechanism (stop nigiri arkd, start custom) - Remove NIGIRI_USE_SYSTEM (redundant with existing NIGIRI_BRANCH) - Detail idempotent start detection logic - Fix cache key to include .env.regtest - Fix port summary to match actual service names - Note new vars need export in start-env.sh
11 tasks: arkade-regtest changes (1-7), SDK integrations (8-10), README update (11). Addresses review feedback: merged idempotent start with ARKD_IMAGE override, fixed cleanup detection, clarified merge ordering for SDK tasks.
- Add lib/env.sh with shared load_env() function used by all scripts - Add .env auto-discovery chain: .env.defaults base + first override from --env flag > ../.env.regtest > .env - Add ARKD_IMAGE / ARKD_WALLET_IMAGE config vars with compose overlay (docker-compose.arkd-override.yml) for custom arkd versions - Make all start-env.sh sections idempotent (skip if already running) - Add service summary output on startup - Add missing submodule detection with helpful error message - Update stop-env.sh and clean-env.sh for arkd-override cleanup
🔍 Arkana PR Review —
|
Add fulmine-delegator container for delegation tests (ports 7010-7012). Includes wallet setup, funding, and settlement in start-env.sh. Needed by dotnet-sdk E2E delegation tests.
🔍 Arkana Review — arkade-regtest#1Solid foundation for shared regtest infra. The Highlights
Observations1. Arkd override detection in stop/clean is fragile docker inspect ark --format '{{.Config.Image}}' 2>/dev/null | grep -v 'nigiri'This assumes nigiri-managed arkd images contain "nigiri" in the image name. If nigiri ever uses if [ -n "${ARKD_IMAGE:-}" ] && docker ps --format '{{.Names}}' | grep -q '^ark$'; thenSince 2. export DELEGATOR_GRPC_PORT DELEGATOR_API_PORT DELEGATOR_HTTP_PORT3. Spec/plan docs (1290 lines) — useful context but these are implementation artifacts. Consider moving them to a wiki or removing after all SDK PRs land. Cross-Repo ImpactThis is the dependency for:
All three SDK PRs point their |
|
Followup review (commit 1d9db91): Retry bump 15→30 for delegator readiness — reasonable given arkd cold-start times. LGTM. One minor note: the delegator wait loop sleeps 2s per attempt, so 30 attempts = 60s max. The arkd wallet init loop above uses 30 attempts × 3s = 90s. Might be worth aligning the delegator to 3s intervals too, since it depends on arkd being fully ready (not just the fulmine binary starting). Currently it could time out if arkd takes >60s to serve. |
Add ARKD_SCHEDULER_TYPE, ARKD_ALLOW_CSV_BLOCK_TYPE, ARKD_VTXO_TREE_EXPIRY, ARKD_UNILATERAL_EXIT_DELAY, ARKD_BOARDING_EXIT_DELAY, ARKD_LIVE_STORE_TYPE to the arkd-override compose. Each SDK can now tune arkd behavior via .env.
🔍 Arkana Review — Updated CommitsScope: ArchitectureClean layered design. The Key Observations
Cross-Repo ImpactThis PR is the foundation for:
All three are open and reference this PR. The DocsThe Nit
Looks solid. The coordinated rollout across all four repos is well-planned. |
|
Followup review (commit Adds missing Without these exports, the delegator and arkd-override compose files would get empty strings for these variables. Good catch — LGTM. |
|
Iterative review (new commits since last review) Two changes:
Clean and correct. The |
|
Iterative review (commit Adds The default in Good fix — LGTM ✅ |
|
Iterative review — Good catch. Both additions are necessary:
These are critical for any SDK using LGTM ✅ |
🔍 Review: Shared regtest env with .env auto-discoveryOverall: Solid infrastructure work. The ✅ What works well
Observations & Suggestions
Cross-repo impactThis PR enables the submodule pattern for:
Those PRs are blocked on this one merging to master (or tracking the feature branch as noted in the plan). No security concerns. All credentials are regtest-only. The compose files don't expose anything beyond localhost. Looks good for merge after addressing the custom-arkd idempotency question. 👍 |
🔍 Arkana PR ReviewPR: feat: shared regtest env with .env auto-discovery OverviewThis PR adds the foundational infrastructure to make arkade-regtest consumable as a git submodule across all Arkade SDKs. Key additions:
Positive Findings
Items to Verify
Security
Cross-Repo ImpactThis is the foundation PR — ts-sdk#386, boltz-swap#106, and dotnet-sdk#56 all depend on this being merged (they currently track the feature branch via Overall: well-structured infrastructure improvement. The |
🔍 Arkana Review —
|
…ttle The fulmine settle endpoint was blocking indefinitely because: 1. No blocks were mined after faucet funding, so the boarding UTXO was never confirmed on-chain 2. The curl call had no timeout, causing the wallet Playwright CI to hang for 27+ minutes until the workflow was cancelled Changes: - Mine 3 blocks before fulmine settle (matching delegator pattern) - Add timeout 120 + --max-time 110 to settle calls (fulmine + delegator) - Make settle non-fatal if it times out - Add --connect-timeout to all service readiness check curls - Add --max-time to service status check curls and Boltz pairs check - Mine blocks + sleep after fulmine settle for commitment tx confirmation
🔍 Arkana Review —
|
🔍 Arkana PR ReviewPR: feat: shared regtest env with .env auto-discovery OverviewMajor infrastructure PR that transforms arkade-regtest from a standalone tool into a shared submodule-ready regtest environment. The ✅ What looks good
|
…ining After restarting Bitcoin Core for low-fee config, chopsticks loses its RPC connection and stops mining blocks. Without block mining, the block scheduler never triggers rounds, causing arkd note, fulmine settle, and delegator settle to all hang indefinitely.
🔍 Arkana PR Review — arkade-regtest#1PR: feat: shared regtest env with .env auto-discovery SummaryThis PR transforms arkade-regtest into a proper shared submodule for all SDK repos. Key changes:
What Looks Good ✅
Observations & Nits
Protocol Correctness ✅
Cross-Repo ImpactThis PR is the foundation for ts-sdk#386, boltz-swap#106, and wallet#492 which add arkade-regtest as a submodule. Those PRs are already open and waiting on this to land. VerdictSolid infrastructure work. The observations above are all nits — nothing blocking. The design is sound and the idempotent + override patterns will save significant maintenance across all SDK repos. |
After Bitcoin Core restarts, both chopsticks and arkd need to be restarted. Chopsticks reconnects to Bitcoin Core, but arkd also needs to re-establish its chain monitoring connection to chopsticks. Without this, the block scheduler never sees new blocks and rounds never trigger, causing settle operations to hang indefinitely.
🔍 Arkana PR Review —
|
Restructure startup sequence so Bitcoin Core restarts happen BEFORE custom arkd starts, not after. This eliminates the mid-flight chain disruption that caused arkd's block scheduler to stop seeing new blocks, preventing rounds from triggering and causing settle operations and test beforeAll hooks to hang indefinitely. New flow: nigiri start → bitcoin restart → chopsticks restart → arkd start Old flow: nigiri start → arkd start → bitcoin restart → (broken arkd)
🔍 Arkana PR ReviewOverall: Solid infrastructure consolidation. This is a well-structured approach to eliminating duplicated regtest infrastructure across SDKs. ✅ What looks good
|
The Bitcoin Core restart for minrelaytxfee=0 breaks nbxplorer's connection to bitcoind. When ark-wallet registers addresses with nbxplorer afterward, nbxplorer can't forward block notifications, so ark-wallet never sees funded transactions and arkd's balance stays at 0. Gate the restart behind BITCOIN_LOW_FEE (default: true for backward compat). SDKs that don't need low-fee transactions set BITCOIN_LOW_FEE=false in their .env.regtest to skip the restart entirely. When the restart IS used, also restart nbxplorer alongside chopsticks and wait for it to fully sync before proceeding.
🔍 Arkana PR Review —
|
… address nigiri ark receive returns a CLIENT boarding address, not the server's wallet address. Sending faucet funds there doesn't give the server on-chain liquidity, so rounds fail with "not enough liquidity, balance: 0". Use GET /v1/admin/wallet/address to get the actual server wallet address and fund it directly. This ensures arkd has on-chain liquidity for processing rounds and creating commitment transactions.
|
Iterative review — new commit Good catch on the root cause: Using One thing to watch: this changes the funding flow for all consumers (wallet, ts-sdk, boltz-swap). If any test assumes there's a pre-existing client VTXO from the startup funding, it will break. The wallet and ts-sdk PRs look fine since they do their own test wallet setup, but worth verifying boltz-swap doesn't depend on it. CI: no checks configured on this repo. Consider adding a basic smoke test workflow that runs |
Boltz uses Bitcoin Core's estimatesmartfee for on-chain transactions. In a fresh regtest, estimatesmartfee fails without enough blocks containing transactions. The old boltz-swap setup.mjs did 21 faucet transactions to generate enough fee data. Replicate this by doing 21 small faucet transactions to the server wallet address, which both funds the server and creates the block history needed for fee estimation.
|
Iterative review — new commit Good fix. Boltz uses Using the server wallet address (from admin API) for all 21 txs is efficient — it both funds the server and creates the fee estimation history in one step. No issues with this commit. |
Boltz creates its own wallet in Bitcoin Core for on-chain operations like reverse swaps and chain swaps. Without funds in this wallet, Boltz fails with "onchain coins could not be sent". After Boltz restart, list Bitcoin Core wallets, find the Boltz wallet, and fund it with 5 BTC via faucet.
🔍 Arkana PR Review — arkade-regtest#1Scope: Core shared regtest infrastructure with Architecture — Looks Solid ✅The layered env approach ( Observations1. 2. 3. 4. 5. Idempotent start — detection via container names + image inspection 6. Implementation plan docs (1011 lines) Minor Nits
VerdictWell-structured foundation for the shared regtest approach. The coordinated PRs in ts-sdk, boltz-swap, and wallet all consume this correctly. 👍 |
|
Iterative review — new commit Increases individual faucet amounts from fractional to 1 BTC per tx across the 21 transactions. This ensures the server has meaningful liquidity (21 BTC) for processing larger test rounds and commitment trees, while still maintaining the 21-tx count needed for Mechanical config change. LGTM. ✅ |
The ARK fee settings (ARK_OFFCHAIN_INPUT_FEE, etc.) from .env.regtest were never passed to the arkd container, causing SDKs that need zero fees (ts-sdk, boltz-swap) to silently run with default 1% input fees.
|
Follow-up review (new commit: ARK fee env var passthrough to the arkd-override compose — LGTM. - ARK_OFFCHAIN_INPUT_FEE=${ARK_OFFCHAIN_INPUT_FEE:-amount * 0.01}
- ARK_ONCHAIN_INPUT_FEE=${ARK_ONCHAIN_INPUT_FEE:-amount * 0.01}
- ARK_OFFCHAIN_OUTPUT_FEE=${ARK_OFFCHAIN_OUTPUT_FEE:-0.0}
- ARK_ONCHAIN_OUTPUT_FEE=${ARK_ONCHAIN_OUTPUT_FEE:-250.0}This was the missing piece — ts-sdk and boltz-swap both set zero fees in One nit: The default |
ARKD_ROUND_INTERVAL and ARK fee env vars were not exported, so docker-compose used defaults instead of .env.regtest overrides.
🔍 PR Review —
|
Not all stacks include nbxplorer (e.g. dotnet-sdk uses nigiri's built-in arkd without BTCPay). The BITCOIN_LOW_FEE restart path now checks docker inspect before trying to restart nbxplorer.
|
🔍 Iterative review (commit Good fix — guards if docker inspect nbxplorer >/dev/null 2>&1; then
# restart + sync wait
fiClean approach. The Cross-repo: Consumed by arkade-os/dotnet-sdk#56 which sets No concerns. ✅ |
When the admin API isn't available (nigiri's built-in arkd), the fallback only funded the onchain address but didn't convert to offchain funds via redeem-notes. This left the CLI wallet without offchain sats, causing "not enough funds" in dotnet-sdk tests.
|
Iterative review (commit New commit restores No concerns. The guard logic ( |
Summary
lib/env.shwith sharedload_env()function used by all scripts.envauto-discovery chain (.env.defaultsbase + first override from--env/../.env.regtest/.env)ARKD_IMAGE/ARKD_WALLET_IMAGEoverride variables with compose overlaystart-env.shsections idempotent (skip setup if services already running)Context
This enables arkade-regtest to be used as a git submodule across ts-sdk, boltz-swap, and dotnet-sdk. See
docs/superpowers/specs/2026-03-26-shared-regtest-across-sdks-design.md.Test plan
./start-env.shworks from repo root (no override)./start-env.sh --env /path/to/.envworks with explicit override.env.regtestin parent dir, run from submodule — override detectedARKD_IMAGE=ghcr.io/arkade-os/arkd:v0.9.0in override — custom arkd starts./start-env.shtwice — second run skips already-running services./clean-env.sh && ./start-env.sh— clean restart works