@lodestar/prover 1.35.0-dev.e9dd48f165 → 1.35.0-dev.fcf8d024ea

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/bin/lodestar-prover.js +3 -0
  2. package/lib/browser/index.d.ts.map +1 -0
  3. package/lib/cli/applyPreset.d.ts.map +1 -0
  4. package/lib/cli/cli.d.ts +3 -3
  5. package/lib/cli/cli.d.ts.map +1 -0
  6. package/lib/cli/cli.js +1 -1
  7. package/lib/cli/cli.js.map +1 -1
  8. package/lib/cli/cmds/index.d.ts.map +1 -0
  9. package/lib/cli/cmds/index.js.map +1 -1
  10. package/lib/cli/cmds/start/handler.d.ts.map +1 -0
  11. package/lib/cli/cmds/start/index.d.ts.map +1 -0
  12. package/lib/cli/cmds/start/options.d.ts.map +1 -0
  13. package/lib/cli/index.d.ts.map +1 -0
  14. package/lib/cli/index.js.map +1 -1
  15. package/lib/cli/options.d.ts.map +1 -0
  16. package/lib/constants.d.ts.map +1 -0
  17. package/lib/index.d.ts +1 -1
  18. package/lib/index.d.ts.map +1 -0
  19. package/lib/index.js +1 -1
  20. package/lib/index.js.map +1 -1
  21. package/lib/interfaces.d.ts.map +1 -0
  22. package/lib/proof_provider/index.d.ts.map +1 -0
  23. package/lib/proof_provider/ordered_map.d.ts.map +1 -0
  24. package/lib/proof_provider/ordered_map.js +2 -0
  25. package/lib/proof_provider/ordered_map.js.map +1 -1
  26. package/lib/proof_provider/payload_store.d.ts.map +1 -0
  27. package/lib/proof_provider/payload_store.js +12 -11
  28. package/lib/proof_provider/payload_store.js.map +1 -1
  29. package/lib/proof_provider/proof_provider.d.ts.map +1 -0
  30. package/lib/proof_provider/proof_provider.js +9 -0
  31. package/lib/proof_provider/proof_provider.js.map +1 -1
  32. package/lib/provider_types/eip1193_provider_type.d.ts.map +1 -0
  33. package/lib/provider_types/ethers_provider_type.d.ts.map +1 -0
  34. package/lib/provider_types/legacy_provider_type.d.ts.map +1 -0
  35. package/lib/provider_types/web3_js_provider_type.d.ts.map +1 -0
  36. package/lib/types.d.ts.map +1 -0
  37. package/lib/utils/assertion.d.ts.map +1 -0
  38. package/lib/utils/consensus.d.ts.map +1 -0
  39. package/lib/utils/conversion.d.ts.map +1 -0
  40. package/lib/utils/errors.d.ts.map +1 -0
  41. package/lib/utils/evm.d.ts.map +1 -0
  42. package/lib/utils/execution.d.ts.map +1 -0
  43. package/lib/utils/file.d.ts.map +1 -0
  44. package/lib/utils/file.js.map +1 -1
  45. package/lib/utils/gitData/gitDataPath.d.ts.map +1 -0
  46. package/lib/utils/gitData/index.d.ts.map +1 -0
  47. package/lib/utils/gitData/index.js.map +1 -1
  48. package/lib/utils/gitData/writeGitData.d.ts.map +1 -0
  49. package/lib/utils/json_rpc.d.ts.map +1 -0
  50. package/lib/utils/process.d.ts.map +1 -0
  51. package/lib/utils/req_resp.d.ts.map +1 -0
  52. package/lib/utils/rpc_provider.d.ts.map +1 -0
  53. package/lib/utils/rpc_provider.js +3 -1
  54. package/lib/utils/rpc_provider.js.map +1 -1
  55. package/lib/utils/validation.d.ts.map +1 -0
  56. package/lib/utils/validation.js.map +1 -1
  57. package/lib/utils/verification.d.ts.map +1 -0
  58. package/lib/utils/version.d.ts.map +1 -0
  59. package/lib/verified_requests/eth_call.d.ts.map +1 -0
  60. package/lib/verified_requests/eth_estimateGas.d.ts.map +1 -0
  61. package/lib/verified_requests/eth_getBalance.d.ts.map +1 -0
  62. package/lib/verified_requests/eth_getBlockByHash.d.ts.map +1 -0
  63. package/lib/verified_requests/eth_getBlockByNumber.d.ts.map +1 -0
  64. package/lib/verified_requests/eth_getCode.d.ts.map +1 -0
  65. package/lib/verified_requests/eth_getTransactionCount.d.ts.map +1 -0
  66. package/lib/web3_provider.d.ts.map +1 -0
  67. package/lib/web3_provider_inspector.d.ts.map +1 -0
  68. package/lib/web3_provider_inspector.js +2 -1
  69. package/lib/web3_provider_inspector.js.map +1 -1
  70. package/lib/web3_proxy.d.ts.map +1 -0
  71. package/lib/web3_proxy.js +1 -1
  72. package/lib/web3_proxy.js.map +1 -1
  73. package/package.json +16 -15
  74. package/src/browser/index.ts +3 -0
  75. package/src/cli/applyPreset.ts +83 -0
  76. package/src/cli/cli.ts +58 -0
  77. package/src/cli/cmds/index.ts +7 -0
  78. package/src/cli/cmds/start/handler.ts +27 -0
  79. package/src/cli/cmds/start/index.ts +18 -0
  80. package/src/cli/cmds/start/options.ts +85 -0
  81. package/src/cli/index.ts +30 -0
  82. package/src/cli/options.ts +73 -0
  83. package/src/constants.ts +6 -0
  84. package/src/index.ts +5 -0
  85. package/src/interfaces.ts +90 -0
  86. package/src/proof_provider/index.ts +1 -0
  87. package/src/proof_provider/ordered_map.ts +25 -0
  88. package/src/proof_provider/payload_store.ts +223 -0
  89. package/src/proof_provider/proof_provider.ts +210 -0
  90. package/src/provider_types/eip1193_provider_type.ts +32 -0
  91. package/src/provider_types/ethers_provider_type.ts +44 -0
  92. package/src/provider_types/legacy_provider_type.ts +123 -0
  93. package/src/provider_types/web3_js_provider_type.ts +35 -0
  94. package/src/types.ts +163 -0
  95. package/src/utils/assertion.ts +11 -0
  96. package/src/utils/consensus.ts +122 -0
  97. package/src/utils/conversion.ts +107 -0
  98. package/src/utils/errors.ts +4 -0
  99. package/src/utils/evm.ts +284 -0
  100. package/src/utils/execution.ts +76 -0
  101. package/src/utils/file.ts +51 -0
  102. package/src/utils/gitData/gitDataPath.ts +48 -0
  103. package/src/utils/gitData/index.ts +70 -0
  104. package/src/utils/gitData/writeGitData.ts +10 -0
  105. package/src/utils/json_rpc.ts +170 -0
  106. package/src/utils/process.ts +111 -0
  107. package/src/utils/req_resp.ts +34 -0
  108. package/src/utils/rpc_provider.ts +117 -0
  109. package/src/utils/validation.ts +161 -0
  110. package/src/utils/verification.ts +112 -0
  111. package/src/utils/version.ts +74 -0
  112. package/src/verified_requests/eth_call.ts +50 -0
  113. package/src/verified_requests/eth_estimateGas.ts +49 -0
  114. package/src/verified_requests/eth_getBalance.ts +26 -0
  115. package/src/verified_requests/eth_getBlockByHash.ts +24 -0
  116. package/src/verified_requests/eth_getBlockByNumber.ts +25 -0
  117. package/src/verified_requests/eth_getCode.ts +50 -0
  118. package/src/verified_requests/eth_getTransactionCount.ts +26 -0
  119. package/src/web3_provider.ts +58 -0
  120. package/src/web3_provider_inspector.ts +88 -0
  121. package/src/web3_proxy.ts +175 -0
