example: cross-chain-arcade — L1→L2 fan-out to multiple contracts (validates #623) - #624
Merged
Merged
Conversation
A minimal example where one L1 contract (an arcade coin dispenser) sends an L1->L2 message to many distinct L2 contracts (arcade machines) in a single L1 transaction. This exercises the multi-target scenario fixed by #623: the settlement chain's global, monotonic L1->L2 message nonce used to be gated as a per-target account nonce, so messages to any target after the first stalled with InvalidNonce. Plain Cairo + starknet.js, L1->L2 only (no Dojo/sozo/Torii/TEE/embedded settlement). Includes arcade + machine contracts, deploy/verify scripts, a React UI, and up.sh/down.sh. verify.ts is the assertion gate: one play_all must reach every machine. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 this adds
A new example,
examples/cross-chain-arcade/— a small "arcade" game whose wholepoint is that one L1 contract sends L1→L2 messages to many different L2
contracts.
An arcade dispenser on the settlement layer ("L1") calls
play_all, which ina single L1 transaction sends an L1→L2 message to four distinct machine
contracts on the appchain ("L2") —
SLOTS,PINBALL,CLAW,RACER, each aseparately deployed contract with its own
insert_coin#[l1_handler]. Thefrontend shows every machine light up;
scripts/verify.tsasserts every machinereceived its coin.
What it demonstrates
This is a targeted regression demo for the L1-handler nonce fix in #623.
The settlement chain's core contract assigns a single, global, monotonic nonce
to every L1→L2 message, regardless of target. Before #623 the pool gated that as a
per-target account nonce, so the moment a sender messaged a second contract
(global nonce
> 0, but that contract's account nonce still0), the message —and every later one — was rejected
InvalidNonceand never mined.play_allreproduces exactly this: four messages to four distinct targets with
non-contiguous per-target nonces. With the fix, all four relay; without it, only
SLOTSwould.The existing
cross-chain-gameexample only ever messages a single L2 target, soit never exercised this path — hence a dedicated, minimal example.
Scope / design
starknet.js, L1→L2 only (the direction fix(pool): don't gate L1-handler txs on account nonce #623 touches). NoDojo,
sozo, Torii, TEE registry, or embedded settlement.katana init rollup(validity mode + dummy fact registry) to deploy a realpiltover core, then boots the appchain from the generated config with
--messaging.enabled.up.sh/down.shbring the whole stack up/down.main: oneplay_all→ all fourmachines credited; the
verify.tsgate passes.Related
🤖 Generated with Claude Code