chore: audit getGasLimitForTx retail execute fallbacks (prevent BASE_GAS_LIMIT OOG) #475
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#475
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
Harden the static Terra Classic gas envelope table so new or overlooked execute messages do not silently fall through to
BASE_GAS_LIMIT(200_000) and fail with retail out of gas copy. Bundle related hygiene (inventory, gap fixes, guardrails) into this single issue.Triggered by mainnet Mint bug report (“Automatic gas sometimes fails” / “all the time”) — root cause for Mint is missing
dripmapping (tracked separately as the P0 Mint fix). This issue covers recurrence prevention and any other retail gaps found in the same audit.Precedent: #384 (
register→ 200k → OOG →REGISTER_FEE_DISCOUNT_GAS_LIMIT).Current codebase
Architecture
executeTerraContract*→broadcastTerraExecuteContracts→estimateTerraClassicFeeForEntries→getGasLimitForTx→buildTerraClassicFee.simulate/estimateFeefor execute envelopes (terraClassicFeeEstimate.ts,docs/frontend.md).BASE_GAS_LIMIT = 200000.sendinners are partially unwrapped ingetGasLimitForTx.Known / suspected gaps (audit starting points)
dripsend→ innerunwrap/ wrap-adjacent msgsUNWRAP_GAS_LIMITapplied for routerunwrap_output; confirmsendhook /wrapMapperpaths map correctly vs legacySWAP_GAS_LIMIT(600k)executeTerraContract*call site whose top-level or inner key is absent fromgetGasLimitForTxgas_usedstill below ceiling on columbus-5executeTerraContractMulti)totalGasLimitForExecuteMsgs— each entry must mapRelated (out of primary scope unless audit proves coupling)
Why a new implementation is needed
Static envelopes are correct for Classic fee reliability (#127) but fragile: every new CosmWasm execute shape must be registered or users hit deterministic OOG. Soft-launch Mint shipped without a gas constant (#473). Without inventory + CI guardrails, the next feature repeats #384 / Mint.
Constraints / guardrails
gas_used+ margin over arbitrary large ceilings; document measurements in tests/comments.effectiveGasPriceUluna()floor (28.325).dripconstant landing in the P0 issue if not already merged.Relevant files
frontend-dapp/src/services/terraclassic/terraGas.tsfrontend-dapp/src/services/terraclassic/terraClassicFeeEstimate.tsfrontend-dapp/src/services/terraclassic/terraBroadcast.tsfrontend-dapp/src/services/terraclassic/transactions.tsexecuteTerraContract*frontend-dapp/src/services/terraclassic/router.tsfrontend-dapp/src/services/terraclassic/faucet.tsfrontend-dapp/src/services/terraclassic/hybridSwapGas.tsfrontend-dapp/src/utils/constants.tsfrontend-dapp/src/utils/humanizeTerraTxError.tsdocs/frontend.mdskills/AGENTS_TERRACLASSIC_GAS.mdfrontend-dapp/src/services/terraclassic/__tests__/transactions.test.tsfrontend-dapp/src/services/terraclassic/__tests__/terraGas.feeDiscount.test.tsRecommended direction
executeTerraContract/executeTerraContractMulti/ CW20sendinner msg shapes vsgetGasLimitForTxbranches.gas_used(LocalTerra optimized and/or columbus-5), add named constant + branch, unit test.BASE_GAS_LIMITunless explicitly allowlisted (e.g. allowance).console.warnwhen fallback hits for unrecognized keys.AGENTS_TERRACLASSIC_GAS.md/ PR template: “new execute msg → gas constant + test.”docs/frontend.mdgas table for any new constants.Acceptance criteria
getGasLimitForTx(issue comment or docs table).BASE_GAS_LIMITuses (e.g. increase/decrease allowance) with rationale.AGENTS_TERRACLASSIC_GAS.mdupdated.Test plan (all paths)
gas_used < gas_wantedBASE_GAS_LIMIT; live smoke if feasiblesendwith each known innertransactions,terraGas.feeDiscount, hybrid/swap gas tests greenTest plan (attack / hack / abuse vectors)
Verification criteria
cd frontend-dapp && npm run test:run -- src/services/terraclassic/__tests__/covers new mapping tests.gas_used < gas_wanted.marked as related to #384
marked as related to #474
mentioned in commit
d3e10ddb7bmentioned in merge request !1015
Implemented on MR !1015 (
fix/475-gas-limit-audit).Inventory:
frontend-dapp/src/services/terraclassic/terraGasRetailInventory.ts(RETAIL_GAS_SHAPE_FIXTURES) + unit guardrailterraGas.retailShapes.test.ts.Gaps fixed:
{ drip }→FAUCET_DRIP_GAS_LIMIT(400k) — also closes #474send→unwrap→UNWRAP_GAS_LIMIT(400k)Allowlist (intentional BASE 200k):
increase_allowance,decrease_allowanceGuardrail: fixtures must map above BASE unless allowlisted; DEV
console.warnon unmapped fallback;make verify-issue-475Docs:
docs/frontend.md,skills/AGENTS_TERRACLASSIC_GAS.md,skills/AGENTS_SOFT_LAUNCH_FAUCET.md, runbook F13mentioned in commit
b598b37758mentioned in merge request !1045
mentioned in issue #559
mentioned in issue #587
marked as related to #587
mentioned in issue #595
mentioned in issue #599
mentioned in issue #600
mentioned in issue #619
mentioned in issue #679
marked as related to #679
mentioned in issue #681
marked as related to #681
mentioned in merge request !1182
mentioned in issue #690
mentioned in issue #708
mentioned in merge request !1198