Watchers

Challenge from the browser

From a re-run that differs to an open dispute, with one signature.

A receipt's page runs the model in the browser and compares the bits. When they differ, the same page opens the challenge. This guide goes from that result to an open dispute, on the page and with the SDK.

Before the button

Open a receipt at /receipts/<address> and press Run it again. The page loads the model, runs every step and sets this browser's trace root beside the operator's. Run it again yourself covers the run.

When the two differ, the panel reads "differ. This browser got other bits." and a row appears under the two trace roots. Its first line is the answer this browser computed, and what follows depends on the receipt:

The receipt isThe row saysAnd offers
answeredA challenge puts <bond> SOL of yours behind that answer.Challenge, or Connect wallet when no wallet is connected.
challenged"This answer is already being challenged.""Open the dispute", which leads to the dispute in play.
final"The window for this answer has closed."Nothing.

The bond shown

The amount in the row is the bond locked behind the answer, which equals the model's bond. challenge moves the same amount from the connected wallet into the program's vault. The wallet also pays the rent of the new Dispute account and the transaction's fee.

The bond comes back when the receipt is finalized with the challenger's answer standing, together with the winner's part of the operator's bond at the moment the dispute resolves. What each ending pays has both cases.

Pressing Challenge

  1. Connect a wallet

    With no wallet connected, Connect wallet stands where the button would be. Press it and pick a wallet. The row then shows Challenge.

  2. Press Challenge

    The page builds one challenge transaction from the run it just made: this browser's output, its trace root, and its state roots at the first split points of the whole run. Nothing is typed in.

  3. Follow the stages

    Four stages appear under the row, and the nav shows "Opening a challenge" beside the wallet:

    StageWhat is happening
    BuildingThe transaction is built and simulated against the chain.
    SigningThe wallet asks for one signature.
    SentThe transaction is on its way and being followed.
    ConfirmedThe dispute is open. The signature is shown with a copy control.
  4. Arrive at the dispute

    On Confirmed the page moves to /disputes/<address>, the new dispute. The receipt is now challenged and its window is paused. The first turn is the defender's.

When it does not open

A failure stops the stages at the one that failed and adds a line with the reason. Nothing is sent unless the stages reached Sent.

Stops atThe line readsWhy
Building"The program refused." WindowClosed (6014).The window ended before the challenge landed. The receipt can be finalized.
Building"The program refused." SameOutput (6016).This browser's output equals the answer and only the trace root differs. A challenge has to carry a different output.
Building"The program refused." SelfChallenge (6025).The connected wallet is the answerer of this receipt.
Building"The program refused." WrongState (6010).The receipt stopped being answered since the page loaded: someone else challenged it first, or it was finalized.
Building"The program refused." with the simulation's errorThe wallet holds less SOL than the bond, the rent and the fee.
Signing"The wallet did not sign."The request was declined in the wallet.
Sent"Not confirmed."The transaction landed and failed, or did not land before its blockhash expired. Press Challenge again.
Sent"Checking." with the signatureIt was sent and the network has not said yet whether it landed. The page keeps reading and does not offer the button again meanwhile: it may still open the dispute.

The codes link to their entries: WindowClosed, SameOutput, SelfChallenge, WrongState.

The program checks them in this order: the receipt's state, the window, the challenger against the answerer, the output's length, the output against the answer, then the number of points.

Where it leads

/disputes/<address> shows the two claims, the interval of steps still disputed, whose turn it is and its deadline. The challenger's first points went in with the challenge, so the page opens on the defender's turn. When the turn comes back, the page offers Play turn.

The page computes each move from the run made on the receipt's page, which lives in the tab. Playing the game is the guide from here.

The same with the SDK

laplace.rerun returns the run, and laplace.challenge takes it.

TypeScript
import { createLaplace, LaplaceError } from '@laplace/sdk'

const laplace = createLaplace({ rpcUrl, apiUrl, wallet })

const { run, matches, outputMatches } = await laplace.rerun(receipt)

if (!matches && !outputMatches) {
  try {
    const { dispute, signature } = await laplace.challenge(receipt, run)
    console.log(dispute.toBase58(), signature)
  } catch (e) {
    if (e instanceof LaplaceError && e.programError) console.log(e.programError.name, e.programError.code)
    else throw e
  }
}

rpcUrl and apiUrl are the network's addresses (Addresses), wallet is the challenger's signer and receipt is the receipt's address.

receiptPublicKey | stringrequired
The receipt to challenge.
runRunrequired
The run rerun returned, or one from (await laplace.model(slug)).run(input, seed). Its output, traceRoot and points(0, stepCount) are what the transaction carries.

rerun resolves to run, output, traceRoot (hex), matches, outputMatches, traceMatches and label. matches is true only when both the output and the trace root equal the receipt's. The sample challenges when the output differs, which is the case the program accepts.

challenge resolves to { dispute, signature }: the dispute's address, derived from the receipt and its count of earlier challenges, and the transaction's signature. On failure it throws LaplaceError with stage and, for the program's refusals, programError as { code, name }: WindowClosed (6014), SameOutput (6016), SelfChallenge (6025), WrongState (6010). Without a wallet it throws with stage wallet and the message Connect a wallet first. At stage unknown the transaction went out and its outcome could not be read for two minutes: read the receipt before challenging again, since it may already be challenged.

The turns that follow are each one v0 transaction the wallet signs. The last step is proven by the network's keeper, so the wallet never signs a proof.

Keep run for as long as the dispute is open. Every turn is computed from it.