Operators

Run a node

Register, bond, set an offer and start laplace serve.

This guide goes from an empty machine to a node that answers requests: a key, SOL behind it, an operator account, a bond, an offer per model, and laplace serve running as a service. An operator is one key. The same key registers, holds the bond, sets the offers and signs every answer.

What the node needs

The CLINode 22 and the laplace command: Install and invoke.
The native step functionThe laplace-vm binary, built once: The native laplace-vm binary.
The network's addressesThe RPC endpoint and the API, as LAPLACE_RPC and LAPLACE_API or --rpc and --api: Addresses.
SOLThe bond, the rent of one Operator account and one Offer account per model, and the fee of each transaction the node sends.
DiskEach served model's program and weights files, and one roots file per answer it holds for the game, 32 bytes per step: about 42 MB for one answer of the market model's 1,318,668 steps. The file sizes and step counts are on each model's page, /models/<slug>.

From a key to an answering node

Registering, bonding and setting an offer can be done from the terminal or on Operate with a browser wallet. Both act on the same accounts, so the wallet connected on Operate must hold the same key the node runs with.

  1. Make or import the key

    Shell
    laplace key new

    It asks for a new password, writes the encrypted key file and prints the public key. To run the node with a keypair that already exists, for example the one in the wallet used on Operate, import its file:

    Shell
    laplace key import ./operator-keypair.json

    laplace key show prints the public key again at any time. The key file covers its location and encryption.

  2. Fund the key

    Send SOL to the public key: the bond you will deposit, plus rent and fees. The bond a model needs behind each answer is bondLamports of GET /v1/models/:slug, shown on the model's page as its bond per answer.

  3. Register as an operator

    Shell
    laplace operator register

    Prints the transaction's signature.

    This creates the Operator account at seeds ["operator", authority]. It is done once per key.

  4. Deposit the bond

    Shell
    laplace operator bond 5

    The amount is in SOL.

    The SOL moves into the program's vault and the operator's free bond rises by the amount. Each answer locks the model's bond from the free balance, so the free bond divided by the model's bond is how many answers the node can have open at once. Bond and offers has the arithmetic.

  5. Set an offer for each model

    Shell
    laplace operator offer judge 20000 --mint <mint>
    laplace operator offer market 10000 --mint <mint>

    The price is a whole number of the mint's base units: 20000 of a 6-decimal mint is 0.02 of the token.

    A requester can name this operator for a model once its offer is active.

  6. Start the node

    Shell
    laplace serve --models judge,market

    It asks for the key's password once, then:

    1. prints a serve line,
    2. fetches each model's program.bin and weights.bin from the API's store into its data folder, and checks each file's SHA-256 against the hash that GET /v1/models/:slug/files lists. The files come gzip-compressed, which takes the market model's 42.2 MB program file down to about 5.6 MB on the wire, and are checked after decompression. Files already on disk with the right hash are kept,
    3. prints models_ready,
    4. starts answering: every 1.5 seconds it reads the requests that name its key and answers each one.

    While the files cannot be fetched it prints models_waiting and tries again every 3 seconds.

  7. See it answering

    Ask the node for an answer, naming its offer:

    Shell
    laplace ask judge --claim "The bridge opened in 1932." --evidence "The bridge opened to traffic in March 1932." --offer <offer address>

    The offer's address is the address field of its entry in GET /v1/offers?model=judge. On Ask the same request is made by picking the model and this operator's offer.

    The node prints an answered line with the receipt, the model, the output's first tokens and the signature. From then on:

    • /operators/<key> shows the operator's record: bond free and locked, receipts answered, the Last answer tile, its receipts and its offers, each marked "live" while it is.
    • Operate shows the "Your node" panel: "Answering" while the last answer is less than 10 minutes old, with the line "Last answer" and its time in UTC.
    • GET /v1/operators/:key returns the same record, with lastAnswerAt.

Keeping it running as a service

A service has no terminal to type the password into, so the password is given as LAPLACE_PASSWORD. Everything else the node takes is a variable too:

Shell
export LAPLACE_RPC="$rpcUrl"
export LAPLACE_API="$apiUrl"
export LAPLACE_KEY=/var/lib/laplace/key.json
export LAPLACE_PASSWORD="$password"
export LAPLACE_DATA=/var/lib/laplace/serve
export LAPLACE_VM_BIN=/usr/local/bin/laplace-vm

node dist/src/cli/main.js serve --models judge,market
VariableHolds
LAPLACE_RPC, LAPLACE_APIThe network's addresses.
LAPLACE_KEYThe path of the encrypted key file.
LAPLACE_KEY_SEALEDIn place of LAPLACE_KEY: the contents of the key file, for a host that takes secrets as variables and has no disk to keep the file on.
LAPLACE_PASSWORDThe key file's password.
LAPLACE_DATAThe data folder. On a host whose disk is not kept between starts, the node downloads the model files again at each start.
LAPLACE_VM_BINThe path of the laplace-vm binary.

The node writes one JSON line per event to standard output and nothing else, so its log is the service's log. It ends its loop on SIGINT or SIGTERM after the current pass. A failed pass prints an error line and the next pass runs 1.5 seconds later, so the service manager only has to start the process and start it again if it exits.

On start the node reads every request that names its key and is still requested, so a request that arrived while the process was down is answered if its answer deadline has not passed. An answer the node posted before a restart is defended after it: when a dispute needs the run, the node runs the receipt's input again.

Leaving

Turn the offers off so no new request names the operator, wait until its receipts are final and the locked bond is free again, then withdraw: Bond and offers.