Start
Run it again yourself
Re-run any receipt in a browser tab, with the SDK or with the CLI, and compare the bits.
Any answered receipt can be run again by anyone: the model is fetched, checked, run on the receipt's input and seed, and its output and trace root are compared with the ones on the receipt. This page does it in the app and with the SDK, says what the CLI offers, and explains what the result means. A re-run needs no wallet and sends nothing.
What is checked before the run
A re-run is only worth something if it runs the model the receipt names. Before the first step, the files are checked twice:
- The files, by hash. The model's file list comes from
GET /v1/models/:slug/files: a program file and a weights file, each named by its SHA-256. Each file is fetched from the store by that hash, and the bytes that arrive are hashed and compared with it. - The roots, against the chain. The VM computes three Merkle roots from the bytes it loaded: the program root, the weights root and the init root. They are compared with
program_root,weights_rootandinit_rooton the receipt'sModelaccount, read from the chain.
A file that is missing, a hash that differs or a root that differs stops the run before it starts. The input and the seed are read from the receipt account itself. The first step writes the seed into the model's state, so it is part of every state root after it and of the trace root, and a re-run takes the receipt's own.
Then the VM executes every step of the model. A run of judge is 134,491 steps and a run of market is 1,318,668.
In the app
Open a receipt at /receipts/<address>, from Receipts or from the link Ask gives. The panel under the answer shows the operator's trace root on the left and this browser's on the right, with the comparison between them.
| Stage | The panel shows |
|---|---|
| Before the answer | Nothing to run again yet. The button appears the moment the operator answers. A void receipt has nothing to run. |
| Ready | The operator's trace, and the Run it again button. Between the two roots: ?. |
| Loading | Loading the model into this browser, with the bytes loaded of the total, checked against its roots. |
| Running | Running step N of M, and this browser's strip filling as the steps complete. |
| Match | ≡ match. This browser's trace root, equal to the operator's character for character. |
| Differ | ≢ differ. This browser's trace root, the answer this browser got, and Challenge while the receipt is answered. |
| Failed | The run did not start, with the reason, and Try again. |
After a run the smaller Run it again button beside the roots runs it once more. The address /receipts/<address>?run=1 starts the run as the page opens.
With the SDK
laplace.rerun(receipt) does the whole thing: it reads the receipt, loads and checks the model as above, runs it in WASM and compares. The WASM module is inside the package, so there is nothing else to install or host.
import { createLaplace } from '@laplace/sdk'
const laplace = createLaplace({
rpcUrl: process.env.LAPLACE_RPC!,
apiUrl: process.env.LAPLACE_API!,
})
const receipt = process.argv[2]!
const result = await laplace.rerun(receipt, {
onProgress: ({ phase, done, total }) => process.stderr.write(`\r${phase} ${done} of ${total}`),
})
const posted = await laplace.receipt(receipt)
console.log()
console.log('operator ', Buffer.from(posted.traceRoot).toString('hex'))
console.log('this run ', result.traceRoot)
console.log(result.matches ? 'match' : 'differ', { output: result.outputMatches, trace: result.traceMatches })
if (result.label) console.log('answer ', result.label)Run it with a receipt's address as the argument. LAPLACE_RPC and LAPLACE_API are the network's addresses from Addresses.
import { createLaplace } from '@laplace/sdk'
export async function runAgain(apiUrl: string, receipt: string, status: HTMLElement, signal?: AbortSignal) {
const laplace = createLaplace({ rpcUrl: `${apiUrl}/v1/rpc`, apiUrl })
const result = await laplace.rerun(receipt, {
signal,
onProgress: ({ phase, done, total }) => {
status.textContent = phase === 'loading' ? `Loading the model: ${done} of ${total} bytes` : `Running step ${done} of ${total}`
},
})
status.textContent = result.matches ? `≡ match ${result.traceRoot}` : `≢ differ ${result.traceRoot}`
return result
}In a page the client reads the chain through the API's relay at /v1/rpc, so one address serves both. The run yields to the page between slices of 2,048 steps, and aborting signal stops it.
No wallet is passed in either sample. The client loads a model once and keeps it, so a second rerun of the same model starts running at once.
onProgress is called with phase: 'loading' and byte counts while the files load, then with phase: 'running' and step counts. TypeScript SDK lists every field of the call.
With the CLI
The CLI has no command that re-runs one receipt. What it has:
laplace watchre-runs receipts continuously. On every pass it reads the latestansweredreceipts of the models it holds, runs each on the native build of the VM, and writes one JSON line per receipt: the eventmatchedwhen output and trace root equal the operator's,challengedwhen the output differs and it opened a challenge, andtrace_differs_output_samewhen only the trace root differs. It signs with the CLI's key, and it opens challenges on its own. Run a watcher is its guide.laplace receipt <address>prints the output and the trace root the operator posted, to set beside a run made with the SDK.
To re-run a single receipt from a terminal, use the Node sample above.
What the result means
rerun resolves with three comparisons against the answer standing on the receipt:
| Field | True when |
|---|---|
outputMatches | This run's output equals the receipt's output, token for token. |
traceMatches | This run's trace root equals the receipt's trace root, byte for byte. The trace root commits to the model's state after every step and to the output, so two runs with the same trace root agree at every step. |
matches | Both of the above. This is what the app shows as ≡. |
It also returns output (this run's tokens), traceRoot (this run's root as hex), label (the label of this run's output: the judge's yes, unclear or no, the market model's negative, neutral or positive) and run, the run itself with its state root after every step.
The answer on the receipt is the one that stands now. After a dispute the operator lost, that is the challenger's output and trace root, and a re-run is compared with those.
How long a run takes
A full run in Node takes 1.2 s for judge and about 12 s for market, as measured. Before the first run of a model the client downloads its program file and its weights file:
| Model | Program file | Weights file |
|---|---|---|
judge | 4.3 MB | 10.1 MB |
market | 42.2 MB, sent compressed as 5.6 MB | 34.9 MB |
The loading progress counts the files' full sizes.
When the run differs
A run that differs is the start of a challenge: the run's output and trace root are posted against the answer with a bond equal to the model's, inside the receipt's window.
- In the app, the panel shows Challenge under the two roots while the receipt is
answered. Challenge from the browser goes from there to an open dispute. - With the SDK, pass the run to
laplace.challenge(receipt, result.run). Keepresult.run: every later turn of the game is computed from it.
A challenge is for a different output. When outputMatches is true and only the trace differs, the program refuses the challenge with SameOutput.