Mint epoch mechanics: height-named units, records, manual rotation lever #16
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
vnprc/hashpool#16
Loading…
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?
Give the mint epoch mechanics: open and close mining epochs with height-named currency units, persist epoch records, and hold provisional-epoch quotes unpaid until their boundary confirms — all exercisable by hand before any trigger exists. Design:
docs/EPOCH_DESIGN.md.Primary goals:
open_epoch(height, block_hash, source)— register the new unit's payment processor entry (via #15), create its keyset, write the epoch record (height, block hash, reward amount, state), and switch quote stamping to the new unit. Unit ishash_<pool>_<height>— pool = compressed pubkey from mint config, lowercase hex — with a deterministic suffix on derivation-index collision.just rotate-epochhitting a localhost admin endpoint that callsopen_epochwith source=manual; manual epochs have no chain boundary and are final immediately. This is the demo and the test harness for everything above.Current state and specifics
The mint has exactly one hardcoded unit (
CurrencyUnit::Custom("hash")inroles/mint/src/lib/mint_manager/setup.rs), created by builder bootstrap; no rotation code exists anywhere. The SV2 quote path hardcodes the unit at creation and immediately marks quotes paid (roles/mint/src/lib/sv2_connection/quote_processing.rs) — the stamping and the pay-now-or-defer branch both live there.Mint::rotate_keysethandles a brand-new unit at the pinned revision (non-empty amounts vector required). Epoch records need a small mint-side store; keep it separate from CDK's own schema. Bump the ehash quote TTL well past the confirmation window (expiry is advisory at the pin; do not rely on that).Witness
On the dev stack:
just rotate-epoch→/v1/keysetsshows the new unit's keyset active, the epoch record exists, and new quotes stamp the new unit while old-epoch quotes still mint. A second rotation repeats it. Restart reuses the current epoch (no re-genesis).Scope
In: mint-side epoch orchestration, records, the quote-path branch, the admin lever. Out: reward detection and finality/dissolve transitions driven by the chain (#18 — this issue provides the functions it calls), sweeper multi-unit handling (#17), settlement.
Part of #13. Gated on #15.
Done, landed on master as vnprc/hashpool#33.
The mint opens a genesis epoch at the current chain height on first boot, every epoch is its own currency unit
hash_<pool-pubkey>_<height>with its own keyset, quotes stamp the current epoch's unit, andjust rotate-epochcloses the current epoch and opens the next. Records persist in a file-backed store beside the mint database, so a restart resumes rather than re-genesising. The statichashunit is gone from mint setup.Two faults were found and fixed during the work, both only by running the stack:
Verified on a live dev stack: genesis at the real chain height, two rotations, a mint restart, and five rewards from an already-closed epoch minted afterwards. The quotable/resolvable split is observable —
/v1/keysetslists every epoch while/v1/infonut04 and nut05 each list exactly one method, the current epoch.Not exercised: the provisional/dissolve lifecycle. Genesis and manual epochs are final immediately, so nothing creates a provisional epoch until vnprc/hashpool#18 lands.
resumable_chainand the unpaid-quote branch inquote_processing.rstherefore exist on master but have only ever run against unit-test fixtures.Open hardening follow-ups from this work: vnprc/hashpool#34, vnprc/hashpool#35, vnprc/hashpool#36.