@lodestar/prover 1.19.0-dev.de3988d58f → 1.19.0-dev.deafa4f162
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.
- package/README.md +40 -10
- package/lib/interfaces.d.ts +27 -22
- package/lib/provider_types/eip1193_provider_type.d.ts +8 -0
- package/lib/provider_types/eip1193_provider_type.js +23 -0
- package/lib/provider_types/eip1193_provider_type.js.map +1 -0
- package/lib/provider_types/ethers_provider_type.d.ts +8 -0
- package/lib/provider_types/ethers_provider_type.js +35 -0
- package/lib/provider_types/ethers_provider_type.js.map +1 -0
- package/lib/provider_types/legacy_provider_type.d.ts +15 -0
- package/lib/provider_types/legacy_provider_type.js +85 -0
- package/lib/provider_types/legacy_provider_type.js.map +1 -0
- package/lib/provider_types/web3_js_provider_type.d.ts +8 -0
- package/lib/provider_types/web3_js_provider_type.js +25 -0
- package/lib/provider_types/web3_js_provider_type.js.map +1 -0
- package/lib/types.d.ts +1 -0
- package/lib/types.js.map +1 -1
- package/lib/utils/assertion.d.ts +0 -10
- package/lib/utils/assertion.js +0 -38
- package/lib/utils/assertion.js.map +1 -1
- package/lib/utils/evm.d.ts +4 -4
- package/lib/utils/execution.d.ts +4 -4
- package/lib/utils/execution.js.map +1 -1
- package/lib/utils/process.d.ts +2 -2
- package/lib/utils/{rpc.d.ts → rpc_provider.d.ts} +15 -4
- package/lib/utils/{rpc.js → rpc_provider.js} +14 -3
- package/lib/utils/rpc_provider.js.map +1 -0
- package/lib/utils/verification.d.ts +4 -4
- package/lib/web3_provider.d.ts +7 -17
- package/lib/web3_provider.js +21 -133
- package/lib/web3_provider.js.map +1 -1
- package/lib/web3_provider_inspector.d.ts +19 -0
- package/lib/web3_provider_inspector.js +67 -0
- package/lib/web3_provider_inspector.js.map +1 -0
- package/lib/web3_proxy.d.ts +1 -1
- package/lib/web3_proxy.js +2 -2
- package/lib/web3_proxy.js.map +1 -1
- package/package.json +10 -10
- package/lib/utils/rpc.js.map +0 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://discord.gg/aMxzVcr)
|
|
4
4
|
[](https://github.com/ethereum/beacon-APIs/releases/tag/v2.1.0)
|
|
5
5
|

|
|
6
|
-

|
|
7
7
|
|
|
8
8
|
> This package is part of [ChainSafe's Lodestar](https://lodestar.chainsafe.io) project
|
|
9
9
|
|
|
@@ -17,15 +17,39 @@ You can use the `@lodestar/prover` in two ways, as a Web3 Provider and as proxy.
|
|
|
17
17
|
import Web3 from "web3";
|
|
18
18
|
import {createVerifiedExecutionProvider, LCTransport} from "@lodestar/prover";
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const httpProvider = new Web3.providers.HttpProvider("https://lodestar-sepoliarpc.chainsafe.io");
|
|
21
|
+
|
|
22
|
+
const {provider, proofProvider} = createVerifiedExecutionProvider(httpProvider, {
|
|
23
|
+
transport: LCTransport.Rest,
|
|
24
|
+
urls: ["https://lodestar-sepolia.chainsafe.io"],
|
|
25
|
+
network: "sepolia",
|
|
26
|
+
wsCheckpoint: "trusted-checkpoint",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const web3 = new Web3(provider);
|
|
30
|
+
|
|
31
|
+
const address = "0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134";
|
|
32
|
+
const balance = await web3.eth.getBalance(address, "latest");
|
|
33
|
+
console.log({balance, address});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
In this scenario the actual provider is mutated to handle the RPC requests and verify those. So here if you use `provider` or `httpProvider` both are the same objects. This behavior is useful when you already have an application and usage of any provider across the code space and don't want to change the code. So you mutate the provider during startup.
|
|
37
|
+
|
|
38
|
+
For some scenarios when you don't want to mutate the provider you can pass an option `mutateProvider` as `false`. In this scenario the object `httpProvider` is not mutated and you get a new object `provider`. This is useful when your provider object does not allow mutation, e.g. Metamask provider accessible through `window.ethereum`. If not provided `mutateProvider` is considered as `true` by default. In coming releases we will switch its default behavior to `false`.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import Web3 from "web3";
|
|
42
|
+
import {createVerifiedExecutionProvider, LCTransport} from "@lodestar/prover";
|
|
43
|
+
|
|
44
|
+
const httpProvider = new Web3.providers.HttpProvider("https://lodestar-sepoliarpc.chainsafe.io");
|
|
45
|
+
|
|
46
|
+
const {provider, proofProvider} = createVerifiedExecutionProvider(httpProvider, {
|
|
47
|
+
transport: LCTransport.Rest,
|
|
48
|
+
urls: ["https://lodestar-sepolia.chainsafe.io"],
|
|
49
|
+
network: "sepolia",
|
|
50
|
+
wsCheckpoint: "trusted-checkpoint",
|
|
51
|
+
mutateProvider: false,
|
|
52
|
+
});
|
|
29
53
|
|
|
30
54
|
const web3 = new Web3(provider);
|
|
31
55
|
|
|
@@ -46,6 +70,12 @@ lodestar-prover proxy \
|
|
|
46
70
|
--port 8080
|
|
47
71
|
```
|
|
48
72
|
|
|
73
|
+
## How to detect a web3 provider
|
|
74
|
+
|
|
75
|
+
There can be different implementations of the web3 providers and each can handle the RPC request differently. We call those different provider types. We had provided builtin support for common providers e.g. web3.js, ethers or any eip1193 compatible providers. We inspect given provider instance at runtime to detect the correct provider type.
|
|
76
|
+
|
|
77
|
+
If your project is using some provider type which is not among above list, you have the option to register a custom provider type with the `createVerifiedExecutionProvider` with the option `providerTypes` which will be an array of your supported provider types. Your custom provider types will have higher priority than default provider types. Please see [existing provide types implementations](./src/provider_types/) to know how to implement your own if needed.
|
|
78
|
+
|
|
49
79
|
## Supported Web3 Methods
|
|
50
80
|
|
|
51
81
|
✅ - Completed
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { NetworkName } from "@lodestar/config/networks";
|
|
|
3
3
|
import { Logger, LogLevel } from "@lodestar/utils";
|
|
4
4
|
import { ProofProvider } from "./proof_provider/proof_provider.js";
|
|
5
5
|
import { JsonRpcRequest, JsonRpcRequestOrBatch, JsonRpcResponse, JsonRpcResponseOrBatch } from "./types.js";
|
|
6
|
-
import {
|
|
6
|
+
import { ELRpcProvider } from "./utils/rpc_provider.js";
|
|
7
7
|
export type { NetworkName } from "@lodestar/config/networks";
|
|
8
8
|
export declare enum LCTransport {
|
|
9
9
|
Rest = "Rest",
|
|
@@ -24,28 +24,13 @@ export type RootProviderInitOptions = ConsensusNodeOptions & NetworkOrConfig & {
|
|
|
24
24
|
};
|
|
25
25
|
export type ELRequestHandler<Params = unknown[], Response = unknown> = (payload: JsonRpcRequestOrBatch<Params>) => Promise<JsonRpcResponseOrBatch<Response> | undefined>;
|
|
26
26
|
export type ELRequestHandlerAny = ELRequestHandler<any, any>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export
|
|
31
|
-
request: (payload: JsonRpcRequest) => Promise<JsonRpcResponse>;
|
|
32
|
-
}
|
|
33
|
-
export interface RequestProvider {
|
|
34
|
-
request(payload: JsonRpcRequestOrBatch, callback: (err: Error | undefined, response: JsonRpcResponseOrBatch) => void): void;
|
|
35
|
-
}
|
|
36
|
-
export interface SendProvider {
|
|
37
|
-
send(payload: JsonRpcRequest, callback: (err?: Error | null, response?: JsonRpcResponse) => void): void;
|
|
38
|
-
}
|
|
39
|
-
export interface EthersProvider {
|
|
40
|
-
send(method: string, params: Array<unknown>): Promise<JsonRpcResponse>;
|
|
41
|
-
}
|
|
42
|
-
export interface SendAsyncProvider {
|
|
43
|
-
sendAsync(payload: JsonRpcRequestOrBatch): Promise<JsonRpcResponseOrBatch>;
|
|
44
|
-
}
|
|
45
|
-
export type Web3Provider = SendProvider | EthersProvider | SendAsyncProvider | RequestProvider | EIP1193Provider | Web3jsProvider;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Kept for backward compatibility. Use `AnyWeb3Provider` type instead.
|
|
29
|
+
*/
|
|
30
|
+
export type Web3Provider = object;
|
|
46
31
|
export type ELVerifiedRequestHandlerOpts<Params = unknown[]> = {
|
|
47
32
|
payload: JsonRpcRequest<Params>;
|
|
48
|
-
rpc:
|
|
33
|
+
rpc: ELRpcProvider;
|
|
49
34
|
proofProvider: ProofProvider;
|
|
50
35
|
logger: Logger;
|
|
51
36
|
};
|
|
@@ -69,5 +54,25 @@ export type RootProviderOptions = {
|
|
|
69
54
|
wsCheckpoint?: string;
|
|
70
55
|
unverifiedWhitelist?: string[];
|
|
71
56
|
};
|
|
72
|
-
export type
|
|
57
|
+
export type ProviderTypeOptions<T extends boolean | undefined> = {
|
|
58
|
+
/**
|
|
59
|
+
* If user specify custom provider types we will register those at the start in given order.
|
|
60
|
+
* So if you provider [custom1, custom2] and we already have [web3js, ethers] then final order
|
|
61
|
+
* of providers will be [custom1, custom2, web3js, ethers]
|
|
62
|
+
*/
|
|
63
|
+
providerTypes?: Web3ProviderType<AnyWeb3Provider>[];
|
|
64
|
+
/**
|
|
65
|
+
* To keep the backward compatible behavior if this option is not set we consider `true` as default.
|
|
66
|
+
* In coming breaking release we may set this option default to `false`.
|
|
67
|
+
*/
|
|
68
|
+
mutateProvider?: T;
|
|
69
|
+
};
|
|
70
|
+
export type VerifiedExecutionInitOptions<T extends boolean | undefined> = LogOptions & ConsensusNodeOptions & NetworkOrConfig & RootProviderOptions & ProviderTypeOptions<T>;
|
|
71
|
+
export type AnyWeb3Provider = object;
|
|
72
|
+
export interface Web3ProviderType<T extends AnyWeb3Provider> {
|
|
73
|
+
name: string;
|
|
74
|
+
matched: (provider: AnyWeb3Provider) => provider is T;
|
|
75
|
+
handler(provider: T): ELRpcProvider["handler"];
|
|
76
|
+
mutateProvider(provider: T, newHandler: ELRpcProvider["handler"]): void;
|
|
77
|
+
}
|
|
73
78
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Web3ProviderType } from "../interfaces.js";
|
|
2
|
+
import { JsonRpcRequestOrBatch, JsonRpcResponseOrBatch } from "../types.js";
|
|
3
|
+
export interface EIP1193Provider {
|
|
4
|
+
request: (payload: JsonRpcRequestOrBatch) => Promise<JsonRpcResponseOrBatch>;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: Web3ProviderType<EIP1193Provider>;
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=eip1193_provider_type.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
name: "eip1193",
|
|
3
|
+
matched(provider) {
|
|
4
|
+
return ("request" in provider &&
|
|
5
|
+
typeof provider.request === "function" &&
|
|
6
|
+
provider.request.constructor.name === "AsyncFunction");
|
|
7
|
+
},
|
|
8
|
+
handler(provider) {
|
|
9
|
+
const request = provider.request.bind(provider);
|
|
10
|
+
return async (payload) => {
|
|
11
|
+
const response = await request(payload);
|
|
12
|
+
return response;
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
mutateProvider(provider, newHandler) {
|
|
16
|
+
Object.assign(provider, {
|
|
17
|
+
request: async function newRequest(payload) {
|
|
18
|
+
return newHandler(payload);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=eip1193_provider_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip1193_provider_type.js","sourceRoot":"","sources":["../../src/provider_types/eip1193_provider_type.ts"],"names":[],"mappings":"AAOA,eAAe;IACb,IAAI,EAAE,SAAS;IACf,OAAO,CAAC,QAAQ;QACd,OAAO,CACL,SAAS,IAAI,QAAQ;YACrB,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU;YACtC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,CACtD,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,QAAQ;QACd,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEhD,OAAO,KAAK,EAAE,OAA8B,EAA+C,EAAE;YAC3F,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;YACxC,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC;IACD,cAAc,CAAC,QAAQ,EAAE,UAAU;QACjC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;YACtB,OAAO,EAAE,KAAK,UAAU,UAAU,CAAC,OAA8B;gBAC/D,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACmC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Web3ProviderType } from "../interfaces.js";
|
|
2
|
+
import { JsonRpcResponse } from "../types.js";
|
|
3
|
+
export interface EthersProvider {
|
|
4
|
+
send(method: string, params: Array<unknown>): Promise<JsonRpcResponse>;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: Web3ProviderType<EthersProvider>;
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=ethers_provider_type.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isBatchRequest } from "../utils/json_rpc.js";
|
|
2
|
+
import web3JsProviderType from "./web3_js_provider_type.js";
|
|
3
|
+
export default {
|
|
4
|
+
name: "ethers",
|
|
5
|
+
matched(provider) {
|
|
6
|
+
return (!web3JsProviderType.matched(provider) &&
|
|
7
|
+
"send" in provider &&
|
|
8
|
+
typeof provider.send === "function" &&
|
|
9
|
+
provider.send.length > 1 &&
|
|
10
|
+
provider.send.constructor.name === "AsyncFunction");
|
|
11
|
+
},
|
|
12
|
+
handler(provider) {
|
|
13
|
+
const send = provider.send.bind(provider);
|
|
14
|
+
return async (payload) => {
|
|
15
|
+
// Because ethers provider public interface does not support batch requests
|
|
16
|
+
// so we need to handle it manually
|
|
17
|
+
if (isBatchRequest(payload)) {
|
|
18
|
+
const responses = [];
|
|
19
|
+
for (const request of payload) {
|
|
20
|
+
responses.push(await send(request.method, request.params));
|
|
21
|
+
}
|
|
22
|
+
return responses;
|
|
23
|
+
}
|
|
24
|
+
return send(payload.method, payload.params);
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
mutateProvider(provider, newHandler) {
|
|
28
|
+
Object.assign(provider, {
|
|
29
|
+
send: function newSend(method, params) {
|
|
30
|
+
return newHandler({ jsonrpc: "2.0", id: 0, method, params });
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=ethers_provider_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ethers_provider_type.js","sourceRoot":"","sources":["../../src/provider_types/ethers_provider_type.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAM5D,eAAe;IACb,IAAI,EAAE,QAAQ;IACd,OAAO,CAAC,QAAQ;QACd,OAAO,CACL,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC;YACrC,MAAM,IAAI,QAAQ;YAClB,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU;YACnC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,CACnD,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,QAAQ;QACd,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE1C,OAAO,KAAK,EAAE,OAA8B,EAA+C,EAAE;YAC3F,2EAA2E;YAC3E,mCAAmC;YACnC,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC5B,MAAM,SAAS,GAAG,EAAE,CAAC;gBACrB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;oBAC9B,SAAS,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC7D,CAAC;gBACD,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC,CAAC;IACJ,CAAC;IACD,cAAc,CAAC,QAAQ,EAAE,UAAU;QACjC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;YACtB,IAAI,EAAE,SAAS,OAAO,CAAC,MAAc,EAAE,MAAsB;gBAC3D,OAAO,UAAU,CAAC,EAAC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAC,CAAC,CAAC;YAC7D,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACkC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Web3ProviderType } from "../interfaces.js";
|
|
2
|
+
import { JsonRpcRequest, JsonRpcRequestOrBatch, JsonRpcResponse, JsonRpcResponseOrBatch } from "../types.js";
|
|
3
|
+
interface RequestProvider {
|
|
4
|
+
request(payload: JsonRpcRequestOrBatch, callback: (err: Error | undefined, response: JsonRpcResponseOrBatch) => void): void;
|
|
5
|
+
}
|
|
6
|
+
interface SendProvider {
|
|
7
|
+
send(payload: JsonRpcRequest, callback: (err?: Error | null, response?: JsonRpcResponse) => void): void;
|
|
8
|
+
}
|
|
9
|
+
interface SendAsyncProvider {
|
|
10
|
+
sendAsync(payload: JsonRpcRequestOrBatch): Promise<JsonRpcResponseOrBatch>;
|
|
11
|
+
}
|
|
12
|
+
type LegacyProvider = RequestProvider | SendProvider | SendAsyncProvider;
|
|
13
|
+
declare const _default: Web3ProviderType<LegacyProvider>;
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=legacy_provider_type.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import web3JsProviderType from "./web3_js_provider_type.js";
|
|
2
|
+
export default {
|
|
3
|
+
name: "legacy",
|
|
4
|
+
matched(provider) {
|
|
5
|
+
return isRequestProvider(provider) || isSendProvider(provider) || isSendAsyncProvider(provider);
|
|
6
|
+
},
|
|
7
|
+
handler(provider) {
|
|
8
|
+
if (isRequestProvider(provider)) {
|
|
9
|
+
const request = provider.request.bind(provider);
|
|
10
|
+
return function newHandler(payload) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
request(payload, (err, response) => {
|
|
13
|
+
if (err) {
|
|
14
|
+
reject(err);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
resolve(response);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (isSendProvider(provider)) {
|
|
24
|
+
const send = provider.send.bind(provider);
|
|
25
|
+
return function newHandler(payload) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
// web3 providers supports batch requests but don't have valid types
|
|
28
|
+
send(payload, (err, response) => {
|
|
29
|
+
if (err) {
|
|
30
|
+
reject(err);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
resolve(response);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// sendAsync provider
|
|
40
|
+
const sendAsync = provider.sendAsync.bind(provider);
|
|
41
|
+
return async function newHandler(payload) {
|
|
42
|
+
const response = await sendAsync(payload);
|
|
43
|
+
return response;
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
mutateProvider(provider, newHandler) {
|
|
47
|
+
if (isRequestProvider(provider)) {
|
|
48
|
+
const newRequest = function newRequest(payload, callback) {
|
|
49
|
+
newHandler(payload)
|
|
50
|
+
.then((response) => callback(undefined, response))
|
|
51
|
+
.catch((err) => callback(err, undefined));
|
|
52
|
+
};
|
|
53
|
+
Object.assign(provider, { request: newRequest });
|
|
54
|
+
}
|
|
55
|
+
if (isSendProvider(provider)) {
|
|
56
|
+
const newSend = function newSend(payload, callback) {
|
|
57
|
+
newHandler(payload)
|
|
58
|
+
.then((response) => callback(undefined, response))
|
|
59
|
+
.catch((err) => callback(err, undefined));
|
|
60
|
+
};
|
|
61
|
+
Object.assign(provider, { send: newSend });
|
|
62
|
+
}
|
|
63
|
+
// sendAsync provider
|
|
64
|
+
Object.assign(provider, { sendAsync: newHandler });
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
function isSendProvider(provider) {
|
|
68
|
+
return (!web3JsProviderType.matched(provider) &&
|
|
69
|
+
"send" in provider &&
|
|
70
|
+
typeof provider.send === "function" &&
|
|
71
|
+
provider.send.length > 1 &&
|
|
72
|
+
provider.send.constructor.name !== "AsyncFunction");
|
|
73
|
+
}
|
|
74
|
+
function isRequestProvider(provider) {
|
|
75
|
+
return (!web3JsProviderType.matched(provider) &&
|
|
76
|
+
"request" in provider &&
|
|
77
|
+
typeof provider.request === "function" &&
|
|
78
|
+
provider.request.length > 1);
|
|
79
|
+
}
|
|
80
|
+
function isSendAsyncProvider(provider) {
|
|
81
|
+
return ("sendAsync" in provider &&
|
|
82
|
+
typeof provider.sendAsync === "function" &&
|
|
83
|
+
provider.sendAsync.constructor.name === "AsyncFunction");
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=legacy_provider_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy_provider_type.js","sourceRoot":"","sources":["../../src/provider_types/legacy_provider_type.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAoB5D,eAAe;IACb,IAAI,EAAE,QAAQ;IACd,OAAO,CAAC,QAAQ;QACd,OAAO,iBAAiB,CAAC,QAAQ,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,CAAC,QAAQ;QACd,IAAI,iB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AC,QAAQ,CAAC;QACrC,MAAM,IAAI,QAAQ;QAClB,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU;QACnC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;QACxB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,CACnD,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAyB;IAClD,OAAO,CACL,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC;QACrC,SAAS,IAAI,QAAQ;QACrB,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU;QACtC,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAC5B,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAyB;IACpD,OAAO,CACL,WAAW,IAAI,QAAQ;QACvB,OAAO,QAAQ,CAAC,SAAS,KAAK,UAAU;QACxC,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,CACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Web3ProviderType } from "../interfaces.js";
|
|
2
|
+
import { JsonRpcRequest, JsonRpcResponse } from "../types.js";
|
|
3
|
+
export interface Web3jsProvider {
|
|
4
|
+
request: (payload: JsonRpcRequest) => Promise<JsonRpcResponse>;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: Web3ProviderType<Web3jsProvider>;
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=web3_js_provider_type.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isBatchRequest } from "../utils/json_rpc.js";
|
|
2
|
+
export default {
|
|
3
|
+
name: "web3js",
|
|
4
|
+
matched(provider) {
|
|
5
|
+
return ("isWeb3Provider" in provider.constructor &&
|
|
6
|
+
provider.constructor.isWeb3Provider(provider));
|
|
7
|
+
},
|
|
8
|
+
handler(provider) {
|
|
9
|
+
const request = provider.request.bind(provider);
|
|
10
|
+
return async (payload) => {
|
|
11
|
+
if (isBatchRequest(payload)) {
|
|
12
|
+
return Promise.all(payload.map((p) => request(p)));
|
|
13
|
+
}
|
|
14
|
+
return request(payload);
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
mutateProvider(provider, newHandler) {
|
|
18
|
+
Object.assign(provider, {
|
|
19
|
+
request: async function newRequest(payload) {
|
|
20
|
+
return newHandler(payload);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=web3_js_provider_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web3_js_provider_type.js","sourceRoot":"","sources":["../../src/provider_types/web3_js_provider_type.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAMpD,eAAe;IACb,IAAI,EAAE,QAAQ;IACd,OAAO,CAAC,QAAQ;QACd,OAAO,CACL,gBAAgB,IAAI,QAAQ,CAAC,WAAW;YACvC,QAAQ,CAAC,WAAwE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAC5G,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,QAAQ;QACd,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEhD,OAAO,KAAK,EAAE,OAA8B,EAA+C,EAAE;YAC3F,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACrD,CAAC;YAED,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC;IACD,cAAc,CAAC,QAAQ,EAAE,UAAU;QACjC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;YACtB,OAAO,EAAE,KAAK,UAAU,UAAU,CAAC,OAA8B;gBAC/D,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACkC,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -119,6 +119,7 @@ export interface ELAccessListResponse {
|
|
|
119
119
|
}
|
|
120
120
|
export type ELStorageProof = Pick<ELProof, "storageHash" | "storageProof">;
|
|
121
121
|
export type ELApi = {
|
|
122
|
+
eth_getBalance: (address: string, block?: number | string) => string;
|
|
122
123
|
eth_createAccessList: (transaction: ELTransaction, block?: ELBlockNumberOrTag) => ELAccessListResponse;
|
|
123
124
|
eth_call: (transaction: ELTransaction, block?: ELBlockNumberOrTag) => HexString;
|
|
124
125
|
eth_estimateGas: (transaction: ELTransaction, block?: ELBlockNumberOrTag) => HexString;
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAoKA,wDAAwD"}
|
package/lib/utils/assertion.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import { Lightclient } from "@lodestar/light-client";
|
|
2
|
-
import { EIP1193Provider, EthersProvider, RequestProvider, SendAsyncProvider, SendProvider, Web3Provider } from "../interfaces.js";
|
|
3
2
|
export declare function assertLightClient(client?: Lightclient): asserts client is Lightclient;
|
|
4
|
-
/**
|
|
5
|
-
* Checks if the provider is a web3.js version 4x.
|
|
6
|
-
*/
|
|
7
|
-
export declare function isWeb3jsProvider(provider: Web3Provider): provider is EIP1193Provider;
|
|
8
|
-
export declare function isSendProvider(provider: Web3Provider): provider is SendProvider;
|
|
9
|
-
export declare function isEthersProvider(provider: Web3Provider): provider is EthersProvider;
|
|
10
|
-
export declare function isRequestProvider(provider: Web3Provider): provider is RequestProvider;
|
|
11
|
-
export declare function isSendAsyncProvider(provider: Web3Provider): provider is SendAsyncProvider;
|
|
12
|
-
export declare function isEIP1193Provider(provider: Web3Provider): provider is EIP1193Provider;
|
|
13
3
|
export declare function isTruthy<T = unknown>(value: T): value is Exclude<T, undefined | null>;
|
|
14
4
|
//# sourceMappingURL=assertion.d.ts.map
|
package/lib/utils/assertion.js
CHANGED
|
@@ -3,44 +3,6 @@ export function assertLightClient(client) {
|
|
|
3
3
|
throw new Error("Light client is not initialized yet.");
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
* Checks if the provider is a web3.js version 4x.
|
|
8
|
-
*/
|
|
9
|
-
export function isWeb3jsProvider(provider) {
|
|
10
|
-
return ("isWeb3Provider" in provider.constructor &&
|
|
11
|
-
provider.constructor.isWeb3Provider(provider));
|
|
12
|
-
}
|
|
13
|
-
export function isSendProvider(provider) {
|
|
14
|
-
return (!isWeb3jsProvider(provider) &&
|
|
15
|
-
"send" in provider &&
|
|
16
|
-
typeof provider.send === "function" &&
|
|
17
|
-
provider.send.length > 1 &&
|
|
18
|
-
provider.send.constructor.name !== "AsyncFunction");
|
|
19
|
-
}
|
|
20
|
-
export function isEthersProvider(provider) {
|
|
21
|
-
return (!isWeb3jsProvider(provider) &&
|
|
22
|
-
"send" in provider &&
|
|
23
|
-
typeof provider.send === "function" &&
|
|
24
|
-
provider.send.length > 1 &&
|
|
25
|
-
provider.send.constructor.name === "AsyncFunction");
|
|
26
|
-
}
|
|
27
|
-
export function isRequestProvider(provider) {
|
|
28
|
-
return (!isWeb3jsProvider(provider) &&
|
|
29
|
-
"request" in provider &&
|
|
30
|
-
typeof provider.request === "function" &&
|
|
31
|
-
provider.request.length > 1);
|
|
32
|
-
}
|
|
33
|
-
export function isSendAsyncProvider(provider) {
|
|
34
|
-
return ("sendAsync" in provider &&
|
|
35
|
-
typeof provider.sendAsync === "function" &&
|
|
36
|
-
provider.sendAsync.constructor.name === "AsyncFunction");
|
|
37
|
-
}
|
|
38
|
-
export function isEIP1193Provider(provider) {
|
|
39
|
-
return (!isWeb3jsProvider(provider) &&
|
|
40
|
-
"request" in provider &&
|
|
41
|
-
typeof provider.request === "function" &&
|
|
42
|
-
provider.request.constructor.name === "AsyncFunction");
|
|
43
|
-
}
|
|
44
6
|
export function isTruthy(value) {
|
|
45
7
|
return value !== undefined && value !== null && value !== false;
|
|
46
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertion.js","sourceRoot":"","sources":["../../src/utils/assertion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assertion.js","sourceRoot":"","sources":["../../src/utils/assertion.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAAC,MAAoB;IACpD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAc,KAAQ;IAC5C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC;AAClE,CAAC"}
|
package/lib/utils/evm.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ import { allForks } from "@lodestar/types";
|
|
|
5
5
|
import { Logger } from "@lodestar/utils";
|
|
6
6
|
import { ProofProvider } from "../proof_provider/proof_provider.js";
|
|
7
7
|
import { ELBlock, ELProof, ELTransaction } from "../types.js";
|
|
8
|
-
import {
|
|
8
|
+
import { ELRpcProvider } from "./rpc_provider.js";
|
|
9
9
|
export declare function createVM({ proofProvider }: {
|
|
10
10
|
proofProvider: ProofProvider;
|
|
11
11
|
}): Promise<VM>;
|
|
12
12
|
export declare function getVMWithState({ rpc, executionPayload, tx, vm, logger, }: {
|
|
13
|
-
rpc:
|
|
13
|
+
rpc: ELRpcProvider;
|
|
14
14
|
vm: VM;
|
|
15
15
|
executionPayload: allForks.ExecutionPayload;
|
|
16
16
|
tx: ELTransaction;
|
|
@@ -26,14 +26,14 @@ export declare function updateVMWithState({ vm, state }: {
|
|
|
26
26
|
vm: VM;
|
|
27
27
|
}): Promise<VM>;
|
|
28
28
|
export declare function executeVMCall({ rpc, tx, vm, executionPayload, network, }: {
|
|
29
|
-
rpc:
|
|
29
|
+
rpc: ELRpcProvider;
|
|
30
30
|
tx: ELTransaction;
|
|
31
31
|
vm: VM;
|
|
32
32
|
executionPayload: allForks.ExecutionPayload;
|
|
33
33
|
network: NetworkName;
|
|
34
34
|
}): Promise<RunTxResult["execResult"]>;
|
|
35
35
|
export declare function executeVMTx({ rpc, tx, vm, executionPayload, network, }: {
|
|
36
|
-
rpc:
|
|
36
|
+
rpc: ELRpcProvider;
|
|
37
37
|
tx: ELTransaction;
|
|
38
38
|
vm: VM;
|
|
39
39
|
executionPayload: allForks.ExecutionPayload;
|
package/lib/utils/execution.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Common } from "@ethereumjs/common";
|
|
2
2
|
import { ELApiParams, ELApiReturn, ELTransaction } from "../types.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ELRpcProvider } from "./rpc_provider.js";
|
|
4
4
|
export type Optional<T, K extends keyof T> = Omit<T, K> & {
|
|
5
5
|
[P in keyof T]?: T[P] | undefined;
|
|
6
6
|
};
|
|
7
|
-
export declare function getELCode(rpc:
|
|
8
|
-
export declare function getELProof(rpc:
|
|
9
|
-
export declare function getELBlock(rpc:
|
|
7
|
+
export declare function getELCode(rpc: ELRpcProvider, args: ELApiParams["eth_getCode"]): Promise<ELApiReturn["eth_getCode"]>;
|
|
8
|
+
export declare function getELProof(rpc: ELRpcProvider, args: ELApiParams["eth_getProof"]): Promise<ELApiReturn["eth_getProof"]>;
|
|
9
|
+
export declare function getELBlock(rpc: ELRpcProvider, args: ELApiParams["eth_getBlockByNumber"]): Promise<ELApiReturn["eth_getBlockByNumber"]>;
|
|
10
10
|
export declare function getChainCommon(network: string): Common;
|
|
11
11
|
export declare function getTxType(tx: ELTransaction): number;
|
|
12
12
|
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/utils/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,aAAa,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAKzD,MAAM,CAAC,KAAK,UAAU,SAAS,
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/utils/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,aAAa,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAKzD,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,GAAkB,EAClB,IAAgC;IAEhC,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,EAAE,EAAC,UAAU,EAAE,KAAK,EAAC,CAAC,CAAC;IAE/E,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,UAAU,CAAC,MAAM,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAkB,EAClB,IAAiC;IAEjC,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,EAAE,EAAC,UAAU,EAAE,KAAK,EAAC,CAAC,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,CAAC,CAAC;QACpD;YACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,OAAO,GAAG,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAiB;IACzC,IAAI,SAAS,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC;QACrE,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,SAAS,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/lib/utils/process.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Logger } from "@lodestar/logger";
|
|
|
2
2
|
import { ELVerifiedRequestHandler } from "../interfaces.js";
|
|
3
3
|
import { ProofProvider } from "../proof_provider/proof_provider.js";
|
|
4
4
|
import { JsonRpcRequestOrBatch, JsonRpcBatchRequest, JsonRpcResponseOrBatch } from "../types.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ELRpcProvider } from "./rpc_provider.js";
|
|
6
6
|
export declare const verifiableMethodHandlers: Record<string, ELVerifiedRequestHandler<any, any>>;
|
|
7
7
|
export declare const verifiableMethods: string[];
|
|
8
8
|
export declare const alwaysAllowedMethods: string[];
|
|
@@ -13,7 +13,7 @@ export declare function splitRequestsInChunks(payload: JsonRpcRequestOrBatch, un
|
|
|
13
13
|
};
|
|
14
14
|
export declare function processAndVerifyRequest({ payload, rpc, proofProvider, logger, }: {
|
|
15
15
|
payload: JsonRpcRequestOrBatch;
|
|
16
|
-
rpc:
|
|
16
|
+
rpc: ELRpcProvider;
|
|
17
17
|
proofProvider: ProofProvider;
|
|
18
18
|
logger: Logger;
|
|
19
19
|
}): Promise<JsonRpcResponseOrBatch | undefined>;
|
|
@@ -4,13 +4,24 @@ import { ELApi, ELApiParams, ELApiReturn, JsonRpcBatchRequest, JsonRpcRequest, J
|
|
|
4
4
|
export type Optional<T, K extends keyof T> = Omit<T, K> & {
|
|
5
5
|
[P in keyof T]?: T[P] | undefined;
|
|
6
6
|
};
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class ELRpcProvider {
|
|
8
8
|
private handler;
|
|
9
9
|
private logger;
|
|
10
10
|
private requestId;
|
|
11
11
|
constructor(handler: ELRequestHandler, logger: Logger);
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Request the EL RPC Provider
|
|
14
|
+
*
|
|
15
|
+
* @template K
|
|
16
|
+
* @template E
|
|
17
|
+
* @param {K} method - RPC Method
|
|
18
|
+
* @param {ELApiParams[K]} params - RPC Params
|
|
19
|
+
* @param {{raiseError?: E}} [opts]
|
|
20
|
+
* @return {*} {Promise<E extends false ? JsonRpcResponse<ELApiReturn[K]> : JsonRpcResponseWithResultPayload<ELApiReturn[K]>>}
|
|
21
|
+
* @memberof ELRpc
|
|
22
|
+
*/
|
|
23
|
+
request<K extends keyof ELApi, E extends boolean>(method: K, params: ELApiParams[K], opts?: {
|
|
24
|
+
raiseError?: E;
|
|
14
25
|
}): Promise<E extends false ? JsonRpcResponse<ELApiReturn[K]> : JsonRpcResponseWithResultPayload<ELApiReturn[K]>>;
|
|
15
26
|
batchRequest<E extends boolean>(input: JsonRpcBatchRequest, opts: {
|
|
16
27
|
raiseError: E;
|
|
@@ -24,4 +35,4 @@ export declare class ELRpc {
|
|
|
24
35
|
verifyCompatibility(): Promise<void>;
|
|
25
36
|
getRequestId(): string;
|
|
26
37
|
}
|
|
27
|
-
//# sourceMappingURL=
|
|
38
|
+
//# sourceMappingURL=rpc_provider.d.ts.map
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { ZERO_ADDRESS } from "../constants.js";
|
|
2
2
|
import { isRequest, isValidBatchResponse, isValidResponse, logRequest, logResponse, mergeBatchReqResp, } from "./json_rpc.js";
|
|
3
3
|
import { isNullish } from "./validation.js";
|
|
4
|
-
export class
|
|
4
|
+
export class ELRpcProvider {
|
|
5
5
|
constructor(handler, logger) {
|
|
6
6
|
this.requestId = 0;
|
|
7
7
|
this.handler = handler;
|
|
8
8
|
this.logger = logger;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Request the EL RPC Provider
|
|
12
|
+
*
|
|
13
|
+
* @template K
|
|
14
|
+
* @template E
|
|
15
|
+
* @param {K} method - RPC Method
|
|
16
|
+
* @param {ELApiParams[K]} params - RPC Params
|
|
17
|
+
* @param {{raiseError?: E}} [opts]
|
|
18
|
+
* @return {*} {Promise<E extends false ? JsonRpcResponse<ELApiReturn[K]> : JsonRpcResponseWithResultPayload<ELApiReturn[K]>>}
|
|
19
|
+
* @memberof ELRpc
|
|
20
|
+
*/
|
|
10
21
|
async request(method, params, opts) {
|
|
11
|
-
const { raiseError } = opts;
|
|
22
|
+
const { raiseError } = opts ?? { raiseError: true };
|
|
12
23
|
const payload = { jsonrpc: "2.0", method, params, id: this.getRequestId() };
|
|
13
24
|
logRequest(payload, this.logger);
|
|
14
25
|
const response = await this.handler(payload);
|
|
@@ -52,4 +63,4 @@ export class ELRpc {
|
|
|
52
63
|
return (++this.requestId).toString();
|
|
53
64
|
}
|
|
54
65
|
}
|
|
55
|
-
//# sourceMappingURL=
|
|
66
|
+
//# sourceMappingURL=rpc_provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc_provider.js","sourceRoot":"","sources":["../../src/utils/rpc_provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAY7C,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAI1C,MAAM,OAAO,aAAa;IAMxB,YAAY,OAAyB,EAAE,MAAc;QAF7C,cAAS,GAAG,CAAC,CAAC;QAG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
|
1
1
|
import { Logger } from "@lodestar/utils";
|
|
2
2
|
import { ProofProvider } from "../proof_provider/proof_provider.js";
|
|
3
3
|
import { ELBlock, ELProof, HexString, JsonRpcRequest } from "../types.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ELRpcProvider } from "./rpc_provider.js";
|
|
5
5
|
type VerificationResult<T> = {
|
|
6
6
|
data: T;
|
|
7
7
|
valid: true;
|
|
@@ -11,14 +11,14 @@ type VerificationResult<T> = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare function verifyAccount({ address, proofProvider, logger, rpc, block, }: {
|
|
13
13
|
address: HexString;
|
|
14
|
-
rpc:
|
|
14
|
+
rpc: ELRpcProvider;
|
|
15
15
|
proofProvider: ProofProvider;
|
|
16
16
|
logger: Logger;
|
|
17
17
|
block?: number | string;
|
|
18
18
|
}): Promise<VerificationResult<ELProof>>;
|
|
19
19
|
export declare function verifyCode({ address, proofProvider, logger, rpc, codeHash, block, }: {
|
|
20
20
|
address: HexString;
|
|
21
|
-
rpc:
|
|
21
|
+
rpc: ELRpcProvider;
|
|
22
22
|
proofProvider: ProofProvider;
|
|
23
23
|
logger: Logger;
|
|
24
24
|
codeHash: HexString;
|
|
@@ -26,7 +26,7 @@ export declare function verifyCode({ address, proofProvider, logger, rpc, codeHa
|
|
|
26
26
|
}): Promise<VerificationResult<string>>;
|
|
27
27
|
export declare function verifyBlock({ payload, proofProvider, logger, rpc, }: {
|
|
28
28
|
payload: JsonRpcRequest<[block: string | number, hydrated: boolean]>;
|
|
29
|
-
rpc:
|
|
29
|
+
rpc: ELRpcProvider;
|
|
30
30
|
proofProvider: ProofProvider;
|
|
31
31
|
logger: Logger;
|
|
32
32
|
}): Promise<VerificationResult<ELBlock>>;
|
package/lib/web3_provider.d.ts
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { Logger } from "@lodestar/utils";
|
|
2
|
-
import {
|
|
2
|
+
import { AnyWeb3Provider, VerifiedExecutionInitOptions } from "./interfaces.js";
|
|
3
3
|
import { ProofProvider } from "./proof_provider/proof_provider.js";
|
|
4
|
-
import {
|
|
5
|
-
export type Web3ProviderTypeHandler<T extends
|
|
4
|
+
import { ELRpcProvider } from "./utils/rpc_provider.js";
|
|
5
|
+
export type Web3ProviderTypeHandler<T extends AnyWeb3Provider> = (provider: T, proofProvider: ProofProvider, logger: Logger) => {
|
|
6
6
|
provider: T;
|
|
7
|
-
|
|
7
|
+
handler: ELRpcProvider["handler"];
|
|
8
8
|
};
|
|
9
|
-
export declare function createVerifiedExecutionProvider<T extends
|
|
10
|
-
provider: T;
|
|
9
|
+
export declare function createVerifiedExecutionProvider<T extends AnyWeb3Provider, Mutate extends undefined | boolean = true, Return = {
|
|
10
|
+
provider: Mutate extends undefined | true ? T : ELRpcProvider;
|
|
11
11
|
proofProvider: ProofProvider;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @export
|
|
17
|
-
* @template T
|
|
18
|
-
* @param {T} provider
|
|
19
|
-
* @param {Logger} logger
|
|
20
|
-
* @return {*} {Web3ProviderTypeHandler<T>}
|
|
21
|
-
*/
|
|
22
|
-
export declare function getProviderTypeHandler<T extends Web3Provider>(provider: T, logger: Logger): Web3ProviderTypeHandler<T>;
|
|
12
|
+
}>(provider: T, opts: VerifiedExecutionInitOptions<Mutate>): Return;
|
|
23
13
|
//# sourceMappingURL=web3_provider.d.ts.map
|
package/lib/web3_provider.js
CHANGED
|
@@ -1,151 +1,39 @@
|
|
|
1
|
-
import { getBrowserLogger } from "@lodestar/logger/browser";
|
|
2
1
|
import { LogLevel } from "@lodestar/logger";
|
|
2
|
+
import { getBrowserLogger } from "@lodestar/logger/browser";
|
|
3
3
|
import { ProofProvider } from "./proof_provider/proof_provider.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ELRpcProvider } from "./utils/rpc_provider.js";
|
|
5
|
+
import { Web3ProviderInspector } from "./web3_provider_inspector.js";
|
|
5
6
|
import { processAndVerifyRequest } from "./utils/process.js";
|
|
6
|
-
import { isBatchRequest } from "./utils/json_rpc.js";
|
|
7
|
-
import { ELRpc } from "./utils/rpc.js";
|
|
8
7
|
export function createVerifiedExecutionProvider(provider, opts) {
|
|
9
8
|
const signal = opts.signal ?? new AbortController().signal;
|
|
10
9
|
const logger = opts.logger ?? getBrowserLogger({ level: opts.logLevel ?? LogLevel.info });
|
|
10
|
+
const mutateProvider = opts.mutateProvider === undefined;
|
|
11
|
+
const customProviderTypes = opts.providerTypes ?? [];
|
|
12
|
+
const providerInspector = Web3ProviderInspector.initWithDefault({ logger });
|
|
13
|
+
for (const providerType of customProviderTypes.reverse()) {
|
|
14
|
+
providerInspector.register(providerType, { index: 0 });
|
|
15
|
+
}
|
|
16
|
+
const providerType = providerInspector.detect(provider);
|
|
17
|
+
logger.debug(`Provider is detected as '${providerType.name}' provider.`);
|
|
11
18
|
const proofProvider = ProofProvider.init({
|
|
12
19
|
...opts,
|
|
13
20
|
signal,
|
|
14
21
|
logger,
|
|
15
22
|
});
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
23
|
+
const nonVerifiedHandler = providerType.handler(provider);
|
|
24
|
+
const nonVerifiedRpc = new ELRpcProvider(nonVerifiedHandler, logger);
|
|
25
|
+
nonVerifiedRpc.verifyCompatibility().catch((err) => {
|
|
19
26
|
logger.error(err);
|
|
20
27
|
logger.error("Due to compatibility issues, verified execution may not work properly.");
|
|
21
28
|
});
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
function handleSendProvider(provider, proofProvider, logger) {
|
|
25
|
-
const send = provider.send.bind(provider);
|
|
26
|
-
const handler = (payload) => new Promise((resolve, reject) => {
|
|
27
|
-
// web3 providers supports batch requests but don't have valid types
|
|
28
|
-
send(payload, (err, response) => {
|
|
29
|
-
if (err) {
|
|
30
|
-
reject(err);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
resolve(response);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
const rpc = new ELRpc(handler, logger);
|
|
38
|
-
function newSend(payload, callback) {
|
|
39
|
-
processAndVerifyRequest({ payload, rpc, proofProvider, logger })
|
|
40
|
-
.then((response) => callback(undefined, response))
|
|
41
|
-
.catch((err) => callback(err, undefined));
|
|
42
|
-
}
|
|
43
|
-
return { provider: Object.assign(provider, { send: newSend }), rpc };
|
|
44
|
-
}
|
|
45
|
-
function handleRequestProvider(provider, proofProvider, logger) {
|
|
46
|
-
const request = provider.request.bind(provider);
|
|
47
|
-
const handler = (payload) => new Promise((resolve, reject) => {
|
|
48
|
-
request(payload, (err, response) => {
|
|
49
|
-
if (err) {
|
|
50
|
-
reject(err);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
resolve(response);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
const rpc = new ELRpc(handler, logger);
|
|
58
|
-
function newRequest(payload, callback) {
|
|
59
|
-
processAndVerifyRequest({ payload, rpc, proofProvider, logger })
|
|
60
|
-
.then((response) => callback(undefined, response))
|
|
61
|
-
.catch((err) => callback(err, undefined));
|
|
62
|
-
}
|
|
63
|
-
return { provider: Object.assign(provider, { request: newRequest }), rpc };
|
|
64
|
-
}
|
|
65
|
-
function handleSendAsyncProvider(provider, proofProvider, logger) {
|
|
66
|
-
const sendAsync = provider.sendAsync.bind(provider);
|
|
67
|
-
const handler = async (payload) => {
|
|
68
|
-
const response = await sendAsync(payload);
|
|
69
|
-
return response;
|
|
70
|
-
};
|
|
71
|
-
const rpc = new ELRpc(handler, logger);
|
|
72
|
-
async function newSendAsync(payload) {
|
|
73
|
-
return processAndVerifyRequest({ payload, rpc, proofProvider, logger });
|
|
74
|
-
}
|
|
75
|
-
return { provider: Object.assign(provider, { sendAsync: newSendAsync }), rpc };
|
|
76
|
-
}
|
|
77
|
-
function handleEIP1193Provider(provider, proofProvider, logger) {
|
|
78
|
-
const request = provider.request.bind(provider);
|
|
79
|
-
const handler = async (payload) => {
|
|
80
|
-
const response = await request(payload);
|
|
81
|
-
return response;
|
|
82
|
-
};
|
|
83
|
-
const rpc = new ELRpc(handler, logger);
|
|
84
|
-
async function newRequest(payload) {
|
|
85
|
-
return processAndVerifyRequest({ payload, rpc, proofProvider, logger });
|
|
86
|
-
}
|
|
87
|
-
return { provider: Object.assign(provider, { request: newRequest }), rpc };
|
|
88
|
-
}
|
|
89
|
-
function handleEthersProvider(provider, proofProvider, logger) {
|
|
90
|
-
const send = provider.send.bind(provider);
|
|
91
|
-
const handler = async (payload) => {
|
|
92
|
-
// Because ethers provider public interface does not support batch requests
|
|
93
|
-
// so we need to handle it manually
|
|
94
|
-
if (isBatchRequest(payload)) {
|
|
95
|
-
const responses = [];
|
|
96
|
-
for (const request of payload) {
|
|
97
|
-
responses.push(await send(request.method, request.params));
|
|
98
|
-
}
|
|
99
|
-
return responses;
|
|
100
|
-
}
|
|
101
|
-
return send(payload.method, payload.params);
|
|
29
|
+
const verifiedHandler = function newVerifiedHandler(payload) {
|
|
30
|
+
return processAndVerifyRequest({ payload, rpc: nonVerifiedRpc, logger, proofProvider });
|
|
102
31
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return
|
|
106
|
-
payload: { jsonrpc: "2.0", id: 0, method, params },
|
|
107
|
-
rpc,
|
|
108
|
-
proofProvider,
|
|
109
|
-
logger,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return { provider: Object.assign(provider, { send: newSend }), rpc };
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* @export
|
|
118
|
-
* @template T
|
|
119
|
-
* @param {T} provider
|
|
120
|
-
* @param {Logger} logger
|
|
121
|
-
* @return {*} {Web3ProviderTypeHandler<T>}
|
|
122
|
-
*/
|
|
123
|
-
export function getProviderTypeHandler(provider, logger) {
|
|
124
|
-
if (isWeb3jsProvider(provider)) {
|
|
125
|
-
logger.debug("Provider is recognized as 'web3.js' provider.");
|
|
126
|
-
// EIP-1193 provider is fully compatible with web3.js#4x provider interface
|
|
127
|
-
return handleEIP1193Provider;
|
|
128
|
-
}
|
|
129
|
-
if (isEthersProvider(provider)) {
|
|
130
|
-
logger.debug("Provider is recognized as 'ethers' provider.");
|
|
131
|
-
return handleEthersProvider;
|
|
132
|
-
}
|
|
133
|
-
if (isEIP1193Provider(provider)) {
|
|
134
|
-
logger.debug("Provider is recognized as 'EIP1193' provider.");
|
|
135
|
-
return handleEIP1193Provider;
|
|
136
|
-
}
|
|
137
|
-
if (isSendProvider(provider)) {
|
|
138
|
-
logger.debug("Provider is recognized as legacy provider with 'send' method.");
|
|
139
|
-
return handleSendProvider;
|
|
140
|
-
}
|
|
141
|
-
if (isRequestProvider(provider)) {
|
|
142
|
-
logger.debug("Provider is recognized as legacy provider with 'request' method.");
|
|
143
|
-
return handleRequestProvider;
|
|
144
|
-
}
|
|
145
|
-
if (isSendAsyncProvider(provider)) {
|
|
146
|
-
logger.debug("Provider is recognized as legacy provider with 'sendAsync' method.");
|
|
147
|
-
return handleSendAsyncProvider;
|
|
32
|
+
if (mutateProvider) {
|
|
33
|
+
providerType.mutateProvider(provider, verifiedHandler);
|
|
34
|
+
return { provider, proofProvider };
|
|
148
35
|
}
|
|
149
|
-
|
|
36
|
+
// Verified RPC
|
|
37
|
+
return { provider: new ELRpcProvider(verifiedHandler, logger), proofProvider };
|
|
150
38
|
}
|
|
151
39
|
//# sourceMappingURL=web3_provider.js.map
|
package/lib/web3_provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web3_provider.js","sourceRoot":"","sources":["../src/web3_provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web3_provider.js","sourceRoot":"","sources":["../src/web3_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EA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M,CAAC,CAAC;IAErE,cAAc,CAAC,mBAAmB,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACjD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClB,MAAM,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;IAEH,MAAM,eAAe,GAAqB,SAAS,kBAAkB,CAAC,OAAO;QAC3E,OAAO,uBAAuB,CAAC,EAAC,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAC,CAAC,CAAC;IACxF,CAAC,CAAC;IAEF,IAAI,cAAc,EAAE,CAAC;QACnB,YAAY,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACvD,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAW,CAAC;IAC7C,CAAC;IAED,eAAe;IACf,OAAO,EAAC,QAAQ,EAAE,IAAI,aAAa,CAAC,eAAe,EAAE,MAAM,CAAC,EAAE,aAAa,EAAW,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Logger } from "@lodestar/logger";
|
|
2
|
+
import { AnyWeb3Provider, Web3ProviderType } from "./interfaces.js";
|
|
3
|
+
export declare class Web3ProviderInspector {
|
|
4
|
+
protected providerTypes: Web3ProviderType<AnyWeb3Provider>[];
|
|
5
|
+
logger: Logger;
|
|
6
|
+
protected constructor(opts: {
|
|
7
|
+
logger: Logger;
|
|
8
|
+
});
|
|
9
|
+
static initWithDefault(opts: {
|
|
10
|
+
logger: Logger;
|
|
11
|
+
}): Web3ProviderInspector;
|
|
12
|
+
getProviderTypes(): Web3ProviderType<AnyWeb3Provider>[];
|
|
13
|
+
register(providerType: Web3ProviderType<AnyWeb3Provider>, opts?: {
|
|
14
|
+
index?: number;
|
|
15
|
+
}): void;
|
|
16
|
+
unregister(indexOrName: string | number): void;
|
|
17
|
+
detect(provider: AnyWeb3Provider): Web3ProviderType<AnyWeb3Provider>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=web3_provider_inspector.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import web3jsProviderType from "./provider_types/web3_js_provider_type.js";
|
|
2
|
+
import ethersProviderType from "./provider_types/ethers_provider_type.js";
|
|
3
|
+
import eip1193ProviderType from "./provider_types/eip1193_provider_type.js";
|
|
4
|
+
import legacyProviderType from "./provider_types/legacy_provider_type.js";
|
|
5
|
+
export class Web3ProviderInspector {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
this.providerTypes = [];
|
|
8
|
+
this.logger = opts.logger;
|
|
9
|
+
}
|
|
10
|
+
static initWithDefault(opts) {
|
|
11
|
+
const inspector = new Web3ProviderInspector(opts);
|
|
12
|
+
inspector.register(web3jsProviderType, { index: 0 });
|
|
13
|
+
inspector.register(ethersProviderType, { index: 1 });
|
|
14
|
+
inspector.register(eip1193ProviderType, { index: 2 });
|
|
15
|
+
inspector.register(legacyProviderType, { index: 3 });
|
|
16
|
+
return inspector;
|
|
17
|
+
}
|
|
18
|
+
getProviderTypes() {
|
|
19
|
+
// Destruct so user can not mutate the output
|
|
20
|
+
return [...this.providerTypes];
|
|
21
|
+
}
|
|
22
|
+
register(providerType, opts) {
|
|
23
|
+
// If user does not provider index, we will register the provider type to last
|
|
24
|
+
let index = opts?.index ?? this.providerTypes.length;
|
|
25
|
+
// If index is larger, let's add type at the end
|
|
26
|
+
if (index > this.providerTypes.length) {
|
|
27
|
+
index = this.providerTypes.length;
|
|
28
|
+
}
|
|
29
|
+
// If a lower index is provided let's add type at the start
|
|
30
|
+
if (index < 0) {
|
|
31
|
+
index = 0;
|
|
32
|
+
}
|
|
33
|
+
if (this.providerTypes.map((p) => p.name).includes(providerType.name)) {
|
|
34
|
+
throw new Error(`Provider type '${providerType.name}' is already registered.`);
|
|
35
|
+
}
|
|
36
|
+
// If some provider type is already register on that index, we will make space for new
|
|
37
|
+
if (this.providerTypes.at(index)) {
|
|
38
|
+
this.logger.debug(`A provider type '${this.providerTypes[index].name}' already existed at index '${index}', now moved down.`);
|
|
39
|
+
this.providerTypes.splice(index, 0, providerType);
|
|
40
|
+
}
|
|
41
|
+
this.logger.debug(`Registered provider type "${providerType.name}" at index ${index}`);
|
|
42
|
+
this.providerTypes[index] = providerType;
|
|
43
|
+
}
|
|
44
|
+
unregister(indexOrName) {
|
|
45
|
+
if (typeof indexOrName === "number") {
|
|
46
|
+
if (indexOrName > this.providerTypes.length || indexOrName < 0) {
|
|
47
|
+
throw new Error(`Provider type at index '${indexOrName}' is not registered.`);
|
|
48
|
+
}
|
|
49
|
+
this.providerTypes.splice(indexOrName, 1);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const index = this.providerTypes.findIndex((p) => p.name == indexOrName);
|
|
53
|
+
if (index < 0) {
|
|
54
|
+
throw Error(`Provider type '${indexOrName}' is not registered.`);
|
|
55
|
+
}
|
|
56
|
+
this.providerTypes.splice(index, 1);
|
|
57
|
+
}
|
|
58
|
+
detect(provider) {
|
|
59
|
+
for (const providerType of Object.values(this.providerTypes)) {
|
|
60
|
+
if (providerType.matched(provider)) {
|
|
61
|
+
return providerType;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
throw new Error(`Given provider could not be detected of any type. Supported types are ${Object.keys(this.providerTypes).join()}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=web3_provider_inspector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web3_provider_inspector.js","sourceRoot":"","sources":["../src/web3_provider_inspector.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,MAAM,2CAA2C,CAAC;AAC3E,OAAO,kBAAkB,MAAM,0CAA0C,CAAC;AAC1E,OAAO,mBAAmB,MAAM,2CAA2C,CAAC;AAC5E,OAAO,kBAAkB,MAAM,0CAA0C,CAAC;AAE1E,MAAM,OAAO,qBAAqB;IAIhC,YAAsB,IAAsB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IAED,MAAM,CAAC,QAAyB;QAC9B,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YAC7D,IAAI,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACnC,OAAO,YAAY,CAAC;YACtB,CAAC;QACH,CAAC;QAED,MAAM,IAAI,KAAK,CACb,yEAAyE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE,CAClH,CAAC;IACJ,CAAC;CACF"}
|
package/lib/web3_proxy.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import http from "node:http";
|
|
3
3
|
import { VerifiedExecutionInitOptions } from "./interfaces.js";
|
|
4
4
|
import { ProofProvider } from "./proof_provider/proof_provider.js";
|
|
5
|
-
export type VerifiedProxyOptions = VerifiedExecutionInitOptions & {
|
|
5
|
+
export type VerifiedProxyOptions = Exclude<VerifiedExecutionInitOptions<false>, "mutateProvider" | "providerTypes"> & {
|
|
6
6
|
executionRpcUrl: string;
|
|
7
7
|
requestTimeout: number;
|
|
8
8
|
};
|
package/lib/web3_proxy.js
CHANGED
|
@@ -8,7 +8,7 @@ import { ProofProvider } from "./proof_provider/proof_provider.js";
|
|
|
8
8
|
import { getResponseForRequest, isBatchRequest } from "./utils/json_rpc.js";
|
|
9
9
|
import { fetchRequestPayload, fetchResponseBody } from "./utils/req_resp.js";
|
|
10
10
|
import { processAndVerifyRequest } from "./utils/process.js";
|
|
11
|
-
import {
|
|
11
|
+
import { ELRpcProvider } from "./utils/rpc_provider.js";
|
|
12
12
|
function createHttpHandler({ info, signal, }) {
|
|
13
13
|
return function handler(payload) {
|
|
14
14
|
return new Promise((resolve, reject) => {
|
|
@@ -61,7 +61,7 @@ export function createVerifiedExecutionProxy(opts) {
|
|
|
61
61
|
changeOrigin: true,
|
|
62
62
|
});
|
|
63
63
|
let proxyServerListeningAddress;
|
|
64
|
-
const rpc = new
|
|
64
|
+
const rpc = new ELRpcProvider(createHttpHandler({
|
|
65
65
|
signal,
|
|
66
66
|
info: () => {
|
|
67
67
|
if (!proxyServerListeningAddress) {
|
package/lib/web3_proxy.js.map
CHANGED
|
@@ -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,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAC,aAAa,EAAC,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAC,qBAAqB,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAC,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAC,
|
|
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,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAC,aAAa,EAAC,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAC,qBAAqB,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAA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;YACtC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI;QACtE,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC5C,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;QACpC,WAAW,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAC,CAAC;AAC9C,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.19.0-dev.
|
|
14
|
+
"version": "1.19.0-dev.deafa4f162",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
"@ethereumjs/tx": "^4.1.2",
|
|
70
70
|
"@ethereumjs/util": "^8.0.6",
|
|
71
71
|
"@ethereumjs/vm": "^6.4.2",
|
|
72
|
-
"@lodestar/api": "1.19.0-dev.
|
|
73
|
-
"@lodestar/config": "1.19.0-dev.
|
|
74
|
-
"@lodestar/light-client": "1.19.0-dev.
|
|
75
|
-
"@lodestar/logger": "1.19.0-dev.
|
|
76
|
-
"@lodestar/params": "1.19.0-dev.
|
|
77
|
-
"@lodestar/types": "1.19.0-dev.
|
|
78
|
-
"@lodestar/utils": "1.19.0-dev.
|
|
72
|
+
"@lodestar/api": "1.19.0-dev.deafa4f162",
|
|
73
|
+
"@lodestar/config": "1.19.0-dev.deafa4f162",
|
|
74
|
+
"@lodestar/light-client": "1.19.0-dev.deafa4f162",
|
|
75
|
+
"@lodestar/logger": "1.19.0-dev.deafa4f162",
|
|
76
|
+
"@lodestar/params": "1.19.0-dev.deafa4f162",
|
|
77
|
+
"@lodestar/types": "1.19.0-dev.deafa4f162",
|
|
78
|
+
"@lodestar/utils": "1.19.0-dev.deafa4f162",
|
|
79
79
|
"ethereum-cryptography": "^2.0.0",
|
|
80
80
|
"find-up": "^6.3.0",
|
|
81
81
|
"http-proxy": "^1.18.1",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"yargs": "^17.7.1"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@lodestar/test-utils": "1.19.0-dev.
|
|
87
|
+
"@lodestar/test-utils": "1.19.0-dev.deafa4f162",
|
|
88
88
|
"@types/http-proxy": "^1.17.10",
|
|
89
89
|
"@types/yargs": "^17.0.24",
|
|
90
90
|
"axios": "^1.3.4",
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"blockchain",
|
|
100
100
|
"prover"
|
|
101
101
|
],
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "14236c409dddcd1655897dc317b50b2da643ae95"
|
|
103
103
|
}
|
package/lib/utils/rpc.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../src/utils/rpc.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAY7C,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAI1C,MAAM,OAAO,KAAK;IAMhB,YAAY,OAAyB,EAAE,MAAc;Q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