Skip to content

feat: Add PRT node Crisium (Lua) - #586

Draft
brunomenezes wants to merge 10 commits into
prerelease/v2-alphafrom
feat/add-lua-node
Draft

brunomenezes wants to merge 10 commits into
prerelease/v2-alphafrom
feat/add-lua-node

Conversation

@brunomenezes

@brunomenezes brunomenezes commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds type = "crisium" to [prt.nodes.<label>], so cartesi run --prt can run the Lua PRT player from machine-emulator's doc/recipes next 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. With mode = "validator" it claims, defends and settles like a sling node, as the honest player or the vandal, on a pool account, a devnet address or your own private_key_file.

Note

The first commit is a wip(sdk) that will not merge: it carries #582's SDK bumps, installs the rollups-node .deb from a main build (run 45906622121) until a release supports cartesi-machine 0.23, makes the cli workflow build and test against the PR's own sdk images, and sets DEFAULT_SDK_VERSION to devel. It is dropped in a rebase once #582 merges and the node is tagged. Draft until then.

What changes

  • @cartesi/sdk: cartesi/rollups-runtime carries crisium and the 18 recipe modules it loads (from the v0.23.0 source tarball, the .deb has none) at /opt/cartesi/prt/recipes, the dave v3.0.0-beta.1 contract artifacts at /opt/cartesi/dave, cast for 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-machine 0.23 is required (^0.23.0), in cartesi doctor too, 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_handler included, which hands the player a Lua module of the project for its anomalies.
  • Tests: the nvram integration tests lose their version gate, which skipped them silently on a pre-release.
  • Library: the [prt] types are exported from @cartesi/cli, so a script can name PrtOptions, PrtNode, the crisium settings and the ResolvedPrt that run({ prt: true }) returns in prtConfig.

Configuration

[prt.nodes.reference]
type = "reference"
claim = false                  # the node reads; the players claim

[prt.nodes.red]
type = "crisium"
mode = "validator"             # claims and settles; kind = "honest" by default
input_policy = "safe"

[prt.nodes.watch]
type = "crisium"               # a sentinel: follows, signs nothing, needs no account
warning_blocks = 5
anomaly_handler = "prt/alerts.lua"   # a Lua module called with each anomaly, instead of a log line

Crisium keys

Key What it does Rules
mode sentinel (default) or validator. A sentinel takes no address, private_key_file or kind.
kind honest (default) or vandal, 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. Validator only.
warning_blocks How long an action may be overdue before the sentinel reports it. Sentinel only.
input_policy, dispute_policy How deep a block must be before an input or a dispute move counts: safe, finalized or a number of blocks. Passed through to the player.
anomaly_handler A .lua file 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 on LUA_PATH after the recipes, so the module may require helpers next to it. A subdirectory such as prt/ keeps the mount to that directory. The file's name must be a Lua module name. Checked to be readable before anything starts.

A crisium entry can't be a sentry (the player submits no sentry claims) and takes no claim (a sentinel already reads). Any of these keys on another type is an error. The player's --first-epoch is 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/image into checkpoints/epoch-0 with the factory's geometry; validator: cast wallet import into 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. With anomaly_handler, the node also mounts the file's directory read-only at /opt/cartesi/prt/handler, after the recipes on LUA_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 Application and InputBox artifacts crisium loads (copies of the interfaces stand in), and crisium never stores its own epoch 0 (hence the helper). A --template=DIR option on the player would remove the helper. PS: These were already shared with other maintainers

Try it locally

