DocsReference
Errors
The twenty errors the curta program returns: each code and name, what it means, and what raises it in each instruction.
Codes
The curta program returns its errors as custom program errors. The codes run from 6000 to 6019, in the order the program declares them.
| Code | Error | What it means |
|---|---|---|
| 6000 | InvalidInstruction | The instruction data does not decode: an unknown tag, a wrong length, an empty weight chunk, a fund amount of zero, or a weight account count other than 1 or 2. |
| 6001 | InvalidAccount | The account list is wrong: its length, an account that is not at the address the program derives or records, a wrong type tag, a wrong writable flag, or one account passed in two roles. |
| 6002 | MissingSignature | An account that must sign did not sign. |
| 6003 | InvalidOwner | An account is not owned by the curta program. |
| 6004 | InvalidSize | An account’s data length, or a weight chunk’s length, is not the one the instruction requires. |
| 6005 | AlreadyInitialized | An account that must be new already holds data. |
| 6006 | InvalidAuthority | The signer is not the key the account records: the Config authority, the model’s publisher or the run’s opener. For init_config, the signer is not the program’s upgrade authority. |
| 6007 | InvalidState | The model or run is not in the state the instruction needs. |
| 6008 | InvalidConfig | A value is outside its range: the turn reward, the protocol share rate, the model’s configuration, the prompt length or max tokens. |
| 6009 | InvalidModel | The model’s name is invalid, the model or Config passed is not the one the run records, or a turn names an unsealed model. |
| 6010 | InvalidWeights | A weight account, a section or its contents does not match the model. |
| 6011 | InvalidOffset | A write offset is not a multiple of 800, or a seal step is not the model’s current step. |
| 6012 | HashMismatch | The hash of the written weights differs from the weights hash the model declared. |
| 6013 | ArithmeticOverflow | A lamport or counter sum passes 64 bits. |
| 6014 | InsufficientBudget | A turn’s charge is above the run’s budget remaining. |
| 6015 | StaleTurn | A turn names a turn index the run has passed: another turn landed first. |
| 6016 | CoreError | The inference core returned an error. |
| 6017 | NotSettled | close_run was sent for a run that has not settled. |
| 6018 | InvalidEvent | The event authority account is not the program’s, or an event instruction is malformed. |
| 6019 | InsufficientFunds | An account holds fewer lamports than the instruction needs. |
The sections below give the exact condition behind each error, instruction by instruction. An error from the inference core reaches a client as CoreError: the program translates every core failure to that one code.
Reading an error
A failed transaction reports the error as a custom code on the instruction that raised it. @curta/sdk exports the names as PROGRAM_ERRORS, and decodeProgramError(code) turns a code into its name, or null for a code outside the program’s range.
import { decodeProgramError } from '@curta/sdk'
const status = (await connection.getSignatureStatuses([signature])).value[0]
const err = status?.err as { InstructionError?: [number, { Custom?: number }] } | null
const custom = err?.InstructionError?.[1]?.Custom
if (custom !== undefined) console.log(decodeProgramError(custom)) // 'StaleTurn' for 6015client.send throws when a transaction fails, with the signature and the error as JSON in the message. A program that calls Curta by CPI sees the same numeric code, since the code belongs to the first program that failed. On the site, a rejected transaction shows its reason at the action that sent it.
Every instruction
These checks come first on every instruction, whatever its tag.
| Code | Error | Raised when |
|---|---|---|
| 6000 | InvalidInstruction | The data is empty, or its first byte is not a tag from 0 to 12. |
| 6000 | InvalidInstruction | The arguments are shorter than the instruction’s layout, or bytes remain after the last argument. |
| 6001 | InvalidAccount | The program id of the instruction is not the curta program. |
| 6001 | InvalidAccount | The account list is not exactly the instruction’s own accounts plus the two trailing ones, or the last account is not the executable curta program. |
| 6001 | InvalidAccount | An account the instruction writes is not marked writable. |
| 6002 | MissingSignature | An account the instruction requires as signer did not sign. |
| 6018 | InvalidEvent | The account before the last is not the event authority address. |
Each Config, Model, Run, weight or vault account an instruction takes passes these:
| Code | Error | Raised when |
|---|---|---|
| 6001 | InvalidAccount | The account’s first eight bytes are not its type’s tag, or a Config account is not at the address derived from "config". |
| 6003 | InvalidOwner | A Config, Model, Run, weight or vault account is not owned by the curta program. |
| 6004 | InvalidSize | The account’s data is shorter than its type: 128 bytes for Config, 4,096 for Model, 256 for Run, 8 for a vault. A weight account is not exactly 2,048 bytes plus its section’s length. |
Config instructions
init_config and set_config.
| Code | Error | Instruction | Raised when |
|---|---|---|---|
| 6001 | InvalidAccount | init_config | config or feeVault is not the address its seeds and the bump passed derive. |
| 6001 | InvalidAccount | init_config | systemProgram is not the System program. |
| 6005 | AlreadyInitialized | init_config | config or feeVault already holds data or is owned by a program other than System. |
| 6006 | InvalidAuthority | init_config | programData is not owned by the upgradeable loader, is not a ProgramData account, or names an upgrade authority other than the signer. |
| 6006 | InvalidAuthority | init_config | The curta program account does not point at the programData account passed. |
| 6006 | InvalidAuthority | set_config | The signer is not the authority the Config records. |
| 6008 | InvalidConfig | init_config | The turn reward is zero, or the protocol share is above 10,000 basis points. |
| 6008 | InvalidConfig | set_config | The turn reward is zero, or the protocol share is above 10,000 basis points. |
Model instructions
create_model, write_weights, seal_model, set_royalty and claim_royalties.
| Code | Error | Instruction | Raised when |
|---|---|---|---|
| 6000 | InvalidInstruction | write_weights | The chunk is empty. |
| 6001 | InvalidAccount | create_model | modelVault is not the address derived for this model, or systemProgram is not the System program. |
| 6001 | InvalidAccount | claim_royalties | publisher and modelVault are the same account. |
| 6003 | InvalidOwner | create_model | model is not owned by the curta program. |
| 6003 | InvalidOwner | write_weights | weights is not owned by the curta program. |
| 6003 | InvalidOwner | seal_model | weights is not owned by the curta program. |
| 6004 | InvalidSize | create_model | model is not exactly 4,096 bytes. |
| 6004 | InvalidSize | write_weights | The chunk runs past the section’s end, or its length is not the smaller of 800 and the bytes left from the offset. |
| 6004 | InvalidSize | write_weights | weights is not exactly 2,048 bytes plus the section’s length. |
| 6004 | InvalidSize | seal_model | weights is not exactly 2,048 bytes plus the section’s length. |
| 6005 | AlreadyInitialized | create_model | model’s first 256 bytes are not all zero, or modelVault already holds data. |
| 6005 | AlreadyInitialized | write_weights | The section has no bytes written and the weight account’s 2,048-byte header is not all zero. |
| 6006 | InvalidAuthority | write_weights | The signer is not the model’s publisher. |
| 6006 | InvalidAuthority | seal_model | The signer is not the model’s publisher. |
| 6006 | InvalidAuthority | set_royalty | The signer is not the model’s publisher. |
| 6006 | InvalidAuthority | claim_royalties | The signer is not the model’s publisher, or modelVault is not the vault the model records. |
| 6007 | InvalidState | write_weights | The model is sealed, or sealing has begun. |
| 6007 | InvalidState | seal_model | The model is already sealed. |
| 6008 | InvalidConfig | create_model | The configuration is outside the supported ranges. |
| 6009 | InvalidModel | create_model | The name is empty, longer than 64 bytes, or not UTF-8. |
| 6010 | InvalidWeights | create_model | The section count is below 2 or above 64, a section length is zero or above 10,483,712 bytes, or two sections name the same address. |
| 6010 | InvalidWeights | write_weights | The section index is not below the model’s section count, or weights is not the address the model names for that section. |
| 6010 | InvalidWeights | write_weights | The section has bytes written and the weight account’s header does not carry this model and section. |
| 6010 | InvalidWeights | write_weights | The chunk’s bit is set and the bytes differ from the ones stored, or the bit is clear and the target bytes are not all zero. |
| 6010 | InvalidWeights | seal_model | A section’s bytes written differ from its length. |
| 6010 | InvalidWeights | seal_model | weights is not the address the model names for the section being sealed, or its header does not carry this model and section. |
| 6010 | InvalidWeights | seal_model | On section zero: the metadata does not parse, its structure is invalid, its configuration, section count or section lengths differ from the Model’s, or a tokenizer entry in this step’s 512 is invalid. |
| 6011 | InvalidOffset | write_weights | The offset is not a multiple of 800. |
| 6011 | InvalidOffset | seal_model | expectedStep is not the model’s seal step. |
| 6012 | HashMismatch | seal_model | The step finishes the last section and the running hash differs from the weights hash. |
| 6013 | ArithmeticOverflow | create_model | The section lengths sum past 64 bits. |
| 6013 | ArithmeticOverflow | seal_model | The seal step passes 64 bits. |
| 6019 | InsufficientFunds | create_model | model holds fewer lamports than the rent of 4,096 bytes. |
| 6019 | InsufficientFunds | claim_royalties | The amount is above the vault’s balance less the rent of 8 bytes. |
Run instructions
open_run, turn, fund, cancel, settle and close_run.
| Code | Error | Instruction | Raised when |
|---|---|---|---|
| 6000 | InvalidInstruction | turn | weightAccountCount is not 1 or 2. |
| 6000 | InvalidInstruction | fund | The amount is zero. |
| 6001 | InvalidAccount | open_run | systemProgram is not the System program, or run and opener are the same account. |
| 6001 | InvalidAccount | turn | cranker and run are the same account, or model, config or a weight account is marked writable. |
| 6001 | InvalidAccount | fund | systemProgram is not the System program, or funder and run are the same account. |
| 6001 | InvalidAccount | settle | modelVault is not the vault the model records, or feeVault is not the one the Config records. |
| 6001 | InvalidAccount | close_run | opener and run are the same account. |
| 6003 | InvalidOwner | open_run | run is not owned by the curta program. |
| 6003 | InvalidOwner | turn | A weight account is not owned by the curta program. |
| 6004 | InvalidSize | open_run | run is not exactly 256 bytes plus the working state for this prompt length and maxTokens. |
| 6004 | InvalidSize | turn | The run account’s length is not 256 bytes plus the working state length it records. |
| 6005 | AlreadyInitialized | open_run | run’s first 256 bytes are not all zero. |
| 6006 | InvalidAuthority | cancel | The signer is not the run’s opener. |
| 6006 | InvalidAuthority | close_run | The signer is not the run’s opener. |
| 6007 | InvalidState | open_run | The model is not sealed. |
| 6007 | InvalidState | turn | The run is not running. |
| 6007 | InvalidState | fund | The run is complete or cancelled. |
| 6007 | InvalidState | cancel | The run is complete or already cancelled. |
| 6007 | InvalidState | settle | The run is running or starved, or is already settled. |
| 6008 | InvalidConfig | open_run | The prompt is longer than 1,024 bytes, or maxTokens is zero or above the model’s context length. |
| 6009 | InvalidModel | turn | model or config is not the one the run records, or the model is not sealed. |
| 6009 | InvalidModel | settle | model or config is not the one the run records. |
| 6010 | InvalidWeights | open_run | metadata is not the model’s section zero account, its header does not carry this model, or its configuration differs from the Model’s. |
| 6010 | InvalidWeights | turn | weightAccountCount differs from the number of matrix sections this turn reads, or a weight account is not the one the model names for the section the turn reads at that position. |
| 6013 | ArithmeticOverflow | open_run | Rent plus budget, or the model’s run counter, passes 64 bits. |
| 6013 | ArithmeticOverflow | turn | A reward, royalty or protocol share sum passes 64 bits. |
| 6013 | ArithmeticOverflow | fund | The budget deposited or remaining passes 64 bits. |
| 6013 | ArithmeticOverflow | settle | The model’s token or royalty counter passes 64 bits. |
| 6014 | InsufficientBudget | turn | The turn’s charge is above the budget remaining. |
| 6015 | StaleTurn | turn | expectedTurn is not the run’s turn count: another turn landed first. |
| 6016 | CoreError | open_run | The prompt contains a zero byte or is not UTF-8, or the temperature is above 1,048,576. |
| 6016 | CoreError | turn | The inference core returns an error while planning or computing the turn. |
| 6017 | NotSettled | close_run | The run’s settled flag is clear. |
| 6019 | InsufficientFunds | open_run | run holds fewer lamports than its rent plus the budget. |
| 6019 | InsufficientFunds | settle | The run account holds fewer lamports than the amounts owed. |
StaleTurn and a starved run
Two outcomes of a turn are part of ordinary operation. StaleTurn means another cranker landed that turn index first: read the run again and send the next index. A turn that finds the budget below its reserve succeeds without an error, sets the run to starved and pays no reward; a turn sent to a starved run then raises InvalidState until a fund returns it to running. Run a cranker shows how the cranker treats both.
The event instruction
The program emits each event as a call to itself whose data opens with the 8-byte event tag. That call is checked like any other:
| Code | Error | Raised when |
|---|---|---|
| 6002 | MissingSignature | The event authority did not sign. Only the program signs for it, so an event instruction sent from outside the program raises this. |
| 6018 | InvalidEvent | The data after the 8-byte event tag is shorter than 149 bytes, or its token list is not a whole number of 4-byte ids. |
| 6018 | InvalidEvent | The instruction carries more or fewer than one account, or that account is not the event authority address. |