Skip to content

Add the Tempo OUSD payments and bonds plugin - #1

Draft
joostjager wants to merge 1 commit into
Mesh-LLM:mainfrom
joostjager:tempo-plugin
Draft

joostjager wants to merge 1 commit into
Mesh-LLM:mainfrom
joostjager:tempo-plugin

Conversation

@joostjager

@joostjager joostjager commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

A Mesh plugin that lets nodes pay for inference in OUSD on Tempo, and lets providers lock a refundable bond that Mesh nodes can require before relaying or routing to them (Mesh-LLM/mesh-llm#3143). Payments and bonds share one wallet and can be turned on separately; they'll be split into separate PRs later.

As with the Lightning plugin, a seller prices a model and a buyer turns on paid buying with one command each, without editing a config file. On testnet, a buyer by default only sees sellers that have locked a bond of at least 1 OUSD with a one-minute exit delay. A seller locks that bond with bond_lock and gets it back with bond_exit, which starts the exit; the plugin then withdraws the bond into the seller's wallet once the delay has passed. A buyer doesn't need a wallet just to check bonds.

Try it on testnet

This runs a seller and a buyer on one machine, on Tempo's Moderato testnet, with no restarts:

  1. The buyer can't see the seller.
  2. The seller posts a bond.
  3. The buyer sees the seller and pays it for inference.
  4. The buyer closes its payment channel.
  5. The seller gets its bond back.

Test coins come from the faucet, so it costs nothing. Amounts are in millionths of OUSD: the price below is 1 OUSD per million tokens, so one unit per token, and the buyer's daily budget is 0.1 OUSD.

Build

You need Mesh's build prerequisites from its CONTRIBUTING.md, including just, Node.js 24, pnpm 10 and a recent Rust. Mesh builds with 1.99.0; 1.94 doesn't work. The plugin pins Rust 1.95.0 and needs a C compiler and Python 3.12+.

git clone --branch peer-evidence https://github.com/joostjager/mesh-llm.git
cd mesh-llm && just mesh && cd ..
git clone --branch tempo-plugin https://github.com/joostjager/ousd-payments-plugin.git
cd ousd-payments-plugin && just package && cd ..

Terminals

Use four terminals, all in the directory you cloned into: a node and a command terminal for each side. Each side gets its own home directory, so the two keep their Mesh and Tempo state apart. In the seller's two terminals:

export MESH=$PWD/mesh-llm/target/debug/mesh-llm TEMPO=$PWD/ousd-payments-plugin/target/release/tempo
export ARCHIVE=$(ls $PWD/ousd-payments-plugin/dist/tempo-v0.1.0-*.tar.gz)
export MODEL=unsloth/Qwen3-0.6B-GGUF:Q4_K_M HOME=/tmp/tempo-seller

In the buyer's two terminals, the same with HOME=/tmp/tempo-buyer:

export MESH=$PWD/mesh-llm/target/debug/mesh-llm TEMPO=$PWD/ousd-payments-plugin/target/release/tempo
export ARCHIVE=$(ls $PWD/ousd-payments-plugin/dist/tempo-v0.1.0-*.tar.gz)
export MODEL=unsloth/Qwen3-0.6B-GGUF:Q4_K_M HOME=/tmp/tempo-buyer

Start the seller

Seller node. Create a wallet first, since a node can only charge or pay if its wallet exists when it starts. Then install the plugin, which grants its requested access so mesh.toml needs no plugin entry, and serve a small model:

$TEMPO wallet init
$MESH plugins install --archive $ARCHIVE --name tempo --version 0.1.0
$MESH serve --model Qwen3-0.6B

After a few seconds it prints a line starting with 📡 Invite created for mesh …:. Copy the invite token from that line. Downloading the model (about 400 MB) takes another minute or two; the buyer can join in the meantime.

Seller commands. Get test coins from the faucet and set a price for the model:

$MESH plugins call tempo control --input '{"command":"fund"}'
$MESH plugins call tempo control --input "{\"command\":\"set_pricing\",\"model\":\"$MODEL\",\"value\":{\"input_per_million\":\"1000000\",\"output_per_million\":\"1000000\"}}"

Start the buyer

Buyer node. Create a wallet, install the plugin, and join the seller's mesh on other ports, putting the invite token in place of INVITE_TOKEN. Wait until it prints ✅ joined mesh:

$TEMPO wallet init
$MESH plugins install --archive $ARCHIVE --name tempo --version 0.1.0
$MESH client --join INVITE_TOKEN --port 9338 --console 3132

Buyer commands. Get test coins and turn on paid buying with a daily budget. --port 3132 addresses the buyer's node:

$MESH plugins call tempo control --port 3132 --input '{"command":"fund"}'
$MESH plugins call tempo control --port 3132 --input '{"command":"policy","value":{"mode":"automatic","daily_budget":"100000"}}'

1. The buyer doesn't see the seller

Buyer commands. The buyer is connected, but the seller has no bond, so its model list is empty and a request is refused with "model not found":

curl -s localhost:9338/v1/models
curl -s localhost:9338/v1/chat/completions -H 'Content-Type: application/json' -d "{\"model\":\"$MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello\"}],\"max_tokens\":16}"

2. The seller posts a bond

Seller commands. Lock the default bond of 1 OUSD with a one-minute exit delay. The plugin publishes it a few seconds later, once the lock is final:

$MESH plugins call tempo control --input '{"command":"bond_lock"}'

3. The buyer sees the seller and pays

Buyer commands. Within seconds, with neither node restarted, the model list shows the seller's model. Send the same request again; this time it's paid and answered. The first paid request opens a payment channel with a 1 OUSD deposit, which takes a few seconds:

curl -s localhost:9338/v1/models
curl -s localhost:9338/v1/chat/completions -H 'Content-Type: application/json' -d "{\"model\":\"$MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello\"}],\"max_tokens\":16}"

4. The buyer closes the channel

Buyer commands. Close the channel now instead of waiting for it to go idle:

$MESH plugins call tempo control --port 3132 --input '{"command":"recover"}'

The seller closes the channel within seconds: it keeps what it billed, and the rest of the deposit goes back to the buyer.

5. The seller gets its bond back

Seller commands. Start the exit:

$MESH plugins call tempo control --input '{"command":"bond_exit"}'

A minute later the buyer stops listing the seller, and the plugin withdraws the bond into the seller's wallet by itself, less gas. The seller's transactions then show a finalized withdraw, and the closed channel with what it captured (for example, 22 for 13 prompt and 9 completion tokens) and what it refunded:

$MESH plugins call tempo control --input '{"command":"transactions","limit":5}'

Stop both nodes with Ctrl-C.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@joostjager
joostjager force-pushed the tempo-plugin branch 8 times, most recently from 8f10ce9 to e9aba8d Compare November 26, 2026 11:03
Implement one Mesh plugin process with an integrated Tempo wallet that
runs independently enabled OUSD payments and provider bonds.

Payments reuse one TIP-1034 channel per buyer and seller, and requests
on it run concurrently. The seller quotes rates and an upfront, the
buyer signs cumulative vouchers, each request is billed from metered
usage with an optional cached-input discount, and the seller captures
only the billed total at close. Buyer policy decides which requests are
paid, so clients send no payment fields. Buyers check a worst-case cost,
a per-request cap and a daily budget before dispatch, top up when a bill
exceeds the deposit, accept numbered bills in order, and recover idle
channels. As in the Lightning plugin, a buyer that has paid needs no
further upfront, and a seller refuses new requests at three unpaid bills
until the operator unblocks the buyer. Config, runtime settings and
controls follow the Lightning plugin, including journaled wallet sends.
Wallet profiles and state are bound to an explicit testnet or mainnet
selection.

Bonds lock OUSD against a mesh and host key until the funding wallet
requests an exit, and refund the full principal after the configured
delay. As a Mesh peer evidence verifier, the plugin publishes its bond
reference and checks other providers' bonds against finalized chain
state, with deadlines derived from their exit delays. A node needs no
wallet to verify bonds, only its RPC. On Moderato the plugin uses the
deployed escrow, and it publishes a bond as soon as its lock finalizes.
Installing the plugin always filters providers by bond: Mesh rejects a
provider without evidence, and buyers require the network's standard
bond of 1 OUSD unless configured lower, which sellers lock by default.
On a network without a configured escrow, such as mainnet today, no
provider qualifies. The offline test fixture can run without a verifier,
for the payment smoke. The default exit delay is one minute on testnet,
so a trial bond comes back within minutes, and one day on mainnet.

A package install needs no Mesh plugin entry or config file: the plugin
writes its default config under ~/.mesh-llm/tempo on first start. The
fund control creates the wallet on first use and asks the testnet faucet
for coins. bond_lock and bond_exit need no arguments, and repeating one
resumes it. bond_exit starts the exit, and once its delay has passed the
plugin withdraws the bond into the wallet. As in the Lightning plugin, a
buyer turns on paid buying with the policy control alone: it then buys
from any seller at its quoted rates, buy_peers and buy_prices only
narrow that, and a channel deposits 1 OUSD unless channel_topup is set.

Pin the Mesh plugin SDK to the companion peer-evidence branch. Include
offline fixtures, packaging, operator documentation and faucet-funded
Moderato trial records.
i386 added a commit to Mesh-LLM/mesh-llm that referenced this pull request Nov 29, 2026
…ied evidence (#3143)

A plugin can now require providers to prove something, such as holding a
refundable bond, before a node relays, lists or routes to them.
Unverified providers reach only their direct peers; pure clients are
exempt. One piece of
[#3132](#3132).

A plugin declares a verifier in its manifest, publishes its own node's
evidence with `PublishPeerEvidence`, and answers verification requests
with a verdict and a deadline. A node runs at most one verifier, which
must start eagerly. A provider that published no evidence is ineligible
without a verifier call. Nodes without a verifier are unchanged.

The [Tempo OUSD
plugin](Mesh-LLM/ousd-payments-plugin#1) uses
this for seller bonds: buyers only route to sellers with a bond in the
escrow.

## Architecture

Evidence is carried in the origin-signed node record, so relays cannot
forge, strip or reattach it. A background task verifies providers when
peers change, a verdict expires or the verifier restarts, and caches
verdicts by mesh, node and evidence digest; gossip, discovery and
routing only read that cache. An acceptance is renewed 10 seconds before
it expires, a failed renewal keeps it until it expires, and a newly
accepted provider is gossiped at once. A verifier restart or shutdown
discards its verdicts. While a verifier is loaded, third-party peer
descriptions are accepted only from signed records. Nodes accept
connections only after plugins start, so the policy applies to the first
peers.

Split placement and stage transport keep their membership checks and do
not consult evidence, so an unverified mesh member can still be chosen
as a stage worker in a seller's split.

## Protocol

Additive: `NodeRecord` field 27 (`peer_evidence`: at most 8 entries,
namespaces up to 64 bytes, values up to 1 KiB), plugin manifest field
18, host capability `peer_evidence.v1`. Relays forward the original
signed bytes, so older nodes pass evidence through unchanged. Older
plugins are unaffected.

## Validation

`mesh-llm-protocol` (15 tests), `mesh-llm-plugin` (98) and the full
`mesh-llm-host-runtime` suite (4,668 lib tests plus its integration
tests) pass, and Clippy with warnings denied is clean on the touched
crates. A two-host Moderato run with the Tempo plugin, on the revision
before the regossip on acceptance, showed no listing before the bond, a
listing about 3 seconds after it, paid inference, an early channel
close, and a bond exit with automatic withdrawal.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Providers can publish namespaced evidence in signed records. Hosts
with a configured verifier check it before including providers in
discovery, model availability, inference routing, or peer relaying.
* Verification results are cached and refreshed in the background.
Providers without accepted evidence may be excluded, while clients do
not require evidence. Inference requests are checked before dispatch.
* Evidence has size and quantity limits, and verifier configuration must
remain consistent across restarts.
* **Documentation**
* Added guidance on verifier setup, evidence publication, validation
limits, and where evidence checks apply.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: James Dumay <james@generalinference.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant