Perna/solidity step#390
Open
mpernambuco wants to merge 13 commits into
Open
Conversation
mpernambuco
force-pushed
the
perna/solidity-step
branch
2 times, most recently
from
July 7, 2026 14:56
2828860 to
2a5cbad
Compare
mpernambuco
force-pushed
the
perna/solidity-step
branch
from
July 9, 2026 12:04
2a5cbad to
d25c978
Compare
added 5 commits
July 11, 2026 14:09
mpernambuco
force-pushed
the
perna/solidity-step
branch
from
July 11, 2026 17:10
f55f233 to
07e7085
Compare
added 8 commits
July 11, 2026 22:46
mpernambuco
marked this pull request as ready for review
July 21, 2026 14:29
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.
Binary step logs, verified by host, zkVM, and Solidity
One binary log format now describes every provable state transition: N machine
cycles, N uarch cycles, a uarch reset, or a CMIO response. The same log file is
verified by three independent implementations — the C++ host, the RISC0 zkVM
guest, and a Solidity library that now lives in this repo and is transpiled from
the emulator's own sources. The per-access JSON log is gone from the machine
API, and this replaces the separate
machine-solidity-steprepo.Highlights:
(
verify_step,verify_step_uarch,verify_reset_uarch,verify_send_cmio_response), RISC0 guest (Groth16 receipt, ~300k gas toverify on-chain regardless of cycle count), Solidity (direct re-execution).
UArchStep,UArchResetand
SendCmioResponseare transpiled from the C++ interpreter sources andcommitted; CI fails on drift (
make -C solidity-step check-gen-all). Thetwo-repo divergence problem is gone by construction.
send_cmio_responsetakes a revertroot hash and stores it in a machine shadow slot; when an input is rejected,
reset_uarchreverts the machine to that recorded state. All of it iswitnessed by the log, so the on-chain verifier replays it without trusting
the prover.
-28%) and 10 KB calldata (was ~15 KB, -32%) versus the old access-log
verifier.
the emulator in seconds, self-checked at record time, and indexed by a
per-directory manifest. An adversarial corpus of tampered logs must be
rejected by C++ and Solidity with the same named error.
Step-log anatomy
A step log is a sparse Merkle witness of a state transition (any number of
steps, or a single operation): only the touched parts of the state tree, enough
to recompute the root before and after.
p1 = uarch shadow state,p2 = uarch RAMhash_before+hash_after(no data) — witnesses a bulk write. e.g.n1 = cmio rx bufferreset_uarch→ uarch-state subtree (hash_after= pristine);send_cmio_response→ rx-buffer subtreehash_before(+ siblings) → root before; mutated pages + nodes'hash_after(+ siblings) → root afterWire format (header + page/node/sibling entries) is specified in
src/step-log.hpp, which is also the shared decoder used bythe host and zkVM replays. The savings over the per-access format come from
amortizing sibling hashes across the whole log instead of repeating ~59 of them
for every read and write.
Scope of the on-chain verifier
solidity-step/verifies exactly one uarch cycle per log (plus reset and CMIOresponse) — the same dispute granularity as the old access-log model.
Multi-cycle logs are a host/zkVM feature; the Solidity entry point rejects them
by design (
requested_cycle_countmust be 1). The decoder recomputes thepre-state root from the witnessed tree before replaying and the post-state root
after, so the log bytes are untrusted input throughout.
CLI: cartesi-machine.lua
New / reshaped options that produce binary step logs:
--log-step-uarch=<filename>[,count:<uarch-cycle-count>][,pretty]Log
<uarch-cycle-count>microarchitecture cycles (default 1) to a binarystep log (was a single fixed micro-step). Logging stops early at the uarch
halt, so a count at or above the per-mcycle budget records one whole mcycle.
Append
,prettyto also emit a human-readable printout to stderr. Theprintout replaces the old access-log dump (one cycle shown; a log that fails
the final root check still prints, plus a trailing WARNING):
--log-reset-uarch=<filename>Reset the microarchitecture state and write a binary step log.
--log-send-cmio-response=reason:<n>,filename:<path>,(file:<path>|hex:<0x…>|str:<text>)Send a CMIO response into the rx buffer and write a binary step log. Response
bytes come from exactly one of
file:/hex:/str:. Expects the machineyielded (
iflags.Y == 1); otherwise the logged transition is a no-op.Cost of verifying one uarch cycle in Solidity
All uarch cycles of the
rv64ui-uarch-addtest program, measured in bothformats — same unit of work (one uarch step per log), so apples to apples:
Cheaper to run and a third less calldata — cheaper on L1, much more so on L2.
Testing
verifier, chained root-to-root across each program. Fixture expectations are
captured from the live recording machine, never from log headers, so a
corrupted header cannot vouch for itself.
name of the rejection it must trigger, and both the C++ and Solidity
verifiers must fail with exactly that error.
prove → verify → Groth16 compress → seal verification against the on-chain
Verifier Router (Sepolia fork).
Building and testing everything from scratch
Coverage