fix(ops): reserve what the contract books, and top up the shortfall - #33
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
force-pushed
the
fix/reserve-estimate
branch
from
September 9, 2026 17:16
0d12399 to
a1a44e2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_LIMITup 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
gasReservecarries over, so a second run would have added the whole amount again. It now subtracts what is already armed:vs the 347 ℏ the previous logic would have asked for.
3. New:
RESERVE_ONLY=1Tops 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
Types and lint clean.