Skip to content

Commit 73b1e26

Browse files
authored
fix(ccip-gateway): Disable Ethers provider cache to allow parallel linea_getProof requests (#301)
1 parent c0097fe commit 73b1e26

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

packages/linea-ccip-gateway/src/evm-gateway/EVMProofHelper.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ export class EVMProofHelper {
5454

5555
/**
5656
* @dev Fetches a set of proofs for the requested state slots.
57-
* @param blockNo A `ProvableBlock`'s number returned by `getProvableBlock`.
58-
* @param address The address of the contract to fetch data from.
59-
* @param slots An array of slots to fetch data for.
60-
* @returns A proof of the given slots, encoded in a manner that this service's
61-
* corresponding decoding library will understand.
57+
*
58+
* Since `FallbackProvider` does not support sending custom RPC requests directly,
59+
* we manually iterate over its underlying providers (which are `JsonRpcProvider` instances).
60+
*
61+
* @param blockNo The block number from which to retrieve the state proof.
62+
* @param address The contract address for which the proof is requested.
63+
* @param slots An array of storage slots to fetch proofs for.
64+
* @returns A `StateProof` object containing the proof data for the given slots.
6265
*/
6366
async getProofs(
6467
blockNo: number,
@@ -73,13 +76,12 @@ export class EVMProofHelper {
7376

7477
logInfo('Calling linea_getProof with args', args);
7578

76-
// We have to reinitialize the provider L2 because of an issue when multiple
77-
// requests are sent at the same time, the provider becomes unaware of
78-
// the linea_getProof method
79-
79+
// `FallbackProvider` does not allow direct custom RPC calls.
80+
// Instead, we iterate over its configured providers and send the request manually.
8081
const providerConfigs = this.providerL2.providerConfigs;
8182

8283
for (const config of providerConfigs) {
84+
// Extract the underlying provider, which is a `JsonRpcProvider`
8385
// @ts-expect-error - We know this is a JsonRpcProvider
8486
const provider: JsonRpcProvider = config.provider;
8587

packages/linea-ccip-gateway/src/server.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ function createFallbackProvider(
3939
{
4040
provider: new JsonRpcProvider(primaryUrl, chainId, {
4141
staticNetwork: true,
42+
batchMaxCount: 1,
43+
cacheTimeout: -1,
44+
polling: false,
45+
batchStallTime: 0,
4246
}),
4347
polling: false,
4448
stallTimeout: PRIMARY_PROVIDER_TIMEOUT,
@@ -51,6 +55,10 @@ function createFallbackProvider(
5155
providers.push({
5256
provider: new JsonRpcProvider(fallbackUrl, chainId, {
5357
staticNetwork: true,
58+
batchMaxCount: 1,
59+
cacheTimeout: -1,
60+
polling: false,
61+
batchStallTime: 0,
5462
}),
5563
polling: false,
5664
stallTimeout: FALLBACK_PROVIDER_TIMEOUT,

0 commit comments

Comments
 (0)