Repository navigation
feat: Add PRT node Crisium (Lua) - #586
Draft
brunomenezes wants to merge 10 commits into
Draft
brunomenezes wants to merge 10 commits into
brunomenezes wants to merge 10 commits into
Conversation
🦋 Changeset detectedLatest commit: a8c8076 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Coverage Report
📁 File Coverage (20 files)
|
brunomenezes
force-pushed
the
feat/add-lua-node
branch
from
November 25, 2026 19:12
e3af30f to
0140d55
Compare
dave v3.0.0-beta.1 sentries claim as soon as an epoch is sealed, so epoch 1, sealed before the stop, already carried both claims
brunomenezes
force-pushed
the
feat/add-lua-node
branch
from
November 27, 2026 08:30
0140d55 to
aa3aac8
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
brunomenezes
force-pushed
the
feat/add-lua-node
branch
2 times, most recently
from
November 27, 2026 10:25
ffdc5f3 to
a8c8076
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.
Summary
Adds
type = "crisium"to[prt.nodes.<label>], socartesi run --prtcan run the Lua PRT player from machine-emulator'sdoc/recipesnext to the rollups-node and the sling nodes. A crisium entry is a sentinel by default: it computes the honest claims, signs nothing, takes no account, and reports as anomalies what a validator should have done and has not. Withmode = "validator"it claims, defends and settles like a sling node, as the honest player or thevandal, on a pool account, a devnet address or your ownprivate_key_file.Note
The first commit is a
wip(sdk)that will not merge: it carries #582's SDK bumps, installs the rollups-node.debfrom amainbuild (run 45906622121) until a release supports cartesi-machine 0.23, makes thecliworkflow build and test against the PR's ownsdkimages, and setsDEFAULT_SDK_VERSIONtodevel. It is dropped in a rebase once #582 merges and the node is tagged. Draft until then.What changes
@cartesi/sdk:cartesi/rollups-runtimecarries crisium and the 18 recipe modules it loads (from the v0.23.0 source tarball, the.debhas none) at/opt/cartesi/prt/recipes, the dave v3.0.0-beta.1 contract artifacts at/opt/cartesi/dave,castfor the validator's signatures,lua-dkjson, and/opt/cartesi/prt/store-first-checkpoint.lua, the helper that stores the checkpoint a player starts epoch 0 from.@cartesi/cli:cartesi-machine0.23 is required (^0.23.0), incartesi doctortoo, since 0.23 can't load machines stored by 0.22; the contracts are regenerated with wagmi-plugin 1.0.0-alpha.10, whose defaults are rollups-contracts and dave v3.0.0-beta.1, so every address moves, the devnet ones included; and the crisium entry type with its keys, resolution, compose services and tests,anomaly_handlerincluded, which hands the player a Lua module of the project for its anomalies.[prt]types are exported from@cartesi/cli, so a script can namePrtOptions,PrtNode, the crisium settings and theResolvedPrtthatrun({ prt: true })returns inprtConfig.Configuration
Crisium keys
modesentinel(default) orvalidator.address,private_key_fileorkind.kindhonest(default) orvandal, a scripted adversary that posts a made-up claim for epoch 0, loses the dispute and then idles: only the honest player stores the checkpoints of later epochs.warning_blocksinput_policy,dispute_policysafe,finalizedor a number of blocks.anomaly_handler.luafile whose module the player calls with each anomaly's kind and message, instead of printing it to stderr. The file's directory is mounted read-only into the node and put onLUA_PATHafter the recipes, so the module mayrequirehelpers next to it. A subdirectory such asprt/keeps the mount to that directory.A crisium entry can't be a
sentry(the player submits no sentry claims) and takes noclaim(a sentinel already reads). Any of these keys on another type is an error. The player's--first-epochis not exposed: it needs the checkpoints of an honest player in the same directory, which comes with the scripted adversaries later.How a crisium node starts
cartesi run --prt→ environment healthy → deploy →secret-init-prt-node-<label>(clone.cartesi/imageintocheckpoints/epoch-0with the factory's geometry; validator:cast wallet importinto a keystore) →prt-node-<label>(lua5.4 crisium.lua, polling anvil). The data lives in a volume per node; a redeploy recreates it, a restart keeps it. Withanomaly_handler, the node also mounts the file's directory read-only at/opt/cartesi/prt/handler, after the recipes onLUA_PATH, and starts the player with--anomaly-handler=<module>.Upstream
Three things this branch works around would be simpler upstream: the recipes are not packaged with the emulator release (the Dockerfile lists the require closure by hand), dave's artifacts tarball lacks the
ApplicationandInputBoxartifacts crisium loads (copies of the interfaces stand in), and crisium never stores its own epoch 0 (hence the helper). A--template=DIRoption on the player would remove the helper. PS: These were already shared with other maintainersTry it locally
Needs Docker with buildx and compose, and bun 1.4.3. Until the SDK is released the
develtag stands in for the published images, and the CLI on this branch defaults to it.Check out the branch and install:
git fetch origin feat/add-lua-node && git switch feat/add-lua-node bun installBuild the images as
cartesi/{sdk,rollups-runtime,rollups-database}:devel. The build fetches the rollups-node.debfirst, then bakes the three images, so it takes a while:Build the CLI and put it on your path. The native binary for your platform lands in
apps/cli/bin/:Create an application and add the PRT nodes to its
cartesi.toml:Build and run with PRT, with a short epoch so the players have something to do:
The startup lists the nodes:
validator red 0x… (crisium honest, devnet account 20, funded by the CLI)andsentinel watch (crisium, signs nothing).Send an input and watch the players, from another shell in the same directory:
Both log
Epoch 0: processed confirmed InputAdded 0., about two minutes after the send on a natural chain, once the input's block is finalized. A natural 2 s chain takes 25 to 40 minutes to settle an epoch, the tournament timeouts. Jumping the chain shortens it, for examplecast rpc --rpc-url http://127.0.0.1:6751/anvil anvil_mine 0x1f4a few times, 500 blocks each.cartesi-dev runprints the port it took, 6751 when free.redstages the claim, accepts it when due and storescheckpoints/epoch-1.watchonly reports, and logs astalled_actionwhen a jump leaves an action overdue pastwarning_blocks.