@lodestar/prover 1.9.1
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/LICENSE +201 -0
- package/README.md +135 -0
- package/lib/cli/applyPreset.d.ts +2 -0
- package/lib/cli/applyPreset.js +72 -0
- package/lib/cli/applyPreset.js.map +1 -0
- package/lib/cli/cli.d.ts +8 -0
- package/lib/cli/cli.js +50 -0
- package/lib/cli/cli.js.map +1 -0
- package/lib/cli/cmds/index.d.ts +4 -0
- package/lib/cli/cmds/index.js +3 -0
- package/lib/cli/cmds/index.js.map +1 -0
- package/lib/cli/cmds/start/handler.d.ts +7 -0
- package/lib/cli/cmds/start/handler.js +30 -0
- package/lib/cli/cmds/start/handler.js.map +1 -0
- package/lib/cli/cmds/start/index.d.ts +5 -0
- package/lib/cli/cmds/start/index.js +15 -0
- package/lib/cli/cmds/start/index.js.map +1 -0
- package/lib/cli/cmds/start/options.d.ts +27 -0
- package/lib/cli/cmds/start/options.js +67 -0
- package/lib/cli/cmds/start/options.js.map +1 -0
- package/lib/cli/index.d.ts +4 -0
- package/lib/cli/index.js +25 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/cli/options.d.ts +22 -0
- package/lib/cli/options.js +50 -0
- package/lib/cli/options.js.map +1 -0
- package/lib/constants.d.ts +6 -0
- package/lib/constants.js +7 -0
- package/lib/constants.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -0
- package/lib/index.web.d.ts +3 -0
- package/lib/index.web.js +3 -0
- package/lib/index.web.js.map +1 -0
- package/lib/interfaces.d.ts +69 -0
- package/lib/interfaces.js +6 -0
- package/lib/interfaces.js.map +1 -0
- package/lib/proof_provider/ordered_map.d.ts +8 -0
- package/lib/proof_provider/ordered_map.js +24 -0
- package/lib/proof_provider/ordered_map.js.map +1 -0
- package/lib/proof_provider/payload_store.d.ts +25 -0
- package/lib/proof_provider/payload_store.js +154 -0
- package/lib/proof_provider/payload_store.js.map +1 -0
- package/lib/proof_provider/proof_provider.d.ts +36 -0
- package/lib/proof_provider/proof_provider.js +171 -0
- package/lib/proof_provider/proof_provider.js.map +1 -0
- package/lib/types.d.ts +136 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/assertion.d.ts +10 -0
- package/lib/utils/assertion.js +34 -0
- package/lib/utils/assertion.js.map +1 -0
- package/lib/utils/command.d.ts +22 -0
- package/lib/utils/command.js +27 -0
- package/lib/utils/command.js.map +1 -0
- package/lib/utils/consensus.d.ts +19 -0
- package/lib/utils/consensus.js +74 -0
- package/lib/utils/consensus.js.map +1 -0
- package/lib/utils/conversion.d.ts +47 -0
- package/lib/utils/conversion.js +94 -0
- package/lib/utils/conversion.js.map +1 -0
- package/lib/utils/errors.d.ts +6 -0
- package/lib/utils/errors.js +6 -0
- package/lib/utils/errors.js.map +1 -0
- package/lib/utils/evm.d.ts +44 -0
- package/lib/utils/evm.js +193 -0
- package/lib/utils/evm.js.map +1 -0
- package/lib/utils/execution.d.ts +12 -0
- package/lib/utils/execution.js +53 -0
- package/lib/utils/execution.js.map +1 -0
- package/lib/utils/file.d.ts +8 -0
- package/lib/utils/file.js +50 -0
- package/lib/utils/file.js.map +1 -0
- package/lib/utils/gitData/gitDataPath.d.ts +17 -0
- package/lib/utils/gitData/gitDataPath.js +37 -0
- package/lib/utils/gitData/gitDataPath.js.map +1 -0
- package/lib/utils/gitData/index.d.ts +6 -0
- package/lib/utils/gitData/index.js +68 -0
- package/lib/utils/gitData/index.js.map +1 -0
- package/lib/utils/gitData/writeGitData.d.ts +3 -0
- package/lib/utils/gitData/writeGitData.js +8 -0
- package/lib/utils/gitData/writeGitData.js.map +1 -0
- package/lib/utils/json_rpc.d.ts +17 -0
- package/lib/utils/json_rpc.js +115 -0
- package/lib/utils/json_rpc.js.map +1 -0
- package/lib/utils/logger.d.ts +4 -0
- package/lib/utils/logger.js +12 -0
- package/lib/utils/logger.js.map +1 -0
- package/lib/utils/process.d.ts +20 -0
- package/lib/utils/process.js +75 -0
- package/lib/utils/process.js.map +1 -0
- package/lib/utils/req_resp.d.ts +5 -0
- package/lib/utils/req_resp.js +33 -0
- package/lib/utils/req_resp.js.map +1 -0
- package/lib/utils/rpc.d.ts +26 -0
- package/lib/utils/rpc.js +55 -0
- package/lib/utils/rpc.js.map +1 -0
- package/lib/utils/validation.d.ts +30 -0
- package/lib/utils/validation.js +94 -0
- package/lib/utils/validation.js.map +1 -0
- package/lib/utils/verification.d.ts +34 -0
- package/lib/utils/verification.js +62 -0
- package/lib/utils/verification.js.map +1 -0
- package/lib/utils/version.d.ts +12 -0
- package/lib/utils/version.js +59 -0
- package/lib/utils/version.js.map +1 -0
- package/lib/verified_requests/eth_call.d.ts +4 -0
- package/lib/verified_requests/eth_call.js +33 -0
- package/lib/verified_requests/eth_call.js.map +1 -0
- package/lib/verified_requests/eth_estimateGas.d.ts +4 -0
- package/lib/verified_requests/eth_estimateGas.js +33 -0
- package/lib/verified_requests/eth_estimateGas.js.map +1 -0
- package/lib/verified_requests/eth_getBalance.d.ts +3 -0
- package/lib/verified_requests/eth_getBalance.js +13 -0
- package/lib/verified_requests/eth_getBalance.js.map +1 -0
- package/lib/verified_requests/eth_getBlockByHash.d.ts +4 -0
- package/lib/verified_requests/eth_getBlockByHash.js +12 -0
- package/lib/verified_requests/eth_getBlockByHash.js.map +1 -0
- package/lib/verified_requests/eth_getBlockByNumber.d.ts +7 -0
- package/lib/verified_requests/eth_getBlockByNumber.js +12 -0
- package/lib/verified_requests/eth_getBlockByNumber.js.map +1 -0
- package/lib/verified_requests/eth_getCode.d.ts +3 -0
- package/lib/verified_requests/eth_getCode.js +32 -0
- package/lib/verified_requests/eth_getCode.js.map +1 -0
- package/lib/verified_requests/eth_getTransactionCount.d.ts +6 -0
- package/lib/verified_requests/eth_getTransactionCount.js +13 -0
- package/lib/verified_requests/eth_getTransactionCount.js.map +1 -0
- package/lib/web3_provider.d.ts +14 -0
- package/lib/web3_provider.js +138 -0
- package/lib/web3_provider.js.map +1 -0
- package/lib/web3_proxy.d.ts +13 -0
- package/lib/web3_proxy.js +136 -0
- package/lib/web3_proxy.js.map +1 -0
- package/package.json +100 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
// This file is created in the build step and is distributed through NPM
|
|
3
|
+
// MUST be in sync with `-/gitDataPath.ts` and `package.json` files.
|
|
4
|
+
import { readGitDataFile } from "./gitDataPath.js";
|
|
5
|
+
/** Reads git data from a persisted file or local git data at build time. */
|
|
6
|
+
export function readAndGetGitData() {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
try {
|
|
9
|
+
// Gets git data containing current branch and commit info from persistent file.
|
|
10
|
+
let persistedGitData;
|
|
11
|
+
try {
|
|
12
|
+
persistedGitData = readGitDataFile();
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
persistedGitData = {};
|
|
16
|
+
}
|
|
17
|
+
const currentGitData = getGitData();
|
|
18
|
+
return {
|
|
19
|
+
// If the CLI is run from source, prioritze current git data
|
|
20
|
+
// over `.git-data.json` file, which might be stale here.
|
|
21
|
+
branch: currentGitData.branch && currentGitData.branch.length > 0
|
|
22
|
+
? currentGitData.branch
|
|
23
|
+
: (_a = persistedGitData.branch) !== null && _a !== void 0 ? _a : "",
|
|
24
|
+
commit: currentGitData.commit && currentGitData.commit.length > 0
|
|
25
|
+
? currentGitData.commit
|
|
26
|
+
: (_b = persistedGitData.commit) !== null && _b !== void 0 ? _b : "",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
return {
|
|
31
|
+
branch: "",
|
|
32
|
+
commit: "",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Gets git data containing current branch and commit info from CLI. */
|
|
37
|
+
export function getGitData() {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return {
|
|
40
|
+
branch: (_a = process.env.GIT_BRANCH) !== null && _a !== void 0 ? _a : getBranch(),
|
|
41
|
+
commit: (_b = process.env.GIT_COMMIT) !== null && _b !== void 0 ? _b : getCommit(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Tries to get branch from git CLI. */
|
|
45
|
+
function getBranch() {
|
|
46
|
+
try {
|
|
47
|
+
return shellSilent("git rev-parse --abbrev-ref HEAD");
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
return "";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Tries to get commit from git from git CLI. */
|
|
54
|
+
function getCommit() {
|
|
55
|
+
try {
|
|
56
|
+
return shellSilent("git rev-parse --verify HEAD");
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Silent shell that won't pollute stdout, or stderr */
|
|
63
|
+
function shellSilent(cmd) {
|
|
64
|
+
return execSync(cmd, { stdio: ["ignore", "pipe", "ignore"] })
|
|
65
|
+
.toString()
|
|
66
|
+
.trim();
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/gitData/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAE5C,wEAAwE;AACxE,oEAAoE;AACpE,OAAO,EAAC,eAAe,EAAU,MAAM,kBAAkB,CAAC;AAE1D,4EAA4E;AAC5E,MAAM,UAAU,iBAAiB;;IAC/B,IAAI;QACF,gFAAgF;QAChF,IAAI,gBAAkC,CAAC;QACvC,IAAI;YACF,gBAAgB,GAAG,eAAe,EAAE,CAAC;SACtC;QAAC,OAAO,CAAC,EAAE;YACV,gBAAgB,GAAG,EAAE,CAAC;SACvB;QAED,MAAM,cAAc,GAAG,UAAU,EAAE,CAAC;QAEpC,OAAO;YACL,4DAA4D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;AACZ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// For RATIONALE of this file, check packages/cli/src/util/gitData/gitDataPath.ts
|
|
3
|
+
// Persist exact commit in NPM distributions for easier tracking of the build
|
|
4
|
+
import { writeGitDataFile } from "./gitDataPath.js";
|
|
5
|
+
import { getGitData } from "./index.js";
|
|
6
|
+
// Script to write the git data file (json) used by the build procedures to persist git data.
|
|
7
|
+
writeGitDataFile(getGitData());
|
|
8
|
+
//# sourceMappingURL=writeGitData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeGitData.js","sourceRoot":"","sources":["../../../src/utils/gitData/writeGitData.ts"],"names":[],"mappings":";AAEA,iFAAiF;AACjF,6EAA6E;AAE7E,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAEtC,6FAA6F;AAC7F,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Logger } from "@lodestar/logger";
|
|
2
|
+
import { JsonRpcErrorPayload, JsonRpcNotificationPayload, JsonRpcRequestPayload, JsonRpcRequest, JsonRpcResponse, JsonRpcResponseWithErrorPayload, JsonRpcResponseWithResultPayload, JsonRpcResponseOrBatch, JsonRpcBatchResponse, JsonRpcRequestOrBatch, JsonRpcBatchRequest } from "../types.js";
|
|
3
|
+
export declare function getResponseForRequest<P, R, E = unknown>(payload: JsonRpcRequest<P>, res?: R, error?: JsonRpcErrorPayload<E>): JsonRpcResponse<R, E>;
|
|
4
|
+
export declare function getErrorResponseForUnverifiedRequest<P, D = unknown>(payload: JsonRpcRequest<P>, message: string, data?: D): JsonRpcResponseWithErrorPayload<D>;
|
|
5
|
+
export declare function isValidResponse<R, E>(response: JsonRpcResponseOrBatch<R, E> | undefined): response is JsonRpcResponseWithResultPayload<R> | JsonRpcResponseWithResultPayload<R>[];
|
|
6
|
+
export declare function isValidBatchResponse<R, E>(payload: JsonRpcBatchRequest, response: JsonRpcBatchResponse<R, E>): response is JsonRpcBatchResponse<R, E> | JsonRpcResponseWithResultPayload<R>[];
|
|
7
|
+
export declare function mergeBatchReqResp(payload: JsonRpcBatchRequest, response: JsonRpcBatchResponse): {
|
|
8
|
+
request: JsonRpcRequest;
|
|
9
|
+
response: JsonRpcResponse;
|
|
10
|
+
}[];
|
|
11
|
+
export declare function isNotification<P>(payload: JsonRpcRequest<P>): payload is JsonRpcNotificationPayload<P>;
|
|
12
|
+
export declare function isRequest<P>(payload: JsonRpcRequest<P>): payload is JsonRpcRequestPayload<P>;
|
|
13
|
+
export declare function isBatchRequest<P>(payload: JsonRpcRequestOrBatch<P>): payload is JsonRpcBatchRequest<P>;
|
|
14
|
+
export declare function isBatchResponse<R>(response: JsonRpcResponseOrBatch<R>): response is JsonRpcBatchResponse<R>;
|
|
15
|
+
export declare function logRequest(payload: JsonRpcRequestOrBatch | undefined | null, logger: Logger): void;
|
|
16
|
+
export declare function logResponse(response: JsonRpcResponseOrBatch | undefined, logger: Logger): void;
|
|
17
|
+
//# sourceMappingURL=json_rpc.d.ts.map
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { UNVERIFIED_RESPONSE_CODE } from "../constants.js";
|
|
2
|
+
import { isNullish } from "./validation.js";
|
|
3
|
+
export function getResponseForRequest(payload, res, error) {
|
|
4
|
+
// If it's a notification
|
|
5
|
+
if (!isRequest(payload)) {
|
|
6
|
+
throw new Error("Cannot generate response for notification");
|
|
7
|
+
}
|
|
8
|
+
if (!isNullish(res) && isNullish(error)) {
|
|
9
|
+
return {
|
|
10
|
+
jsonrpc: payload.jsonrpc,
|
|
11
|
+
id: payload.id,
|
|
12
|
+
result: res,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
if (!isNullish(error)) {
|
|
16
|
+
return {
|
|
17
|
+
jsonrpc: payload.jsonrpc,
|
|
18
|
+
id: payload.id,
|
|
19
|
+
error,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
throw new Error("Either result or error must be defined.");
|
|
23
|
+
}
|
|
24
|
+
export function getErrorResponseForUnverifiedRequest(payload, message, data) {
|
|
25
|
+
return isNullish(data)
|
|
26
|
+
? getResponseForRequest(payload, undefined, {
|
|
27
|
+
code: UNVERIFIED_RESPONSE_CODE,
|
|
28
|
+
message,
|
|
29
|
+
})
|
|
30
|
+
: getResponseForRequest(payload, undefined, {
|
|
31
|
+
code: UNVERIFIED_RESPONSE_CODE,
|
|
32
|
+
message,
|
|
33
|
+
data,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function isValidResponsePayload(response) {
|
|
37
|
+
return !isNullish(response) && isNullish(response.error);
|
|
38
|
+
}
|
|
39
|
+
export function isValidResponse(response) {
|
|
40
|
+
return Array.isArray(response) ? response.every(isValidResponsePayload) : isValidResponsePayload(response);
|
|
41
|
+
}
|
|
42
|
+
export function isValidBatchResponse(payload, response) {
|
|
43
|
+
for (const [index, req] of payload.entries()) {
|
|
44
|
+
if (isRequest(req)) {
|
|
45
|
+
if (response[index].id !== req.id || !isValidResponse(response[index]))
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
export function mergeBatchReqResp(payload, response) {
|
|
52
|
+
const result = [];
|
|
53
|
+
for (const [index, req] of payload.entries()) {
|
|
54
|
+
if (isRequest(req)) {
|
|
55
|
+
// Some providers return raw json-rpc response, some return only result
|
|
56
|
+
// we need to just merge the result back based on the provider
|
|
57
|
+
result.push({ request: req, response: response[index] });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
export function isNotification(payload) {
|
|
63
|
+
return !("id" in payload);
|
|
64
|
+
}
|
|
65
|
+
export function isRequest(payload) {
|
|
66
|
+
return "id" in payload;
|
|
67
|
+
}
|
|
68
|
+
export function isBatchRequest(payload) {
|
|
69
|
+
return Array.isArray(payload);
|
|
70
|
+
}
|
|
71
|
+
export function isBatchResponse(response) {
|
|
72
|
+
return Array.isArray(response);
|
|
73
|
+
}
|
|
74
|
+
function logRequestPayload(payload, logger) {
|
|
75
|
+
logger.debug("PR -> EL", {
|
|
76
|
+
id: isRequest(payload) ? payload.id : "notification",
|
|
77
|
+
method: payload.method,
|
|
78
|
+
params: JSON.stringify(payload.params),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export function logRequest(payload, logger) {
|
|
82
|
+
if (payload === undefined || payload === null) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for (const p of isBatchRequest(payload) ? payload : [payload]) {
|
|
86
|
+
logRequestPayload(p, logger);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function logResponsePayload(response, logger) {
|
|
90
|
+
if (response === undefined || response === null) {
|
|
91
|
+
logger.debug("PR <- EL (empty response)");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (isValidResponse(response)) {
|
|
95
|
+
logger.debug("PR <- EL", {
|
|
96
|
+
id: response.id,
|
|
97
|
+
result: JSON.stringify(response.result),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
logger.debug("PR <- E:", {
|
|
102
|
+
id: response.id,
|
|
103
|
+
error: JSON.stringify(response.error),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export function logResponse(response, logger) {
|
|
108
|
+
if (response === undefined || response === null) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
for (const p of isBatchResponse(response) ? response : [response]) {
|
|
112
|
+
logResponsePayload(p, logger);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=json_rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json_rpc.js","sourceRoot":"","sources":["../../src/utils/json_rpc.ts"],"names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Q,CAAC,EAAE;YACf,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;SACtC,CAAC,CAAC;KACJ;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAA4C,EAAE,MAAc;IACtF,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE;QAC/C,OAAO;KACR;IAED,KAAK,MAAM,CAAC,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE;QACjE,kBAAkB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;KAC/B;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getBrowserLogger } from "@lodestar/logger/browser";
|
|
2
|
+
import { getEmptyLogger } from "@lodestar/logger/empty";
|
|
3
|
+
export function getLogger(opts) {
|
|
4
|
+
if (opts.logger)
|
|
5
|
+
return opts.logger;
|
|
6
|
+
if (opts.logLevel) {
|
|
7
|
+
return getBrowserLogger({ level: opts.logLevel });
|
|
8
|
+
}
|
|
9
|
+
// For the case when user don't want to fill in the logs of consumer browser
|
|
10
|
+
return getEmptyLogger();
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAGtD,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC;IAEpC,IAAI,IAAI,CAAC,QAAQ,EAAE;QACjB,OAAO,gBAAgB,CAAC,EAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAC,CAAC,CAAC;KACjD;IAED,4EAA4E;IAC5E,OAAO,cAAc,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Logger } from "@lodestar/logger";
|
|
2
|
+
import { ELVerifiedRequestHandler } from "../interfaces.js";
|
|
3
|
+
import { ProofProvider } from "../proof_provider/proof_provider.js";
|
|
4
|
+
import { JsonRpcRequestOrBatch, JsonRpcBatchRequest, JsonRpcResponseOrBatch } from "../types.js";
|
|
5
|
+
import { ELRpc } from "./rpc.js";
|
|
6
|
+
export declare const verifiableMethodHandlers: Record<string, ELVerifiedRequestHandler<any, any>>;
|
|
7
|
+
export declare const verifiableMethods: string[];
|
|
8
|
+
export declare const alwaysAllowedMethods: string[];
|
|
9
|
+
export declare function splitRequestsInChunks(payload: JsonRpcRequestOrBatch, unverifiedWhitelist?: string[]): {
|
|
10
|
+
verifiable: JsonRpcBatchRequest;
|
|
11
|
+
nonVerifiable: JsonRpcBatchRequest;
|
|
12
|
+
blocked: JsonRpcBatchRequest;
|
|
13
|
+
};
|
|
14
|
+
export declare function processAndVerifyRequest({ payload, rpc, proofProvider, logger, }: {
|
|
15
|
+
payload: JsonRpcRequestOrBatch;
|
|
16
|
+
rpc: ELRpc;
|
|
17
|
+
proofProvider: ProofProvider;
|
|
18
|
+
logger: Logger;
|
|
19
|
+
}): Promise<JsonRpcResponseOrBatch | undefined>;
|
|
20
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { eth_getBalance } from "../verified_requests/eth_getBalance.js";
|
|
2
|
+
import { eth_getTransactionCount } from "../verified_requests/eth_getTransactionCount.js";
|
|
3
|
+
import { eth_getBlockByHash } from "../verified_requests/eth_getBlockByHash.js";
|
|
4
|
+
import { eth_getBlockByNumber } from "../verified_requests/eth_getBlockByNumber.js";
|
|
5
|
+
import { eth_getCode } from "../verified_requests/eth_getCode.js";
|
|
6
|
+
import { eth_call } from "../verified_requests/eth_call.js";
|
|
7
|
+
import { eth_estimateGas } from "../verified_requests/eth_estimateGas.js";
|
|
8
|
+
import { getResponseForRequest, isBatchRequest, isRequest } from "./json_rpc.js";
|
|
9
|
+
import { isNullish } from "./validation.js";
|
|
10
|
+
/* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/no-explicit-any */
|
|
11
|
+
export const verifiableMethodHandlers = {
|
|
12
|
+
eth_getBalance: eth_getBalance,
|
|
13
|
+
eth_getTransactionCount: eth_getTransactionCount,
|
|
14
|
+
eth_getBlockByHash: eth_getBlockByHash,
|
|
15
|
+
eth_getBlockByNumber: eth_getBlockByNumber,
|
|
16
|
+
eth_getCode: eth_getCode,
|
|
17
|
+
eth_call: eth_call,
|
|
18
|
+
eth_estimateGas: eth_estimateGas,
|
|
19
|
+
};
|
|
20
|
+
export const verifiableMethods = Object.keys(verifiableMethodHandlers);
|
|
21
|
+
export const alwaysAllowedMethods = ["eth_subscribe", "eth_unsubscribe", "eth_getProof"];
|
|
22
|
+
export function splitRequestsInChunks(payload, unverifiedWhitelist) {
|
|
23
|
+
const verifiable = [];
|
|
24
|
+
const nonVerifiable = [];
|
|
25
|
+
const blocked = [];
|
|
26
|
+
for (const pay of isBatchRequest(payload) ? payload : [payload]) {
|
|
27
|
+
if (isRequest(pay) && verifiableMethods.includes(pay.method)) {
|
|
28
|
+
verifiable.push(pay);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
// If unverifiedWhitelist is not set that implies all methods are allowed
|
|
32
|
+
if ((isRequest(pay) && isNullish(unverifiedWhitelist)) || (unverifiedWhitelist === null || unverifiedWhitelist === void 0 ? void 0 : unverifiedWhitelist.includes(pay.method))) {
|
|
33
|
+
nonVerifiable.push(pay);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (alwaysAllowedMethods.includes(pay.method)) {
|
|
37
|
+
nonVerifiable.push(pay);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
blocked.push(pay);
|
|
41
|
+
}
|
|
42
|
+
return { verifiable, nonVerifiable, blocked };
|
|
43
|
+
}
|
|
44
|
+
export async function processAndVerifyRequest({ payload, rpc, proofProvider, logger, }) {
|
|
45
|
+
await proofProvider.waitToBeReady();
|
|
46
|
+
const { verifiable, nonVerifiable, blocked } = splitRequestsInChunks(payload, proofProvider.opts.unverifiedWhitelist);
|
|
47
|
+
const verifiedResponses = [];
|
|
48
|
+
const nonVerifiedResponses = [];
|
|
49
|
+
const blockedResponses = [];
|
|
50
|
+
for (const request of verifiable) {
|
|
51
|
+
logger.debug("Processing verifiable request", {
|
|
52
|
+
method: request.method,
|
|
53
|
+
params: JSON.stringify(request.params),
|
|
54
|
+
});
|
|
55
|
+
const verifiableRequestHandler = verifiableMethodHandlers[request.method];
|
|
56
|
+
const response = await verifiableRequestHandler({ payload: request, rpc, proofProvider, logger });
|
|
57
|
+
verifiedResponses.push(response);
|
|
58
|
+
}
|
|
59
|
+
if (nonVerifiable.length > 0) {
|
|
60
|
+
logger.warn("Forwarding non-verifiable requests to EL provider.", { count: nonVerifiable.length });
|
|
61
|
+
const response = await rpc.batchRequest(nonVerifiable, { raiseError: false });
|
|
62
|
+
nonVerifiedResponses.push(...response.map((r) => r.response));
|
|
63
|
+
}
|
|
64
|
+
for (const request of blocked) {
|
|
65
|
+
blockedResponses.push(getResponseForRequest(request, undefined, { message: `Method "${request.method}" not allowed.` }));
|
|
66
|
+
}
|
|
67
|
+
const responses = [...verifiedResponses, ...nonVerifiedResponses, ...blockedResponses];
|
|
68
|
+
if (responses.length === 1) {
|
|
69
|
+
return responses[0];
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return responses;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAC,MAAM,wCAAwC,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BAAwB,GAAG,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC1E,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAAC,EAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,EAAC,CAAC,CAAC;QAChG,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAClC;IAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;QAC5B,MAAM,CAAC,IAAI,CAAC,oDAAoD,EAAE,EAAC,KAAK,EAAE,aAAa,CAAC,MAAM,EAAC,CAAC,CAAC;QACjG,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,aAAa,EAAE,EAAC,UAAU,EAAE,KAAK,EAAC,CAAC,CAAC;QAC5E,oBAAoB,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;KAC/D;IAED,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE;QAC7B,gBAAgB,CAAC,IAAI,CACnB,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,EAAC,OAAO,EAAE,WAAW,OAAO,CAAC,MAAM,gBAAgB,EAAC,CAAC,CAChG,CAAC;KACH;IAED,MAAM,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,oBAAoB,EAAE,GAAG,gBAAgB,CAAC,CAAC;IAEvF,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;KACrB;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import http from "node:http";
|
|
2
|
+
import { JsonRpcRequestPayload, JsonRpcResponse } from "../types.js";
|
|
3
|
+
export declare const fetchRequestPayload: (req: http.IncomingMessage) => Promise<JsonRpcRequestPayload>;
|
|
4
|
+
export declare const fetchResponseBody: (res: http.IncomingMessage) => Promise<JsonRpcResponse>;
|
|
5
|
+
//# sourceMappingURL=req_resp.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const fetchRequestPayload = async (req) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
let body = "";
|
|
4
|
+
req.on("data", (chunk) => {
|
|
5
|
+
body += chunk;
|
|
6
|
+
});
|
|
7
|
+
req.on("end", () => {
|
|
8
|
+
try {
|
|
9
|
+
resolve(JSON.parse(body));
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
reject(err);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export const fetchResponseBody = async (res) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
let body = "";
|
|
20
|
+
res.on("data", (chunk) => {
|
|
21
|
+
body += chunk;
|
|
22
|
+
});
|
|
23
|
+
res.on("end", () => {
|
|
24
|
+
try {
|
|
25
|
+
resolve(JSON.parse(body));
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
reject(err);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=req_resp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"req_resp.js","sourceRoot":"","sources":["../../src/utils/req_resp.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,GAAyB,EAAkC,EAAE;IACrG,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YACvB,IAAI,IAAI,KAAK,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACjB,IAAI;gBACF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAA0B,CAAC,CAAC;aACpD;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,CAAC,GAAG,CAAC,CAAC;aACb;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,GAAyB,EAA4B,EAAE;IAC7F,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YACvB,IAAI,IAAI,KAAK,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACjB,IAAI;gBACF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAoB,CAAC,CAAC;aAC9C;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,CAAC,GAAG,CAAC,CAAC;aACb;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Logger } from "@lodestar/logger";
|
|
2
|
+
import { ELRequestHandler } from "../interfaces.js";
|
|
3
|
+
import { ELApi, ELApiParams, ELApiReturn, JsonRpcBatchRequest, JsonRpcRequest, JsonRpcResponse, JsonRpcResponseWithResultPayload } from "../types.js";
|
|
4
|
+
export type Optional<T, K extends keyof T> = Omit<T, K> & {
|
|
5
|
+
[P in keyof T]?: T[P] | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare class ELRpc {
|
|
8
|
+
private handler;
|
|
9
|
+
private logger;
|
|
10
|
+
constructor(handler: ELRequestHandler, logger: Logger);
|
|
11
|
+
request<K extends keyof ELApi, E extends boolean>(method: K, params: ELApiParams[K], opts: {
|
|
12
|
+
raiseError: E;
|
|
13
|
+
}): Promise<E extends false ? JsonRpcResponse<ELApiReturn[K]> : JsonRpcResponseWithResultPayload<ELApiReturn[K]>>;
|
|
14
|
+
batchRequest<E extends boolean>(input: JsonRpcBatchRequest, opts: {
|
|
15
|
+
raiseError: E;
|
|
16
|
+
}): Promise<E extends false ? {
|
|
17
|
+
request: JsonRpcRequest;
|
|
18
|
+
response: JsonRpcResponse;
|
|
19
|
+
}[] : {
|
|
20
|
+
request: JsonRpcRequest;
|
|
21
|
+
response: JsonRpcResponseWithResultPayload<unknown>;
|
|
22
|
+
}[]>;
|
|
23
|
+
verifyCompatibility(): Promise<void>;
|
|
24
|
+
private getRequestId;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=rpc.d.ts.map
|
package/lib/utils/rpc.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ZERO_ADDRESS } from "../constants.js";
|
|
2
|
+
import { isRequest, isValidBatchResponse, isValidResponse, logRequest, logResponse, mergeBatchReqResp, } from "./json_rpc.js";
|
|
3
|
+
import { isNullish } from "./validation.js";
|
|
4
|
+
export class ELRpc {
|
|
5
|
+
constructor(handler, logger) {
|
|
6
|
+
this.handler = handler;
|
|
7
|
+
this.logger = logger;
|
|
8
|
+
}
|
|
9
|
+
async request(method, params, opts) {
|
|
10
|
+
const { raiseError } = opts;
|
|
11
|
+
const payload = { jsonrpc: "2.0", method, params, id: this.getRequestId() };
|
|
12
|
+
logRequest(payload, this.logger);
|
|
13
|
+
const response = await this.handler(payload);
|
|
14
|
+
logResponse(response, this.logger);
|
|
15
|
+
if (raiseError && !isValidResponse(response)) {
|
|
16
|
+
throw new Error(`Invalid response from RPC. method=${method} params=${JSON.stringify(params)}`);
|
|
17
|
+
}
|
|
18
|
+
return response;
|
|
19
|
+
}
|
|
20
|
+
async batchRequest(input, opts) {
|
|
21
|
+
const payloads = [];
|
|
22
|
+
for (const req of input) {
|
|
23
|
+
if (isRequest(req) && isNullish(req.id)) {
|
|
24
|
+
payloads.push({ jsonrpc: "2.0", method: req.method, params: req.params, id: this.getRequestId() });
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
payloads.push(req);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
logRequest(payloads, this.logger);
|
|
31
|
+
const response = await this.handler(payloads);
|
|
32
|
+
logResponse(response, this.logger);
|
|
33
|
+
if (isNullish(response)) {
|
|
34
|
+
throw new Error("Invalid empty response from server.");
|
|
35
|
+
}
|
|
36
|
+
if (opts.raiseError && !isValidBatchResponse(payloads, response)) {
|
|
37
|
+
throw new Error(`Invalid response from RPC. payload=${JSON.stringify(payloads)} response=${JSON.stringify(response)}}`);
|
|
38
|
+
}
|
|
39
|
+
return mergeBatchReqResp(payloads, response);
|
|
40
|
+
}
|
|
41
|
+
async verifyCompatibility() {
|
|
42
|
+
try {
|
|
43
|
+
await this.request("eth_getProof", [ZERO_ADDRESS, [], "latest"], { raiseError: true });
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
this.logger.error("Execution compatibility failed.", undefined, err);
|
|
47
|
+
throw new Error("RPC does not support 'eth_getProof', which is required for the prover to work properly.");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
getRequestId() {
|
|
51
|
+
// TODO: Find better way to generate random id
|
|
52
|
+
return (Math.random() * 10000).toFixed(0);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,eA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@@
|
|
|
1
|
+
import { Bytes32, allForks } from "@lodestar/types";
|
|
2
|
+
import { Logger } from "@lodestar/utils";
|
|
3
|
+
import { ChainForkConfig } from "@lodestar/config";
|
|
4
|
+
import { ELBlock, ELProof, ELStorageProof, HexString } from "../types.js";
|
|
5
|
+
export declare function isBlockNumber(block: number | string): boolean;
|
|
6
|
+
export declare function isValidAccount({ address, stateRoot, proof, logger, }: {
|
|
7
|
+
address: HexString;
|
|
8
|
+
stateRoot: Bytes32;
|
|
9
|
+
proof: ELProof;
|
|
10
|
+
logger: Logger;
|
|
11
|
+
}): Promise<boolean>;
|
|
12
|
+
export declare function isValidStorageKeys({ storageKeys, proof, logger, }: {
|
|
13
|
+
storageKeys: HexString[];
|
|
14
|
+
proof: ELStorageProof;
|
|
15
|
+
logger: Logger;
|
|
16
|
+
}): Promise<boolean>;
|
|
17
|
+
export declare function isValidBlock({ executionPayload, block, logger, config, }: {
|
|
18
|
+
executionPayload: allForks.ExecutionPayload;
|
|
19
|
+
block: ELBlock;
|
|
20
|
+
logger: Logger;
|
|
21
|
+
config: ChainForkConfig;
|
|
22
|
+
}): Promise<boolean>;
|
|
23
|
+
export declare function isValidCodeHash({ codeHash, codeResponse, }: {
|
|
24
|
+
codeHash: string;
|
|
25
|
+
codeResponse: string;
|
|
26
|
+
logger: Logger;
|
|
27
|
+
}): Promise<boolean>;
|
|
28
|
+
export declare function isNullish<T>(val: T | undefined | null): val is null | undefined;
|
|
29
|
+
export declare function isPresent<T>(val: T | undefined | null): val is T;
|
|
30
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Block } from "@ethereumjs/block";
|
|
2
|
+
import { RLP } from "@ethereumjs/rlp";
|
|
3
|
+
import { Trie } from "@ethereumjs/trie";
|
|
4
|
+
import { Account, KECCAK256_NULL_S } from "@ethereumjs/util";
|
|
5
|
+
import { keccak256 } from "ethereum-cryptography/keccak.js";
|
|
6
|
+
import { blockDataFromELBlock, bufferToHex, hexToBuffer, padLeft } from "./conversion.js";
|
|
7
|
+
import { getChainCommon } from "./execution.js";
|
|
8
|
+
const emptyAccountSerialize = new Account().serialize();
|
|
9
|
+
const storageKeyLength = 32;
|
|
10
|
+
export function isBlockNumber(block) {
|
|
11
|
+
if (typeof block === "number") {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
// If block is hex and less than 32 byte long it is a block number, else it's a block hash
|
|
15
|
+
return hexToBuffer(block).byteLength < 32;
|
|
16
|
+
}
|
|
17
|
+
export async function isValidAccount({ address, stateRoot, proof, logger, }) {
|
|
18
|
+
const trie = await Trie.create();
|
|
19
|
+
const key = keccak256(hexToBuffer(address));
|
|
20
|
+
try {
|
|
21
|
+
const expectedAccountRLP = await trie.verifyProof(Buffer.from(stateRoot), Buffer.from(key), proof.accountProof.map(hexToBuffer));
|
|
22
|
+
// Shresth Agrawal (2022) Patronum source code. https://github.com/lightclients/patronum
|
|
23
|
+
const account = Account.fromAccountData({
|
|
24
|
+
nonce: BigInt(proof.nonce),
|
|
25
|
+
balance: BigInt(proof.balance),
|
|
26
|
+
storageRoot: proof.storageHash,
|
|
27
|
+
codeHash: proof.codeHash,
|
|
28
|
+
});
|
|
29
|
+
return account.serialize().equals(expectedAccountRLP ? expectedAccountRLP : emptyAccountSerialize);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
logger.error("Error verifying account proof", undefined, err);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export async function isValidStorageKeys({ storageKeys, proof, logger, }) {
|
|
37
|
+
const trie = await Trie.create();
|
|
38
|
+
for (let i = 0; i < storageKeys.length; i++) {
|
|
39
|
+
const sp = proof.storageProof[i];
|
|
40
|
+
const key = keccak256(padLeft(hexToBuffer(storageKeys[i]), storageKeyLength));
|
|
41
|
+
try {
|
|
42
|
+
const expectedStorageRLP = await trie.verifyProof(hexToBuffer(proof.storageHash), Buffer.from(key), sp.proof.map(hexToBuffer));
|
|
43
|
+
const isStorageValid = (!expectedStorageRLP && sp.value === "0x0") ||
|
|
44
|
+
(!!expectedStorageRLP && expectedStorageRLP.equals(RLP.encode(sp.value)));
|
|
45
|
+
if (!isStorageValid)
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
logger.error("Error verifying storage keys", undefined, err);
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
export async function isValidBlock({ executionPayload, block, logger, config, }) {
|
|
56
|
+
const common = getChainCommon(config.PRESET_BASE);
|
|
57
|
+
common.setHardforkByBlockNumber(executionPayload.blockNumber, undefined, executionPayload.timestamp);
|
|
58
|
+
const blockObject = Block.fromBlockData(blockDataFromELBlock(block), { common });
|
|
59
|
+
if (bufferToHex(executionPayload.blockHash) !== bufferToHex(blockObject.hash())) {
|
|
60
|
+
logger.error("Block hash does not match", {
|
|
61
|
+
rpcBlockHash: bufferToHex(blockObject.hash()),
|
|
62
|
+
beaconExecutionBlockHash: bufferToHex(executionPayload.blockHash),
|
|
63
|
+
});
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (bufferToHex(executionPayload.parentHash) !== bufferToHex(blockObject.header.parentHash)) {
|
|
67
|
+
logger.error("Block parent hash does not match", {
|
|
68
|
+
rpcBlockHash: bufferToHex(blockObject.header.parentHash),
|
|
69
|
+
beaconExecutionBlockHash: bufferToHex(executionPayload.parentHash),
|
|
70
|
+
});
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (!(await blockObject.validateTransactionsTrie())) {
|
|
74
|
+
logger.error("Block transactions could not be verified.", {
|
|
75
|
+
blockHash: bufferToHex(blockObject.hash()),
|
|
76
|
+
blockNumber: blockObject.header.number,
|
|
77
|
+
});
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
export async function isValidCodeHash({ codeHash, codeResponse, }) {
|
|
83
|
+
// if there is no code hash for that address
|
|
84
|
+
if (codeResponse === "0x" && codeHash === `0x${KECCAK256_NULL_S}`)
|
|
85
|
+
return true;
|
|
86
|
+
return bufferToHex(keccak256(hexToBuffer(codeResponse))) === codeHash;
|
|
87
|
+
}
|
|
88
|
+
export function isNullish(val) {
|
|
89
|
+
return val === null || val === undefined;
|
|
90
|
+
}
|
|
91
|
+
export function isPresent(val) {
|
|
92
|
+
return !isNullish(val);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAC,OAAO,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,SAAS,EAAC,MAAM,iCAAiC,CAAC;AAK1D,OAAO,EAAC,oBAAoB,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAC,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE9C,MAAM,qBAAqB,GAAG,IAAI,OAAO,EAAE,CAAC,SAAS,EAAE,CAAC;AACxD,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,MAAM,UAAU,aAAa,CAAC,KAAsB;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,IAAI,CAAC;KACb;IAED,0FAA0F;IAC1F,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,OAAO,EACP,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