Skip to content

Commit 1deb137

Browse files
committed
lodestar prover working, changed default rpc, fixed request id collision bug in prover
1 parent e8fcfc2 commit 1deb137

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

patches/@lodestar+prover+1.12.0.patch

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ index 1fdc555..c44186a 100644
2424
value: tx.value,
2525
gas: tx.gas ? tx.gas : numberToHex(gasLimit),
2626
gasPrice: "0x0",
27+
diff --git a/node_modules/@lodestar/prover/lib/utils/rpc.js b/node_modules/@lodestar/prover/lib/utils/rpc.js
28+
index 0d8c741..05c195f 100644
29+
--- a/node_modules/@lodestar/prover/lib/utils/rpc.js
30+
+++ b/node_modules/@lodestar/prover/lib/utils/rpc.js
31+
@@ -49,7 +49,7 @@ export class ELRpc {
32+
}
33+
getRequestId() {
34+
// TODO: Find better way to generate random id
35+
- return (Math.random() * 10000).toFixed(0);
36+
+ return (Math.random() * 100000000000000000).toFixed(0);
37+
}
38+
}
39+
//# sourceMappingURL=rpc.js.map
40+
\ No newline at end of file
2741
diff --git a/node_modules/@lodestar/prover/lib/utils/validation.js b/node_modules/@lodestar/prover/lib/utils/validation.js
2842
index b5454bc..a46412d 100644
2943
--- a/node_modules/@lodestar/prover/lib/utils/validation.js

src/LightClientVerifier.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export class LightClientVerifier {
106106
private elRpcUrl: string;
107107
public provider: Web3jsProvider | undefined;
108108
public proofProvider: ProofProvider | undefined;
109+
private multicall: Multicall | undefined;
109110

110111
constructor({ network, elRpcUrl, beaconApiUrl, initialCheckpoint }: LightClientVerifierInitArgs) {
111112
this.elRpcUrl = elRpcUrl;
@@ -209,6 +210,11 @@ export class LightClientVerifier {
209210
this.provider = provider;
210211
this.proofProvider = proofProvider;
211212
this.web3 = new Web3(provider);
213+
this.multicall = new Multicall({
214+
web3Instance: this.web3,
215+
tryAggregate: true,
216+
multicallCustomContractAddress: '0xca11bde05977b3631167028862be2a173976ca11', // Getting multicall address from network fails
217+
});
212218
await this.waitForClientToStart();
213219
}
214220

@@ -244,23 +250,17 @@ export class LightClientVerifier {
244250
let ethBalance;
245251
try {
246252
let balance = await this.web3!.eth.getBalance(address);
247-
console.log('eth', balance);
248253
ethBalance = {
249254
balance: Number(this.web3!.utils.fromWei(balance, 'ether')),
250255
verified: true,
251256
};
252257
} catch (e) {
253-
console.log('ERROR eth balance', e);
254258
ethBalance = {
255259
balance: 0,
256260
verified: false,
257261
};
258262
}
259-
const multicall = new Multicall({
260-
web3Instance: this.web3,
261-
tryAggregate: true,
262-
multicallCustomContractAddress: '0xca11bde05977b3631167028862be2a173976ca11', // Getting multicall address from network fails
263-
});
263+
const erc20Balances: Record<string, VerifiedBalance> = {};
264264

265265
const contractCallContext: ContractCallContext[] = erc20Contracts.map((erc20ContractAddress) => {
266266
return {
@@ -273,13 +273,12 @@ export class LightClientVerifier {
273273
],
274274
};
275275
});
276-
const erc20Balances: Record<string, VerifiedBalance> = {};
277-
const results: ContractCallResults = await multicall.call(contractCallContext);
276+
277+
const results: ContractCallResults = await this.multicall!.call(contractCallContext);
278278

279279
for (const key of Object.keys(results.results)) {
280280
const result = results.results[key];
281281
const erc20ContractAddress = key;
282-
console.log(erc20ContractAddress, result);
283282
if (result && result.callsReturnContext) {
284283
// @ts-ignore
285284
const balanceResult = result.callsReturnContext.find((call) => call.reference === 'balanceOf');
@@ -289,7 +288,6 @@ export class LightClientVerifier {
289288
if (balanceResult?.success && decimalsResult?.success) {
290289
const decimals = decimalsResult?.returnValues[0];
291290
const balance = parseFloat(formatUnits(hexToNumberString(balanceResult?.returnValues[0].hex), decimals));
292-
console.log('contract', erc20ContractAddress, balance);
293291
erc20Balances[erc20ContractAddress] = { balance: balance, verified: true };
294292
} else {
295293
erc20Balances[erc20ContractAddress] = { balance: 0, verified: false };

src/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const runningStorageName = 'running';
1212
export const initialConfig: LightClientVerifierInitArgs = {
1313
network: 'mainnet',
1414
beaconApiUrl: 'https://lodestar-mainnet.chainsafe.io',
15-
elRpcUrl: 'https://lodestar-mainnetrpc.chainsafe.io',
15+
elRpcUrl: 'https://rpc.ankr.com/eth',
1616
initialCheckpoint: '0x7fd9dccecb5fc37db1b9a12607795d4777635aa10ac774a07e871086a004c775',
1717
};
1818

src/pages/background/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LightClientVerifierInitArgs, LightClientVerifier } from '../../LightClientVerifier';
1+
import { LightClientVerifier } from '../../LightClientVerifier';
22
import { Actions, configStorageName, runningStorageName, initialConfig } from '../../common';
33
import { getStorageItem, setStorageItem, setStorageData } from '../../storage';
44

webpack/webpack.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
55

66
const webpack = require('webpack');
77
module.exports = {
8-
devtool: 'inline-source-map',
8+
devtool: 'source-map',
99
mode: 'production',
1010
externals: {
1111
'node:http': '{}',

0 commit comments

Comments
 (0)