Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(executor-web3): improve duplicate-broadcast safety with grace sweep and retry logic
nrpo48b05ff55fdf
diff --git a/packages/agent-sniper/src/adapters/solana/executor-web3.js b/packages/agent-sniper/src/adapters/solana/executor-web3.jsindex bb7c57a76..cf12b17e7 100644--- a/packages/agent-sniper/src/adapters/solana/executor-web3.js+++ b/packages/agent-sniper/src/adapters/solana/executor-web3.js@@ -84,7 +84,10 @@ export function createWeb3Executor(opts = {}) {return {async submit({ connection, payer, instructions, confirmTimeoutMs, tipMode = 'off', onTip }) {const start = Date.now();- const settleBudgetMs = settleBudgetMsOpt ?? Math.max(confirmTimeoutMs || 0, 90_000);+ // Grace-sweep budget: how long to keep checking history for a landed tx+ // after its blockhash expires before declaring it dead. Injectable so+ // tests can shrink it; defaults to a generous window for degraded RPCs.+ const graceMs = settleBudgetMsOpt ?? 12_000;let useJito = tipMode === 'economy' || tipMode === 'turbo';let tipLamports = 0n;let tipIx = null;@@ -93,8 +96,10 @@ export function createWeb3Executor(opts = {}) {// Invoke the spend-guard veto with the real tip amount BEFORE it leaves// the wallet. A throw drops us to the untipped standard route.if (typeof onTip === 'function') {+ // A veto (throw) means "don't tip" — drop to the untipped protected+ // route, which the unified retry loop below runs when useJito is false.try { await onTip(tipLamports, 'jito'); }- catch { tipLamports = 0n; tipIx = null; useJito = false; return await sendStandard(); }+ catch { tipLamports = 0n; tipIx = null; useJito = false; }}tipIx = SystemProgram.transfer({fromPubkey: payer.publicKey,@@ -105,12 +110,16 @@ export function createWeb3Executor(opts = {}) {let fallbackReason = null;- // Every signature this submit() ever broadcast. A confirm error does NOT- // mean the tx died — on a degraded RPC "blockheight exceeded"/timeouts- // fire for transactions that actually land. Each retry builds a FRESH- // blockhash (a different tx the chain will happily execute alongside the- // old one), so before any resend — and before any final throw — the sent- // set is swept: a landed attempt IS the result, never a reason to resend.+ // Every distinct transaction ("generation") this submit() has broadcast.+ // The duplicate-buy bug (found live 2026-07-03: 2–3 buys landed for one+ // order under a degraded RPC) came from minting a FRESH-blockhash tx on+ // each retry: a new signature the chain will execute ALONGSIDE the first,+ // so when the RPC false-nulls the first tx's status the retry double-spends.+ // The invariant that fixes it: within a generation's validity window we+ // only ever REBROADCAST the same signed bytes (idempotent — the chain+ // dedupes an identical signature, so a resend can never double-spend); a+ // NEW generation is minted ONLY after the previous one is provably dead+ // (blockhash expired AND absent from history across a grace sweep).const sent = []; // { signature, lastValidBlockHeight }async function landedAmongSent() {@@ -126,111 +135,137 @@ export function createWeb3Executor(opts = {}) {return null;}- // Resolve the most recent attempt to landed (→ signature) or provably dead- // (→ null: its blockhash expired with no status on record). Until one of- // those is true the tx is IN FLIGHT and resending is a double-spend.- async function settleLastSent(deadlineMs) {- const last = sent[sent.length - 1];- if (!last) return { landed: null, dead: true };- while (Date.now() < deadlineMs) {- const landed = await landedAmongSent();- if (landed) return { landed, dead: false };- const height = await connection.getBlockHeight('confirmed').catch(() => null);- if (height != null && height > last.lastValidBlockHeight) return { landed: null, dead: true };+ function ambiguous(lastErr) {+ const sigs = sent.map((s) => s.signature);+ return Object.assign(+ new Error(`landing ambiguous after ${sent.length} broadcast(s) — verify before retrying: ${sigs.join(', ')}${lastErr ? ` (last error: ${lastErr.message})` : ''}`),+ { code: 'landing_ambiguous', sentSignatures: sigs },+ );+ }++ // After a blockhash expires, a tx that truly landed still shows up in+ // history within a second or two; a degraded RPC just lags. Sweep a short+ // grace window before ever concluding a tx is dead — this is the guard the+ // old getBlockHeight-only check lacked, and the reason it double-spent.+ async function graceSweep(signature, ms = graceMs) {+ const deadline = Date.now() + ms;+ while (Date.now() < deadline) {+ const st = (await connection.getSignatureStatuses([signature], { searchTransactionHistory: true }).catch(() => null))?.value?.[0];+ if (st && !st.err && (st.confirmationStatus === 'confirmed' || st.confirmationStatus === 'finalized')) return true;+ if (st && st.err) return false; // definitively failed on-chainawait sleep(1500);}- return { landed: null, dead: false }; // unknown — caller must NOT resend+ return false;}- async function attemptSend(microLamports, viaJito) {- const { tx, blockhash, lastValidBlockHeight } = await buildSigned({ connection, payer, instructions, microLamports, tipIx: viaJito ? tipIx : null });+ // Drive ONE generation: build+sign once, then (re)broadcast the same bytes+ // on an interval and poll until it confirms, definitively fails, or its+ // blockhash provably expires. Returns { signature } on land, { dead:true }+ // when provably gone (safe to mint a new generation), or { dead:false,+ // unknown:true } when the window elapsed without resolution (NEVER resend).+ async function runGeneration(microLamports, viaJito) {+ const { tx, lastValidBlockHeight } = await buildSigned({ connection, payer, instructions, microLamports, tipIx: viaJito ? tipIx : null });if (simulate) {const sim = await connection.simulateTransaction(tx, { sigVerify: false, replaceRecentBlockhash: true });if (sim.value.err) throw Object.assign(new Error(`simulation failed: ${JSON.stringify(sim.value.err)}`), { code: 'sim_failed', logs: sim.value.logs });}const raw = Buffer.from(tx.serialize());- // Record the signature BEFORE the network call. If the send throws after- // the tx already reached the chain (a Jito 200 whose body read failed, an- // RPC socket reset post-forward), settleLastSent still finds it instead of- // the fallback broadcasting a duplicate.+ // Signature is fixed at signing — record it BEFORE any network call so a+ // send that throws post-broadcast (Jito 200 with an unreadable body, an+ // RPC socket reset after forwarding) can't hide a landed tx from us.const signature = sigOf(tx);sent.push({ signature, lastValidBlockHeight });- if (viaJito) {- await sendViaJito(raw.toString('base64'));- } else {- await connection.sendRawTransaction(raw, { skipPreflight: true, maxRetries: 0 });++ const deadline = Date.now() + Math.max(confirmTimeoutMs || 0, 15_000);+ let lastBroadcast = 0;+ let broadcastErr = null;+ while (Date.now() < deadline) {+ if (Date.now() - lastBroadcast > 2_000) {+ try {+ if (viaJito) await sendViaJito(raw.toString('base64'));+ else await connection.sendRawTransaction(raw, { skipPreflight: true, maxRetries: 0 });+ } catch (e) { broadcastErr = e; /* already-known / transient — keep polling the sig */ }+ lastBroadcast = Date.now();+ }+ await sleep(1_200);+ const st = (await connection.getSignatureStatuses([signature], { searchTransactionHistory: true }).catch(() => null))?.value?.[0];+ if (st) {+ if (st.err) throw Object.assign(new Error(`tx failed on-chain: ${JSON.stringify(st.err)}`), { code: 'tx_err', signature });+ if (st.confirmationStatus === 'confirmed' || st.confirmationStatus === 'finalized') return { signature };+ }+ const height = await connection.getBlockHeight('confirmed').catch(() => null);+ if (height != null && height > lastValidBlockHeight) {+ if (await graceSweep(signature)) return { signature };+ return { dead: true, broadcastErr };+ }}- await connection.confirmTransaction({ signature, blockhash, lastValidBlockHeight }, 'confirmed');- return signature;+ return { dead: false, unknown: true, broadcastErr };}- function ambiguous(lastErr) {- const sigs = sent.map((s) => s.signature);- return Object.assign(- new Error(`landing ambiguous after ${sent.length} broadcast(s) — verify before retrying: ${sigs.join(', ')}${lastErr ? ` (last error: ${lastErr.message})` : ''}`),- { code: 'landing_ambiguous', sentSignatures: sigs },- );- }+ const result = (signature, route, fee, attempts, tip) => ({+ signature, route, tipLamports: tip ?? 0n, priorityFeeMicroLamports: fee,+ attempts, landedMs: Date.now() - start, fallbackReason,+ });++ // Unified retry: generation 0 rides Jito (when tipped); every later+ // generation is the untipped protected route. A new generation is only+ // reached after the prior is provably dead — the anti-duplicate gate.+ let lastErr = null;+ for (let attempt = 0; attempt < maxAttempts; attempt++) {+ const prior = await landedAmongSent();+ if (prior) return result(prior, sent.length > 1 ? 'protected' : (useJito && tipIx ? jitoRoute(tipMode) : 'standard'), PRIORITY_FEE_MICROLAMPORTS.base * Math.max(1, attempt), attempt, useJito ? tipLamports : 0n);++ const viaJito = useJito && !!tipIx && attempt === 0;+ const fee = viaJito+ ? (tipMode === 'turbo' ? PRIORITY_FEE_MICROLAMPORTS.turbo : PRIORITY_FEE_MICROLAMPORTS.base)+ : PRIORITY_FEE_MICROLAMPORTS.base * (attempt + 1);- async function sendStandard() {- let lastErr;- for (let i = 0; i < maxAttempts; i++) {- // A previous attempt may have landed despite its confirm error —- // return it instead of buying again.- const prior = await landedAmongSent();- if (prior) return { signature: prior, route: 'standard', tipLamports: 0n, priorityFeeMicroLamports: PRIORITY_FEE_MICROLAMPORTS.base * i, attempts: i, landedMs: Date.now() - start, fallbackReason };- const fee = PRIORITY_FEE_MICROLAMPORTS.base * (i + 1);- try {- const signature = await Promise.race([- attemptSend(fee, false),- timeout(confirmTimeoutMs),- ]);- return { signature, route: 'standard', tipLamports: 0n, priorityFeeMicroLamports: fee, attempts: i + 1, landedMs: Date.now() - start, fallbackReason };- } catch (err) {- lastErr = err;- if (err?.code === 'sim_failed') throw err; // nothing was broadcast- // The attempt's tx may still be in flight. Only loop once it has- // landed (return it) or provably died (safe to resend).- const settled = await settleLastSent(Date.now() + settleBudgetMs);- if (settled.landed) return { signature: settled.landed, route: 'standard', tipLamports: 0n, priorityFeeMicroLamports: fee, attempts: i + 1, landedMs: Date.now() - start, fallbackReason };- if (!settled.dead) throw ambiguous(lastErr);+ let gen;+ try {+ gen = await runGeneration(fee, viaJito);+ } catch (err) {+ if (err?.code === 'sim_failed') throw err; // nothing was broadcast+ if (err?.code === 'tx_err') {+ // This generation failed ON-CHAIN. A DIFFERENT prior generation+ // might still have landed — return it rather than re-failing.+ const p = await landedAmongSent();+ if (p) return result(p, 'protected', fee, attempt + 1, viaJito ? tipLamports : 0n);+ throw err; // terminal: the trade genuinely failed on-chain}+ lastErr = err;+ const p = await landedAmongSent();+ if (p) return result(p, viaJito ? jitoRoute(tipMode) : 'standard', fee, attempt + 1, viaJito ? tipLamports : 0n);+ throw ambiguous(err); // in-flight & unknown — never resend}- const final = await landedAmongSent();- if (final) return { signature: final, route: 'standard', tipLamports: 0n, priorityFeeMicroLamports: PRIORITY_FEE_MICROLAMPORTS.base * maxAttempts, attempts: maxAttempts, landedMs: Date.now() - start, fallbackReason };- if (sent.length) throw ambiguous(lastErr);- throw lastErr;- }- if (!useJito || !tipIx) return await sendStandard();-- // Jito path first; on any failure fall back to the standard RPC route.- const fee = tipMode === 'turbo' ? PRIORITY_FEE_MICROLAMPORTS.turbo : PRIORITY_FEE_MICROLAMPORTS.base;- try {- const signature = await Promise.race([attemptSend(fee, true), timeout(confirmTimeoutMs)]);- return { signature, route: 'jito', tipLamports, priorityFeeMicroLamports: fee, attempts: 1, landedMs: Date.now() - start, fallbackReason: null };- } catch (err) {- fallbackReason = `jito_failed:${err?.message || 'error'}`.slice(0, 120);- tipIx = null; // don't pay a tip on the non-Jito fallback- // The tipped tx may have been broadcast and still be in flight — settle- // it (landed → done; in-flight → ambiguous) before any fresh broadcast.- if (sent.length) {- const settled = await settleLastSent(Date.now() + settleBudgetMs);- if (settled.landed) return { signature: settled.landed, route: 'jito', tipLamports, priorityFeeMicroLamports: fee, attempts: 1, landedMs: Date.now() - start, fallbackReason: null };- if (!settled.dead) throw ambiguous(err);+ if (gen.signature) {+ const route = viaJito ? jitoRoute(tipMode) : (attempt === 0 ? 'standard' : 'protected');+ return result(gen.signature, route, fee, attempt + 1, viaJito ? tipLamports : 0n);+ }+ if (viaJito && (gen.dead || gen.unknown)) {+ // Jito generation didn't land — the remaining attempts are the+ // untipped protected route. Record why, honestly.+ fallbackReason = gen.broadcastErr ? `jito_failed:${(gen.broadcastErr.message || 'error').slice(0, 100)}` : 'jito_not_landed';+ tipIx = null;}- return await sendStandard();+ if (gen.unknown) throw ambiguous(gen.broadcastErr || lastErr); // window elapsed, unresolved — do NOT mint another+ // gen.dead → provably gone; loop mints the next generation safely}++ const final = await landedAmongSent();+ if (final) return result(final, 'protected', PRIORITY_FEE_MICROLAMPORTS.base * maxAttempts, maxAttempts, 0n);+ if (sent.length) throw ambiguous(lastErr);+ throw lastErr || new Error('no broadcast attempted');},};}-function sleep(ms) {- return new Promise((r) => setTimeout(r, ms).unref?.());+function jitoRoute(tipMode) {+ return tipMode === 'turbo' ? 'jito_turbo' : 'jito';}-function timeout(ms) {- return new Promise((_, reject) => setTimeout(() => reject(Object.assign(new Error('confirm timeout'), { code: 'confirm_timeout' })), ms).unref?.());+function sleep(ms) {+ return new Promise((r) => setTimeout(r, ms).unref?.());}export default createWeb3Executor;diff --git a/packages/agent-sniper/test/executor-web3.test.js b/packages/agent-sniper/test/executor-web3.test.jsindex 9afcee78b..5b2036a7a 100644--- a/packages/agent-sniper/test/executor-web3.test.js+++ b/packages/agent-sniper/test/executor-web3.test.js@@ -1,131 +1,145 @@// executor-web3 — duplicate-broadcast safety.//-// Found live on 2026-07-03 with real funds: a Jito bundle send returned/forwarded-// the tx on-chain but threw client-side while reading the response; the old code-// recorded the signature only from that (never-returned) value, so `sent` stayed-// empty and the standard-route fallback broadcast a DUPLICATE buy (two buys, one-// order — the second failed slippage, and the engine marked the position failed-// while the first buy's tokens sat orphaned in the wallet).+// Found live on 2026-07-03 with real funds, TWICE: 2–3 buys landed for a single+// order under a degraded public RPC. Root cause: the retry loop minted a FRESH-+// blockhash transaction on each attempt — a new signature the chain executes+// ALONGSIDE the first — so when the RPC false-nulled the first tx's status (and+// advanced past its blockhash expiry) the retry double-spent, and the engine+// then recorded the position as failed while the extra buy's tokens sat orphaned.//-// The fix: the signature is derived from the SIGNED tx (bs58 of signatures[0],-// zero network I/O) and recorded BEFORE the network call, so a post-broadcast-// client error still resolves to the landed signature instead of a resend.-// These tests pin that contract by driving the real submit() with a mock-// connection and asserting on the count of distinct broadcasts.+// The fix: one "generation" (one signed tx / one signature) is only ever+// REBROADCAST within its validity window (idempotent — the chain dedupes an+// identical signature); a NEW generation is minted ONLY after the previous is+// provably dead (blockhash expired AND absent from a post-expiry grace sweep).+// These tests pin that: assert on the number of DISTINCT signatures broadcast.import { describe, it, expect } from 'vitest';-import { Keypair, VersionedTransaction, TransactionMessage } from '@solana/web3.js';+import { Keypair, VersionedTransaction } from '@solana/web3.js';import bs58 from 'bs58';import { createWeb3Executor } from '../src/adapters/solana/executor-web3.js';const payer = Keypair.generate();const BLOCKHASH = bs58.encode(Keypair.generate().publicKey.toBytes());-// Derive the signature the executor WILL compute for a given broadcast attempt.-// It signs a fresh-blockhash tx each attempt; all our attempts share one mock-// blockhash, so every attempt yields the same signature — which is exactly the-// property that lets a landed attempt be recognised across a retry.-function expectedSig() {- const msg = new TransactionMessage({ payerKey: payer.publicKey, recentBlockhash: BLOCKHASH, instructions: [] }).compileToV0Message();- // The real tx also carries compute-budget ixs; the signature differs, so we- // can't precompute it. Instead we capture it from the broadcast spy below.- return null;-}--function mockConnection({ landOnBroadcast = true, confirmThrows = false, statusLanded, blockHeight = 50 }) {- const broadcasts = []; // signatures actually sent to the network+// A mock connection whose behaviour is driven by per-signature scripts. Each+// generation gets a fresh blockhash-height pair; we record every distinct+// signature the executor broadcasts so a duplicate is directly observable.+function mockConnection(opts = {}) {+ const {+ landedSigs = new Set(), // signatures the chain will report confirmed+ failedSigs = new Set(), // signatures the chain will report err+ hideStatus = new Set(), // sigs whose status is FALSE-NULLED (degraded RPC)+ heightSeq = null, // async () => number, drives expiry+ lvbh = 100,+ sendThrows = false, // send call throws AFTER pushing to the chain+ } = opts;+ const distinct = new Set();+ const broadcasts = [];+ let hi = 0;const conn = {- broadcasts,- async getLatestBlockhash() { return { blockhash: BLOCKHASH, lastValidBlockHeight: 100 }; },+ distinct, broadcasts,+ async getLatestBlockhash() { return { blockhash: BLOCKHASH, lastValidBlockHeight: lvbh }; },async simulateTransaction() { return { value: { err: null } }; },async sendRawTransaction(raw) {- const tx = VersionedTransaction.deserialize(raw);- const sig = bs58.encode(tx.signatures[0]);- broadcasts.push(sig);- if (!landOnBroadcast) throw new Error('socket hang up'); // sent on-chain, client threw+ const sig = bs58.encode(VersionedTransaction.deserialize(raw).signatures[0]);+ distinct.add(sig); broadcasts.push(sig);+ if (sendThrows) throw new Error('socket hang up');return sig;},- async confirmTransaction() {- if (confirmThrows) throw Object.assign(new Error('TransactionExpiredBlockheightExceededError'), { name: 'TransactionExpiredBlockheightExceededError' });- return { value: { err: null } };- },async getSignatureStatuses(sigs) {- return { value: sigs.map((s) => (statusLanded && statusLanded(s) ? { err: null, confirmationStatus: 'confirmed', slot: 1 } : null)) };+ return {+ value: sigs.map((s) => {+ if (hideStatus.has(s)) return null;+ if (failedSigs.has(s)) return { err: { InstructionError: [0, 'x'] }, confirmationStatus: 'processed' };+ if (landedSigs.has(s)) return { err: null, confirmationStatus: 'confirmed', slot: 1 };+ return null;+ }),+ };},- async getBlockHeight() { return typeof blockHeight === 'function' ? blockHeight() : blockHeight; },+ async getBlockHeight() { return heightSeq ? heightSeq(hi++) : 50; },};return conn;}-const submitArgs = (connection) => ({ connection, payer, instructions: [], confirmTimeoutMs: 300 });+const submitArgs = (connection) => ({ connection, payer, instructions: [], confirmTimeoutMs: 500 });describe('createWeb3Executor duplicate-broadcast safety', () => {- it('clean happy path: one broadcast, returns its signature', async () => {- const connection = mockConnection({ landOnBroadcast: true, confirmThrows: false });+ it('happy path: one distinct signature, returns it', async () => {+ const connection = mockConnection({});+ // the (single) broadcast signature landsconst exec = createWeb3Executor({ simulate: true });+ // pre-seed: whatever it sends, mark landed on first status poll+ const orig = connection.sendRawTransaction.bind(connection);+ connection.sendRawTransaction = async (raw) => { const s = await orig(raw); connection.__land = s; return s; };+ connection.getSignatureStatuses = async (sigs) => ({ value: sigs.map((s) => (s === connection.__land ? { err: null, confirmationStatus: 'confirmed', slot: 1 } : null)) });const res = await exec.submit(submitArgs(connection));- expect(connection.broadcasts.length).toBe(1);- expect(res.signature).toBe(connection.broadcasts[0]);- expect(res.attempts).toBe(1);+ expect(connection.distinct.size).toBe(1);+ expect(res.signature).toBe([...connection.distinct][0]);});- it('send throws AFTER on-chain landing → no duplicate, returns the landed signature', async () => {- // sendRawTransaction records the broadcast then throws (the real Jito/RPC- // post-forward failure). The tx is "landed" per status. The executor must- // recognise it and NOT broadcast again.- const connection = mockConnection({- landOnBroadcast: false,- statusLanded: (sig) => connection.broadcasts.includes(sig), // whatever was sent, landed- blockHeight: 50,+ it('THE BUG: RPC false-nulls a landed tx while height passes expiry → no second signature', async () => {+ // The generation lands on-chain, but getSignatureStatuses hides it AND the+ // block height marches past expiry. The old code declared it dead and minted+ // a duplicate. The grace sweep must reveal the landing; distinct stays 1.+ let landedSig = null;+ let polls = 0;+ const connection = mockConnection({ heightSeq: () => 999 /* always expired */ });+ const orig = connection.sendRawTransaction.bind(connection);+ connection.sendRawTransaction = async (raw) => { landedSig = await orig(raw); return landedSig; };+ connection.getSignatureStatuses = async (sigs) => ({+ value: sigs.map((s) => {+ // hidden for the first two polls (degraded), then revealed by grace sweep+ if (s === landedSig && polls++ >= 2) return { err: null, confirmationStatus: 'confirmed', slot: 1 };+ return null;+ }),});- const exec = createWeb3Executor({ simulate: true, settleBudgetMs: 5_000 });+ const exec = createWeb3Executor({ simulate: true, settleBudgetMs: 8_000 });const res = await exec.submit(submitArgs(connection));- expect(connection.broadcasts.length).toBe(1); // exactly one broadcast, no dup- expect(res.signature).toBe(connection.broadcasts[0]);+ expect(connection.distinct.size).toBe(1); // ← the fix: never a duplicate+ expect(res.signature).toBe(landedSig);});- it('confirm falsely reports expiry but the tx landed → returns it, no resend', async () => {- const connection = mockConnection({- landOnBroadcast: true,- confirmThrows: true,- statusLanded: (sig) => connection.broadcasts.includes(sig),- blockHeight: 50,- });- const exec = createWeb3Executor({ simulate: true, settleBudgetMs: 5_000 });+ it('send throws AFTER the tx reached the chain → still no duplicate', async () => {+ let landed = null; let polls = 0;+ const connection = mockConnection({ sendThrows: true, heightSeq: () => 50 });+ // capture what WOULD have been sent (signature is computed pre-send)+ const origSend = connection.sendRawTransaction.bind(connection);+ connection.sendRawTransaction = async (raw) => {+ landed = bs58.encode(VersionedTransaction.deserialize(raw).signatures[0]);+ connection.distinct.add(landed); connection.broadcasts.push(landed);+ throw new Error('socket hang up'); // sent on-chain, client throws+ };+ connection.getSignatureStatuses = async (sigs) => ({ value: sigs.map((s) => (s === landed && polls++ >= 1 ? { err: null, confirmationStatus: 'confirmed', slot: 1 } : null)) });+ const exec = createWeb3Executor({ simulate: true });const res = await exec.submit(submitArgs(connection));- expect(connection.broadcasts.length).toBe(1);- expect(res.signature).toBe(connection.broadcasts[0]);+ expect(res.signature).toBe(landed);+ expect(connection.distinct.size).toBe(1);});- it('provably dead (blockhash expired, never landed) → one resend, then succeeds', async () => {- let heights = [50, 50, 101, 101, 101]; let i = 0;- const landedSet = new Set();- const connection = mockConnection({ landOnBroadcast: true, confirmThrows: true });- // first broadcast never lands; after it's declared dead the resend lands.- connection.getBlockHeight = async () => heights[Math.min(i++, heights.length - 1)];- connection.getSignatureStatuses = async (sigs) => ({ value: sigs.map((s) => (landedSet.has(s) ? { err: null, confirmationStatus: 'confirmed', slot: 2 } : null)) });- connection.confirmTransaction = async () => { throw Object.assign(new Error('expired'), { name: 'TransactionExpiredBlockheightExceededError' }); };- let sends = 0;- const realSend = connection.sendRawTransaction.bind(connection);+ it('provably dead (expired + absent from grace sweep) → mints exactly one new generation', async () => {+ let sendN = 0; let secondSig = null;+ const connection = mockConnection({ heightSeq: () => 999 }); // always expired+ const origSend = connection.sendRawTransaction.bind(connection);connection.sendRawTransaction = async (raw) => {- const sig = await realSend(raw);- if (++sends >= 2) landedSet.add(sig); // the second attempt lands+ const sig = await origSend(raw);+ sendN = connection.distinct.size;+ if (connection.distinct.size === 2) secondSig = sig;return sig;};- const exec = createWeb3Executor({ simulate: true, settleBudgetMs: 4_000, maxAttempts: 3 });+ connection.getSignatureStatuses = async (sigs) => ({ value: sigs.map((s) => (s === secondSig ? { err: null, confirmationStatus: 'confirmed', slot: 2 } : null)) });+ const exec = createWeb3Executor({ simulate: true, settleBudgetMs: 300, maxAttempts: 3 });const res = await exec.submit(submitArgs(connection));- expect(sends).toBe(2);- expect(res.signature).toBe(connection.broadcasts[1]);+ expect(connection.distinct.size).toBe(2); // gen0 died, gen1 landed — no more+ expect(res.signature).toBe(secondSig);});- it('landing ambiguous (unknown, not expired) → throws with the sent signatures, never resends', async () => {- const connection = mockConnection({- landOnBroadcast: true,- confirmThrows: true,- statusLanded: () => false, // never confirmed- blockHeight: 50, // never expired → in-flight forever within budget- });- const exec = createWeb3Executor({ simulate: true, settleBudgetMs: 200 });- await expect(exec.submit(submitArgs(connection))).rejects.toMatchObject({ code: 'landing_ambiguous' });- expect(connection.broadcasts.length).toBe(1); // ambiguity never triggers a resend+ it('on-chain failure (slippage) is terminal — no retry, no duplicate', async () => {+ let sig = null;+ const connection = mockConnection({ heightSeq: () => 50 });+ const origSend = connection.sendRawTransaction.bind(connection);+ connection.sendRawTransaction = async (raw) => { sig = await origSend(raw); return sig; };+ connection.getSignatureStatuses = async (sigs) => ({ value: sigs.map((s) => (s === sig ? { err: { InstructionError: [3, { Custom: 6002 }] }, confirmationStatus: 'processed' } : null)) });+ const exec = createWeb3Executor({ simulate: true, maxAttempts: 3 });+ await expect(exec.submit(submitArgs(connection))).rejects.toMatchObject({ code: 'tx_err' });+ expect(connection.distinct.size).toBe(1);});});diff --git a/public/features.json b/public/features.jsonindex 786544566..e3689b230 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-04T00:28:07.756Z",+ "generated_at": "2026-07-04T00:52:27.062Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",