@pimlico/alto 0.0.7 → 0.0.9
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/esm/cli/alto.js +3 -1
- package/esm/cli/alto.js.map +1 -1
- package/esm/cli/config/bundler.d.ts +320 -272
- package/esm/cli/config/bundler.js +26 -7
- package/esm/cli/config/bundler.js.map +1 -1
- package/esm/cli/config/options.js +65 -10
- package/esm/cli/config/options.js.map +1 -1
- package/esm/cli/customTransport.js +40 -7
- package/esm/cli/customTransport.js.map +1 -1
- package/esm/cli/deploySimulationsContract.d.ts +8 -0
- package/esm/cli/deploySimulationsContract.js +35 -0
- package/esm/cli/deploySimulationsContract.js.map +1 -0
- package/esm/cli/handler.d.ts +2 -2
- package/esm/cli/handler.js +78 -89
- package/esm/cli/handler.js.map +1 -1
- package/esm/cli/instrumentation.js +4 -2
- package/esm/cli/instrumentation.js.map +1 -1
- package/esm/cli/parseArgs.d.ts +8 -0
- package/esm/cli/parseArgs.js +21 -0
- package/esm/cli/parseArgs.js.map +1 -0
- package/esm/cli/setupServer.d.ts +4 -9
- package/esm/cli/setupServer.js +100 -82
- package/esm/cli/setupServer.js.map +1 -1
- package/esm/createConfig.d.ts +15 -0
- package/esm/createConfig.js +8 -0
- package/esm/createConfig.js.map +1 -0
- package/esm/executor/executor.d.ts +48 -14
- package/esm/executor/executor.js +262 -139
- package/esm/executor/executor.js.map +1 -1
- package/esm/executor/executorManager.d.ts +14 -10
- package/esm/executor/executorManager.js +36 -39
- package/esm/executor/executorManager.js.map +1 -1
- package/esm/executor/senderManager.d.ts +11 -6
- package/esm/executor/senderManager.js +39 -36
- package/esm/executor/senderManager.js.map +1 -1
- package/esm/executor/utilityWalletMonitor.d.ts +9 -5
- package/esm/executor/utilityWalletMonitor.js +8 -8
- package/esm/executor/utilityWalletMonitor.js.map +1 -1
- package/esm/executor/utils.d.ts +2 -1
- package/esm/executor/utils.js +7 -2
- package/esm/executor/utils.js.map +1 -1
- package/esm/handlers/arbitrumGasPriceManager.d.ts +11 -0
- package/esm/handlers/arbitrumGasPriceManager.js +29 -0
- package/esm/handlers/arbitrumGasPriceManager.js.map +1 -0
- package/esm/handlers/eventManager.d.ts +7 -3
- package/esm/handlers/eventManager.js +24 -16
- package/esm/handlers/eventManager.js.map +1 -1
- package/esm/handlers/gasPriceManager.d.ts +14 -41
- package/esm/handlers/gasPriceManager.js +87 -208
- package/esm/handlers/gasPriceManager.js.map +1 -1
- package/esm/handlers/mantleGasPriceManager.d.ts +20 -0
- package/esm/handlers/mantleGasPriceManager.js +28 -0
- package/esm/handlers/mantleGasPriceManager.js.map +1 -0
- package/esm/mempool/mempool.d.ts +13 -10
- package/esm/mempool/mempool.js +29 -26
- package/esm/mempool/mempool.js.map +1 -1
- package/esm/mempool/reputationManager.d.ts +4 -6
- package/esm/mempool/reputationManager.js +25 -29
- package/esm/mempool/reputationManager.js.map +1 -1
- package/esm/mempool/store.d.ts +1 -1
- package/esm/rpc/estimation/gasEstimationHandler.d.ts +7 -7
- package/esm/rpc/estimation/gasEstimationHandler.js +18 -33
- package/esm/rpc/estimation/gasEstimationHandler.js.map +1 -1
- package/esm/rpc/estimation/gasEstimationsV06.d.ts +7 -7
- package/esm/rpc/estimation/gasEstimationsV06.js +90 -48
- package/esm/rpc/estimation/gasEstimationsV06.js.map +1 -1
- package/esm/rpc/estimation/gasEstimationsV07.d.ts +7 -12
- package/esm/rpc/estimation/gasEstimationsV07.js +53 -37
- package/esm/rpc/estimation/gasEstimationsV07.js.map +1 -1
- package/esm/rpc/nonceQueuer.d.ts +10 -6
- package/esm/rpc/nonceQueuer.js +10 -10
- package/esm/rpc/nonceQueuer.js.map +1 -1
- package/esm/rpc/rpcHandler.d.ts +19 -16
- package/esm/rpc/rpcHandler.js +98 -90
- package/esm/rpc/rpcHandler.js.map +1 -1
- package/esm/rpc/server.d.ts +9 -7
- package/esm/rpc/server.js +27 -25
- package/esm/rpc/server.js.map +1 -1
- package/esm/rpc/validation/SafeValidator.d.ts +11 -6
- package/esm/rpc/validation/SafeValidator.js +14 -11
- package/esm/rpc/validation/SafeValidator.js.map +1 -1
- package/esm/rpc/validation/TracerResultParserV06.d.ts +1 -1
- package/esm/rpc/validation/TracerResultParserV06.js.map +1 -1
- package/esm/rpc/validation/TracerResultParserV07.d.ts +1 -1
- package/esm/rpc/validation/TracerResultParserV07.js +1 -1
- package/esm/rpc/validation/TracerResultParserV07.js.map +1 -1
- package/esm/rpc/validation/UnsafeValidator.d.ts +11 -12
- package/esm/rpc/validation/UnsafeValidator.js +28 -29
- package/esm/rpc/validation/UnsafeValidator.js.map +1 -1
- package/esm/types/contracts/ArbitrumL1FeeAbi.d.ts +32 -0
- package/esm/types/contracts/ArbitrumL1FeeAbi.js +42 -0
- package/esm/types/contracts/ArbitrumL1FeeAbi.js.map +1 -0
- package/esm/types/contracts/EntryPointSimulationsV6.d.ts +34 -0
- package/esm/types/contracts/EntryPointSimulationsV6.js +48 -0
- package/esm/types/contracts/EntryPointSimulationsV6.js.map +1 -0
- package/esm/types/contracts/{EntryPointSimulations.d.ts → EntryPointSimulationsV7.d.ts} +1 -9
- package/esm/types/contracts/{EntryPointSimulations.js → EntryPointSimulationsV7.js} +1 -13
- package/esm/types/contracts/EntryPointSimulationsV7.js.map +1 -0
- package/esm/types/contracts/MantleBvmGasPriceOracle.d.ts +219 -0
- package/esm/types/contracts/MantleBvmGasPriceOracle.js +177 -0
- package/esm/types/contracts/MantleBvmGasPriceOracle.js.map +1 -0
- package/esm/types/contracts/OpL1FeeAbi.d.ts +114 -0
- package/esm/types/contracts/OpL1FeeAbi.js +74 -0
- package/esm/types/contracts/OpL1FeeAbi.js.map +1 -0
- package/esm/types/contracts/PimlicoEntryPointSimulations.d.ts +1 -1
- package/esm/types/contracts/PimlicoEntryPointSimulations.js +1 -1
- package/esm/types/contracts/PimlicoEntryPointSimulations.js.map +1 -1
- package/esm/types/contracts/index.d.ts +5 -1
- package/esm/types/contracts/index.js +5 -1
- package/esm/types/contracts/index.js.map +1 -1
- package/esm/types/interfaces.d.ts +2 -2
- package/esm/types/mempool.d.ts +1 -2
- package/esm/types/mempool.js.map +1 -1
- package/esm/types/schemas.d.ts +26 -26
- package/esm/types/schemas.js +3 -3
- package/esm/types/schemas.js.map +1 -1
- package/esm/types/utils.d.ts +1 -1
- package/esm/utils/bigInt.js +2 -2
- package/esm/utils/bigInt.js.map +1 -1
- package/esm/utils/helpers.js +1 -1
- package/esm/utils/helpers.js.map +1 -1
- package/esm/utils/metrics.d.ts +1 -0
- package/esm/utils/metrics.js +7 -0
- package/esm/utils/metrics.js.map +1 -1
- package/esm/utils/rpc-reply.d.ts +1 -1
- package/esm/utils/timedQueue.d.ts +12 -0
- package/esm/utils/timedQueue.js +51 -0
- package/esm/utils/timedQueue.js.map +1 -0
- package/esm/utils/userop.d.ts +3 -3
- package/esm/utils/userop.js +4 -3
- package/esm/utils/userop.js.map +1 -1
- package/esm/utils/validation.d.ts +14 -6
- package/esm/utils/validation.js +160 -168
- package/esm/utils/validation.js.map +1 -1
- package/lib/cli/alto.js +2 -0
- package/lib/cli/alto.js.map +1 -1
- package/lib/cli/config/bundler.d.ts +320 -272
- package/lib/cli/config/bundler.js +25 -6
- package/lib/cli/config/bundler.js.map +1 -1
- package/lib/cli/config/options.js +65 -10
- package/lib/cli/config/options.js.map +1 -1
- package/lib/cli/customTransport.js +38 -5
- package/lib/cli/customTransport.js.map +1 -1
- package/lib/cli/deploySimulationsContract.d.ts +8 -0
- package/lib/cli/deploySimulationsContract.js +39 -0
- package/lib/cli/deploySimulationsContract.js.map +1 -0
- package/lib/cli/handler.d.ts +2 -2
- package/lib/cli/handler.js +77 -88
- package/lib/cli/handler.js.map +1 -1
- package/lib/cli/instrumentation.js +4 -2
- package/lib/cli/instrumentation.js.map +1 -1
- package/lib/cli/parseArgs.d.ts +8 -0
- package/lib/cli/parseArgs.js +25 -0
- package/lib/cli/parseArgs.js.map +1 -0
- package/lib/cli/setupServer.d.ts +4 -9
- package/lib/cli/setupServer.js +100 -82
- package/lib/cli/setupServer.js.map +1 -1
- package/lib/createConfig.d.ts +15 -0
- package/lib/createConfig.js +12 -0
- package/lib/createConfig.js.map +1 -0
- package/lib/executor/executor.d.ts +48 -14
- package/lib/executor/executor.js +258 -135
- package/lib/executor/executor.js.map +1 -1
- package/lib/executor/executorManager.d.ts +14 -10
- package/lib/executor/executorManager.js +34 -37
- package/lib/executor/executorManager.js.map +1 -1
- package/lib/executor/senderManager.d.ts +11 -6
- package/lib/executor/senderManager.js +39 -36
- package/lib/executor/senderManager.js.map +1 -1
- package/lib/executor/utilityWalletMonitor.d.ts +9 -5
- package/lib/executor/utilityWalletMonitor.js +8 -8
- package/lib/executor/utilityWalletMonitor.js.map +1 -1
- package/lib/executor/utils.d.ts +2 -1
- package/lib/executor/utils.js +9 -3
- package/lib/executor/utils.js.map +1 -1
- package/lib/handlers/arbitrumGasPriceManager.d.ts +11 -0
- package/lib/handlers/arbitrumGasPriceManager.js +33 -0
- package/lib/handlers/arbitrumGasPriceManager.js.map +1 -0
- package/lib/handlers/eventManager.d.ts +7 -3
- package/lib/handlers/eventManager.js +24 -16
- package/lib/handlers/eventManager.js.map +1 -1
- package/lib/handlers/gasPriceManager.d.ts +14 -41
- package/lib/handlers/gasPriceManager.js +85 -206
- package/lib/handlers/gasPriceManager.js.map +1 -1
- package/lib/handlers/mantleGasPriceManager.d.ts +20 -0
- package/lib/handlers/mantleGasPriceManager.js +32 -0
- package/lib/handlers/mantleGasPriceManager.js.map +1 -0
- package/lib/mempool/mempool.d.ts +13 -10
- package/lib/mempool/mempool.js +28 -25
- package/lib/mempool/mempool.js.map +1 -1
- package/lib/mempool/reputationManager.d.ts +4 -6
- package/lib/mempool/reputationManager.js +25 -29
- package/lib/mempool/reputationManager.js.map +1 -1
- package/lib/mempool/store.d.ts +1 -1
- package/lib/rpc/estimation/gasEstimationHandler.d.ts +7 -7
- package/lib/rpc/estimation/gasEstimationHandler.js +18 -33
- package/lib/rpc/estimation/gasEstimationHandler.js.map +1 -1
- package/lib/rpc/estimation/gasEstimationsV06.d.ts +7 -7
- package/lib/rpc/estimation/gasEstimationsV06.js +88 -46
- package/lib/rpc/estimation/gasEstimationsV06.js.map +1 -1
- package/lib/rpc/estimation/gasEstimationsV07.d.ts +7 -12
- package/lib/rpc/estimation/gasEstimationsV07.js +52 -36
- package/lib/rpc/estimation/gasEstimationsV07.js.map +1 -1
- package/lib/rpc/nonceQueuer.d.ts +10 -6
- package/lib/rpc/nonceQueuer.js +9 -9
- package/lib/rpc/nonceQueuer.js.map +1 -1
- package/lib/rpc/rpcHandler.d.ts +19 -16
- package/lib/rpc/rpcHandler.js +97 -89
- package/lib/rpc/rpcHandler.js.map +1 -1
- package/lib/rpc/server.d.ts +9 -7
- package/lib/rpc/server.js +26 -24
- package/lib/rpc/server.js.map +1 -1
- package/lib/rpc/validation/SafeValidator.d.ts +11 -6
- package/lib/rpc/validation/SafeValidator.js +13 -10
- package/lib/rpc/validation/SafeValidator.js.map +1 -1
- package/lib/rpc/validation/TracerResultParserV06.d.ts +1 -1
- package/lib/rpc/validation/TracerResultParserV07.d.ts +1 -1
- package/lib/rpc/validation/TracerResultParserV07.js +1 -1
- package/lib/rpc/validation/TracerResultParserV07.js.map +1 -1
- package/lib/rpc/validation/UnsafeValidator.d.ts +11 -12
- package/lib/rpc/validation/UnsafeValidator.js +28 -29
- package/lib/rpc/validation/UnsafeValidator.js.map +1 -1
- package/lib/types/contracts/ArbitrumL1FeeAbi.d.ts +32 -0
- package/lib/types/contracts/ArbitrumL1FeeAbi.js +45 -0
- package/lib/types/contracts/ArbitrumL1FeeAbi.js.map +1 -0
- package/lib/types/contracts/EntryPointSimulationsV6.d.ts +34 -0
- package/lib/types/contracts/EntryPointSimulationsV6.js +51 -0
- package/lib/types/contracts/EntryPointSimulationsV6.js.map +1 -0
- package/lib/types/contracts/{EntryPointSimulations.d.ts → EntryPointSimulationsV7.d.ts} +1 -9
- package/lib/types/contracts/{EntryPointSimulations.js → EntryPointSimulationsV7.js} +2 -14
- package/lib/types/contracts/EntryPointSimulationsV7.js.map +1 -0
- package/lib/types/contracts/MantleBvmGasPriceOracle.d.ts +219 -0
- package/lib/types/contracts/MantleBvmGasPriceOracle.js +180 -0
- package/lib/types/contracts/MantleBvmGasPriceOracle.js.map +1 -0
- package/lib/types/contracts/OpL1FeeAbi.d.ts +114 -0
- package/lib/types/contracts/OpL1FeeAbi.js +77 -0
- package/lib/types/contracts/OpL1FeeAbi.js.map +1 -0
- package/lib/types/contracts/PimlicoEntryPointSimulations.d.ts +1 -1
- package/lib/types/contracts/PimlicoEntryPointSimulations.js +1 -1
- package/lib/types/contracts/PimlicoEntryPointSimulations.js.map +1 -1
- package/lib/types/contracts/index.d.ts +5 -1
- package/lib/types/contracts/index.js +5 -1
- package/lib/types/contracts/index.js.map +1 -1
- package/lib/types/interfaces.d.ts +2 -2
- package/lib/types/mempool.d.ts +1 -2
- package/lib/types/mempool.js.map +1 -1
- package/lib/types/schemas.d.ts +26 -26
- package/lib/types/schemas.js +3 -3
- package/lib/types/schemas.js.map +1 -1
- package/lib/types/utils.d.ts +1 -1
- package/lib/utils/bigInt.js +2 -2
- package/lib/utils/bigInt.js.map +1 -1
- package/lib/utils/metrics.d.ts +1 -0
- package/lib/utils/metrics.js +7 -0
- package/lib/utils/metrics.js.map +1 -1
- package/lib/utils/rpc-reply.d.ts +1 -1
- package/lib/utils/timedQueue.d.ts +12 -0
- package/lib/utils/timedQueue.js +55 -0
- package/lib/utils/timedQueue.js.map +1 -0
- package/lib/utils/userop.d.ts +3 -3
- package/lib/utils/userop.js +3 -2
- package/lib/utils/userop.js.map +1 -1
- package/lib/utils/validation.d.ts +14 -6
- package/lib/utils/validation.js +164 -168
- package/lib/utils/validation.js.map +1 -1
- package/package.json +1 -1
- package/esm/types/contracts/EntryPointSimulations.js.map +0 -1
- package/lib/types/contracts/EntryPointSimulations.js.map +0 -1
package/esm/cli/handler.js
CHANGED
|
@@ -1,58 +1,52 @@
|
|
|
1
1
|
import { SenderManager } from "../executor/index.js";
|
|
2
|
+
import { GasPriceManager } from "../handlers/index.js";
|
|
2
3
|
import { createMetrics, initDebugLogger, initProductionLogger } from "../utils/index.js";
|
|
3
4
|
import { Registry } from "prom-client";
|
|
4
|
-
import { createPublicClient, createWalletClient,
|
|
5
|
-
import {
|
|
6
|
-
import { optionArgsSchema } from "./config/index.js";
|
|
5
|
+
import { createPublicClient, createWalletClient, formatEther, fallback, publicActions } from "viem";
|
|
6
|
+
import { UtilityWalletMonitor } from "../executor/utilityWalletMonitor.js";
|
|
7
7
|
import { customTransport } from "./customTransport.js";
|
|
8
8
|
import { setupServer } from "./setupServer.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!parsing.success) {
|
|
16
|
-
const error = fromZodError(parsing.error);
|
|
17
|
-
throw new Error(error.message);
|
|
18
|
-
}
|
|
19
|
-
return parsing.data;
|
|
20
|
-
};
|
|
21
|
-
const preFlightChecks = async (publicClient, parsedArgs) => {
|
|
22
|
-
for (const entrypoint of parsedArgs.entrypoints) {
|
|
23
|
-
const entryPointCode = await publicClient.getBytecode({
|
|
9
|
+
import { createConfig } from "../createConfig.js";
|
|
10
|
+
import { parseArgs } from "./parseArgs.js";
|
|
11
|
+
import { deploySimulationsContract } from "./deploySimulationsContract.js";
|
|
12
|
+
const preFlightChecks = async (config) => {
|
|
13
|
+
for (const entrypoint of config.entrypoints) {
|
|
14
|
+
const entryPointCode = await config.publicClient.getCode({
|
|
24
15
|
address: entrypoint
|
|
25
16
|
});
|
|
26
|
-
if (entryPointCode === "0x") {
|
|
17
|
+
if (entryPointCode === undefined || entryPointCode === "0x") {
|
|
27
18
|
throw new Error(`entry point ${entrypoint} does not exist`);
|
|
28
19
|
}
|
|
29
20
|
}
|
|
30
|
-
if (
|
|
31
|
-
const simulations =
|
|
32
|
-
const simulationsCode = await publicClient.
|
|
21
|
+
if (config.entrypointSimulationContract) {
|
|
22
|
+
const simulations = config.entrypointSimulationContract;
|
|
23
|
+
const simulationsCode = await config.publicClient.getCode({
|
|
33
24
|
address: simulations
|
|
34
25
|
});
|
|
35
26
|
if (simulationsCode === undefined || simulationsCode === "0x") {
|
|
36
27
|
throw new Error(`EntryPointSimulations contract ${simulations} does not exist`);
|
|
37
28
|
}
|
|
38
29
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
logger = initDebugLogger(parsedArgs["log-level"]);
|
|
30
|
+
if (config.refillHelperContract) {
|
|
31
|
+
const refillHelper = config.refillHelperContract;
|
|
32
|
+
const refillHelperCode = await config.publicClient.getCode({
|
|
33
|
+
address: refillHelper
|
|
34
|
+
});
|
|
35
|
+
if (refillHelperCode === undefined || refillHelperCode === "0x") {
|
|
36
|
+
throw new Error(`RefillHelper contract ${refillHelper} does not exist`);
|
|
37
|
+
}
|
|
48
38
|
}
|
|
49
|
-
|
|
39
|
+
};
|
|
40
|
+
export async function bundlerHandler(args_) {
|
|
41
|
+
const args = parseArgs(args_);
|
|
42
|
+
const logger = args.json
|
|
43
|
+
? initProductionLogger(args.logLevel)
|
|
44
|
+
: initDebugLogger(args.logLevel);
|
|
50
45
|
const getChainId = async () => {
|
|
51
46
|
const client = createPublicClient({
|
|
52
|
-
transport: customTransport(
|
|
47
|
+
transport: customTransport(args.rpcUrl, {
|
|
53
48
|
logger: logger.child({ module: "public_client" }, {
|
|
54
|
-
level:
|
|
55
|
-
parsedArgs["log-level"]
|
|
49
|
+
level: args.publicClientLogLevel || args.logLevel
|
|
56
50
|
})
|
|
57
51
|
})
|
|
58
52
|
});
|
|
@@ -61,53 +55,57 @@ export async function bundlerHandler(args) {
|
|
|
61
55
|
const chainId = await getChainId();
|
|
62
56
|
const chain = {
|
|
63
57
|
id: chainId,
|
|
64
|
-
name: args
|
|
58
|
+
name: args.networkName,
|
|
65
59
|
nativeCurrency: {
|
|
66
60
|
name: "ETH",
|
|
67
61
|
symbol: "ETH",
|
|
68
62
|
decimals: 18
|
|
69
63
|
},
|
|
70
64
|
rpcUrls: {
|
|
71
|
-
default: { http: [args
|
|
72
|
-
public: { http: [args
|
|
65
|
+
default: { http: [args.rpcUrl] },
|
|
66
|
+
public: { http: [args.rpcUrl] }
|
|
73
67
|
}
|
|
74
68
|
};
|
|
75
|
-
|
|
76
|
-
transport: customTransport(args
|
|
69
|
+
let publicClient = createPublicClient({
|
|
70
|
+
transport: customTransport(args.rpcUrl, {
|
|
77
71
|
logger: logger.child({ module: "public_client" }, {
|
|
78
|
-
level:
|
|
79
|
-
parsedArgs["log-level"]
|
|
72
|
+
level: args.publicClientLogLevel || args.logLevel
|
|
80
73
|
})
|
|
81
74
|
}),
|
|
82
75
|
chain
|
|
83
76
|
});
|
|
77
|
+
if (args.chainType === "skale") {
|
|
78
|
+
// SKALE only allows white listed addresses to deploy contracts.
|
|
79
|
+
publicClient = publicClient
|
|
80
|
+
.extend((client) => ({
|
|
81
|
+
async call(args) {
|
|
82
|
+
args.account = "0x4337000c2828F5260d8921fD25829F606b9E8680";
|
|
83
|
+
return await client.call(args);
|
|
84
|
+
}
|
|
85
|
+
}))
|
|
86
|
+
.extend(publicActions);
|
|
87
|
+
}
|
|
88
|
+
const createWalletTransport = (url) => customTransport(url, {
|
|
89
|
+
logger: logger.child({ module: "wallet_client" }, { level: args.walletClientLogLevel || args.logLevel })
|
|
90
|
+
});
|
|
91
|
+
const walletClient = createWalletClient({
|
|
92
|
+
transport: args.sendTransactionRpcUrl
|
|
93
|
+
? fallback([
|
|
94
|
+
createWalletTransport(args.sendTransactionRpcUrl),
|
|
95
|
+
createWalletTransport(args.rpcUrl)
|
|
96
|
+
], { rank: false })
|
|
97
|
+
: createWalletTransport(args.rpcUrl),
|
|
98
|
+
chain
|
|
99
|
+
});
|
|
84
100
|
// if flag is set, use utility wallet to deploy the simulations contract
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const walletClient = createWalletClient({
|
|
90
|
-
transport: http(args["rpc-url"]),
|
|
91
|
-
account: parsedArgs["utility-private-key"]
|
|
92
|
-
});
|
|
93
|
-
const deployHash = await walletClient.deployContract({
|
|
94
|
-
chain,
|
|
95
|
-
abi: [],
|
|
96
|
-
bytecode: PimlicoEntryPointSimulationsDeployBytecode
|
|
101
|
+
if (args.deploySimulationsContract) {
|
|
102
|
+
args.entrypointSimulationContract = await deploySimulationsContract({
|
|
103
|
+
args,
|
|
104
|
+
publicClient
|
|
97
105
|
});
|
|
98
|
-
const receipt = await client.getTransactionReceipt({
|
|
99
|
-
hash: deployHash
|
|
100
|
-
});
|
|
101
|
-
const simulationsContract = receipt.contractAddress;
|
|
102
|
-
if (simulationsContract === null) {
|
|
103
|
-
throw new Error("Failed to deploy simulationsContract");
|
|
104
|
-
}
|
|
105
|
-
parsedArgs["entrypoint-simulation-contract"] = simulationsContract;
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
parsedArgs["log-level"]
|
|
110
|
-
}), parsedArgs["gas-price-bump"], parsedArgs["gas-price-expiry"], parsedArgs["gas-price-refresh-interval"], parsedArgs["chain-type"]);
|
|
107
|
+
const config = createConfig({ ...args, logger, publicClient, walletClient });
|
|
108
|
+
const gasPriceManager = new GasPriceManager(config);
|
|
111
109
|
await gasPriceManager.init();
|
|
112
110
|
const registry = new Registry();
|
|
113
111
|
registry.setDefaultLabels({
|
|
@@ -115,33 +113,24 @@ export async function bundlerHandler(args) {
|
|
|
115
113
|
chainId
|
|
116
114
|
});
|
|
117
115
|
const metrics = createMetrics(registry);
|
|
118
|
-
await preFlightChecks(
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
parsedArgs["log-level"]
|
|
124
|
-
})
|
|
125
|
-
}),
|
|
126
|
-
chain
|
|
116
|
+
await preFlightChecks(config);
|
|
117
|
+
const senderManager = new SenderManager({
|
|
118
|
+
config,
|
|
119
|
+
metrics,
|
|
120
|
+
gasPriceManager
|
|
127
121
|
});
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}));
|
|
122
|
+
const utilityWalletAddress = config.utilityPrivateKey?.address;
|
|
123
|
+
if (utilityWalletAddress && config.utilityWalletMonitor) {
|
|
124
|
+
const utilityWalletMonitor = new UtilityWalletMonitor({
|
|
125
|
+
config,
|
|
126
|
+
metrics,
|
|
127
|
+
utilityWalletAddress
|
|
128
|
+
});
|
|
136
129
|
await utilityWalletMonitor.start();
|
|
137
130
|
}
|
|
138
|
-
metrics.executorWalletsMinBalance.set(Number.parseFloat(formatEther(
|
|
131
|
+
metrics.executorWalletsMinBalance.set(Number.parseFloat(formatEther(config.minExecutorBalance || 0n)));
|
|
139
132
|
await setupServer({
|
|
140
|
-
|
|
141
|
-
walletClient,
|
|
142
|
-
parsedArgs,
|
|
143
|
-
logger,
|
|
144
|
-
rootLogger,
|
|
133
|
+
config,
|
|
145
134
|
registry,
|
|
146
135
|
metrics,
|
|
147
136
|
senderManager,
|
package/esm/cli/handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../cli/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EACH,aAAa,EACb,eAAe,EACf,oBAAoB,
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../cli/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EACH,aAAa,EACb,eAAe,EACf,oBAAoB,EACvB,MAAM,aAAa,CAAA;AACpB,OAA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C,WAAW,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,CAClE,CAAA;IAED,MAAM,WAAW,CAAC;QACd,MAAM;QACN,QAAQ;QACR,OAAO;QACP,aAAa;QACb,eAAe;KAClB,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -3,10 +3,10 @@ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
|
|
|
3
3
|
import { FastifyInstrumentation } from "@opentelemetry/instrumentation-fastify";
|
|
4
4
|
import { HttpInstrumentation } from "@opentelemetry/instrumentation-http";
|
|
5
5
|
import { PinoInstrumentation } from "@opentelemetry/instrumentation-pino";
|
|
6
|
+
import { UndiciInstrumentation } from "@opentelemetry/instrumentation-undici";
|
|
6
7
|
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
7
8
|
import { ParentBasedSampler, SamplingDecision } from "@opentelemetry/sdk-trace-base";
|
|
8
9
|
import { SemanticAttributes } from "@opentelemetry/semantic-conventions";
|
|
9
|
-
import { UndiciInstrumentation } from "@opentelemetry/instrumentation-undici";
|
|
10
10
|
class CustomSampler {
|
|
11
11
|
shouldSample(_context, _traceId, _spanName, spanKind, attributes) {
|
|
12
12
|
const ignoredRoutes = ["/metrics", "/health"];
|
|
@@ -29,7 +29,9 @@ const sdk = new NodeSDK({
|
|
|
29
29
|
new HttpInstrumentation({
|
|
30
30
|
requireParentforOutgoingSpans: true
|
|
31
31
|
}),
|
|
32
|
-
new UndiciInstrumentation(
|
|
32
|
+
new UndiciInstrumentation({
|
|
33
|
+
requireParentforSpans: true
|
|
34
|
+
}),
|
|
33
35
|
new FastifyInstrumentation(),
|
|
34
36
|
new PinoInstrumentation()
|
|
35
37
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../cli/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EAAE,iBA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AC,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAC/C,CAAC;YACC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,CAAC,UAAU,EAAE,CAAA;QACpD,CAAC;QACD,WAAW;QACX,OAAO,EAAE,QAAQ,EAAE,gBAAgB,CAAC,kBAAkB,EAAE,CAAA;IAC5D,CAAC;IACD,QAAQ;QACJ,OAAO,eAAe,CAAA;IAC1B,CAAC;CACJ;AAED,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC;IACpB,aAAa,EAAE,IAAI,iBAAiB,EAAE;IACtC,gBAAgB,EAAE;QACd,IAAI,mBAAmB,CAAC;YACpB,6BAA6B,EAAE,IAAI;SACtC,CAAC;QACF,IAAI,qBAAqB,CAAC;YACtB,qBAAqB,EAAE,IAAI;SAC9B,CAAC;QACF,IAAI,sBAAsB,EAAE;QAC5B,IAAI,mBAAmB,EAAE;KAC5B;IACD,OAAO,EAAE,IAAI,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,aAAa,EAAE,EAAE,CAAC;CACjE,CAAC,CAAA;AAEF,GAAG,CAAC,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type IOptions, type IOptionsInput } from "./index.js";
|
|
2
|
+
type CamelCase<S extends string> = S extends `${infer P1}-${infer P2}${infer P3}` ? `${P1}${Uppercase<P2>}${CamelCase<P3>}` : S extends `${infer P1}_${infer P2}${infer P3}` ? `${P1}${Uppercase<P2>}${CamelCase<P3>}` : S;
|
|
3
|
+
export type CamelCasedProperties<T> = {
|
|
4
|
+
[K in keyof T as CamelCase<Extract<K, string>>]: T[K];
|
|
5
|
+
};
|
|
6
|
+
export declare const parseArgs: (args: IOptionsInput) => CamelCasedProperties<IOptions>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=parseArgs.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { optionArgsSchema } from "./index.js";
|
|
2
|
+
import { fromZodError } from "zod-validation-error";
|
|
3
|
+
function toCamelCase(str) {
|
|
4
|
+
return str.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace("-", "").replace("_", ""));
|
|
5
|
+
}
|
|
6
|
+
function convertKeysToCamelCase(obj) {
|
|
7
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
8
|
+
const camelCaseKey = toCamelCase(key);
|
|
9
|
+
acc[camelCaseKey] = obj[key];
|
|
10
|
+
return acc;
|
|
11
|
+
}, {});
|
|
12
|
+
}
|
|
13
|
+
export const parseArgs = (args) => {
|
|
14
|
+
const parsing = optionArgsSchema.safeParse(args);
|
|
15
|
+
if (!parsing.success) {
|
|
16
|
+
const error = fromZodError(parsing.error);
|
|
17
|
+
throw new Error(error.message);
|
|
18
|
+
}
|
|
19
|
+
return convertKeysToCamelCase(parsing.data);
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=parseArgs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseArgs.js","sourceRoot":"","sources":["../../cli/parseArgs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,gBAAgB,EAAsB,MAAM,WAAW,CAAA;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAanD,SAAS,WAAW,CAAC,GAAW;IAC5B,OAAO,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE,CACzC,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CACxD,CAAA;AACL,CAAC;AAED,SAAS,sBAAsB,CAC3B,GAAM;IAEN,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAC1B,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACT,MAAM,YAAY,GAAG,WAAW,CAC5B,GAAG,CAC2B,CACjC;QAAC,GAAW,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC,GAAc,CAAC,CAAA;QAEjD,OAAO,GAAG,CAAA;IACd,CAAC,EACD,EAA6B,CAChC,CAAA;AACL,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CACrB,IAAmB,EACW,EAAE;IAChC,MAAM,OAAO,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAChD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACzC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAC/C,CAAC,CAAA"}
|
package/esm/cli/setupServer.d.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import type { SenderManager } from "../executor/index.js";
|
|
2
2
|
import { type GasPriceManager } from "../handlers/index.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Metrics } from "../utils/index.js";
|
|
4
4
|
import type { Registry } from "prom-client";
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
client: PublicClient<Transport, Chain>;
|
|
9
|
-
walletClient: WalletClient<Transport, Chain>;
|
|
10
|
-
parsedArgs: IOptions;
|
|
11
|
-
logger: Logger;
|
|
12
|
-
rootLogger: Logger;
|
|
5
|
+
import type { AltoConfig } from "../createConfig.js";
|
|
6
|
+
export declare const setupServer: ({ config, registry, metrics, senderManager, gasPriceManager }: {
|
|
7
|
+
config: AltoConfig;
|
|
13
8
|
registry: Registry;
|
|
14
9
|
metrics: Metrics;
|
|
15
10
|
senderManager: SenderManager;
|
package/esm/cli/setupServer.js
CHANGED
|
@@ -2,141 +2,161 @@ import { Executor, ExecutorManager } from "../executor/index.js";
|
|
|
2
2
|
import { CompressionHandler, EventManager } from "../handlers/index.js";
|
|
3
3
|
import { MemoryMempool, Monitor, NullReputationManager, ReputationManager } from "../mempool/index.js";
|
|
4
4
|
import { NonceQueuer, RpcHandler, SafeValidator, Server, UnsafeValidator } from "../rpc/index.js";
|
|
5
|
-
const getReputationManager = (
|
|
6
|
-
if (
|
|
7
|
-
return new ReputationManager(
|
|
8
|
-
level: parsedArgs["reputation-manager-log-level"] ||
|
|
9
|
-
parsedArgs["log-level"]
|
|
10
|
-
}));
|
|
5
|
+
const getReputationManager = (config) => {
|
|
6
|
+
if (config.safeMode) {
|
|
7
|
+
return new ReputationManager(config);
|
|
11
8
|
}
|
|
12
9
|
return new NullReputationManager();
|
|
13
10
|
};
|
|
14
|
-
const getValidator = ({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const getValidator = ({ config, senderManager, metrics, gasPriceManager }) => {
|
|
12
|
+
if (config.safeMode) {
|
|
13
|
+
return new SafeValidator({
|
|
14
|
+
config,
|
|
15
|
+
senderManager,
|
|
16
|
+
metrics,
|
|
17
|
+
gasPriceManager
|
|
18
|
+
});
|
|
21
19
|
}
|
|
22
|
-
return new UnsafeValidator(
|
|
20
|
+
return new UnsafeValidator({
|
|
21
|
+
config,
|
|
22
|
+
metrics,
|
|
23
|
+
gasPriceManager
|
|
24
|
+
});
|
|
23
25
|
};
|
|
24
26
|
const getMonitor = () => {
|
|
25
27
|
return new Monitor();
|
|
26
28
|
};
|
|
27
|
-
const getMempool = ({ monitor, reputationManager, validator,
|
|
28
|
-
return new MemoryMempool(
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const getMempool = ({ config, monitor, reputationManager, validator, metrics, eventManager }) => {
|
|
30
|
+
return new MemoryMempool({
|
|
31
|
+
config,
|
|
32
|
+
monitor,
|
|
33
|
+
reputationManager,
|
|
34
|
+
validator,
|
|
35
|
+
metrics,
|
|
36
|
+
eventManager
|
|
37
|
+
});
|
|
31
38
|
};
|
|
32
|
-
const getEventManager = ({
|
|
33
|
-
return new EventManager(
|
|
39
|
+
const getEventManager = ({ config, metrics }) => {
|
|
40
|
+
return new EventManager({ config, metrics });
|
|
34
41
|
};
|
|
35
|
-
const getCompressionHandler = async (
|
|
42
|
+
const getCompressionHandler = async (config) => {
|
|
36
43
|
let compressionHandler = null;
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
compressionHandler = await CompressionHandler.createAsync(
|
|
44
|
+
if (config.bundleBulkerAddress !== undefined &&
|
|
45
|
+
config.perOpInflatorAddress !== undefined) {
|
|
46
|
+
compressionHandler = await CompressionHandler.createAsync(config.bundleBulkerAddress, config.perOpInflatorAddress, config.publicClient);
|
|
40
47
|
}
|
|
41
48
|
return compressionHandler;
|
|
42
49
|
};
|
|
43
|
-
const getExecutor = ({
|
|
44
|
-
return new Executor(
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
const getExecutor = ({ mempool, config, senderManager, reputationManager, metrics, compressionHandler, gasPriceManager, eventManager }) => {
|
|
51
|
+
return new Executor({
|
|
52
|
+
mempool,
|
|
53
|
+
config,
|
|
54
|
+
senderManager,
|
|
55
|
+
reputationManager,
|
|
56
|
+
metrics,
|
|
57
|
+
compressionHandler,
|
|
58
|
+
gasPriceManager,
|
|
59
|
+
eventManager
|
|
60
|
+
});
|
|
47
61
|
};
|
|
48
|
-
const getExecutorManager = ({ executor, mempool, monitor, reputationManager,
|
|
49
|
-
return new ExecutorManager(
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
const getExecutorManager = ({ config, executor, mempool, monitor, reputationManager, metrics, gasPriceManager, eventManager }) => {
|
|
63
|
+
return new ExecutorManager({
|
|
64
|
+
config,
|
|
65
|
+
executor,
|
|
66
|
+
mempool,
|
|
67
|
+
monitor,
|
|
68
|
+
reputationManager,
|
|
69
|
+
metrics,
|
|
70
|
+
gasPriceManager,
|
|
71
|
+
eventManager
|
|
72
|
+
});
|
|
52
73
|
};
|
|
53
|
-
const getNonceQueuer = ({
|
|
54
|
-
return new NonceQueuer(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
74
|
+
const getNonceQueuer = ({ config, mempool, eventManager }) => {
|
|
75
|
+
return new NonceQueuer({
|
|
76
|
+
config,
|
|
77
|
+
mempool,
|
|
78
|
+
eventManager
|
|
79
|
+
});
|
|
58
80
|
};
|
|
59
|
-
const getRpcHandler = ({
|
|
60
|
-
return new RpcHandler(
|
|
81
|
+
const getRpcHandler = ({ config, validator, mempool, executor, monitor, nonceQueuer, executorManager, reputationManager, metrics, compressionHandler, gasPriceManager, eventManager }) => {
|
|
82
|
+
return new RpcHandler({
|
|
83
|
+
config,
|
|
84
|
+
validator,
|
|
85
|
+
mempool,
|
|
86
|
+
executor,
|
|
87
|
+
monitor,
|
|
88
|
+
nonceQueuer,
|
|
89
|
+
executorManager,
|
|
90
|
+
reputationManager,
|
|
91
|
+
metrics,
|
|
92
|
+
compressionHandler,
|
|
93
|
+
gasPriceManager,
|
|
94
|
+
eventManager
|
|
95
|
+
});
|
|
61
96
|
};
|
|
62
|
-
const getServer = ({
|
|
63
|
-
return new Server(
|
|
97
|
+
const getServer = ({ config, rpcEndpoint, registry, metrics }) => {
|
|
98
|
+
return new Server({
|
|
99
|
+
config,
|
|
100
|
+
rpcEndpoint,
|
|
101
|
+
registry,
|
|
102
|
+
metrics
|
|
103
|
+
});
|
|
64
104
|
};
|
|
65
|
-
export const setupServer = async ({
|
|
105
|
+
export const setupServer = async ({ config, registry, metrics, senderManager, gasPriceManager }) => {
|
|
66
106
|
const validator = getValidator({
|
|
67
|
-
|
|
68
|
-
logger,
|
|
69
|
-
parsedArgs,
|
|
107
|
+
config,
|
|
70
108
|
senderManager,
|
|
71
109
|
metrics,
|
|
72
|
-
gasPriceManager
|
|
73
|
-
walletClient
|
|
74
|
-
});
|
|
75
|
-
const reputationManager = getReputationManager({
|
|
76
|
-
client,
|
|
77
|
-
parsedArgs,
|
|
78
|
-
logger
|
|
79
|
-
});
|
|
80
|
-
const compressionHandler = await getCompressionHandler({
|
|
81
|
-
client,
|
|
82
|
-
parsedArgs
|
|
110
|
+
gasPriceManager
|
|
83
111
|
});
|
|
112
|
+
const reputationManager = getReputationManager(config);
|
|
113
|
+
const compressionHandler = await getCompressionHandler(config);
|
|
84
114
|
const eventManager = getEventManager({
|
|
85
|
-
|
|
86
|
-
chainId: client.chain.id,
|
|
87
|
-
logger,
|
|
115
|
+
config,
|
|
88
116
|
metrics
|
|
89
117
|
});
|
|
90
|
-
if (
|
|
91
|
-
await senderManager.validateAndRefillWallets(
|
|
118
|
+
if (config.refillingWallets) {
|
|
119
|
+
await senderManager.validateAndRefillWallets();
|
|
92
120
|
setInterval(async () => {
|
|
93
|
-
await senderManager.validateAndRefillWallets(
|
|
94
|
-
},
|
|
121
|
+
await senderManager.validateAndRefillWallets();
|
|
122
|
+
}, config.executorRefillInterval * 1000);
|
|
95
123
|
}
|
|
96
124
|
const monitor = getMonitor();
|
|
97
125
|
const mempool = getMempool({
|
|
126
|
+
config,
|
|
98
127
|
monitor,
|
|
99
128
|
reputationManager,
|
|
100
129
|
validator,
|
|
101
|
-
client,
|
|
102
|
-
parsedArgs,
|
|
103
|
-
logger,
|
|
104
130
|
metrics,
|
|
105
131
|
eventManager
|
|
106
132
|
});
|
|
107
133
|
const executor = getExecutor({
|
|
108
|
-
|
|
109
|
-
|
|
134
|
+
mempool,
|
|
135
|
+
config,
|
|
110
136
|
senderManager,
|
|
111
137
|
reputationManager,
|
|
112
|
-
parsedArgs,
|
|
113
|
-
logger,
|
|
114
138
|
metrics,
|
|
115
139
|
compressionHandler,
|
|
116
140
|
gasPriceManager,
|
|
117
141
|
eventManager
|
|
118
142
|
});
|
|
119
143
|
const executorManager = getExecutorManager({
|
|
144
|
+
config,
|
|
120
145
|
executor,
|
|
121
146
|
mempool,
|
|
122
147
|
monitor,
|
|
123
148
|
reputationManager,
|
|
124
|
-
client,
|
|
125
|
-
parsedArgs,
|
|
126
|
-
logger,
|
|
127
149
|
metrics,
|
|
128
150
|
gasPriceManager,
|
|
129
151
|
eventManager
|
|
130
152
|
});
|
|
131
153
|
const nonceQueuer = getNonceQueuer({
|
|
154
|
+
config,
|
|
132
155
|
mempool,
|
|
133
|
-
client,
|
|
134
|
-
parsedArgs,
|
|
135
|
-
logger,
|
|
136
156
|
eventManager
|
|
137
157
|
});
|
|
138
158
|
const rpcEndpoint = getRpcHandler({
|
|
139
|
-
|
|
159
|
+
config,
|
|
140
160
|
validator,
|
|
141
161
|
mempool,
|
|
142
162
|
executor,
|
|
@@ -144,21 +164,19 @@ export const setupServer = async ({ client, walletClient, parsedArgs, logger, ro
|
|
|
144
164
|
nonceQueuer,
|
|
145
165
|
executorManager,
|
|
146
166
|
reputationManager,
|
|
147
|
-
parsedArgs,
|
|
148
|
-
logger,
|
|
149
167
|
metrics,
|
|
150
168
|
compressionHandler,
|
|
151
169
|
gasPriceManager,
|
|
152
170
|
eventManager
|
|
153
171
|
});
|
|
154
|
-
if (
|
|
172
|
+
if (config.flushStuckTransactionsDuringStartup) {
|
|
155
173
|
executor.flushStuckTransactions();
|
|
156
174
|
}
|
|
175
|
+
const rootLogger = config.getLogger({ module: "root" }, { level: config.logLevel });
|
|
157
176
|
rootLogger.info(`Initialized ${senderManager.wallets.length} executor wallets`);
|
|
158
177
|
const server = getServer({
|
|
178
|
+
config,
|
|
159
179
|
rpcEndpoint,
|
|
160
|
-
parsedArgs,
|
|
161
|
-
logger,
|
|
162
180
|
registry,
|
|
163
181
|
metrics
|
|
164
182
|
});
|