Gas: register and deregister messages missing from getGasLimitForTx FT-3 & FT-4 UI blocked by gas underestimation #384

Closed
opened 2026-06-16 14:15:52 +00:00 by totdking · 12 comments
totdking commented 2026-06-16 14:15:52 +00:00 (Migrated from gitlab.com)
No description provided.
totdking commented 2026-06-16 14:17:09 +00:00 (Migrated from gitlab.com)

Summary

After the ISSUE-030 (#383) fix deployed TCL8Y (18-decimal CL8Y proxy) on LocalTerra, CLI verification passes 6/6 and on-chain registration and deregistration succeed via CLI. However, the /tiers UI register button fails with:

Transaction needed more gas than estimated. Try again -- gas usage can vary slightly between blocks.

The root cause is a missing case in getGasLimitForTx() in frontend-dapp/src/services/terraclassic/terraGas.ts. This function maps execute message types to gas limit constants. It has no handler for register or deregister messages. Both fall through to BASE_GAS_LIMIT = 200_000. The actual gas consumed by a Tier 1 registration is approximately 204,438, which exceeds the 200,000 fallback by a small margin. The CLI succeeds because it uses --gas auto --gas-adjustment 1.3, which resolves to approximately 265,770.

The deregister message consumes approximately 160,932 gas, which is below the BASE_GAS_LIMIT. Deregister may succeed intermittently from the frontend, but it has no dedicated constant and its behavior is unguaranteed.


Reproduction steps

  1. Deploy LocalTerra with make deploy-local (ISSUE-030 fix applied -- TCL8Y at 18 decimals)
  2. Confirm make verify-issue-383 passes 6/6
  3. Open the frontend at http://localhost:5173/tiers
  4. Connect dev wallet with a TCL8Y balance >= 1,000,000,000,000,000,000 (Tier 1 minimum)
  5. Click Register for Tier 1
  6. Observe: transaction fails with "Transaction needed more gas than estimated"

Expected behavior

The register and deregister execute messages should have dedicated gas constants in getGasLimitForTx() that cover actual on-chain consumption with a safety buffer. Both actions should succeed from the frontend UI without gas errors.


Actual behavior

Both register and deregister fall through to BASE_GAS_LIMIT = 200_000 in getGasLimitForTx(). The register message consumes ~204,438 gas and fails. The deregister message consumes ~160,932 gas and may succeed, but has no dedicated constant.


Required developer fix

In frontend-dapp/src/services/terraclassic/terraGas.ts, add dedicated cases to getGasLimitForTx() for register and deregister execute messages:

  • register: suggest 300,000 (actual ~204,438; buffer covers block-to-block variance)
  • deregister: suggest 250,000 (actual ~160,932; buffer covers block-to-block variance)

The CLI auto-estimate uses --gas-adjustment 1.3. Applying 1.3x to the actual consumption gives 265,770 for register and 209,211 for deregister. The suggested constants include additional buffer above the adjusted values.


Environment

  • Chain: localterra
  • LCD: http://localhost:1317
  • Wallet: Keplr (Terra Classic)
  • Browser: Chrome
  • Page: /tiers
  • TCL8Y contract: terra19jq6mj84cnt9p7sagjxqf8hxtczwc8wlpuwe4sh62w45aheseues8d5g8g (18 decimals, supply 10^25)
  • Fee-discount contract: terra1tctn9s9hjrfy9ng5h5pdkxefehwaes7h244rvr2kz4qflptfs6psyyxcpg
  • File: frontend-dapp/src/services/terraclassic/terraGas.ts

Severity: P2 -- production impact depends on whether production gas estimation is handled differently; blocks FT-3 and FT-4 frontend verification on LocalTerra.

Suggested GitLab label/title prefix: Gas:

Related checklist items: FT-3, FT-4

cc: @PlasticDigits

### Summary After the ISSUE-030 (#383) fix deployed TCL8Y (18-decimal CL8Y proxy) on LocalTerra, CLI verification passes 6/6 and on-chain registration and deregistration succeed via CLI. However, the `/tiers` UI register button fails with: > Transaction needed more gas than estimated. Try again -- gas usage can vary slightly between blocks. The root cause is a missing case in `getGasLimitForTx()` in `frontend-dapp/src/services/terraclassic/terraGas.ts`. This function maps execute message types to gas limit constants. It has no handler for `register` or `deregister` messages. Both fall through to `BASE_GAS_LIMIT = 200_000`. The actual gas consumed by a Tier 1 registration is approximately 204,438, which exceeds the 200,000 fallback by a small margin. The CLI succeeds because it uses `--gas auto --gas-adjustment 1.3`, which resolves to approximately 265,770. The deregister message consumes approximately 160,932 gas, which is below the BASE_GAS_LIMIT. Deregister may succeed intermittently from the frontend, but it has no dedicated constant and its behavior is unguaranteed. --- ### Reproduction steps 1. Deploy LocalTerra with `make deploy-local` (ISSUE-030 fix applied -- TCL8Y at 18 decimals) 2. Confirm `make verify-issue-383` passes 6/6 3. Open the frontend at `http://localhost:5173/tiers` 4. Connect dev wallet with a TCL8Y balance \>= 1,000,000,000,000,000,000 (Tier 1 minimum) 5. Click Register for Tier 1 6. Observe: transaction fails with "Transaction needed more gas than estimated" --- ### Expected behavior The register and deregister execute messages should have dedicated gas constants in `getGasLimitForTx()` that cover actual on-chain consumption with a safety buffer. Both actions should succeed from the frontend UI without gas errors. --- ### Actual behavior Both `register` and `deregister` fall through to `BASE_GAS_LIMIT = 200_000` in `getGasLimitForTx()`. The register message consumes \~204,438 gas and fails. The deregister message consumes \~160,932 gas and may succeed, but has no dedicated constant. --- ### Required developer fix In `frontend-dapp/src/services/terraclassic/terraGas.ts`, add dedicated cases to `getGasLimitForTx()` for `register` and `deregister` execute messages: - `register`: suggest 300,000 (actual \~204,438; buffer covers block-to-block variance) - `deregister`: suggest 250,000 (actual \~160,932; buffer covers block-to-block variance) The CLI auto-estimate uses `--gas-adjustment 1.3`. Applying 1.3x to the actual consumption gives 265,770 for register and 209,211 for deregister. The suggested constants include additional buffer above the adjusted values. --- ### Environment - Chain: localterra - LCD: [http://localhost:1317](http://localhost:1317) - Wallet: Keplr (Terra Classic) - Browser: Chrome - Page: `/tiers` - TCL8Y contract: `terra19jq6mj84cnt9p7sagjxqf8hxtczwc8wlpuwe4sh62w45aheseues8d5g8g` (18 decimals, supply 10^25) - Fee-discount contract: `terra1tctn9s9hjrfy9ng5h5pdkxefehwaes7h244rvr2kz4qflptfs6psyyxcpg` - File: `frontend-dapp/src/services/terraclassic/terraGas.ts` --- **Severity:** P2 -- production impact depends on whether production gas estimation is handled differently; blocks FT-3 and FT-4 frontend verification on LocalTerra. **Suggested GitLab label/title prefix:** `Gas:` **Related checklist items:** FT-3, FT-4 cc: @PlasticDigits
PlasticDigits commented 2026-06-16 14:19:05 +00:00 (Migrated from gitlab.com)

Best not to hardcode gas constants - however do add suggested as fallback but investigate why the gas is not being properly calculated first in teraGas

Best not to hardcode gas constants - however do add suggested as fallback but investigate why the gas is not being properly calculated first in teraGas
PlasticDigits commented 2026-06-16 14:44:28 +00:00 (Migrated from gitlab.com)

mentioned in merge request !913

mentioned in merge request !913
totdking commented 2026-06-16 15:04:59 +00:00 (Migrated from gitlab.com)

Verification

Works as expected, the discount all work accordingly to the checklist's demands

### Verification Works as expected, the discount all work accordingly to the checklist's demands
PlasticDigits commented 2026-06-16 15:14:31 +00:00 (Migrated from gitlab.com)

Verification — GitLab #384 (PASS)

Verified on main @ 45e5e255 (MR fix/issue-384-fee-discount-gas-limits, merged).

Fix confirmed

getGasLimitForTx() in frontend-dapp/src/services/terraclassic/terraGas.ts now maps:

Message Constant Limit
register REGISTER_FEE_DISCOUNT_GAS_LIMIT 300,000
deregister DEREGISTER_FEE_DISCOUNT_GAS_LIMIT 250,000

Per maintainer comment: dApp uses per-message fallback envelopes via terraClassicFeeEstimate.ts (not LCD tx simulation); dedicated constants are the intended pattern here.

Results

Check Result How
Unit: getGasLimitForTx register/deregister PASS make verify-issue-384 [1] — 4 tests in terraGas.feeDiscount.test.ts + transactions.test.ts
Constants > measured LocalTerra gas PASS make verify-issue-384 [2] — 300k > 204,438; 250k > 160,932
Live register gas_used < 300k PASS make verify-issue-384 [3] — gas_used=209,016
Live deregister gas_used < 250k PASS make verify-issue-384 [4] — gas_used=128,363
FT-3 tier-1 register (CLI) PASS make verify-issue-383 [4] — 6/6
FT-4 deregister (CLI) PASS make verify-issue-383 [5] — 6/6
FT-3 /tiers UI register (simulated wallet) PASS Playwright e2e/fee-tier-tx.spec.ts — Tier 1 registered; Deregister + Active visible; no gas error alert
FT-4 /tiers UI deregister (Keplr) SKIP Not run in this session; CLI + gas headroom cover FT-4; register was the failing path in the issue
Docs / skills cross-links PASS skills/AGENTS_TERRACLASSIC_GAS.md, skills/AGENTS_FEE_DISCOUNT_TIERS.md, docs/frontend.md, scripts/qa/README.md reference #384 + make verify-issue-384

Environment

  • Fresh LocalTerra deploy (make setup-cloud-localterra --fresh --skip-build)
  • TCL8Y 18-decimal proxy; make verify-issue-383 6/6 prerequisite met

Follow-up

  • e2e/fee-tier-tx.spec.ts assertion uses .or(Deregister).or(Active) and fails Playwright strict mode when both appear after success — consider .first() or asserting absence of .alert-error instead (cosmetic test fix, not gas).

Closing — acceptance criteria met on main.

## Verification — GitLab #384 (PASS) Verified on `main` @ `45e5e255` (MR `fix/issue-384-fee-discount-gas-limits`, merged). ### Fix confirmed `getGasLimitForTx()` in `frontend-dapp/src/services/terraclassic/terraGas.ts` now maps: | Message | Constant | Limit | |---------|----------|-------| | `register` | `REGISTER_FEE_DISCOUNT_GAS_LIMIT` | 300,000 | | `deregister` | `DEREGISTER_FEE_DISCOUNT_GAS_LIMIT` | 250,000 | Per maintainer comment: dApp uses per-message fallback envelopes via `terraClassicFeeEstimate.ts` (not LCD tx simulation); dedicated constants are the intended pattern here. ### Results | Check | Result | How | |-------|--------|-----| | Unit: `getGasLimitForTx` register/deregister | **PASS** | `make verify-issue-384` [1] — 4 tests in `terraGas.feeDiscount.test.ts` + `transactions.test.ts` | | Constants > measured LocalTerra gas | **PASS** | `make verify-issue-384` [2] — 300k > 204,438; 250k > 160,932 | | Live register `gas_used` < 300k | **PASS** | `make verify-issue-384` [3] — `gas_used=209,016` | | Live deregister `gas_used` < 250k | **PASS** | `make verify-issue-384` [4] — `gas_used=128,363` | | FT-3 tier-1 register (CLI) | **PASS** | `make verify-issue-383` [4] — 6/6 | | FT-4 deregister (CLI) | **PASS** | `make verify-issue-383` [5] — 6/6 | | FT-3 `/tiers` UI register (simulated wallet) | **PASS** | Playwright `e2e/fee-tier-tx.spec.ts` — Tier 1 registered; **Deregister** + **Active** visible; no gas error alert | | FT-4 `/tiers` UI deregister (Keplr) | **SKIP** | Not run in this session; CLI + gas headroom cover FT-4; register was the failing path in the issue | | Docs / skills cross-links | **PASS** | `skills/AGENTS_TERRACLASSIC_GAS.md`, `skills/AGENTS_FEE_DISCOUNT_TIERS.md`, `docs/frontend.md`, `scripts/qa/README.md` reference #384 + `make verify-issue-384` | ### Environment - Fresh LocalTerra deploy (`make setup-cloud-localterra --fresh --skip-build`) - TCL8Y 18-decimal proxy; `make verify-issue-383` 6/6 prerequisite met ### Follow-up - `e2e/fee-tier-tx.spec.ts` assertion uses `.or(Deregister).or(Active)` and fails Playwright strict mode when **both** appear after success — consider `.first()` or asserting absence of `.alert-error` instead (cosmetic test fix, not gas). Closing — acceptance criteria met on `main`.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-06-16 15:14:32 +00:00
Brouie commented 2026-06-28 23:24:44 +00:00 (Migrated from gitlab.com)

mentioned in issue #337

mentioned in issue #337
PlasticDigits commented 2026-07-12 07:09:45 +00:00 (Migrated from gitlab.com)

mentioned in issue #474

mentioned in issue #474
PlasticDigits commented 2026-07-12 07:09:46 +00:00 (Migrated from gitlab.com)

marked as related to #474

marked as related to #474
PlasticDigits commented 2026-07-12 07:09:49 +00:00 (Migrated from gitlab.com)

mentioned in issue #475

mentioned in issue #475
PlasticDigits commented 2026-07-12 07:09:49 +00:00 (Migrated from gitlab.com)

marked as related to #475

marked as related to #475
PlasticDigits commented 2026-08-26 01:06:40 +00:00 (Migrated from gitlab.com)

mentioned in issue #651

mentioned in issue #651
PlasticDigits commented 2026-08-26 01:49:29 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1153

mentioned in merge request !1153
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic#384
No description provided.