@@ -1 +1 @@
1
- {"version":3,"file":"web3_proxy.js","sourceRoot":"","sources":["../src/web3_proxy.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,aAAa,EAAC,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAC,qBAAqB,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAC,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAOtD,SAAS,iBAAiB,CAAC,EACzB,IAAI,EACJ,MAAM,GAIP;IACC,OAAO,SAAS,OAAO,CAAC,OAA8B;QACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,UAAU,GAAG,IAAI,EAAE,CAAC;YAC1B,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;gBACnC,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;YACvC,CAAC;YAED,MAAM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dd48f165",
14
+ "version": "1.35.0-dev.fcf8d024ea",
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
+ "bun": "./src/index.ts",
18
19
  "import": "./lib/index.js"
19
20
  },
20
21
  "./browser": {
22
+ "bun": "./src/browser/index.ts",
21
23
  "import": "./lib/browser/index.js"
22
24
  }
23
25
  },
@@ -35,11 +37,10 @@
35
37
  },
36
38
  "types": "./lib/index.d.ts",
37
39
  "files": [
38
- "lib/**/*.d.ts",
39
- "lib/**/*.js",
40
- "lib/**/*.js.map",
41
- "*.d.ts",
42
- "*.js"
40
+ "src",
41
+ "lib",
42
+ "bin",
43
+ "!**/*.tsbuildinfo"
43
44
  ],
