Skip to content

Commit f96810e

Browse files
authored
fix: Disable json rpc batching in viem http transports (#19073)
We are getting sporadic `Transaction creation failed` in next. These are produced by viem when the execution client returns a -32003 error code, which geth produces only when the size of a batch response exceeds a threshold. Under the hood, viem defaults to batching requests. So if we disable batching altogether, maybe we stop seeing this error. Worth a try.
2 parents 598d440 + 8ef7ab4 commit f96810e

File tree

22 files changed

+37
-32
lines changed

22 files changed

+37
-32
lines changed

yarn-project/archiver/src/archiver/archiver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,15 @@ export class Archiver
230230
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
231231
const publicClient = createPublicClient({
232232
chain: chain.chainInfo,
233-
transport: fallback(config.l1RpcUrls.map(url => http(url))),
233+
transport: fallback(config.l1RpcUrls.map(url => http(url, { batch: false }))),
234234
pollingInterval: config.viemPollingIntervalMS,
235235
});
236236

237237
// Create debug client using debug RPC URLs if available, otherwise fall back to regular RPC URLs
238238
const debugRpcUrls = config.l1DebugRpcUrls.length > 0 ? config.l1DebugRpcUrls : config.l1RpcUrls;
239239
const debugClient = createPublicClient({
240240
chain: chain.chainInfo,
241-
transport: fallback(debugRpcUrls.map(url => http(url))),
241+
transport: fallback(debugRpcUrls.map(url => http(url, { batch: false }))),
242242
pollingInterval: config.viemPollingIntervalMS,
243243
}) as ViemPublicDebugClient;
244244

yarn-project/archiver/src/archiver/l1/bin/retrieve-calldata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ async function main() {
7676
// Create viem public client
7777
const publicClient = createPublicClient({
7878
chain: mainnet,
79-
transport: http(rpcUrl),
79+
transport: http(rpcUrl, { batch: false }),
8080
});
8181

8282
logger.info('Fetching transaction...');

yarn-project/aztec-node/src/aztec-node/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
242242

243243
const publicClient = createPublicClient({
244244
chain: ethereumChain.chainInfo,
245-
transport: fallback(config.l1RpcUrls.map((url: string) => http(url))),
245+
transport: fallback(config.l1RpcUrls.map((url: string) => http(url, { batch: false }))),
246246
pollingInterval: config.viemPollingIntervalMS,
247247
});
248248

yarn-project/blob-client/src/client/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ export class HttpBlobClient implements BlobClientInterface {
504504
// Ping execution node to get the parentBeaconBlockRoot for this block
505505
let parentBeaconBlockRoot: string | undefined;
506506
const client = createPublicClient({
507-
transport: fallback(l1RpcUrls.map(url => http(url))),
507+
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
508508
});
509509
try {
510510
const res: RpcBlock = await client.request({

yarn-project/cli/src/cmds/infrastructure/sequencers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ export async function sequencers(opts: {
2626
const chain = createEthereumChain(l1RpcUrls, chainId);
2727
const publicClient = createPublicClient({
2828
chain: chain.chainInfo,
29-
transport: fallback(l1RpcUrls.map(url => http(url))),
29+
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
3030
});
3131

3232
const walletClient = mnemonic
3333
? createWalletClient({
3434
account: mnemonicToAccount(mnemonic),
3535
chain: chain.chainInfo,
36-
transport: fallback(l1RpcUrls.map(url => http(url))),
36+
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
3737
})
3838
: undefined;
3939

yarn-project/cli/src/cmds/l1/get_l1_addresses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function getL1Addresses(
1717
const chain = createEthereumChain(rpcUrls, chainId);
1818
const publicClient: ViemPublicClient = createPublicClient({
1919
chain: chain.chainInfo,
20-
transport: fallback(rpcUrls.map(url => http(url))),
20+
transport: fallback(rpcUrls.map(url => http(url, { batch: false }))),
2121
pollingInterval: 100,
2222
});
2323
const addresses = await RegistryContract.collectAddresses(publicClient, registryAddress.toString(), rollupVersion);

yarn-project/cli/src/cmds/l1/get_l1_balance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function getL1Balance(
1818
const chain = createEthereumChain(l1RpcUrls, chainId);
1919
const publicClient = createPublicClient({
2020
chain: chain.chainInfo,
21-
transport: fallback(l1RpcUrls.map(url => http(url))),
21+
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
2222
});
2323

2424
let balance = 0n;

yarn-project/cli/src/cmds/l1/prover_stats.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export async function proverStats(opts: {
4747
.then(a => a.rollupAddress);
4848

4949
const chain = createEthereumChain(l1RpcUrls, chainId).chainInfo;
50-
const publicClient = createPublicClient({ chain, transport: fallback(l1RpcUrls.map(url => http(url))) });
50+
const publicClient = createPublicClient({
51+
chain,
52+
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
53+
});
5154
const lastBlockNum = endBlock ?? (await publicClient.getBlockNumber());
5255
debugLog.verbose(`Querying events on rollup at ${rollup.toString()} from ${startBlock} up to ${lastBlockNum}`);
5356

yarn-project/cli/src/cmds/validator_keys/new.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export async function newValidatorKeystore(options: NewValidatorKeystoreOptions,
135135
const chain = createEthereumChain(l1RpcUrls, l1ChainId);
136136
const publicClient = createPublicClient({
137137
chain: chain.chainInfo,
138-
transport: fallback(l1RpcUrls.map(url => http(url))),
138+
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
139139
});
140140
const gse = new GSEContract(publicClient, gseAddress);
141141

yarn-project/cli/src/cmds/validator_keys/staker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export async function generateStakerJson(options: StakerOptions, log: LogFn): Pr
273273
const chain = createEthereumChain(l1RpcUrls, l1ChainId);
274274
const publicClient = createPublicClient({
275275
chain: chain.chainInfo,
276-
transport: fallback(l1RpcUrls.map(url => http(url))),
276+
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
277277
});
278278
const gse = new GSEContract(publicClient, gseAddress);
279279

0 commit comments

Comments
 (0)