Genesis Run: a provably fair Bitcoin-block game on Stacks, plus a league for bots (feedback welcome)

hi stacks forum. we’re blip labs, a small team making free games on stacks where a bitcoin block picks each day’s map, so nobody could pick it, us included.

what’s live:

  • genesis run, a free browser game: playgenesis.run/play
  • the bot cup, a separate league where bots play the same game through an open API: playgenesis.run/agents
  • the 5-step fair check and open kits (MIT) are on the site and on github under blip-labs/blip

along the way we sent two small fixes upstream: stacks explorer #2870 and leather mobile #2916.

nov 2-8 the bot cup runs a 50 STX contest for bot builders. rules are on the agents page.

no token, nothing to buy. honest feedback on the game is the most useful thing you could give us.

Nice work on the fair page. The list of what it doesn’t prove is more honest than most.

On the anchor, todaysAnchor takes the first block after midnight as soon as it appears, and the worker caches it for the day. At that moment it has zero confirmations. One-block reorgs still happen on Bitcoin now and then, with nobody throwing a block away on purpose. If the anchor gets orphaned, the cached hash is no longer in the chain, so mempool.space and bitcoin-block-hash at that height show a different hash from the one the day was played on. Keeping the anchor pending until it has a few confirmations (3 is about 30 minutes) avoids that.

The miner of a block near midnight also sets its timestamp, anywhere above the median of the previous 11 blocks and up to 2 hours ahead. So without throwing anything away they can decide whether their own block becomes the anchor or leave it to the next one, and a block mined at 23:00 can carry a 00:30 timestamp and show the day’s map early. For a free game that hardly matters, but “nobody could pick it” is a bit stronger than the rule. Using the median time past instead of the block’s own timestamp, the reason BIP 113 moved locktime to it, makes that much harder to move, at the cost of the map switching about an hour after midnight.

In the contract, seal-week accepts any week number, and since map-insert never overwrites, a wrong number sealed once stays forever and blocks the real week. Asserting the week is the last sealed week plus one closes that before mainnet.

thanks Carlos, this is exactly the kind of review we were hoping for. all three were real, and all three are fixed:

  1. confirmations. the anchor now stays pending until it has 3 confirmations, so a 1-block reorg can’t swap a map we already served.
  2. miner timestamps. from Monday Nov 9 (UTC) the anchor is the first block whose median time past is at or after midnight, BIP 113 style. a miner can no longer pull its own block into the day with its clock. earlier days keep the old rule so no served map changes. the map now lands an hour or two after midnight, which is fine for us. the fair page explains it.
  3. seal-week. weeks now seal strictly in order (last sealed + 1), and only once the week is over by the chain’s own clock (stacks-block-time). so a typo can’t lock out a real week. quiet weeks seal empty so the chain never stalls. this goes in a fresh testnet deploy before anything touches mainnet.

code is in the open kit if you want to poke at it again. really appreciate you taking the time.

The new seal-week still has one opening: next-week starts as none, so the very first seal accepts any past week. If that first number comes out too high, the real first week can never be sealed after it, and if it’s too low every week in between has to be sealed empty before you catch up. Setting next-week to the first week at deploy, instead of none, closes that.

medianTimePast reads the 11 blocks before the candidate, so the candidate’s own miner can’t pull it into the day with its timestamp now.

good catch again, you’re right. a none start meant the very first seal could land on any past week.

fixed: there’s now a FIRST-WEEK constant set at deploy, and next-week starts there, so the first seal has to be exactly that week and every one after is +1. it also checks the order before the week-is-over check, so any wrong number gets the same clear error. the simnet checks now cover a week before the start, an arbitrary past week, and a far-future typo on the first seal.

and thanks for confirming the median time past change.