Skip to content

fix(ops): reserve what the contract books, and top up the shortfall - #33

Merged
edycutjong merged 1 commit into
mainfrom
fix/reserve-estimate
Sep 9, 2026
Merged

edycutjong merged 1 commit into
mainfrom
fix/reserve-estimate

Conversation

@edycutjong

Copy link
Copy Markdown
Owner

Two bugs the first live run exposed — both found by running it, not by reading it.

1. The estimate used the charged fee, not the booked one

A renewal is finally charged 1.53–1.60 ℏ, but the contract reserves against RENEWAL_GAS_LIMIT up front: 1.97 ℏ. So funding 282 ℏ bought 143 renewals, not the 176 the script promised — enough to cover the start of judging and not the end.

Measured empirically: funded 282 ℏ, read renewalsRemaining() back as 143 → 1.97 each.

2. It funded the total, not the shortfall

gasReserve carries over, so a second run would have added the whole amount again. It now subtracts what is already armed:

gas  +66 HBAR (143 armed, 33 short) -> 176 total at ~1.97 each

vs the 347 ℏ the previous logic would have asked for.

3. New: RESERVE_ONLY=1

Tops up the reserve without re-terming or opening a second subscription — the operation you actually want once the demo is running and only gas is short.

Live result

hasAccess true · active true · 3441s left of a 3600s window
periodsFunded 176 · reserve arms 176 · schedule armed
gas runs to 2026-09-17 00:16Z
judging starts 2026-09-14T16:00Z  COVERED
judging ends   2026-09-16T23:59Z  COVERED

Types and lint clean.

@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
build Ready Ready Preview Sep 9, 2026 5:16pm UTC

Two bugs the first live run exposed, both found by running it rather than by
reading it.

The reserve estimate was the CHARGED fee, not the BOOKED one. A renewal is
finally charged 1.53-1.60 HBAR, but the contract reserves against
RENEWAL_GAS_LIMIT up front -- 1.97. Funding 282 HBAR therefore bought 143
renewals, not the 176 the script promised: enough to cover the START of judging
and not the end. Measured by funding it and reading renewalsRemaining() back.

The derivation funded the TOTAL rather than the SHORTFALL. gasReserve carries
over, so a second run would have added the whole amount again. It now subtracts
what is already armed: with 143 armed and 176 needed it asks for 66 HBAR, not
347.

Adds RESERVE_ONLY=1, which tops up the reserve without re-terming the contract
or opening a second subscription -- the operation you actually want once the
demo is running and only the gas is short.

Live result: 176 renewals armed, runs to 2026-09-17T00:16Z, covering judging
start (09-14 16:00Z) and end (09-16 23:59Z).
@edycutjong
edycutjong merged commit 04003ad into main Sep 9, 2026
9 checks passed
@edycutjong
edycutjong deleted the fix/reserve-estimate branch September 9, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant