Reference
Program instructions
Every instruction: accounts, arguments, checks, effects and events.
The laplace program has 16 instructions. This page gives, for each one, who signs, the accounts in the order the program takes them, the arguments, every check with the error it raises, and what changes when it lands.
| Instruction | Signer | Arguments | Effect |
|---|---|---|---|
init_config | admin: the program's upgrade authority (checked through its ProgramData) | fee_recipient, protocol_share_bps, slash_winner_bps, answer_deadline_secs, turn_deadline_secs, withdraw_cooldown_secs | creates Config and the Vault, with registration_open false |
set_config | admin | same, plus new_admin, registration_open | updates Config; registration_open true lets anyone register models |
register_model | publisher: the admin while registration_open is false | slug, arch, weights_root, program_root, init_root, step_count, state_pages, chunk_count, input_max, output_len, window_secs, bond_lamports, files_hash | creates an immutable Model |
register_operator | authority | none | creates Operator |
deposit_bond | authority | lamports | SOL into the vault, bond_free += lamports |
request_withdraw | authority | lamports | marks free bond for withdrawal after withdraw_cooldown_secs |
withdraw_bond | authority | none | pays the marked amount from the vault once the cooldown passed and it is still free |
set_offer | authority | price, active (mint as an account) | creates or updates the Offer |
request | requester | nonce, seed, input, max_fee | refuses an offer priced above max_fee; creates Receipt (requested), moves price of the offer's mint into the escrow; answer_deadline = now + answer_deadline_secs |
answer | the named operator | output, trace_root | bond_free -= model.bond, bond_locked += model.bond; window starts; answered |
cancel_request | requester | none | after the answer deadline with no answer: full refund, void |
challenge | challenger | index, output, trace_root, points | inside the window, output must differ: challenger's bond (= model bond) into the vault, Dispute number index opens over steps [0, step_count] with the challenger's first points; window pauses; challenged |
bisect | the side on turn | select, points | picks the first sub-interval of the other side's points it disagrees with, commits its own points inside it; when one step is left, proving |
prove_step | anyone | payload (below) | executes step lo with laplace-vm, compares the root it leads to with hi_root, pays out (below). Sent as a v1 transaction. |
claim_timeout | anyone | none | the side on turn missed deadline: it loses as if proven wrong |
finalize | anyone | none | after the window with no dispute open: fee to the answerer less protocol_share_bps to the fee recipient (same instruction); bond unlocks (to bond_free for an operator, to the wallet for a challenger); final |
Conventions
Instruction data. An 8-byte discriminator, then the arguments Borsh-encoded in the order listed: integers little-endian, a Vec as a u32 length followed by its elements, a [u8; 32] as 32 bytes.
Accounts. Each table lists the accounts in the order the instruction takes them. W marks a writable account and S a signer. Seeds are those on Program accounts. An optional account that is left out is passed as the program id in its position.
Fixed programs. system_program is 11111111111111111111111111111111, token_program is TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA and associated_token_program is ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL.
Checks. Account checks run before the instruction's own checks, which run in the order listed. A check with a name from 6000 up raises one of the program's errors. A check on how an account relates to another raises one of Anchor's constraint errors, named in the tables as ConstraintHasOne, ConstraintSeeds, ConstraintAddress, ConstraintRaw, ConstraintTokenMint, ConstraintTokenOwner and ConstraintAssociated. An amount or deadline that overflows, and a vault or bond_locked balance that would go below 0, raises MathOverflow.
Time. now is Clock.unix_timestamp in the slot the instruction lands.
Events. The program emits no events. Every effect is a change to the accounts listed, and prove_step writes one log line.
Builders. ix in @laplace/sdk has one builder per instruction, returning a web3.js TransactionInstruction with the accounts already derived. Each section gives its signature.
| Instruction | Discriminator (bytes) |
|---|---|
init_config | 23, 235, 115, 232, 168, 96, 1, 231 |
set_config | 108, 158, 154, 175, 212, 98, 52, 66 |
register_model | 111, 236, 93, 31, 195, 210, 142, 125 |
register_operator | 49, 242, 151, 125, 212, 136, 31, 89 |
deposit_bond | 120, 89, 18, 253, 112, 125, 87, 255 |
request_withdraw | 137, 95, 187, 96, 250, 138, 31, 182 |
withdraw_bond | 222, 199, 141, 31, 188, 93, 155, 40 |
set_offer | 230, 220, 7, 113, 40, 254, 223, 140 |
request | 46, 101, 67, 11, 76, 137, 12, 173 |
answer | 72, 214, 44, 32, 53, 222, 9, 244 |
cancel_request | 65, 196, 177, 247, 83, 151, 33, 130 |
challenge | 16, 107, 14, 39, 244, 150, 81, 187 |
bisect | 152, 154, 208, 235, 126, 186, 40, 168 |
prove_step | 64, 25, 26, 183, 166, 1, 169, 230 |
claim_timeout | 130, 234, 45, 53, 120, 90, 86, 178 |
finalize | 171, 61, 218, 56, 127, 115, 12, 217 |
Transaction format
Every instruction but one fits a legacy or v0 transaction of 1,232 bytes, and the SDK sends them as v0 with send. Each v0 transaction opens with two Compute Budget instructions: a compute-unit limit taken from its own simulation, and a compute-unit price (Priority fees).
prove_step carries a step's inputs and Merkle proofs, which run past that size, so it is sent as a v1 transaction of up to 4096 bytes. The SDK builds and sends it with sendV1 (or compileV1 and serializeV1): the signer signs the message bytes with signMessage, the transaction asks for 1,400,000 compute units, and its priority fee rides in the v1 header. A server key sends it: the network's keeper proves every game that reaches its last step, and the nodes prove their own. One step on chain describes the transaction and the payload in full.
init_config
The admin's. Creates Config and the vault and records the bump of the fee escrow authority. It runs once per program.
Signer: admin, which must be the program's upgrade authority.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | admin | W | S | The upgrade authority. Pays the rent of both accounts. |
| 2 | config | W | Seeds ["config"]. Created here. | |
| 3 | vault | W | Seeds ["vault"]. Created here. | |
| 4 | escrow | Seeds ["escrow"]. | ||
| 5 | program | The program id. | ||
| 6 | program_data | The program's ProgramData account: seeds [program id] under BPFLoaderUpgradeab1e11111111111111111111111. | ||
| 7 | system_program | The System Program. |
Arguments
One argument, args, of type ConfigArgs:
fee_recipientPubkeyrequired- The wallet that receives the protocol's share.
protocol_share_bpsu16required- Basis points of each finalized fee for the fee recipient.
slash_winner_bpsu16required- Basis points of a lost bond for the winner.
answer_deadline_secsi64required- Seconds an operator has to answer.
turn_deadline_secsi64required- Seconds a side has for a turn.
withdraw_cooldown_secsi64required- Seconds between requesting a withdrawal and withdrawing.
Checks
| Check | Error |
|---|---|
program_data is this program's ProgramData account | ConstraintRaw |
admin is the upgrade authority in program_data | Unauthorized |
Both basis-point values are at most 10,000, answer_deadline_secs and turn_deadline_secs are above 0, withdraw_cooldown_secs is 0 or more | InvalidConfig |
Effects. Config is created with admin set to the signer, the six values from args, the bumps of the config, the vault and the escrow authority, and registration_open set to false, so only the admin registers models until set_config opens registration. The vault is created empty.
Builder: ix.initConfig(admin, config), with config as { feeRecipient, protocolShareBps, slashWinnerBps, answerDeadlineSecs, turnDeadlineSecs, withdrawCooldownSecs }.
set_config
The admin's. Replaces every value of Config, names the admin and opens or closes model registration.
Signer: admin, the key in Config.admin.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | admin | S | Config.admin. | |
| 2 | config | W | Seeds ["config"]. |
Arguments
argsConfigArgsrequired- The six values, as in
init_config. All six are written. new_adminPubkeyrequired- The admin from now on. Pass the current admin to keep it.
registration_openboolrequiredtruelets any key register a model;falsekeepsregister_modelto the admin.
Checks
| Check | Error |
|---|---|
admin equals Config.admin | Unauthorized |
The same bounds as init_config | InvalidConfig |
Effects. The six values, admin and registration_open are replaced. Receipts and disputes already open keep the deadlines they were given. A later finalize, prove_step or claim_timeout reads the share, the split and the fee recipient as they are then.
Builder: ix.setConfig(admin, config, newAdmin, registrationOpen).
register_model
Creates a Model. Nothing writes to it afterwards.
Signer: publisher: the admin while Config.registration_open is false, any key once it is true.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | publisher | W | S | The admin, or any key while registration is open. Pays the rent. |
| 2 | config | Seeds ["config"]. | ||
| 3 | model | W | Seeds ["model", slug]. Created here. | |
| 4 | system_program | The System Program. |
Arguments
One argument, args, of type ModelArgs:
slugVec<u8>required- The slug's bytes.
archu8required- The architecture number from the manifest.
weights_root[u8; 32]required- Merkle root of the weight chunks.
program_root[u8; 32]required- Merkle root of the step descriptors.
init_root[u8; 32]required- The state root before step 0.
step_countu32required- Steps in one run.
state_pagesu32required- Pages in the state.
chunk_countu32required- Weight chunks.
input_maxu16required- Most input tokens.
output_lenu16required- Exact output tokens.
window_secsu32required- The window in seconds.
bond_lamportsu64required- The bond per answer in lamports.
files_hash[u8; 32]required- SHA-256 of the manifest file.
Checks
| Check | Error |
|---|---|
Config.registration_open is true, or publisher is Config.admin | Unauthorized |
slug is 1 to 24 bytes, each a to z, 0 to 9 or - | InvalidModel |
step_count, state_pages, chunk_count, window_secs and bond_lamports are above 0 | InvalidModel |
input_max and output_len are each 1 to 64 | InvalidModel |
A slug that is already registered fails in the System Program, because its account exists.
Effects. The Model is created with the arguments, publisher set to the signer and registered_at set to now.
Builder: ix.registerModel(publisher, model), with model as { slug, arch, weightsRoot, programRoot, initRoot, stepCount, statePages, chunkCount, inputMax, outputLen, windowSecs, bondLamports, filesHash }. Publish a model is the guide.
register_operator
Creates the signer's Operator account.
Signer: authority.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | authority | W | S | The operator's key. Pays the rent. |
| 2 | operator | W | Seeds ["operator", authority]. Created here. | |
| 3 | system_program | The System Program. |
No arguments and no checks of its own. A key that is already registered fails in the System Program.
Effects. Operator is created with authority, registered_at set to now, and every balance and counter at 0.
Builder: ix.registerOperator(authority).
deposit_bond
Moves SOL from the operator's wallet into the vault as free bond.
Signer: authority.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | authority | W | S | The operator's key. |
| 2 | operator | W | Seeds ["operator", authority]. | |
| 3 | vault | W | Seeds ["vault"]. | |
| 4 | system_program | The System Program. |
Arguments
lamportsu64required- The amount to deposit.
Checks
| Check | Error |
|---|---|
operator is the signer's Operator account | ConstraintSeeds |
A wallet that holds less than lamports fails in the System Program.
Effects. lamports move from authority to the vault. bond_free rises by lamports.
Builder: ix.depositBond(authority, lamports).
request_withdraw
Marks free bond for withdrawal and starts the cooldown.
Signer: authority.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | authority | S | The operator's key. | |
| 2 | config | Seeds ["config"]. | ||
| 3 | operator | W | Seeds ["operator", authority]. |
Arguments
lamportsu64required- The amount to mark.
Checks
| Check | Error |
|---|---|
lamports is above 0 and at most bond_free | InsufficientFreeBond |
Effects. withdraw_amount is set to lamports and withdraw_at to now + Config.withdraw_cooldown_secs. A new request replaces the earlier one and restarts the cooldown. The marked amount stays in bond_free and answer can still draw on it.
Builder: ix.requestWithdraw(authority, lamports).
withdraw_bond
Pays the marked amount from the vault to the operator's wallet.
Signer: authority.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | authority | W | S | The operator's key. Receives the lamports. |
| 2 | operator | W | Seeds ["operator", authority]. | |
| 3 | vault | W | Seeds ["vault"]. |
No arguments.
Checks
| Check | Error |
|---|---|
withdraw_amount is above 0 | NoWithdrawal |
now is at or after withdraw_at | WithdrawNotReady |
withdraw_amount is at most bond_free | InsufficientFreeBond |
Effects. bond_free falls by withdraw_amount, that many lamports move from the vault to authority, and withdraw_amount and withdraw_at return to 0.
Builder: ix.withdrawBond(authority).
set_offer
Creates or replaces the operator's offer for one model.
Signer: authority.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | authority | W | S | The operator's key. Pays the rent the first time. |
| 2 | operator | Seeds ["operator", authority]. The key must be registered. | ||
| 3 | model | The Model account. | ||
| 4 | mint | The SPL Token mint the price is charged in. | ||
| 5 | offer | W | Seeds ["offer", authority, model]. Created here if it does not exist. | |
| 6 | system_program | The System Program. |
Arguments
priceu64required- The fee per request, in the mint's base units.
activeboolrequired- Whether the offer takes requests.
No checks of its own.
Effects. The offer's operator, model, mint, price and active are written and updated_at is set to now. Requests already made keep the mint and fee recorded on their receipts.
Builder: ix.setOffer(authority, model, mint, price, active).
request
Creates a receipt and moves the offer's price into the fee escrow.
Signer: requester.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | requester | W | S | Pays the fee and the rent. |
| 2 | config | Seeds ["config"]. | ||
| 3 | model | The offer's Model account. | ||
| 4 | offer | The Offer being taken. | ||
| 5 | mint | The offer's mint. | ||
| 6 | receipt | W | Seeds ["receipt", requester, nonce]. Created here. | |
| 7 | requester_token | W | A token account of mint owned by requester. The SDK passes the associated token account. | |
| 8 | escrow | Seeds ["escrow"]. | ||
| 9 | escrow_token | W | The associated token account of escrow for mint. Created here if it does not exist. | |
| 10 | token_program | The SPL Token program. | ||
| 11 | associated_token_program | The Associated Token program. | ||
| 12 | system_program | The System Program. |
Arguments
nonceu64required- Chosen by the requester. Part of the receipt's address, so each nonce is used once per requester.
seedu64required- The run's seed, loaded into the model's state with the input.
inputVec<u16>required- The input token ids.
max_feeu64required- The most the requester pays, in the mint's base units: the price they were shown. An offer repriced above it is refused.
Checks
| Check | Error |
|---|---|
offer.model equals model | ConstraintHasOne |
offer.mint equals mint | MintMismatch |
requester_token holds mint | ConstraintTokenMint |
requester_token is owned by requester | ConstraintTokenOwner |
offer.active is true | OfferInactive |
offer.price is at most max_fee | FeeAboveMax |
input has at least 1 token and at most model.input_max | InvalidInput |
A requester_token balance below the price fails in the Token program.
Effects. offer.price moves from requester_token to escrow_token. The receipt is created with model, operator (the offer's), requester, nonce, seed, mint, fee (the price), the input, state requested, requested_at = now and answer_deadline = now + Config.answer_deadline_secs.
Builder: ix.request(requester, offer, nonce, seed, input, maxFee), with offer as { address, model, mint }.
answer
Posts the output and trace root and locks the model's bond behind them.
Signer: authority, the operator the receipt names.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | authority | S | The operator's key. | |
| 2 | operator | W | Seeds ["operator", authority]. | |
| 3 | receipt | W | The receipt being answered. | |
| 4 | model | The receipt's Model account. |
Arguments
outputVec<u16>required- The output token ids.
trace_root[u8; 32]required- The trace root of the run.
Checks
| Check | Error |
|---|---|
receipt.model equals model | ConstraintHasOne |
The receipt is requested | WrongState |
receipt.operator equals authority | NotNamedOperator |
now is at or before answer_deadline | AnswerDeadlinePassed |
output has exactly model.output_len tokens | InvalidOutput |
bond_free is at least model.bond_lamports | InsufficientFreeBond |
Effects. On the operator: bond_free falls and bond_locked rises by the model's bond, answered rises by 1, last_answer_at = now. On the receipt: output, trace_root, answerer = authority, answerer_is_operator = true, bond set to the model's bond, state answered, answered_at = now, window_ends_at = now + model.window_secs.
Builder: ix.answer(authority, receipt, model, output, traceRoot).
cancel_request
Returns the fee of a request that was not answered in time.
Signer: requester.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | requester | S | The receipt's requester. | |
| 2 | config | Seeds ["config"]. | ||
| 3 | receipt | W | The receipt being cancelled. | |
| 4 | mint | The receipt's mint. | ||
| 5 | requester_token | W | The token account of mint that receives the refund. The SDK passes the requester's associated token account. | |
| 6 | escrow | Seeds ["escrow"]. | ||
| 7 | escrow_token | W | The associated token account of escrow for mint. | |
| 8 | token_program | The SPL Token program. |
No arguments.
Checks
| Check | Error |
|---|---|
receipt.requester equals requester | Unauthorized |
receipt.mint equals mint | MintMismatch |
requester_token holds mint | ConstraintTokenMint |
escrow_token is the escrow's associated token account for mint | ConstraintTokenOwner, ConstraintAssociated |
The receipt is requested | WrongState |
now is after answer_deadline | AnswerDeadlineOpen |
Effects. receipt.fee moves from escrow_token to requester_token. The receipt's state becomes void and finalized_at = now.
Builder: ix.cancelRequest(requester, receipt, mint).
challenge
Opens a dispute against the standing answer with a rival output, trace root and bond.
Signer: challenger.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | challenger | W | S | Pays the bond and the dispute's rent. |
| 2 | config | Seeds ["config"]. | ||
| 3 | receipt | W | The receipt being challenged. | |
| 4 | model | The receipt's Model account. | ||
| 5 | dispute | W | Seeds ["dispute", receipt, index]. Created here. | |
| 6 | vault | W | Seeds ["vault"]. | |
| 7 | system_program | The System Program. |
Arguments
indexu16required- The receipt's current
disputescount. Part of the dispute's address. outputVec<u16>required- The challenger's output token ids.
trace_root[u8; 32]required- The challenger's trace root.
pointsVec<[u8; 32]>required- The challenger's state roots at the split points of
[0, step_count].
Checks
| Check | Error |
|---|---|
receipt.model equals model | ConstraintHasOne |
The receipt is answered | WrongState |
index equals receipt.disputes | WrongState |
now is before window_ends_at | WindowClosed |
challenger is not receipt.answerer | SelfChallenge |
output has exactly model.output_len tokens | InvalidOutput |
output differs from the receipt's output | SameOutput |
points has the number of split points of [0, step_count]: 7 when step_count is above 8, otherwise step_count - 1 | PointCount |
Effects. model.bond_lamports move from challenger to the vault. The dispute is created with:
defenderanddefender_is_operatorfrom the receipt's answerer, and both sides' outputs and trace roots,bondset to the model's bond,lo = 0,hi = step_count,lo_root = model.init_root,hi_rootset to the output leaf of the challenger's output,hi_ownerthe challenger,- the challenger's
points,turnthe defender,deadline = now + Config.turn_deadline_secs,turns = 1, stateopen,opened_at = now.
On the receipt: state challenged, window_remaining = window_ends_at - now, dispute set to the new account, disputes raised by 1.
Builder: ix.challenge(challenger, receipt, model, index, output, traceRoot, points).
bisect
One turn of the game: the side on turn selects a sub-interval of the other side's points and commits its own points inside it.
Signer: signer, the side on turn.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | signer | S | The defender or the challenger, whichever turn names. | |
| 2 | config | Seeds ["config"]. | ||
| 3 | dispute | W | The dispute. |
Arguments
selectu8required- The index of the sub-interval to keep, from 0. With
mpoints stored there arem + 1sub-intervals. pointsVec<[u8; 32]>required- The signer's state roots at the split points of the selected sub-interval. Empty when that sub-interval is one step.
Checks
| Check | Error |
|---|---|
The dispute is open | WrongState |
signer is the side on turn | NotYourTurn |
now is at or before deadline | TurnExpired |
select is at most the number of points stored | SelectOutOfRange |
points has the number of split points of the selected sub-interval, and none when it is one step | PointCount |
Effects. With the stored points at steps p[1] … p[m] of [lo, hi]:
select = 0keeps[lo, p[1]],select = mkeeps[p[m], hi], and any other valueskeeps[p[s], p[s+1]].- A new
lotakes its root from the stored point there. A newhitakes its root from the stored point there, andhi_ownerbecomes the side that committed those points. Whenhidoes not move,hi_rootandhi_ownerstay. turnsrises by 1 anddeadline = now + Config.turn_deadline_secs.- If the interval is now one step:
points_lenbecomes 0, the state becomesprovingandturnis set tohi_owner. - Otherwise the signer's
pointsare stored andturnpasses to the other side.
The split points of an interval are lo + floor((hi - lo) * i / 8) for i from 1 to 7, or every interior step when hi - lo is 8 or less.
Builder: ix.bisect(signer, dispute, select, points).
prove_step
Executes the one disputed step and settles the dispute on its result. Sent as a v1 transaction.
Signer: signer, any key.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | signer | S | Any key. | |
| 2 | config | Seeds ["config"]. | ||
| 3 | dispute | W | The dispute. | |
| 4 | receipt | W | The dispute's receipt. | |
| 5 | model | The receipt's Model account. | ||
| 6 | vault | W | Seeds ["vault"]. | |
| 7 | fee_recipient | W | Config.fee_recipient. | |
| 8 | defender | W | dispute.defender. | |
| 9 | challenger | W | dispute.challenger. | |
| 10 | defender_operator | W | Optional. The defender's Operator account, seeds ["operator", defender]. Required when defender_is_operator is true. |
Arguments
payloadVec<u8>required- Step
lo's descriptor, the state pages it opens and its weight chunk, each with a Merkle proof. One step on chain gives the format.
Checks
| Check | Error |
|---|---|
dispute.receipt equals receipt, receipt.model equals model | ConstraintHasOne |
fee_recipient, defender and challenger are the addresses on Config and the dispute | ConstraintAddress |
The dispute is proving | WrongState |
The payload's step is lo | BadStep |
Its descriptor hashes into program_root, its pages hash into lo_root, its chunk hashes into weights_root, nothing follows it, and the step executes | BadProof |
The defender is an operator (defender_is_operator), whichever side wins: defender_operator is passed and its authority is the defender | Unauthorized |
Effects. The program executes step lo from lo_root on the receipt's input and seed and gets the root the step leads to. If that root equals hi_root, hi_owner wins. If it differs, the other side wins. The program logs step <lo> computed <first 8 bytes of the root>, then settles as Settlement describes, with resolved_by = 0 and computed_root set to the root it computed.
Builder: ix.proveStep(signer, accounts, payload), with accounts as { dispute, receipt, model, feeRecipient, defender, challenger, defenderIsOperator }. laplace.proveStep(dispute) builds the payload from an honest run and sends it as a v1 transaction, for a server key. laplace.playTurn never sends it: at the last step it returns { kind: 'proving', step }.
claim_timeout
Settles a dispute against the side that missed its turn.
Signer: signer, any key.
Accounts. The same ten accounts as prove_step, in the same order.
No arguments.
Checks
| Check | Error |
|---|---|
The account checks of prove_step | ConstraintHasOne, ConstraintAddress |
The dispute is open or proving | WrongState |
now is after deadline | TurnOpen |
The defender is an operator (defender_is_operator), whichever side wins: defender_operator is passed and its authority is the defender | Unauthorized |
Effects. The side on turn loses and the other side wins. The dispute settles as Settlement describes, with resolved_by = 1 and computed_root zero.
Builder: ix.claimTimeout(signer, accounts), with the same accounts as ix.proveStep.
Settlement
prove_step and claim_timeout end a dispute the same way. With bond as the dispute's bond:
to_winner = floor(bond * Config.slash_winner_bps / 10000)
to_protocol = bond - to_winner| The challenger wins | The defender wins | |
|---|---|---|
| Vault to winner's wallet | to_winner to challenger | to_winner to defender |
Vault to fee_recipient | to_protocol | to_protocol |
Defender's Operator, when the defender is an operator | bond_locked falls by bond, disputes_lost rises by 1 | disputes_won rises by 1 |
| Receipt's answer | output and trace_root become the challenger's, answerer the challenger, answerer_is_operator = false, bond the dispute's bond, answered_at = now | Unchanged |
| Receipt's window | window_ends_at = now + model.window_secs | window_ends_at = now + window_remaining |
In both cases the receipt's state returns to answered, its dispute is cleared and window_remaining returns to 0. The dispute's state becomes resolved, with winner and resolved_at = now.
The winner's own bond does not move. A winning challenger's bond stays in the vault behind the answer that now stands, and leaves at finalize.
finalize
Closes a receipt whose window has ended: pays the fee, unlocks the bond and makes the receipt final.
Signer: signer, any key.
Accounts
| # | Account | W | S | Address |
|---|---|---|---|---|
| 1 | signer | W | S | Any key. |
| 2 | config | Seeds ["config"]. | ||
| 3 | receipt | W | The receipt. | |
| 4 | mint | The receipt's mint. | ||
| 5 | escrow | Seeds ["escrow"]. | ||
| 6 | escrow_token | W | The associated token account of escrow for mint. | |
| 7 | answerer | W | receipt.answerer. | |
| 8 | answerer_token | W | The associated token account of answerer for mint. It must exist. | |
| 9 | fee_recipient_token | W | The associated token account of Config.fee_recipient for mint. It must exist. | |
| 10 | vault | W | Seeds ["vault"]. | |
| 11 | operator | W | Optional. The answerer's Operator account, seeds ["operator", answerer], passed when answerer_is_operator is true. | |
| 12 | token_program | The SPL Token program. |
No arguments.
Checks
| Check | Error |
|---|---|
receipt.mint equals mint | MintMismatch |
| The three token accounts are the associated token accounts named above | ConstraintTokenOwner, ConstraintAssociated |
The receipt is answered | WrongState |
now is at or after window_ends_at | WindowOpen |
answerer equals receipt.answerer | Unauthorized |
The answerer is an operator: operator is passed and its authority is the answerer | Unauthorized |
Effects.
share = floor(fee * Config.protocol_share_bps / 10000)fee - sharemoves fromescrow_tokentoanswerer_token, andsharetofee_recipient_token. A part that is 0 is not transferred.- When the answerer is an operator, its
bond_lockedfalls and itsbond_freerises by the receipt's bond. When the answerer is a challenger, the receipt's bond moves from the vault to the answerer's wallet. - The receipt's state becomes
finalandfinalized_at = now.
Builder: ix.finalize(signer, accounts), with accounts as { receipt, mint, answerer, answererIsOperator, feeRecipient }. laplace.finalize(receipt) sends it after two instructions that create the answerer's and the fee recipient's token accounts if they are missing.