Needs Docker with buildx and compose, and bun 1.4.3. Until the SDK is released the devel tag stands in for the published images, and the CLI on this branch defaults to it.

  1. Check out the branch and install:

    git fetch origin feat/add-lua-node && git switch feat/add-lua-node
    bun install
  2. Build the images as cartesi/{sdk,rollups-runtime,rollups-database}:devel. The build fetches the rollups-node .deb first, then bakes the three images, so it takes a while:

    bun run build --filter @cartesi/sdk
  3. Build the CLI and put it on your path. The native binary for your platform lands in apps/cli/bin/:

    bun run build --filter @cartesi/cli
    alias cartesi-dev=$PWD/apps/cli/bin/cartesi-darwin-arm64   # or -darwin-x64, -linux-x64, -linux-arm64
  4. Create an application and add the PRT nodes to its cartesi.toml:

    cartesi-dev create prt-demo --template typescript && cd prt-demo
    [prt.nodes.reference]
    type = "reference"
    claim = false                  # the node reads; the players claim
    
    [prt.nodes.red]
    type = "crisium"
    mode = "validator"             # honest, on devnet account 20
    
    [prt.nodes.watch]
    type = "crisium"               # a sentinel: no account
  5. Build and run with PRT, with a short epoch so the players have something to do:

    cartesi-dev build
    cartesi-dev run --prt --epoch-length 30

    The startup lists the nodes: validator red 0x… (crisium honest, devnet account 20, funded by the CLI) and sentinel watch (crisium, signs nothing).

  6. Send an input and watch the players, from another shell in the same directory:

    cartesi-dev send
    cartesi-dev logs -f

    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 example cast rpc --rpc-url http://127.0.0.1:6751/anvil anvil_mine 0x1f4 a few times, 500 blocks each. cartesi-dev run prints the port it took, 6751 when free. red stages the claim, accepts it when due and stores checkpoints/epoch-1. watch only reports, and logs a stalled_action when a jump leaves an action overdue past warning_blocks.

@changeset-bot

changeset-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a8c8076

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cartesi/cli Minor
@cartesi/sdk Minor

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

@brunomenezes brunomenezes moved this to 🧑‍💻 In Progress in Rollups Tooling Nov 25, 2026
Comment thread packages/sdk/Dockerfile Resolved
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 85.99% (🎯 0%) 14801 / 17212
🔵 Statements 85.99% 14801 / 17212
🔵 Functions 82.04% 411 / 501
🔵 Branches 0% 0 / 0
📁 File Coverage (20 files)
File Lines Statements Functions Branches Uncovered Lines
apps/cli/src/api/build.ts 🔴 6.74% 🔴 6.74% 🔴 0% 🔴 0% 90-146, 151-157, 172-273
apps/cli/src/api/connection.ts 🟢 88.89% 🟢 88.89% 🟢 100% 🔴 0% 70-72
apps/cli/src/api/deposit/common.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/api/deposit/erc1155.ts 🔴 4.21% 🔴 4.21% 🔴 0% 🔴 0% 80-159, 170-263, 272-302
apps/cli/src/api/deposit/erc20.ts 🔴 8% 🔴 8% 🔴 0% 🔴 0% 32-45, 77-154
apps/cli/src/api/deposit/erc721.ts 🔴 6.3% 🔴 6.3% 🔴 0% 🔴 0% 41-50, 79-187
apps/cli/src/api/deposit/ether.ts 🔴 15.56% 🔴 15.56% 🔴 0% 🔴 0% 29-66
apps/cli/src/api/deposit/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/api/deposit/progress.ts 🟡 66.67% 🟡 66.67% 🔴 0% 🔴 0% 14, 18
apps/cli/src/api/doctor.ts 🟡 75.82% 🟡 75.82% 🟢 100% 🔴 0% 61-74, 88-90, 103-105, 118-...
apps/cli/src/api/logs.ts 🔴 38.82% 🔴 38.82% 🟡 60% 🔴 0% 12-23, 136-175
apps/cli/src/api/run.ts 🔴 4.98% 🔴 4.98% 🔴 0% 🔴 0% 222-244, 248-261, 268-286, ...
apps/cli/src/api/send.ts 🟡 71.96% 🟡 71.96% 🟡 75% 🔴 0% 46-47, 74-78, 95, 104, 156-176
apps/cli/src/api/types.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/base.ts 🔴 42.11% 🔴 42.11% 🟡 70.59% 🔴 0% 62, 101-174, 200-204, 208-2...
apps/cli/src/builder/directory.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/docker.ts 🟢 87.5% 🟢 87.5% 🟢 81.82% 🔴 0% 89-91, 93, 126-128, 186-195
apps/cli/src/builder/empty.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/none.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -

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
@socket-security

socket-security Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​cartesi/​wagmi-plugin@​1.0.0-alpha.9 ⏵ 1.0.0-alpha.10731009896 +1100

View full report

@brunomenezes
brunomenezes force-pushed the feat/add-lua-node branch 2 times, most recently from ffdc5f3 to a8c8076 Compare November 27, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo
Status: 🧑‍💻 In Progress

Development

Successfully merging this pull request may close these issues.

2 participants