feat(tempo): TIP-1034 precompile support#442
Draft
0xrusowsky wants to merge 26 commits into
Draft
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
4d86912 to
201f931
Compare
201f931 to
bea3fb3
Compare
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.
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 legacytempo.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.
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.
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_URLis also propagated into both the HTTP transport and chain metadata, so targeted devnet runs can be invoked with:Reviewer notes
scoped as a PoC for testing the new TIP-1034 precompile through the
mppxsession model. without accounting for tests ~3.4k LOCsuggested review order:
src/tempo/precompile/Types.tssrc/tempo/precompile/Channel.tssrc/tempo/precompile/Voucher.tssrc/tempo/precompile/Chain.tssrc/tempo/precompile/client/ChannelOps.tssrc/tempo/precompile/session/Client.tssrc/tempo/precompile/server/Session.tssrc/tempo/session/ChannelStore.tssrc/tempo/precompile/**/*.integration.test.ts