44
45
  "scripts": {
45
46
  "clean": "rm -rf lib && rm -f *.tsbuildinfo",
@@ -66,13 +67,13 @@
66
67
  "@ethereumjs/tx": "^4.1.2",
67
68
  "@ethereumjs/util": "^8.0.6",
68
69
  "@ethereumjs/vm": "^6.4.2",
69
- "@lodestar/api": "1.35.0-dev.e9dd48f165",
70
- "@lodestar/config": "1.35.0-dev.e9dd48f165",
71
- "@lodestar/light-client": "1.35.0-dev.e9dd48f165",
72
- "@lodestar/logger": "1.35.0-dev.e9dd48f165",
73
- "@lodestar/params": "1.35.0-dev.e9dd48f165",
74
- "@lodestar/types": "1.35.0-dev.e9dd48f165",
75
- "@lodestar/utils": "1.35.0-dev.e9dd48f165",
70
+ "@lodestar/api": "1.35.0-dev.fcf8d024ea",
71
+ "@lodestar/config": "1.35.0-dev.fcf8d024ea",
72
+ "@lodestar/light-client": "1.35.0-dev.fcf8d024ea",
73
+ "@lodestar/logger": "1.35.0-dev.fcf8d024ea",
74
+ "@lodestar/params": "1.35.0-dev.fcf8d024ea",
75
+ "@lodestar/types": "1.35.0-dev.fcf8d024ea",
76
+ "@lodestar/utils": "1.35.0-dev.fcf8d024ea",
76
77
  "ethereum-cryptography": "^2.0.0",
77
78
  "find-up": "^6.3.0",
78
79
  "http-proxy": "^1.18.1",
@@ -81,7 +82,7 @@
81
82
  "yargs": "^17.7.1"
82
83
  },
83
84
  "devDependencies": {
84
- "@lodestar/test-utils": "1.35.0-dev.e9dd48f165",
85
+ "@lodestar/test-utils": "1.35.0-dev.fcf8d024ea",
85
86
  "@types/http-proxy": "^1.17.10",
86
87
  "@types/yargs": "^17.0.24",
87
88
  "axios": "^1.3.4",
@@ -96,5 +97,5 @@
96
97
  "blockchain",
97
98
  "prover"
98
99
  ],
99
- "gitHead": "82df91624346f748ec7695eb2caf4160417c989f"
100
+ "gitHead": "d72abda1a1607ce062febfcfc4528b9e9848c288"
100
101
  }
