Skip to content

feat(machine-tool): replay and prove through the Go machine stack - #797

Draft
mpolitzer wants to merge 2 commits into
next/2.0from
feature/ew-with-replay-api
Draft

mpolitzer wants to merge 2 commits into
next/2.0from
feature/ew-with-replay-api

Conversation

@mpolitzer

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Terminal replay targets cannot be snapshotted, and the maximum input index silently overflows.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Migrates replay and proof generation to the native Go machine stack.

Changes:

  • Adds memory-proof support to machine.Machine.
  • Replaces external CLI/Lua replay and proof logic with Go APIs.
  • Updates builds, mocks, integration tests, and scripts.
File Description
Makefile Builds machine-tool with CGO/libcartesi.
pkg/​machine/​machine.go Exposes GetProof.
pkg/​machine/​implementation.go Implements memory-proof retrieval.
pkg/​machine/​machine_test.go Tests proof generation.
internal/​manager/​instance_test.go Updates machine mock.
internal/​advancer/​determinism_test.go Updates deterministic runtime mock.
cmd/​cartesi-rollups-machine-tool/​main.go Moves replay and proof operations into Go.
cmd/​cartesi-rollups-machine-tool/​replay_dave.go Removes subprocess-based Dave replay.
cmd/​cartesi-rollups-machine-tool/​replay_dave.lua Removes Lua replay implementation.
cmd/​cartesi-rollups-machine-tool/​replay_dave_test.go Removes obsolete helper tests.
scripts/​withdrawal-lifecycle Uses database-backed replay templates.
test/​integration/​withdrawal_lifecycle_test.go Updates machine-tool invocation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/cartesi-rollups-machine-tool/main.go
Comment thread cmd/cartesi-rollups-machine-tool/main.go
Replace the Lua Dave replay and the cartesi-machine CLI invocations with
the in-process machine stack. replay now drives a manager.MachineInstance
through internal/replay.Run (per-input verification against persisted
canonical evidence), stores with CreateSnapshot, and reads the root
in-memory; prove accounts-drive loads the stored machine with
machine.Load and builds the proof with the new machine.Machine.GetProof.

Expose GetProof on the machine interface with the implementation and the
test-mock stubs. Drop the --template (template now comes from the DB and
is hash-verified), --lua, --cartesi-sdk-root, and --cartesi-machine flags,
and delete replay_dave.lua with its Go plumbing. Build
cartesi-rollups-machine-tool with CGO and the libcartesi rpath like the
other machine-linked artifacts, and update the withdrawal-lifecycle
script and integration test for the flag removal.
@mpolitzer
mpolitzer force-pushed the feature/ew-with-replay-api branch from 73933bb to 6e38d7b Compare September 22, 2026 10:47
A replay whose target is the application's terminal input ends in a
terminal machine state that CreateSnapshot and Hash cannot read —
MachineInstanceImpl disposes the runtime on terminal completion — so the
store step failed with an opaque ErrMachineClosed only after a full replay.

Check the last processed input's persisted status before creating the
machine instance. If it is terminal and the requested range reaches it,
fail fast and hint at replaying up to the preceding input. replay.Run's
contradiction check remains the backstop for a terminal input that is not
the application's last.

Drop the HasRuntime method (MachineInstanceImpl, the MachineInstance
interface, and the test mocks) that the previous after-the-fact check used.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Native machine replay and proof generation span database state, emulator behavior, and contract-facing proofs, requiring final human and CI validation.

Review effort: Balanced
Findings: None

Resolved since last review (2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants