Skip to content

feat(tempo): TIP-1034 precompile support#442

Draft
0xrusowsky wants to merge 26 commits into
wevm:mainfrom
0xrusowsky:rus/tempo-precompile
Draft

feat(tempo): TIP-1034 precompile support#442
0xrusowsky wants to merge 26 commits into
wevm:mainfrom
0xrusowsky:rus/tempo-precompile

Conversation

@0xrusowsky
Copy link
Copy Markdown

@0xrusowsky 0xrusowsky commented May 14, 2026

Motivation

this PR adds an opt-in Tempo TIP-1034 precompile-backed session implementation as a PoC for exercising and validating the new payment-channel precompile from mppx. It does so in an add-only approach, preserving the legacy tempo.session(...) backend unchanged.

Solution

the new implementation keeps the same session lifecycle as the legacy backend: clients open or reuse channels, submit vouchers as session credentials, and servers verify those vouchers, track accepted spend, and eventually settle or close on-chain.

the goal was parity with the legacy implementation while minimizing divergences. To that end, it reuses existing session store concepts, keeps receipt semantics and channel bookkeeping aligned, and only adds TIP-1034-specific state where required, such as channel descriptors and on-chain channel state.

TIP-1034 precompile primitives

the precompile path includes the same general-purpose session helpers as the legacy backend, such as voucher signing/verification, credential parsing, client credential creation, and channel state management.

it also adds the primitives needed specifically for TIP-1034 channels: computing precompile channel IDs and expiring nonce hashes, encoding precompile calldata, persisting and validating channel descriptors, reading channel state from the precompile, and broadcasting precompile management transactions for open, top-up, settle, request-close, withdraw, and close.

Client-side opt-in API

added a client-side session method that follows the same credential lifecycle as the legacy client while backing channel management with TIP-1034 precompile channels. The client can open or reuse a session channel, top it up when needed, create voucher credentials during the session, and create close credentials when the session is finalized. Tracks channel descriptors so credentials can be bound to the corresponding TIP-1034 channel.

import { Mppx, tempo } from 'mppx/client'

const client = Mppx.create({ methods: [tempo.precompile.session({ account, maxDeposit: '10' })] })

Server-side opt-in API

a server-side session method that follows the same verification and receipt flow as the legacy server while validating credentials against TIP-1034 descriptors and on-chain precompile state. The server verifies open, top-up, voucher, and close credentials; persists the precompile channel descriptor. Keeps stored channel state aligned with emitted events and on-chain state; rejects stale, closed, underfunded, or invalid voucher states; and returns normal session receipts for accepted credentials.

import { Mppx, tempo } from 'mppx/server'

const server = Mppx.create({ methods: [ tempo.precompile.Server.session(
   { amount: '1', chainId, currency, recipient, store, unitType: 'request' }
)]})

it also includes server-driven settlement and close helpers, including fee-payer/fee-token support where applicable; settlement reads the highest accepted voucher from storage and submits the corresponding precompile transaction.

Testing

integration tests can now run against either localnet or devnet. In devnet mode, the test setup uses the same deterministic mnemonic as localnet, funds the required accounts through the Tempo faucet, and locks setup across workers to avoid concurrent faucet/setup races.

VITE_RPC_URL is also propagated into both the HTTP transport and chain metadata, so targeted devnet runs can be invoked with:

VITE_NODE_ENV=devnet VITE_RPC_URL=<devnet-rpc-url> \
pnpm exec vp test src/tempo/precompile/Chain.integration.test.ts src/tempo/precompile/server/Session.integration.test.ts

Reviewer notes

scoped as a PoC for testing the new TIP-1034 precompile through the mppx session model. without accounting for tests ~3.4k LOC

suggested review order:

  1. src/tempo/precompile/Types.ts
  2. src/tempo/precompile/Channel.ts
  3. src/tempo/precompile/Voucher.ts
  4. src/tempo/precompile/Chain.ts
  5. src/tempo/precompile/client/ChannelOps.ts
  6. src/tempo/precompile/session/Client.ts
  7. src/tempo/precompile/server/Session.ts
  8. src/tempo/session/ChannelStore.ts
  9. integration tests under src/tempo/precompile/**/*.integration.test.ts

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 14, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedox@​0.14.18 ⏵ 0.14.209710099 +197 +2100

View full report

@0xrusowsky 0xrusowsky force-pushed the rus/tempo-precompile branch from 4d86912 to 201f931 Compare May 14, 2026 14:29
@0xrusowsky 0xrusowsky force-pushed the rus/tempo-precompile branch from 201f931 to bea3fb3 Compare May 14, 2026 14:29
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