Skip to content

fix: Try to lessen Linea finalizer RPC burden#1740

Closed
pxrl wants to merge 1 commit intomasterfrom
pxrl/lineaFinalizer
Closed

fix: Try to lessen Linea finalizer RPC burden#1740
pxrl wants to merge 1 commit intomasterfrom
pxrl/lineaFinalizer

Conversation

@pxrl
Copy link
Copy Markdown
Collaborator

@pxrl pxrl commented Aug 9, 2024

The Linea SDK implements some unfortunate RPC queries that are not well-suited to being called in parallel. This seems to be resulting in errors being returned by upstream RPC providers. Serialise some queries, with a longer delay on retry, in order to try to lessen the load and reduce the error rate. This will inevitably lead to a longer execution time, but might help to save the bot from throwing.

The Linea SDK implements some unfortunate RPC queries that are not
well-suited to being called in parallel. This seems to be resulting in
errors being returned by upstream RPC providers. Serialise some queries,
with a longer delay on retry, in order to try to lessen the load and
reduce the error rate. This will inevitably lead to a longer execution
time, but might help to save the bot from throwing.
@pxrl pxrl requested a review from bmzig August 9, 2024 20:42
@james-a-morris
Copy link
Copy Markdown
Contributor

Side thought: we can just override the rpc provider that is set in the constructor. Here's what the constructor SDK looks like in JS:

    constructor(options) {
        this.network = options.network;
        this.mode = options.mode;
        this.l2MessageTreeDepth = options.l2MessageTreeDepth ?? constants_1.DEFAULT_L2_MESSAGE_TREE_DEPTH;
        if (options.mode === "read-write") {
            this.l1SignerPrivateKey = options.l1SignerPrivateKey;
            this.l2SignerPrivateKey = options.l2SignerPrivateKey;
            this.maxFeePerGas = options.feeEstimatorOptions?.maxFeePerGas;
            this.gasFeeEstimationPercentile = options.feeEstimatorOptions?.gasFeeEstimationPercentile;
        }
        this.l1Provider = new ProviderService_1.default(options.l1RpcUrl);
        this.l2Provider = new ProviderService_1.default(options.l2RpcUrl);
    }

and ProviderService is:

import { ethers } from "ethers";
import { JsonRpcProvider } from "@ethersproject/providers";
export default class ProviderService {
    provider: JsonRpcProvider;
    constructor(rpcUrl: string);
    getSigner(privateKey: string): ethers.Signer;
}

with it's JS being:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ethers_1 = require("ethers");
const providers_1 = require("@ethersproject/providers");
class ProviderService {
    constructor(rpcUrl) {
        this.provider = new providers_1.JsonRpcProvider(rpcUrl);
    }
    getSigner(privateKey) {
        try {
            return new ethers_1.Wallet(privateKey, this.provider);
        }
        catch (e) {
            throw new Error("Something went wrong when trying to generate Wallet. Please check your private key and the provider url.");
        }
    }
}
exports.default = ProviderService;

We can probably create a class identical to ProviderService, create two instances of it and override the state set by the constructor with:

    (sdk as unknown as Record<string, unknown>)["l1Provider"] = new ProviderService( <- with our RPC provider)`

Copy link
Copy Markdown
Contributor

@james-a-morris james-a-morris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pxrl
Copy link
Copy Markdown
Collaborator Author

pxrl commented Oct 15, 2025

Closing this now because we haven't seen any issues for a long time.

@pxrl pxrl closed this Oct 15, 2025
@pxrl pxrl deleted the pxrl/lineaFinalizer branch March 20, 2026 14:25
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.

4 participants