@@ -0,0 +1,3 @@
1
+ export * from "../interfaces.js";
2
+ export * from "../proof_provider/index.js";
3
+ export {createVerifiedExecutionProvider} from "../web3_provider.js";
@@ -0,0 +1,83 @@
1
+ // MUST import this file first before anything and not import any Lodestar code.
2
+ import {setHasher} from "@chainsafe/persistent-merkle-tree";
3
+ import {hasher as hashtreeHasher} from "@chainsafe/persistent-merkle-tree/hasher/hashtree";
4
+
5
+ // Without setting this first, persistent-merkle-tree will use noble instead
6
+ setHasher(hashtreeHasher);
7
+
8
+ //
9
+ // ## Rationale
10
+ //
11
+ // Lodestar implemented PRESET / CONFIG separation to allow importing types and preset constants directly
12
+ // see https://github.com/ChainSafe/lodestar/pull/2585
13
+ //
14
+ // However this prevents dynamic configuration changes which is exactly what the CLI required before.
15
+ // - The dev command can't apply the minimal preset dynamically
16
+ // - `--network gnosis` can't apply a different preset dynamically
17
+ // - `--network chiado` can't apply a different preset dynamically
18
+ //
19
+ // Running this file allows us to keep a static export strategy while NOT requiring users to
20
+ // set LODESTAR_PRESET manually every time.
21
+
22
+ // IMPORTANT: only import Lodestar code here which does not import any other Lodestar libraries
23
+ import {PresetName, presetFromJson, setActivePreset} from "@lodestar/params/setPreset";
24
+ import {readFile} from "../utils/file.js";
25
+
26
+ const network = valueOfArg("network");
27
+ const preset = valueOfArg("preset");
28
+ const presetFile = valueOfArg("presetFile");
29
+
30
+ // Apply preset flag if present
31
+ if (preset) {
32
+ process.env.LODESTAR_PRESET = preset;
33
+ }
34
+
35
+ // If ENV is set overrides, network (otherwise can not override network --dev in mainnet mode)
36
+ else if (process.env.LODESTAR_PRESET) {
37
+ // break
38
+ }
39
+
40
+ // Translate network to preset
41
+ else if (network) {
42
+ if (network === "dev") {
43
+ process.env.LODESTAR_PRESET = "minimal";
44
+ // the kzg library has hardcoded the mainnet value, do not use presets
45
+ setActivePreset(PresetName.minimal, {FIELD_ELEMENTS_PER_BLOB: 4096});
46
+ } else if (network === "gnosis" || network === "chiado") {
47
+ process.env.LODESTAR_PRESET = "gnosis";
48
+ }
49
+ }
50
+
51
+ if (presetFile) {
52
+ // Override the active preset with custom values from file
53
+ // Do not modify the preset to use as a base by passing null
54
+ setActivePreset(null, presetFromJson(readFile(presetFile) ?? {}));
55
+ }
56
+
57
+ /**
58
+ * Valid syntax
59
+ * - `--preset minimal`
60
+ * - `--preset=minimal`
61
+ */
62
+ function valueOfArg(argName: string): string | null {
63
+ // Syntax `--preset minimal`
64
+ // process.argv = ["--preset", "minimal"];
65
+
66
+ {
67
+ const index = process.argv.indexOf(`--${argName}`);
68
+ if (index > -1) {
69
+ return process.argv[index + 1] ?? "";
70
+ }
71
+ }
72
+
73
+ // Syntax `--preset=minimal`
74
+ {
75
+ const prefix = `--${argName}=`;
76
+ const item = process.argv.find((arg) => arg.startsWith(prefix));
77
+ if (item) {
78
+ return item.slice(prefix.length);
79
+ }
80
+ }
81
+
82
+ return null;
83
+ }
package/src/cli/cli.ts ADDED
@@ -0,0 +1,58 @@
1
+ // Must not use `* as yargs`, see https://github.com/yargs/yargs/issues/1131
2
+ import yargs, {Argv} from "yargs";
3
+ import {hideBin} from "yargs/helpers";
4
+ import {registerCommandToYargs} from "@lodestar/utils";
5
+ import {getVersionData} from "../utils/version.js";
6
+ import {cmds, proverProxyStartCommand} from "./cmds/index.js";
7
+ import {globalOptions} from "./options.js";
8
+
9
+ const {version} = getVersionData();
10
+ const topBanner = `🌟 Lodestar Prover Proxy: Ethereum RPC proxy for RPC responses, verified against the trusted block hashes.
11
+ * Version: ${version}
12
+ * by ChainSafe Systems, 2018-${new Date().getFullYear()}`;
13
+ const bottomBanner = `📖 For more information, check the CLI reference:
14
+ * https://chainsafe.github.io/lodestar/reference/cli
15
+
16
+ ✍️ Give feedback and report issues on GitHub:
17
+ * https://github.com/ChainSafe/lodestar`;
18
+
19
+ export const yarg = yargs((hideBin as (args: string[]) => string[])(process.argv));
20
+
21
+ /**
22
+ * Common factory for running the CLI and running integration tests
23
+ * The CLI must actually be executed in a different script
24
+ */
25
+ export function getLodestarProverCli(): Argv {
26
+ const prover = yarg
27
+ .env("LODESTAR")
28
+ .parserConfiguration({
29
+ // As of yargs v16.1.0 dot-notation breaks strictOptions()
30
+ // Manually processing options is typesafe tho more verbose
31
+ "dot-notation": false,
32
+ })
33
+ .options(globalOptions)
34
+ // blank scriptName so that help text doesn't display the cli name before each command
35
+ .scriptName("")
36
+ .demandCommand(1)
37
+ // Control show help behaviour below on .fail()
38
+ .showHelpOnFail(false)
39
+ .usage(topBanner)
40
+ .epilogue(bottomBanner)
41
+ .version(topBanner)
42
+ .alias("h", "help")
43
+ .alias("v", "version")
44
+ .recommendCommands();
45
+
46
+ // yargs.command and all ./cmds
47
+ for (const cmd of cmds) {
48
+ registerCommandToYargs(prover, cmd);
49
+ }
50
+
51
+ // Register the proxy command as the default one
52
+ registerCommandToYargs(prover, {...proverProxyStartCommand, command: "*"});
53
+
54
+ // throw an error if we see an unrecognized cmd
55
+ prover.recommendCommands().strict();
56
+
57
+ return prover;
58
+ }
@@ -0,0 +1,7 @@
1
+ import {CliCommand} from "@lodestar/utils";
2
+ import {GlobalArgs} from "../options.js";
3
+ import {proverProxyStartCommand} from "./start/index.js";
4
+
5
+ export {proverProxyStartCommand} from "./start/index.js";
6
+
7
+ export const cmds: Required<CliCommand<GlobalArgs, Record<never, never>>>["subcommands"] = [proverProxyStartCommand];
@@ -0,0 +1,27 @@
1
+ import {ChainConfig, chainConfigFromJson} from "@lodestar/config";
2
+ import {readFile} from "../../../utils/file.js";
3
+ import {VerifiedProxyOptions, createVerifiedExecutionProxy} from "../../../web3_proxy.js";
4
+ import {GlobalArgs, parseGlobalArgs} from "../../options.js";
5
+ import {StartArgs, parseStartArgs} from "./options.js";
6
+
7
+ /**
8
+ * Runs a beacon node.
9
+ */
10
+ export async function proverProxyStartHandler(args: StartArgs & GlobalArgs): Promise<void> {
11
+ const {network, logLevel, paramsFile} = parseGlobalArgs(args);
12
+ const opts = parseStartArgs(args);
13
+
14
+ const config: Partial<ChainConfig> = paramsFile ? chainConfigFromJson(readFile(paramsFile)) : {};
15
+
16
+ const options: VerifiedProxyOptions = {
17
+ ...opts,
18
+ logLevel,
19
+ ...(network ? {network} : {config}),
20
+ };
21
+
22
+ const {server, proofProvider} = createVerifiedExecutionProxy(options);
23
+
24
+ server.listen(opts.port);
25
+
26
+ await proofProvider.waitToBeReady();
27
+ }
@@ -0,0 +1,18 @@
1
+ import {CliCommand} from "@lodestar/utils";
2
+ import {GlobalArgs} from "../../options.js";
3
+ import {proverProxyStartHandler} from "./handler.js";
4
+ import {StartArgs, startOptions} from "./options.js";
5
+
6
+ export const proverProxyStartCommand: CliCommand<StartArgs, GlobalArgs> = {
7
+ command: "proxy",
8
+ describe: "Start proxy server",
9
+ examples: [
10
+ {
11
+ command:
12
+ "start --network sepolia --execution-rpc https://lodestar-sepoliarpc.chainsafe.io --mode rest --beacon-rpc https://lodestar-sepolia.chainsafe.io",
13
+ description: "Start a proxy server and connect to the sepolia testnet",
14
+ },
15
+ ],
16
+ options: startOptions,
17
+ handler: proverProxyStartHandler,
18
+ };
@@ -0,0 +1,85 @@
1
+ import {CliCommandOptions} from "@lodestar/utils";
2
+ import {DEFAULT_PROXY_REQUEST_TIMEOUT} from "../../../constants.js";
3
+ import {LCTransport} from "../../../interfaces.js";
4
+ import {alwaysAllowedMethods} from "../../../utils/process.js";
5
+
6
+ export type StartArgs = {
7
+ port: number;
8
+ executionRpcUrl: string;
9
+ beaconUrls: string[];
10
+ wsCheckpoint?: string;
11
+ unverifiedWhitelist?: string[];
12
+ requestTimeout: number;
13
+ };
14
+
15
+ export type StartOptions = {
16
+ executionRpcUrl: string;
17
+ port: number;
18
+ wsCheckpoint?: string;
19
+ unverifiedWhitelist?: string[];
20
+ requestTimeout: number;
21
+ } & {transport: LCTransport.Rest; urls: string[]};
22
+
23
+ export const startOptions: CliCommandOptions<StartArgs> = {
24
+ port: {
25
+ description: "Port number to start the proxy.",
26
+ type: "number",
27
+ default: 8080,
28
+ },
29
+
30
+ executionRpcUrl: {
31
+ description: "RPC url for the execution node.",
32
+ type: "string",
33
+ demandOption: true,
34
+ group: "execution",
35
+ },
36
+
37
+ unverifiedWhitelist: {
38
+ description: `Methods which are allowed to forward. If not provided, all methods are allowed. ${alwaysAllowedMethods.join(
39
+ ","
40
+ )} are always allowed.`,
41
+ type: "array",
42
+ demandOption: false,
43
+ group: "execution",
44
+ },
45
+
46
+ requestTimeout: {
47
+ description: "Number of ms to wait for a response from the execution node.",
48
+ default: DEFAULT_PROXY_REQUEST_TIMEOUT,
49
+ type: "number",
50
+ demandOption: false,
51
+ group: "execution",
52
+ },
53
+
54
+ beaconUrls: {
55
+ description: "Urls of the beacon nodes to connect to.",
56
+ type: "array",
57
+ string: true,
58
+ coerce: (urls: string[]): string[] =>
59
+ // Parse ["url1,url2"] to ["url1", "url2"]
60
+ urls.flatMap((item) => item.split(",")),
61
+ demandOption: true,
62
+ group: "beacon",
63
+ },
64
+
65
+ wsCheckpoint: {
66
+ description:
67
+ "The trusted checkpoint root to start the lightclient. If not provided will initialize from the latest finalized slot. It shouldn't be older than weak subjectivity period",
68
+ type: "string",
69
+ demandOption: false,
70
+ group: "beacon",
71
+ },
72
+ };
73
+
74
+ export function parseStartArgs(args: StartArgs): StartOptions {
75
+ // Remove undefined values to allow deepmerge to inject default values downstream
76
+ return {
77
+ port: args.port,
78
+ executionRpcUrl: args.executionRpcUrl,
79
+ transport: LCTransport.Rest,
80
+ urls: args.beaconUrls ?? [],
81
+ wsCheckpoint: args.wsCheckpoint,
82
+ unverifiedWhitelist: args.unverifiedWhitelist,
83
+ requestTimeout: args.requestTimeout ?? DEFAULT_PROXY_REQUEST_TIMEOUT,
84
+ };
85
+ }
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+
3
+ // MUST import first to apply preset from args and set ssz hasher
4
+ import "./applyPreset.js";
5
+
6
+ import {YargsError} from "../utils/errors.js";
7
+ import {getLodestarProverCli, yarg} from "./cli.js";
8
+ import "source-map-support/register.js";
9
+
10
+ const prover = getLodestarProverCli();
11
+
12
+ void prover
13
+ .fail((msg, err) => {
14
+ if (msg?.includes("Not enough non-option arguments")) {
15
+ // Show command help message when no command is provided
16
+ yarg.showHelp();
17
+ // biome-ignore lint/suspicious/noConsole: This code will run only in browser so console will be available.
18
+ console.log("\n");
19
+ }
20
+
21
+ const errorMessage =
22
+ err !== undefined ? (err instanceof YargsError ? err.message : err.stack) : msg || "Unknown error";
23
+
24
+ // biome-ignore lint/suspicious/noConsole: We want to explicitly want to log error to console
25
+ console.error(` ✖ ${errorMessage}\n`);
26
+ process.exit(1);
27
+ })
28
+
29
+ // Execute CLI
30
+ .parse();
@@ -0,0 +1,73 @@
1
+ import {NetworkName, networksChainConfig} from "@lodestar/config/networks";
2
+ import {ACTIVE_PRESET} from "@lodestar/params";
3
+ import {CliCommandOptions, LogLevel, LogLevels} from "@lodestar/utils";
4
+ import {YargsError} from "../utils/errors.js";
5
+
6
+ export type GlobalArgs = {
7
+ network?: string;
8
+ logLevel: string;
9
+ presetFile?: string;
10
+ preset: string;
11
+ paramsFile?: string;
12
+ };
13
+
14
+ export type GlobalOptions = {
15
+ logLevel: LogLevel;
16
+ } & ({paramsFile: string; network?: never} | {network: NetworkName; paramsFile?: never});
17
+
18
+ export const globalOptions: CliCommandOptions<GlobalArgs> = {
19
+ network: {
20
+ description: "Specify the network to connect.",
21
+ type: "string",
22
+ choices: [
23
+ ...Object.keys(networksChainConfig), // Leave always as last network. The order matters for the --help printout
24
+ "dev",
25
+ ],
26
+ conflicts: ["paramsFile"],
27
+ },
28
+
29
+ paramsFile: {
30
+ description: "Network configuration file",
31
+ type: "string",
32
+ conflicts: ["network"],
33
+ },
34
+
35
+ logLevel: {
36
+ description: "Set the log level.",
37
+ type: "string",
38
+ choices: LogLevels,
39
+ default: "info",
40
+ },
41
+
42
+ // hidden option to allow for LODESTAR_PRESET to be set
43
+ preset: {
44
+ hidden: true,
45
+ type: "string",
46
+ default: ACTIVE_PRESET,
47
+ },
48
+
49
+ presetFile: {
50
+ hidden: true,
51
+ description: "Preset configuration file to override the active preset with custom values",
52
+ type: "string",
53
+ },
54
+ };
55
+
56
+ export function parseGlobalArgs(args: GlobalArgs): GlobalOptions {
57
+ // Remove undefined values to allow deepmerge to inject default values downstream
58
+ if (args.network) {
59
+ return {
60
+ network: args.network as NetworkName,
61
+ logLevel: args.logLevel as LogLevel,
62
+ };
63
+ }
64
+
65
+ if (args.paramsFile) {
66
+ return {
67
+ logLevel: args.logLevel as LogLevel,
68
+ paramsFile: args.paramsFile,
69
+ };
70
+ }
71
+
72
+ throw new YargsError("Either --network or --paramsFile must be provided");
73
+ }
@@ -0,0 +1,6 @@
1
+ // https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/p2p-interface.md#configuration
2
+ export const MAX_REQUEST_LIGHT_CLIENT_UPDATES = 128;
3
+ export const MAX_PAYLOAD_HISTORY = 32;
4
+ export const VERIFICATION_FAILED_RESPONSE_CODE = -33091;
5
+ export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
6
+ export const DEFAULT_PROXY_REQUEST_TIMEOUT = 3000;
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./interfaces.js";
2
+ export * from "./proof_provider/index.js";
3
+ export {isVerificationFailedError} from "./utils/json_rpc.js";
4
+ export {createVerifiedExecutionProvider} from "./web3_provider.js";
5
+ export {createVerifiedExecutionProxy} from "./web3_proxy.js";
@@ -0,0 +1,90 @@
1
+ import {ChainConfig} from "@lodestar/config";
2
+ import {NetworkName} from "@lodestar/config/networks";
3
+ import {LogLevel, Logger} from "@lodestar/utils";
4
+ import {ProofProvider} from "./proof_provider/proof_provider.js";
5
+ import {JsonRpcRequest, JsonRpcRequestOrBatch, JsonRpcResponse, JsonRpcResponseOrBatch} from "./types.js";
6
+ import {ELRpcProvider} from "./utils/rpc_provider.js";
7
+
8
+ export type {NetworkName} from "@lodestar/config/networks";
9
+ export enum LCTransport {
10
+ Rest = "Rest",
11
+ P2P = "P2P",
12
+ }
13
+
14
+ // Provide either network or config. This will be helpful to connect to a custom network
15
+ export type NetworkOrConfig = {network: NetworkName; config?: never} | {network?: never; config: Partial<ChainConfig>};
16
+
17
+ export type RootProviderInitOptions = ConsensusNodeOptions &
18
+ NetworkOrConfig & {
19
+ signal: AbortSignal;
20
+ logger: Logger;
21
+ wsCheckpoint?: string;
22
+ unverifiedWhitelist?: string[];
23
+ };
24
+
25
+ // The `undefined` is necessary to match the types for the web3 1.x
26
+ export type ELRequestHandler<Params = unknown[], Response = unknown> = (
27
+ payload: JsonRpcRequestOrBatch<Params>
28
+ ) => Promise<JsonRpcResponseOrBatch<Response> | undefined>;
29
+
30
+ // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` type here
31
+ export type ELRequestHandlerAny = ELRequestHandler<any, any>;
32
+
33
+ /**
34
+ * @deprecated Kept for backward compatibility. Use `AnyWeb3Provider` type instead.
35
+ */
36
+ export type Web3Provider = object;
37
+
38
+ export type ELVerifiedRequestHandlerOpts<Params = unknown[]> = {
39
+ payload: JsonRpcRequest<Params>;
40
+ rpc: ELRpcProvider;
41
+ proofProvider: ProofProvider;
42
+ logger: Logger;
43
+ };
44
+
45
+ export type ELVerifiedRequestHandler<Params = unknown[], Response = unknown> = (
46
+ opts: ELVerifiedRequestHandlerOpts<Params>
47
+ ) => Promise<JsonRpcResponse<Response>>;
48
+
49
+ // Either a logger is provided by user or user specify a log level
50
+ // If both are skipped then we don't log anything (useful for browser plugins)
51
+ export type LogOptions = {logger?: Logger; logLevel?: never} | {logLevel?: LogLevel; logger?: never};
52
+
53
+ export type ConsensusNodeOptions =
54
+ | {transport: LCTransport.Rest; urls: string[]}
55
+ | {transport: LCTransport.P2P; bootnodes: string[]};
56
+
57
+ export type RootProviderOptions = {
58
+ signal?: AbortSignal;
59
+ wsCheckpoint?: string;
60
+ unverifiedWhitelist?: string[];
61
+ };
62
+
63
+ export type ProviderTypeOptions<T extends boolean | undefined> = {
64
+ /**
65
+ * If user specify custom provider types we will register those at the start in given order.
66
+ * So if you provider [custom1, custom2] and we already have [web3js, ethers] then final order
67
+ * of providers will be [custom1, custom2, web3js, ethers]
68
+ */
69
+ providerTypes?: Web3ProviderType<AnyWeb3Provider>[];
70
+ /**
71
+ * To keep the backward compatible behavior if this option is not set we consider `true` as default.
72
+ * In coming breaking release we may set this option default to `false`.
73
+ */
74
+ mutateProvider?: T;
75
+ };
76
+
77
+ export type VerifiedExecutionInitOptions<T extends boolean | undefined> = LogOptions &
78
+ ConsensusNodeOptions &
79
+ NetworkOrConfig &
80
+ RootProviderOptions &
81
+ ProviderTypeOptions<T>;
82
+
83
+ export type AnyWeb3Provider = object;
84
+
85
+ export interface Web3ProviderType<T extends AnyWeb3Provider> {
86
+ name: string;
87
+ matched: (provider: AnyWeb3Provider) => provider is T;
88
+ handler(provider: T): ELRpcProvider["handler"];
89
+ mutateProvider(provider: T, newHandler: ELRpcProvider["handler"]): void;
90
+ }
@@ -0,0 +1 @@
1
+ export * from "./proof_provider.js";
@@ -0,0 +1,25 @@
1
+ export class OrderedMap<T> extends Map<number, T> {
2
+ private _min?: number;
3
+ private _max?: number;
4
+
5
+ get min(): number | undefined {
6
+ return this._min;
7
+ }
8
+
9
+ get max(): number | undefined {
10
+ return this._max;
11
+ }
12
+
13
+ set(key: number, value: T): this {
14
+ if (this._min === undefined || key < this._min) {
15
+ this._min = key;
16
+ }
17
+
18
+ if (this._max === undefined || key > this._max) {
19
+ this._max = key;
20
+ }
21
+
22
+ super.set(key, value);
23
+ return this;
24
+ }
25
+ }