Skip to content

fix(tempo): coordinate owner approvals over http to a relay - #5672

Merged
jxom merged 1 commit into
mainfrom
fix/tempo-http-relay-owner-approvals
Nov 26, 2026
Merged

jxom merged 1 commit into
mainfrom
fix/tempo-http-relay-owner-approvals

Conversation

@jxom

@jxom jxom commented Nov 26, 2026

Copy link
Copy Markdown
Member

Summary

Owner-approved Tempo sends now coordinate through any transport that serves the account_* methods, not only withRelay. A plain http(...) transport pointed at a relay with Relay.accounts (for example https://api.tempo.xyz/rpc/sponsor) now stores pending approvals on a random nonce lane and loads missing configs from the relay, the same as withRelay.

Problem

src/tempo/chainConfig.ts only treated an owner-approved send as coordinated when client.transport.accounts === true, which only withRelay sets. Over plain http to a relay:

  • The pending approval was stored on protocol nonce key 0, so a second pending operation for the same account failed on completion with Nonce provided for the transaction is lower than the current nonce of the account.
  • An address-only Account.fromConfig(address) threw An account config is required to prepare a transaction. even though the relay holds the config.

Fix

When owner is passed and the transport does not advertise accounts, Viem probes account_getConfig once per transport. A successful answer (a config or null) means the transport serves the account methods, so the send is coordinated. MethodNotFound/MethodNotSupported means it does not, and Viem keeps the previous behavior (nonce key 0, config required). Only definitive answers are cached; other errors fall back to the previous behavior for that call and are probed again next time. Sends without owner make no extra request. withRelay short-circuits on its accounts flag, so it behaves exactly as before.

I chose detection over "always use a random nonce lane when owner is passed" because owners submitting a full quorum straight to a node would otherwise pay for a new nonce key on every send, and the missing-config case needs the relay anyway.

Repro and proof

Tempo testnet (42431), a local Relay.create server with Relay.accounts and Relay.feePayer, a 2-of-2 configurable account. Create two pending owner-approved operations, then complete both (two.ts):

first second
http(relay), before success Nonce provided for the transaction is lower than the current nonce of the account.
http(relay), after success success
withRelay(http(), http(relay)), after success success

(Before: reproduced on 2 of 2 runs. One unrelated run timed out on testnet latency in each configuration.)

two.ts
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
import { Account, createClient, http, Relay, Store, withRelay } from 'viem/tempo'

const mode = process.argv[2] ?? 'http'
const feePayer = privateKeyToAccount(generatePrivateKey())
await createClient({ testnet: true }).request({ method: 'tempo_fundAddress' as never, params: [feePayer.address] as never })

const relay = Relay.create({
  client: createClient({ testnet: true }),
  plugins: [Relay.accounts({ store: Store.memory() }), Relay.feePayer({ account: feePayer })],
})
const server = Bun.serve({ fetch: relay.fetch, port: 0 })
const url = `http://localhost:${server.port}`
const client = createClient({ testnet: true, transport: mode === 'http' ? http(url) : withRelay(http(), http(url)) })

const owner_1 = Account.fromSecp256k1(generatePrivateKey())
const owner_2 = Account.fromSecp256k1(generatePrivateKey())
const account = Account.fromConfig({ owners: [owner_1.address, owner_2.address], threshold: 2 })

async function start(data: `0x${string}`) {
  const pending = await client.sendTransactionSync({
    account, calls: [{ data, to: '0xcafebabecafebabecafebabecafebabecafebabe' }], feePayer: true, owner: owner_1,
  } as never)
  return (pending as { transactionHash: `0x${string}` }).transactionHash
}
async function finish(hash: `0x${string}`) {
  try {
    const receipt = await client.sendTransactionSync({ account, hash, owner: owner_2 } as never)
    return (receipt as { status: string }).status
  } catch (error) {
    return 'ERROR ' + (error as Error).message.split('\n')[0]
  }
}

const a = await start('0xdeadbeef')
const b = await start('0xbeefdead')
console.log(mode, 'first:', await finish(a))
console.log(mode, 'second:', await finish(b))
server.stop()
process.exit(0)

Tests

  • New e2e test coordinates pending operations through an http transport to a Fetch relay: plain http to a Relay.create Fetch server, two pending operations (the second from an address-only account), asserts distinct non-zero nonce keys and that both complete. Fails without the fix (An account config is required to prepare a transaction.).
  • The existing address requires a config test still passes against a plain node transport, covering the fallback when the probe gets MethodNotFound.
  • pnpm test --project tempo --run on e2e.accounts, chainConfig.accounts, chainConfig, Transport, actions/accessKey, Account.accounts, Relay: all pass. tsc -b: clean.

Docs

  • Relay connect guide: new "Send All Requests to a Relay" recipe.
  • Account.fromConfig and createClient docs no longer imply only withRelay coordinates.

@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
viem Error Error Nov 26, 2026 5:56am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 036175d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T05:54:50.935422Z 036175d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jxom
jxom enabled auto-merge (squash) November 26, 2026 05:56
@jxom
jxom disabled auto-merge November 26, 2026 05:56
@jxom
jxom merged commit 64aef96 into main Nov 26, 2026
39 of 40 checks passed
@jxom
jxom deleted the fix/tempo-http-relay-owner-approvals branch November 26, 2026 05:56

This branch had an error being deployed

1 failed deployment
Preview — 036175d4 Deployed Nov 26, 2026 by vercel[bot]
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.

2 participants