Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/linea/LineaProver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { HexString, HexString32, ProofRef } from '../types.js';
import type { HexString, HexString32, ProofRef, Provider } from '../types.js';
import { BlockProver, makeStorageKey, type TargetNeed } from '../vm.js';
import { ZeroAddress, ZeroHash } from 'ethers/constants';
import { withResolvers, toPaddedHex, isRPCError } from '../utils.js';
Expand All @@ -15,7 +15,8 @@ export class LineaProver extends BlockProver {
static readonly isContract = isContract;
static readonly encodeProof = encodeProof;
static readonly latest = this._createLatest();
stateRoot?: HexString32;
shomeiProvider: Provider | undefined;
stateRoot: HexString32 | undefined;
override async fetchStateRoot() {
if (!this.stateRoot) throw new Error(`unknown stateRoot`);
return this.stateRoot;
Expand Down Expand Up @@ -159,13 +160,15 @@ export class LineaProver extends BlockProver {
}
async fetchProofs(target: HexString, slots: bigint[] = []) {
const ps: Promise<RPCLineaGetProof>[] = [];
const provider = this.shomeiProvider ?? this.provider;
for (let i = 0; ; ) {
ps.push(
// 20240825: most cloud providers seem to reject batched getProof
// since we aren't in control of provider construction (ie. batchMaxSize)
// sendImmediate is a temporary hack to avoid this issue
// 20241027: use GatewayProvider
this.provider.send('linea_getProof', [
// 20240227: add optional separate provider
provider.send('linea_getProof', [
target,
slots
.slice(i, (i += this.proofBatchSize))
Expand Down
18 changes: 18 additions & 0 deletions src/linea/LineaRollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
ProofSequence,
} from '../types.js';
import { Contract, EventLog } from 'ethers/contract';
import { JsonRpcProvider } from 'ethers/providers';
import { LineaProver } from './LineaProver.js';
import { ROLLUP_ABI } from './types.js';
import { CHAINS } from '../chains.js';
Expand Down Expand Up @@ -57,6 +58,22 @@ export class LineaRollup extends AbstractRollup<LineaCommit> {
firstCommitV3: 6391917n,
};

protected _shomeiProvider: JsonRpcProvider | undefined;

// "linea_getProof" is implemented by https://github.com/Consensys/shomei/
// https://documenter.getpostman.com/view/27370530/2s93ebTr7h#8c98cbd9-5c3b-4e1a-8d8e-790a2a9ab305
// this appears to be implemented as a passthru rpc call
// if we know the URL directly, we can avoid an extra hop
// TODO: acquire a direct shomei rpc url
setShomeiURL(url: string | undefined) {
this._shomeiProvider = url
? new JsonRpcProvider(url, 1, {
staticNetwork: true,
batchMaxCount: 1, // batching not supported
})
: undefined;
}

readonly firstCommitV3: bigint | undefined;
readonly L1MessageService: Contract;
constructor(providers: ProviderPair, config: LineaConfig) {
Expand Down Expand Up @@ -127,6 +144,7 @@ export class LineaRollup extends AbstractRollup<LineaCommit> {
}
const prover = new LineaProver(this.provider2, index);
prover.stateRoot = stateRoot;
prover.shomeiProvider = this._shomeiProvider;
return { index, startIndex, stateRoot, prevStateRoot, prover };
}
override encodeWitness(
Expand Down
Loading