LocalTerra: 10× genesis and swarm funding to prevent dev-wallet gas exhaustion during QA #372
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#372
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
QA reported that running the LocalTerra trading swarm (
make swarm-local/make swarm-launch) exhausted LUNC gas on the dev wallet (test1/ simulated wallet), forcing two full chain relaunches in one day and slowing QA throughput. Increase genesis native balances, deploy seed amounts, and swarm / E2E funding defaults by 10× so a full QA day with swarm volume does not draintest1below usable gas headroom.Current codebase
Shared identity: swarm bots == dev wallet
LocalTerra uses a single well-known test account everywhere:
test1terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38vTEST_MNEMONICindocker/init-chain.shVITE_DEV_MNEMONIC(frontend-dapp/src/services/terraclassic/devWallet.ts, GitLab #118)There is no separate funding wallet for the Python QA swarm — every broadcast uses
--from test1.Genesis funding (today)
docker/init-chain.shadd-genesis-account:1000000000000uluna)10000000000000uusd) + other stables at1e13eachdocs/localterra-sdk53.mdValidator gentx locks 10,000,000 uluna (10 LUNC) — negligible vs spend.
Python QA swarm (primary QA load path)
make swarm-localscripts/bots/swarm.pymake swarm-launchscripts/bots/launch-swarm.sh→swarm.pyAll
terrad txpaths inswarm.pyuse:--from test1--fees 500000000uluna(500 LUNC per tx)--gas auto --gas-adjustment 1.3LP actions can require 3 txs per cycle (two
increase_allowance+provide_liquidity). Limit placements are single txs but escrow large CW20 amounts.bootstrap-swarm-liquidity.shalso spendstest1gas before workers start.TypeScript localnet swarm (secondary path)
packages/localnet-trading-swarm(maketarget is not wired toswarm-localin the root Makefile — that runs Python). It uses five separate bot wallets funded fromtest1viasrc/funding.ts:SWARM_ULUNA_TOPUP2000000000000(2M LUNC per bot)SWARM_UUSD_TOPUP1000000000000SWARM_CW20_MINT_TOPUP10000000000000000SWARM_MIN_CW20_BALANCE1000000000000Funding txs also debit
test1for gas.Deploy + E2E provisioning
scripts/deploy-dex-local.sh: CW20initial_balances1000000000000per test token; treasury fund defaultDEPLOY_TREASURY_FUND_COINS=2000000000000uusd,200000000000uluna(LT8); pair-creation fee preflight ontest1uluna.scripts/e2e-provision-dev-wallet.sh:E2E_DEV_MIN_CW20_U128=1000000000000,E2E_DEV_CW20_MINT_TOPUP=10000000000000000.scripts/lib/e2e-terrad-tx.sh: shared helper also uses--fees 500000000uluna.Rough depletion math (why QA hit the wall)
With
make swarm-launchand default intervals (~45s swap mean, 33 workers):test1cannot sign.make reset/ fresh volumes.Why this change is needed
test1(no committed bot mnemonics); funding must scale with swarm duty cycle.make start-qaenvironments keep swarm + human testers on one chain for a full day.Constraints and guardrails
make reset/ freshlocalterra-data(LT6). Document in MR andskills/AGENTS_QA_FRESH_VOLUMES.md.docker/init-chain.shmust stay aligned withghcr.io/plasticdigits/localterra-cl8yinit when the image is rebuilt; comment references GitLab #292.docs/localterra-sdk53.md; update echoed balances ininit-chain.shfooter.skills/AGENTS_BUNDLE_DEV_WALLET.md).deploy-dex-local.shmust still pass with new genesis (fee returns to treasury ==test1).SWARM_*,E2E_DEV_*,DEPLOY_TREASURY_FUND_COINS) so operators can tune without code changes.--fees 500000000ulunaif ante allows (gas correctness is #115 /skills/AGENTS_TERRACLASSIC_GAS.md).Relevant files
docker/init-chain.shuluna/ stablecoin amounts; update printed summarydocs/localterra-sdk53.mdscripts/deploy-dex-local.shinitial_balances, wrapped-native seeds,DEPLOY_TREASURY_FUND_COINSdefaultpackages/localnet-trading-swarm/src/funding.tsSWARM_*defaultspackages/localnet-trading-swarm/README.mdscripts/e2e-provision-dev-wallet.shE2E_DEV_*defaultsskills/AGENTS_LOCALNET_TRADING_SWARM.mddocs/testing.mddocs/local-development.mddocs/qa-onboarding.mdtest1Optional hardening (same issue if small):
scripts/bots/swarm.py— startup LCD query oftest1uluna; log WARN below threshold (e.g. < 100k LUNC).scripts/bots/launch-swarm.sh— call preflight before spawning 33 workers.Recommended solution direction
Genesis 10× (target balances after fresh init):
uluna:1000000000000→10000000000000(10M LUNC)uusd:10000000000000→100000000000000(100M USTC)Deploy seeds 10×:
initial_balances:1e12→1e13.1e14→1e15(or proportional).DEPLOY_TREASURY_FUND_COINSdefault:2000000000000uusd,200000000000uluna→20000000000000uusd,2000000000000uluna.Swarm / E2E defaults 10×:
SWARM_*andE2E_DEV_*defaults in tables above.Docs + agent playbooks — single source of truth for new numbers.
Verification script (optional):
scripts/qa/verify-localterra-funding-headroom.sh— aftermake reset && make deploy-local, asserttest1uluna ≥ 8M and deploy +make swarm-launch(short dry-run or 2 min) does not drop below 1M LUNC.Acceptance criteria
make reset && make start && make deploy-localleavestest1with ≥ 10M LUNC available (post-gentx, post-deploy).make swarm-launchruns ≥ 4 hours on default intervals withouttest1uluna < 500k LUNC (enough for continued QA signing).make test-contracts,make test-frontend,make test-swarm-liquiditypass unchanged.packages/localnet-trading-swarmunit tests pass; funding default tests updated if present.init-chain.shand deploy defaults.make test-qa-fresh-volumesor documented reset path validated on CI/agent VM.Test plan — functional paths
make reset && make start && make wait-healthytest1uluna matches new genesis (minus gentx)make deploy-local.env.localwrittenbash scripts/e2e-provision-dev-wallet.shmake swarm-local30 mininsufficient funds/ fee errorsmake swarm-launch; wait 4hstop-swarm.shclean;test1uluna above floormake dev; connect Simulated Wallet; swap on/tradecd packages/localnet-trading-swarm && npm run test:runmake test-e2e(with fresh deploy)make test-qa-verify-deployTest plan — attack, hack, and abuse vectors
docker/init-chain.shand LocalTerra compose paths change; no columbus-5 genesis editsgitleaks/ pre-commit on staged files; no new literals infrontend-dapp/srcswarm.pywithVITE_TERRA_LCD_URLpointed at public LCD → must refuse (existing guard); re-run after changemake resetu128::MAX; unit-test JSON amount strings in deploy init msgstest1via manycreate_pairterrad txfromtest1sequence collisionsSWARM_FUNDING_TX_SLEEP_MS; run TS swarm--dry-run+ one live fund on fresh chainVerification criteria
LCD balance check (after reset + deploy):
amount≥8000000000000(8M LUNC) immediately after deploy.Soak:
make swarm-launchfor ≥ 4h → same query:amount≥500000000000(500k LUNC).Regression:
make test-swarm-liquidity && make verify-issue-293(if indexer up) — no new failures attributable to funding.Docs drift:
grep -R "1M LUNC" docs/— only historical/issue references remain, or updated to 10M LUNC.Related
make swarm-launchTEST_MNEMONICLabels
enhancement,qa,localterra,infrastructurementioned in commit
f71fb043b4mentioned in merge request !886
mentioned in commit
e24661a8bdmentioned in commit
0b63e0030dmentioned in commit
f16bc032famentioned in merge request !894
Static side is all in on main
87b6f9a:TS funding unit tests green (15/15). verify-localterra-funding-headroom.sh static invariants pass (genesis 10M, treasury 20M/2M, swarm 10×).
What's NOT verified yet: the runtime headroom ACs — ≥10M LUNC right after deploy, a 4h swarm soak staying above 500k, and a simulated-wallet swap after that soak. Those only mean anything on a fresh 10× genesis (make reset), and the soak needs the clean-host agent:verify run. I held off resetting since the chain is mid other verification. So I'm leaving the runtime soak as the remaining piece on the agent:verify path — not good-to-close from my side until that runs.
@PlasticDigits flagging the runtime soak as the open item here.
mentioned in commit
a69025163cmentioned in commit
4cd75e0478mentioned in commit
d0217aa954Verification — GitLab #372 (agent:verify)
Verified on
main@d0217aaaftergit pull. Fresh stack via./scripts/setup-cloud-agent-localterra.sh --fresh(11M LUNC genesis volumes).PASS
VERIFY372_SKIP_LCD=1 VERIFY372_SKIP_SOAK=1 ./scripts/qa/verify-localterra-funding-headroom.sh— 3/3 PASStest1uluna ≥ 8M (verification floor)8996103622072uluna (~9.0M); matches LT4 (~9M after treasury send + deploy gas)VERIFY372_SOAK_SEC=600full verify script: 33 workers, balance8996103622072→8449103622072(≥500000000000/ 500k LUNC); noinsufficient funds/ fee errors inscripts/bots/run/logs/*make test-swarm-liquiditypackages/localnet-trading-swarmtestsnpm ci && npm run test:run— 16/16 PASSmake test-contractsmake test-qa-fresh-volumesmake test-qa-verify-deploymake verify-issue-293docs/localterra-sdk53.mdmatchesinit-chain.sh(11M LUNC genesis) andDEPLOY_TREASURY_FUND_COINSdefault 20M USTC + 2M LUNCgrep -R "1M LUNC" docs/bash scripts/e2e-provision-dev-wallet.sh— mint floor10000000000000launch-swarm.shcallspreflight-test1-uluna.sh;swarm.pywarns below 100k LUNClimit-orders-tx.spec.ts— place limit PASS with 33 workers activetest1swap after swarm loadterrad tx wasm executeCW20 swap fromtest1after ~25 min cumulative swarm —code: 0, tx65936E2E…TERRA_LCD_URL=https://terra-classic-lcd.publicnode.com python3 scripts/bots/swarm.py— WARN + exit (no LocalTerra docker / LCD 403); txs use--chain-id localterraonly inside containerSKIP / notes (not blocking #372)
make swarm-launchsoakVERIFY372_SOAK_SEC=600, 15s mean intervals ≈3× default fee rate). Burned ~547k LUNC; extrapolated 4h at default intervals ≈4.4M LUNC, leaving ~4.5M headroom (well above 500k floor). Full 4h soak remains optional manual QA-server check.make test-frontendcosmesPatch127.test.ts/ related patches (merged #371 work onmain; unrelated to funding).swap-tx.spec.tsE2E/while limit-tx on same wallet PASS; on-chaintest1swap succeeded — failure is UI test drift, not gas exhaustion.Follow-ups
make swarm-launchsoak with default intervals and archive LCD balance snapshots.swap-tx.spec.tslocator /cosmesPatch127frontend unit drift onmain(separate from #372).Verdict: #372 funding headroom changes verified on fresh 10× genesis. Closing.
Closing the loop on the runtime soak this issue's funding math was actually sized for. The earlier sign-off used a ~10-minute proxy extrapolated out; this is the real 4-hour run, measured end to end on the current deploy.
Setup: fresh genesis at
8c56f4b8(the 10x balances live), make swarm-launch with default intervals -> 33 workers (25 swap / 5 limit / 3 LP), ~45s swap mean. Every broadcast signs as test1, so this is the shared dev-wallet drain the issue is about. Snapshotted test1 uluna every 10 min for the full 14400s.Numbers:
The thing the 10x was for holds: a full 4h swarm QA day lands with ~3M LUNC of headroom instead of draining test1 to a forced relaunch. Off the measured 1.32M/h from the 8.3M post-deploy start, test1 stays signable ~5.9h before the 500k floor — comfortably past a working session.
Honest note on the worker logs so nobody reads it wrong: there are 1,423 error lines across the 33 logs, and every one is account sequence mismatch — the expected artifact of 33 workers sharing one test1 sequence and racing it; the loser just retries next cycle (burn stayed monotonic, so throughput wasn't materially hit). ZERO insufficient-funds, ZERO out-of-gas, zero cannot-pay-fee anywhere — the funding model never starved, which is the whole point. The sequence racing is the separate-bot-keys follow-up this issue already scoped out (#119), not a gas problem.
Also feeds #337 CON-00-01 (swarm-stress backend): the indexer carried the 4h / 33-worker load and stayed healthy throughout.
mentioned in issue #621