Repository navigation
Add the Tempo OUSD payments and bonds plugin - #1
Draft
joostjager wants to merge 1 commit into
Draft
joostjager wants to merge 1 commit into
joostjager wants to merge 1 commit into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
joostjager
force-pushed
the
tempo-plugin
branch
8 times, most recently
from
November 26, 2026 11:03
8f10ce9 to
e9aba8d
Compare
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.
joostjager
force-pushed
the
tempo-plugin
branch
from
November 26, 2026 13:41
e9aba8d to
4f75c9b
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_lockand gets it back withbond_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:
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+.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:
In the buyer's two terminals, the same with
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.tomlneeds no plugin entry, and serve a small model:$TEMPO wallet init$MESH serve --model Qwen3-0.6BAfter 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:
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 client --join INVITE_TOKEN --port 9338 --console 3132Buyer commands. Get test coins and turn on paid buying with a daily budget.
--port 3132addresses the buyer's node: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":
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:
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:
4. The buyer closes the channel
Buyer commands. Close the channel now instead of waiting for it to go idle:
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:
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:Stop both nodes with Ctrl-C.