Repository navigation
feat: resume runs, soften the first descent and add contract admin - #37
Merged
Merged
Conversation
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.
What
Resume an unverified run (#17). The client now keeps
{ seed, loadout, actions }in local storage on every effective action of a verified run. On load, once the player's record has been read, it asks the contract for the open run (get_open_run) and decides:The save is cleared once the run settles, or when the contract refuses it for good. Saved data is validated before use (version, ranges, action codes, 2,048 actions, 4 KB). To make replay safe,
state.tsno longer writes progress to storage while a run ends; the app records it once, on the live end-of-run event, so a restored run cannot be counted twice.Softer first descent (#18). The balance simulator showed kits clearing from 20.0% to 58.8% at rank 0. Two changes:
Both are mirrored in
world.rsand the golden vectors are regenerated.The creator now shows a Forgiving / Balanced / Risky label and "Clears about N in 100 descents" for the selected kit, plus a button back to the recommended kit. The numbers come from
client/scripts/kit-difficulty.ts(bun run kits), which plays 2,000 seeded runs per kit with the balanced policy and writeskitDifficulty.generated.ts. CI regenerates it and fails on any difference, so the hints cannot drift. The default draft also reads its kit from that table instead of a hand typed one.Balance (rank 0, balanced policy)
Every kit now sits inside the 25 to 60 percent band, and a test enforces it.
Tests
bun test(new, 20 tests): replay equals live state at every point of a full descent including the next dice roll, discard rules for another seed or delver, 4 KB and 2,048 action caps, malformed data, unavailable storage, resume of a won run and of a lost run, kit table band, recommended kit and tiers.cargo test: 71 contract tests (8 new for the admin paths) and the golden replay of 600 vectors pass.bun run typecheckandbun run buildpass. CI now also runsbun testand checks the kit table.Contract admin and upgrade path
The simulation changed, and the previous deployment could never be changed, so this branch also gives the contract an admin and redeploys it.
adminthat must sign the deployment.admin.rsaddsupgrade(new_wasm_hash),set_admin(new_admin)(both the current and the new admin must sign, so the role cannot go to a mistyped address),renounce_admin()(the contract can never change afterwards, later calls fail withFrozen), and the read onlyadmin()andversion(). Each change emits an event (upgraded,admin_changed,admin_renounced).start_runandfinish_run.onchain-boundary.mdsay so plainly, and name the way out: renounce, or move the role to a multisig, before any mainnet release. The old claims that there is no admin and that the issuer was locked are corrected.New testnet deployment
CDEAFSBG7JBN6XMP4HRL7LFBL7L67K4RJK3CIRBV23W3TJQCEADZ7R6NGCZCKB4FUIS5BGEMJOC3EQWKLGH662BOY3HFLH3WWPCGQJXOILDXP7GZGAD752QFRTNEMQW2SELGHQ5VAMIV3O7H4XRLJN2K2TQFGGXKNFG7CQUKDMCOMMONCAAFYL2QZU274NLA2IFDB4L6SUNVQKT6OLB6UXGL5L5LMQCFJXSUYFO3,DMRARECC4RQ4HLTPTXMCZ3OKDL546XXJGOQ5PI2ET6U33C2XTO4BTS6AJV4ANA,DMCORECC27JVKNDSUM5FDGP4JZDZTKGHJ5RJV7XHJGITTUGOUFE4DVPN6PGLMIVerified against the network, not the local keystore:
TxBadAuth.client/scripts/chain-smoke.tsran end to end with a throwaway account: a lost run, a full clear that earned delver 0, and a veteran clear that raised it to 2 clears. The relics minted on chain (2DMCOMMONand 2DMCOREon the account, read from Horizon). Thefinish_runtransactions, allsuccessfulon Horizon:602d5a167cadfd23e81857282429f8ae41d85522a367613c9888edf6e6da89c028b5a324723890ff494860b0661a6083f5dcdf7f9f6bef2f1fbee8928fadf850a73fa14a5c92ef3fcc4fece8a7803322ef2170672cfcea6f0de9982d775bed2fUpgrade was exercised for real on a separate throwaway deployment so the main one stays untouched: deploy,
start_run, upload a build withversion2,upgrade. Afterwardsversionread 2 and the open run was unchanged. Thenrenounce_admin:admin()returned null andupgradefailed with error 12 (Frozen). An upgrade attempted without the admin's signature was refused. Incargo testthe upgrade path runs against a minimal uploaded wasm, so the authorization, the event and the refusals are covered without a testnet.The deployment steps are scripted and repeatable in the private repository, including the Horizon and Stellar Asset Contract admin checks. Nothing here touches mainnet.
Closes #17
Closes #18