@pimlico/alto 0.0.0-main.20250307T203608 → 0.0.0-main.20250324T173449
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 +5 -3
- package/esm/cli/alto.js.map +1 -1
- package/esm/cli/config/bundler.d.ts +87 -36
- package/esm/cli/config/bundler.js +15 -3
- package/esm/cli/config/bundler.js.map +1 -1
- package/esm/cli/config/options.d.ts +2 -1
- package/esm/cli/config/options.js +59 -5
- package/esm/cli/config/options.js.map +1 -1
- package/esm/cli/handler.js +3 -4
- package/esm/cli/handler.js.map +1 -1
- package/esm/cli/setupServer.d.ts +1 -1
- package/esm/cli/setupServer.js +109 -49
- package/esm/cli/setupServer.js.map +1 -1
- package/esm/createConfig.d.ts +1 -0
- package/esm/createConfig.js +1 -0
- package/esm/createConfig.js.map +1 -1
- package/esm/executor/executor.d.ts +3 -3
- package/esm/executor/executor.js +7 -4
- package/esm/executor/executor.js.map +1 -1
- package/esm/executor/executorManager.d.ts +14 -12
- package/esm/executor/executorManager.js +131 -97
- package/esm/executor/executorManager.js.map +1 -1
- package/esm/executor/index.d.ts +1 -1
- package/esm/executor/index.js +1 -1
- package/esm/executor/senderManager/createMemorySenderManager.d.ts +8 -0
- package/esm/executor/senderManager/createMemorySenderManager.js +41 -0
- package/esm/executor/senderManager/createMemorySenderManager.js.map +1 -0
- package/esm/executor/senderManager/createRedisSenderManager.d.ts +8 -0
- package/esm/executor/senderManager/createRedisSenderManager.js +78 -0
- package/esm/executor/senderManager/createRedisSenderManager.js.map +1 -0
- package/esm/executor/senderManager/flushOnStartUp.d.ts +9 -0
- package/esm/executor/senderManager/flushOnStartUp.js +33 -0
- package/esm/executor/senderManager/flushOnStartUp.js.map +1 -0
- package/esm/executor/senderManager/index.d.ts +15 -0
- package/esm/executor/senderManager/index.js +20 -0
- package/esm/executor/senderManager/index.js.map +1 -0
- package/esm/executor/senderManager/validateAndRefill.d.ts +11 -0
- package/esm/executor/senderManager/validateAndRefill.js +111 -0
- package/esm/executor/senderManager/validateAndRefill.js.map +1 -0
- package/esm/executor/utils.d.ts +8 -2
- package/esm/executor/utils.js +12 -3
- package/esm/executor/utils.js.map +1 -1
- package/esm/handlers/arbitrumGasPriceManager.d.ts +7 -4
- package/esm/handlers/arbitrumGasPriceManager.js +19 -13
- package/esm/handlers/arbitrumGasPriceManager.js.map +1 -1
- package/esm/handlers/eventManager.js +5 -4
- package/esm/handlers/eventManager.js.map +1 -1
- package/esm/handlers/gasPriceManager.d.ts +1 -4
- package/esm/handlers/gasPriceManager.js +81 -48
- package/esm/handlers/gasPriceManager.js.map +1 -1
- package/esm/handlers/mantleGasPriceManager.d.ts +6 -3
- package/esm/handlers/mantleGasPriceManager.js +23 -11
- package/esm/handlers/mantleGasPriceManager.js.map +1 -1
- package/esm/handlers/optimismManager.d.ts +5 -2
- package/esm/handlers/optimismManager.js +8 -5
- package/esm/handlers/optimismManager.js.map +1 -1
- package/esm/mempool/index.d.ts +0 -1
- package/esm/mempool/index.js +0 -1
- package/esm/mempool/index.js.map +1 -1
- package/esm/mempool/mempool.d.ts +95 -27
- package/esm/mempool/mempool.js +132 -252
- package/esm/mempool/mempool.js.map +1 -1
- package/esm/mempool/monitoring.d.ts +8 -4
- package/esm/mempool/monitoring.js +72 -9
- package/esm/mempool/monitoring.js.map +1 -1
- package/esm/rpc/estimation/gasEstimationHandler.d.ts +10 -4
- package/esm/rpc/estimation/gasEstimationHandler.js +16 -19
- package/esm/rpc/estimation/gasEstimationHandler.js.map +1 -1
- package/esm/rpc/estimation/gasEstimationsV07.d.ts +7 -0
- package/esm/rpc/estimation/gasEstimationsV07.js +69 -4
- package/esm/rpc/estimation/gasEstimationsV07.js.map +1 -1
- package/esm/rpc/methods/debug_bundler_clearReputation.js.map +1 -1
- package/esm/rpc/methods/debug_bundler_dumpMempool.js +2 -2
- package/esm/rpc/methods/debug_bundler_dumpMempool.js.map +1 -1
- package/esm/rpc/methods/debug_bundler_setBundlingMode.js.map +1 -1
- package/esm/rpc/methods/eth_chainId.js +1 -1
- package/esm/rpc/methods/eth_chainId.js.map +1 -1
- package/esm/rpc/methods/eth_sendUserOperation.js +2 -2
- package/esm/rpc/methods/eth_sendUserOperation.js.map +1 -1
- package/esm/rpc/methods/index.js +0 -5
- package/esm/rpc/methods/index.js.map +1 -1
- package/esm/rpc/methods/pimlico_sendUserOperationNow.js +2 -3
- package/esm/rpc/methods/pimlico_sendUserOperationNow.js.map +1 -1
- package/esm/rpc/rpcHandler.d.ts +4 -7
- package/esm/rpc/rpcHandler.js +37 -37
- package/esm/rpc/rpcHandler.js.map +1 -1
- package/esm/rpc/validation/SafeValidator.js +2 -2
- package/esm/rpc/validation/SafeValidator.js.map +1 -1
- package/esm/rpc/validation/UnsafeValidator.d.ts +7 -2
- package/esm/rpc/validation/UnsafeValidator.js +20 -4
- package/esm/rpc/validation/UnsafeValidator.js.map +1 -1
- package/esm/store/createMemoryOutstandingStore.d.ts +28 -0
- package/esm/store/createMemoryOutstandingStore.js +221 -0
- package/esm/store/createMemoryOutstandingStore.js.map +1 -0
- package/esm/store/createMempoolStore.d.ts +8 -0
- package/esm/store/createMempoolStore.js +193 -0
- package/esm/store/createMempoolStore.js.map +1 -0
- package/esm/store/createRedisOutstandingStore.d.ts +27 -0
- package/esm/store/createRedisOutstandingStore.js +344 -0
- package/esm/store/createRedisOutstandingStore.js.map +1 -0
- package/esm/store/createRedisStore.d.ts +9 -0
- package/esm/store/createRedisStore.js +131 -0
- package/esm/store/createRedisStore.js.map +1 -0
- package/esm/store/createStore.d.ts +6 -0
- package/esm/store/createStore.js +66 -0
- package/esm/store/createStore.js.map +1 -0
- package/esm/store/index.d.ts +81 -0
- package/esm/store/index.js +2 -0
- package/esm/store/index.js.map +1 -0
- package/esm/types/interfaces.d.ts +7 -3
- package/esm/types/mempool.d.ts +2 -15
- package/esm/types/mempool.js.map +1 -1
- package/esm/types/schemas.d.ts +4617 -7632
- package/esm/types/schemas.js +19 -42
- package/esm/types/schemas.js.map +1 -1
- package/esm/utils/minMaxQueue/createMemoryMinMaxQueue.d.ts +6 -0
- package/esm/utils/minMaxQueue/createMemoryMinMaxQueue.js +53 -0
- package/esm/utils/minMaxQueue/createMemoryMinMaxQueue.js.map +1 -0
- package/esm/utils/minMaxQueue/createRedisMinMaxQueue.d.ts +7 -0
- package/esm/utils/minMaxQueue/createRedisMinMaxQueue.js +98 -0
- package/esm/utils/minMaxQueue/createRedisMinMaxQueue.js.map +1 -0
- package/esm/utils/minMaxQueue/index.d.ts +12 -0
- package/esm/utils/minMaxQueue/index.js +12 -0
- package/esm/utils/minMaxQueue/index.js.map +1 -0
- package/esm/utils/validation.js +8 -10
- package/esm/utils/validation.js.map +1 -1
- package/lib/cli/alto.js +3 -1
- package/lib/cli/alto.js.map +1 -1
- package/lib/cli/config/bundler.d.ts +87 -36
- package/lib/cli/config/bundler.js +16 -4
- package/lib/cli/config/bundler.js.map +1 -1
- package/lib/cli/config/options.d.ts +2 -1
- package/lib/cli/config/options.js +60 -6
- package/lib/cli/config/options.js.map +1 -1
- package/lib/cli/handler.js +3 -4
- package/lib/cli/handler.js.map +1 -1
- package/lib/cli/setupServer.d.ts +1 -1
- package/lib/cli/setupServer.js +108 -48
- package/lib/cli/setupServer.js.map +1 -1
- package/lib/createConfig.d.ts +1 -0
- package/lib/createConfig.js +1 -0
- package/lib/createConfig.js.map +1 -1
- package/lib/executor/executor.d.ts +3 -3
- package/lib/executor/executor.js +7 -4
- package/lib/executor/executor.js.map +1 -1
- package/lib/executor/executorManager.d.ts +14 -12
- package/lib/executor/executorManager.js +131 -97
- package/lib/executor/executorManager.js.map +1 -1
- package/lib/executor/index.d.ts +1 -1
- package/lib/executor/index.js +1 -1
- package/lib/executor/senderManager/createMemorySenderManager.d.ts +8 -0
- package/lib/executor/senderManager/createMemorySenderManager.js +45 -0
- package/lib/executor/senderManager/createMemorySenderManager.js.map +1 -0
- package/lib/executor/senderManager/createRedisSenderManager.d.ts +8 -0
- package/lib/executor/senderManager/createRedisSenderManager.js +85 -0
- package/lib/executor/senderManager/createRedisSenderManager.js.map +1 -0
- package/lib/executor/senderManager/flushOnStartUp.d.ts +9 -0
- package/lib/executor/senderManager/flushOnStartUp.js +37 -0
- package/lib/executor/senderManager/flushOnStartUp.js.map +1 -0
- package/lib/executor/senderManager/index.d.ts +15 -0
- package/lib/executor/senderManager/index.js +25 -0
- package/lib/executor/senderManager/index.js.map +1 -0
- package/lib/executor/senderManager/validateAndRefill.d.ts +11 -0
- package/lib/executor/senderManager/validateAndRefill.js +115 -0
- package/lib/executor/senderManager/validateAndRefill.js.map +1 -0
- package/lib/executor/utils.d.ts +8 -2
- package/lib/executor/utils.js +12 -3
- package/lib/executor/utils.js.map +1 -1
- package/lib/handlers/arbitrumGasPriceManager.d.ts +7 -4
- package/lib/handlers/arbitrumGasPriceManager.js +19 -13
- package/lib/handlers/arbitrumGasPriceManager.js.map +1 -1
- package/lib/handlers/eventManager.js +5 -4
- package/lib/handlers/eventManager.js.map +1 -1
- package/lib/handlers/gasPriceManager.d.ts +1 -4
- package/lib/handlers/gasPriceManager.js +81 -48
- package/lib/handlers/gasPriceManager.js.map +1 -1
- package/lib/handlers/mantleGasPriceManager.d.ts +6 -3
- package/lib/handlers/mantleGasPriceManager.js +23 -11
- package/lib/handlers/mantleGasPriceManager.js.map +1 -1
- package/lib/handlers/optimismManager.d.ts +5 -2
- package/lib/handlers/optimismManager.js +8 -5
- package/lib/handlers/optimismManager.js.map +1 -1
- package/lib/mempool/index.d.ts +0 -1
- package/lib/mempool/index.js +0 -1
- package/lib/mempool/index.js.map +1 -1
- package/lib/mempool/mempool.d.ts +95 -27
- package/lib/mempool/mempool.js +133 -253
- package/lib/mempool/mempool.js.map +1 -1
- package/lib/mempool/monitoring.d.ts +8 -4
- package/lib/mempool/monitoring.js +72 -9
- package/lib/mempool/monitoring.js.map +1 -1
- package/lib/rpc/estimation/gasEstimationHandler.d.ts +10 -4
- package/lib/rpc/estimation/gasEstimationHandler.js +15 -18
- package/lib/rpc/estimation/gasEstimationHandler.js.map +1 -1
- package/lib/rpc/estimation/gasEstimationsV07.d.ts +7 -0
- package/lib/rpc/estimation/gasEstimationsV07.js +69 -4
- package/lib/rpc/estimation/gasEstimationsV07.js.map +1 -1
- package/lib/rpc/methods/debug_bundler_clearReputation.js.map +1 -1
- package/lib/rpc/methods/debug_bundler_dumpMempool.js +2 -2
- package/lib/rpc/methods/debug_bundler_dumpMempool.js.map +1 -1
- package/lib/rpc/methods/debug_bundler_setBundlingMode.js.map +1 -1
- package/lib/rpc/methods/eth_chainId.js +1 -1
- package/lib/rpc/methods/eth_chainId.js.map +1 -1
- package/lib/rpc/methods/eth_sendUserOperation.js +2 -2
- package/lib/rpc/methods/eth_sendUserOperation.js.map +1 -1
- package/lib/rpc/methods/index.js +0 -5
- package/lib/rpc/methods/index.js.map +1 -1
- package/lib/rpc/methods/pimlico_sendUserOperationNow.js +2 -3
- package/lib/rpc/methods/pimlico_sendUserOperationNow.js.map +1 -1
- package/lib/rpc/rpcHandler.d.ts +4 -7
- package/lib/rpc/rpcHandler.js +37 -37
- package/lib/rpc/rpcHandler.js.map +1 -1
- package/lib/rpc/validation/SafeValidator.js +2 -2
- package/lib/rpc/validation/SafeValidator.js.map +1 -1
- package/lib/rpc/validation/UnsafeValidator.d.ts +7 -2
- package/lib/rpc/validation/UnsafeValidator.js +20 -4
- package/lib/rpc/validation/UnsafeValidator.js.map +1 -1
- package/lib/store/createMemoryOutstandingStore.d.ts +28 -0
- package/lib/store/createMemoryOutstandingStore.js +226 -0
- package/lib/store/createMemoryOutstandingStore.js.map +1 -0
- package/lib/store/createMempoolStore.d.ts +8 -0
- package/lib/store/createMempoolStore.js +197 -0
- package/lib/store/createMempoolStore.js.map +1 -0
- package/lib/store/createRedisOutstandingStore.d.ts +27 -0
- package/lib/store/createRedisOutstandingStore.js +349 -0
- package/lib/store/createRedisOutstandingStore.js.map +1 -0
- package/lib/store/createRedisStore.d.ts +9 -0
- package/lib/store/createRedisStore.js +138 -0
- package/lib/store/createRedisStore.js.map +1 -0
- package/lib/store/createStore.d.ts +6 -0
- package/lib/store/createStore.js +70 -0
- package/lib/store/createStore.js.map +1 -0
- package/lib/store/index.d.ts +81 -0
- package/lib/store/index.js +6 -0
- package/lib/store/index.js.map +1 -0
- package/lib/types/interfaces.d.ts +7 -3
- package/lib/types/mempool.d.ts +2 -15
- package/lib/types/mempool.js.map +1 -1
- package/lib/types/schemas.d.ts +4617 -7632
- package/lib/types/schemas.js +24 -47
- package/lib/types/schemas.js.map +1 -1
- package/lib/utils/minMaxQueue/createMemoryMinMaxQueue.d.ts +6 -0
- package/lib/utils/minMaxQueue/createMemoryMinMaxQueue.js +57 -0
- package/lib/utils/minMaxQueue/createMemoryMinMaxQueue.js.map +1 -0
- package/lib/utils/minMaxQueue/createRedisMinMaxQueue.d.ts +7 -0
- package/lib/utils/minMaxQueue/createRedisMinMaxQueue.js +105 -0
- package/lib/utils/minMaxQueue/createRedisMinMaxQueue.js.map +1 -0
- package/lib/utils/minMaxQueue/index.d.ts +12 -0
- package/lib/utils/minMaxQueue/index.js +16 -0
- package/lib/utils/minMaxQueue/index.js.map +1 -0
- package/lib/utils/validation.js +8 -10
- package/lib/utils/validation.js.map +1 -1
- package/package.json +2 -2
- package/esm/executor/senderManager.d.ts +0 -26
- package/esm/executor/senderManager.js +0 -216
- package/esm/executor/senderManager.js.map +0 -1
- package/esm/mempool/nonceQueuer.d.ts +0 -32
- package/esm/mempool/nonceQueuer.js +0 -143
- package/esm/mempool/nonceQueuer.js.map +0 -1
- package/esm/mempool/store.d.ts +0 -22
- package/esm/mempool/store.js +0 -124
- package/esm/mempool/store.js.map +0 -1
- package/esm/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.d.ts +0 -979
- package/esm/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.js +0 -22
- package/esm/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.js.map +0 -1
- package/esm/rpc/methods/pimlico_experimental_sendUserOperation7702.d.ts +0 -422
- package/esm/rpc/methods/pimlico_experimental_sendUserOperation7702.js +0 -19
- package/esm/rpc/methods/pimlico_experimental_sendUserOperation7702.js.map +0 -1
- package/esm/utils/slidingWindowTimedQueue.d.ts +0 -12
- package/esm/utils/slidingWindowTimedQueue.js +0 -48
- package/esm/utils/slidingWindowTimedQueue.js.map +0 -1
- package/lib/executor/senderManager.d.ts +0 -26
- package/lib/executor/senderManager.js +0 -220
- package/lib/executor/senderManager.js.map +0 -1
- package/lib/mempool/nonceQueuer.d.ts +0 -32
- package/lib/mempool/nonceQueuer.js +0 -147
- package/lib/mempool/nonceQueuer.js.map +0 -1
- package/lib/mempool/store.d.ts +0 -22
- package/lib/mempool/store.js +0 -128
- package/lib/mempool/store.js.map +0 -1
- package/lib/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.d.ts +0 -979
- package/lib/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.js +0 -25
- package/lib/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.js.map +0 -1
- package/lib/rpc/methods/pimlico_experimental_sendUserOperation7702.d.ts +0 -422
- package/lib/rpc/methods/pimlico_experimental_sendUserOperation7702.js +0 -22
- package/lib/rpc/methods/pimlico_experimental_sendUserOperation7702.js.map +0 -1
- package/lib/utils/slidingWindowTimedQueue.d.ts +0 -12
- package/lib/utils/slidingWindowTimedQueue.js +0 -52
- package/lib/utils/slidingWindowTimedQueue.js.map +0 -1
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SenderManager = void 0;
|
|
4
|
-
const types_1 = require("../types/index.js");
|
|
5
|
-
const async_mutex_1 = require("async-mutex");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
|
-
const utils_1 = require("./utils.js");
|
|
8
|
-
const waitForTransactionReceipt = async (publicClient, tx) => {
|
|
9
|
-
try {
|
|
10
|
-
return await publicClient.waitForTransactionReceipt({ hash: tx });
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return await waitForTransactionReceipt(publicClient, tx);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
class SenderManager {
|
|
17
|
-
config;
|
|
18
|
-
wallets;
|
|
19
|
-
utilityAccount;
|
|
20
|
-
availableWallets;
|
|
21
|
-
metrics;
|
|
22
|
-
semaphore;
|
|
23
|
-
gasPriceManager;
|
|
24
|
-
logger;
|
|
25
|
-
walletProcessingTime = new Map();
|
|
26
|
-
constructor({ config, metrics, gasPriceManager }) {
|
|
27
|
-
this.config = config;
|
|
28
|
-
this.logger = config.getLogger({ module: "executor" }, {
|
|
29
|
-
level: config.executorLogLevel || config.logLevel
|
|
30
|
-
});
|
|
31
|
-
const maxSigners = config.maxExecutors;
|
|
32
|
-
const wallets = config.executorPrivateKeys;
|
|
33
|
-
if (maxSigners !== undefined && wallets.length > maxSigners) {
|
|
34
|
-
this.wallets = wallets.slice(0, maxSigners);
|
|
35
|
-
this.availableWallets = wallets.slice(0, maxSigners);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
this.wallets = wallets;
|
|
39
|
-
this.availableWallets = wallets;
|
|
40
|
-
}
|
|
41
|
-
this.utilityAccount = this.config.utilityPrivateKey;
|
|
42
|
-
this.metrics = metrics;
|
|
43
|
-
metrics.walletsAvailable.set(this.availableWallets.length);
|
|
44
|
-
metrics.walletsTotal.set(this.wallets.length);
|
|
45
|
-
this.semaphore = new async_mutex_1.Semaphore(this.availableWallets.length);
|
|
46
|
-
this.gasPriceManager = gasPriceManager;
|
|
47
|
-
}
|
|
48
|
-
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
|
|
49
|
-
async validateAndRefillWallets() {
|
|
50
|
-
const minBalance = this.config.minExecutorBalance;
|
|
51
|
-
if (!(minBalance && this.utilityAccount)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const utilityWalletBalance = await this.config.publicClient.getBalance({
|
|
55
|
-
address: this.utilityAccount.address
|
|
56
|
-
});
|
|
57
|
-
const balancesMissing = {};
|
|
58
|
-
const balanceRequestPromises = this.availableWallets.map(async (wallet) => {
|
|
59
|
-
const balance = await this.config.publicClient.getBalance({
|
|
60
|
-
address: wallet.address
|
|
61
|
-
});
|
|
62
|
-
this.metrics.executorWalletsBalances.set({
|
|
63
|
-
wallet: wallet.address
|
|
64
|
-
}, Number.parseFloat((0, viem_1.formatEther)(balance)));
|
|
65
|
-
if (balance < minBalance) {
|
|
66
|
-
const missingBalance = (minBalance * 6n) / 5n - balance;
|
|
67
|
-
balancesMissing[wallet.address] = missingBalance;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
await Promise.all(balanceRequestPromises);
|
|
71
|
-
const totalBalanceMissing = Object.values(balancesMissing).reduce((a, b) => a + b, 0n);
|
|
72
|
-
if (utilityWalletBalance < (totalBalanceMissing * 11n) / 10n) {
|
|
73
|
-
this.logger.info({ balancesMissing, totalBalanceMissing }, "balances missing");
|
|
74
|
-
this.metrics.utilityWalletInsufficientBalance.set(1);
|
|
75
|
-
this.logger.error({
|
|
76
|
-
minBalance: (0, viem_1.formatEther)(minBalance),
|
|
77
|
-
utilityWalletBalance: (0, viem_1.formatEther)(utilityWalletBalance),
|
|
78
|
-
totalBalanceMissing: (0, viem_1.formatEther)(totalBalanceMissing),
|
|
79
|
-
minRefillAmount: (0, viem_1.formatEther)(totalBalanceMissing - utilityWalletBalance),
|
|
80
|
-
utilityAccount: this.utilityAccount.address
|
|
81
|
-
}, "utility wallet has insufficient balance to refill wallets");
|
|
82
|
-
return;
|
|
83
|
-
// throw new Error(
|
|
84
|
-
// `utility wallet ${
|
|
85
|
-
// this.utilityAccount.address
|
|
86
|
-
// } has insufficient balance ${formatEther(
|
|
87
|
-
// utilityWalletBalance
|
|
88
|
-
// )} < ${formatEther(totalBalanceMissing)}`
|
|
89
|
-
// )
|
|
90
|
-
}
|
|
91
|
-
this.metrics.utilityWalletInsufficientBalance.set(0);
|
|
92
|
-
if (Object.keys(balancesMissing).length > 0) {
|
|
93
|
-
let maxFeePerGas;
|
|
94
|
-
let maxPriorityFeePerGas;
|
|
95
|
-
try {
|
|
96
|
-
const gasPriceParameters = await this.gasPriceManager.tryGetNetworkGasPrice();
|
|
97
|
-
maxFeePerGas = gasPriceParameters.maxFeePerGas;
|
|
98
|
-
maxPriorityFeePerGas = gasPriceParameters.maxPriorityFeePerGas;
|
|
99
|
-
}
|
|
100
|
-
catch (e) {
|
|
101
|
-
this.logger.error(e, "No gas price available");
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (this.config.refillHelperContract) {
|
|
105
|
-
const instructions = [];
|
|
106
|
-
for (const [address, missingBalance] of Object.entries(balancesMissing)) {
|
|
107
|
-
instructions.push({
|
|
108
|
-
to: address,
|
|
109
|
-
value: missingBalance,
|
|
110
|
-
data: "0x"
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
const callEngine = (0, viem_1.getContract)({
|
|
114
|
-
abi: types_1.CallEngineAbi,
|
|
115
|
-
address: this.config.refillHelperContract,
|
|
116
|
-
client: {
|
|
117
|
-
public: this.config.publicClient,
|
|
118
|
-
wallet: this.config.walletClient
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
const tx = await callEngine.write.execute([instructions], {
|
|
122
|
-
account: this.utilityAccount,
|
|
123
|
-
value: totalBalanceMissing,
|
|
124
|
-
maxFeePerGas: maxFeePerGas * 2n,
|
|
125
|
-
maxPriorityFeePerGas: maxPriorityFeePerGas * 2n
|
|
126
|
-
});
|
|
127
|
-
await waitForTransactionReceipt(this.config.publicClient, tx);
|
|
128
|
-
for (const [address, missingBalance] of Object.entries(balancesMissing)) {
|
|
129
|
-
this.logger.info({ tx, executor: address, missingBalance }, "refilled wallet");
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
for (const [address, missingBalance] of Object.entries(balancesMissing)) {
|
|
134
|
-
const tx = await this.config.walletClient.sendTransaction({
|
|
135
|
-
account: this.utilityAccount,
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
to: address,
|
|
138
|
-
value: missingBalance,
|
|
139
|
-
maxFeePerGas: this.config.legacyTransactions
|
|
140
|
-
? undefined
|
|
141
|
-
: maxFeePerGas,
|
|
142
|
-
maxPriorityFeePerGas: this.config.legacyTransactions
|
|
143
|
-
? undefined
|
|
144
|
-
: maxPriorityFeePerGas,
|
|
145
|
-
gasPrice: this.config.legacyTransactions
|
|
146
|
-
? maxFeePerGas
|
|
147
|
-
: undefined
|
|
148
|
-
});
|
|
149
|
-
await waitForTransactionReceipt(this.config.publicClient, tx);
|
|
150
|
-
this.logger.info({ tx, executor: address, missingBalance }, "refilled wallet");
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
this.logger.info("no wallets need to be refilled");
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
async getWallet() {
|
|
159
|
-
this.logger.trace(`waiting for semaphore with count ${this.semaphore.getValue()}`);
|
|
160
|
-
await this.semaphore.waitForUnlock();
|
|
161
|
-
await this.semaphore.acquire();
|
|
162
|
-
const wallet = this.availableWallets.shift();
|
|
163
|
-
// should never happen because of semaphore
|
|
164
|
-
if (!wallet) {
|
|
165
|
-
this.semaphore.release();
|
|
166
|
-
this.logger.error("no more wallets");
|
|
167
|
-
throw new Error("no more wallets");
|
|
168
|
-
}
|
|
169
|
-
this.logger.trace({ executor: wallet.address }, "got wallet from sender manager");
|
|
170
|
-
this.metrics.walletsAvailable.set(this.availableWallets.length);
|
|
171
|
-
this.walletProcessingTime.set(wallet.address, new Date());
|
|
172
|
-
return wallet;
|
|
173
|
-
}
|
|
174
|
-
pushWallet(wallet) {
|
|
175
|
-
this.availableWallets.push(wallet);
|
|
176
|
-
this.semaphore.release();
|
|
177
|
-
this.logger.trace({ executor: wallet.address }, "pushed wallet to sender manager");
|
|
178
|
-
const processingTime = this.walletProcessingTime.get(wallet.address);
|
|
179
|
-
if (processingTime) {
|
|
180
|
-
const time = Date.now() - processingTime.getTime();
|
|
181
|
-
this.metrics.walletsProcessingTime.observe(time / 1000);
|
|
182
|
-
this.walletProcessingTime.delete(wallet.address);
|
|
183
|
-
}
|
|
184
|
-
this.metrics.walletsAvailable.set(this.availableWallets.length);
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
markWalletProcessed(executor) {
|
|
188
|
-
if (!this.availableWallets.includes(executor)) {
|
|
189
|
-
this.pushWallet(executor);
|
|
190
|
-
}
|
|
191
|
-
return Promise.resolve();
|
|
192
|
-
}
|
|
193
|
-
async flushOnStartUp() {
|
|
194
|
-
const allWallets = new Set(this.wallets);
|
|
195
|
-
const utilityWallet = this.utilityAccount;
|
|
196
|
-
if (utilityWallet) {
|
|
197
|
-
allWallets.add(utilityWallet);
|
|
198
|
-
}
|
|
199
|
-
const wallets = Array.from(allWallets);
|
|
200
|
-
let gasPrice;
|
|
201
|
-
try {
|
|
202
|
-
gasPrice = await this.gasPriceManager.tryGetNetworkGasPrice();
|
|
203
|
-
}
|
|
204
|
-
catch (e) {
|
|
205
|
-
this.logger.error({ error: e }, "error flushing stuck transaction");
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
const promises = wallets.map((wallet) => {
|
|
209
|
-
try {
|
|
210
|
-
(0, utils_1.flushStuckTransaction)(this.config.publicClient, this.config.walletClient, wallet, gasPrice.maxFeePerGas * 5n, this.logger);
|
|
211
|
-
}
|
|
212
|
-
catch (e) {
|
|
213
|
-
this.logger.error({ error: e }, "error flushing stuck transaction");
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
await Promise.all(promises);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
exports.SenderManager = SenderManager;
|
|
220
|
-
//# sourceMappingURL=senderManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"senderManager.js","sourceRoot":"","sources":["../../executor/senderManager.ts"],"names":[],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AAM,IAAI,CAAC,eAAe,CAAC,qBAAqB,EAAE,CAAA;QACjE,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,kCAAkC,CAAC,CAAA;YACnE,OAAM;QACV,CAAC;QAED,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACpC,IAAI,CAAC;gBACD,IAAA,6BAAqB,EACjB,IAAI,CAAC,MAAM,CAAC,YAAY,EACxB,IAAI,CAAC,MAAM,CAAC,YAAY,EACxB,MAAM,EACN,QAAQ,CAAC,YAAY,GAAG,EAAE,EAC1B,IAAI,CAAC,MAAM,CACd,CAAA;YACL,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,EAAE,KAAK,EAAE,CAAC,EAAE,EACZ,kCAAkC,CACrC,CAAA;YACL,CAAC;QACL,CAAC,CAAC,CAAA;QAEF,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC;CACJ;AArSD,sCAqSC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { EventManager } from "../handlers/index.js";
|
|
2
|
-
import type { MemoryMempool } from "./index.js";
|
|
3
|
-
import { UserOperation } from "../types/index.js";
|
|
4
|
-
import type { Logger } from "../utils/index.js";
|
|
5
|
-
import { type Address, type Hash, type PublicClient } from "viem";
|
|
6
|
-
import type { AltoConfig } from "../createConfig.js";
|
|
7
|
-
type QueuedUserOperation = {
|
|
8
|
-
entryPoint: Address;
|
|
9
|
-
userOperationHash: Hash;
|
|
10
|
-
userOperation: UserOperation;
|
|
11
|
-
nonceKey: bigint;
|
|
12
|
-
nonceSequence: bigint;
|
|
13
|
-
addedAt: number;
|
|
14
|
-
};
|
|
15
|
-
export declare class NonceQueuer {
|
|
16
|
-
queuedUserOperations: QueuedUserOperation[];
|
|
17
|
-
config: AltoConfig;
|
|
18
|
-
mempool: MemoryMempool;
|
|
19
|
-
logger: Logger;
|
|
20
|
-
eventManager: EventManager;
|
|
21
|
-
constructor({ config, mempool, eventManager }: {
|
|
22
|
-
config: AltoConfig;
|
|
23
|
-
mempool: MemoryMempool;
|
|
24
|
-
eventManager: EventManager;
|
|
25
|
-
});
|
|
26
|
-
process(): Promise<void>;
|
|
27
|
-
add(userOperation: UserOperation, entryPoint: Address): void;
|
|
28
|
-
resubmitUserOperation(userOperation: UserOperation, entryPoint: Address): void;
|
|
29
|
-
getAvailableUserOperations(publicClient: PublicClient): Promise<QueuedUserOperation[]>;
|
|
30
|
-
}
|
|
31
|
-
export {};
|
|
32
|
-
//# sourceMappingURL=nonceQueuer.d.ts.map
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NonceQueuer = void 0;
|
|
4
|
-
const types_1 = require("../types/index.js");
|
|
5
|
-
const utils_1 = require("../utils/index.js");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
|
-
class NonceQueuer {
|
|
8
|
-
queuedUserOperations = [];
|
|
9
|
-
config;
|
|
10
|
-
mempool;
|
|
11
|
-
logger;
|
|
12
|
-
eventManager;
|
|
13
|
-
constructor({ config, mempool, eventManager }) {
|
|
14
|
-
this.config = config;
|
|
15
|
-
this.mempool = mempool;
|
|
16
|
-
this.logger = config.getLogger({ module: "nonce_queuer" }, {
|
|
17
|
-
level: config.nonceQueuerLogLevel || config.logLevel
|
|
18
|
-
});
|
|
19
|
-
this.eventManager = eventManager;
|
|
20
|
-
setInterval(() => {
|
|
21
|
-
this.process();
|
|
22
|
-
}, 2000);
|
|
23
|
-
}
|
|
24
|
-
async process() {
|
|
25
|
-
// remove queued ops that have been in the queue for more than 15 minutes
|
|
26
|
-
this.queuedUserOperations = this.queuedUserOperations.filter((qop) => {
|
|
27
|
-
return qop.addedAt > Date.now() - 1000 * 60 * 15;
|
|
28
|
-
});
|
|
29
|
-
if (this.queuedUserOperations.length === 0) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const availableOps = await this.getAvailableUserOperations(this.config.publicClient);
|
|
33
|
-
if (availableOps.length === 0) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
this.queuedUserOperations = this.queuedUserOperations.filter((qop) => {
|
|
37
|
-
return !availableOps.some((op) => {
|
|
38
|
-
return op.userOperationHash === qop.userOperationHash;
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
availableOps.map((op) => {
|
|
42
|
-
this.resubmitUserOperation(op.userOperation, op.entryPoint);
|
|
43
|
-
});
|
|
44
|
-
this.logger.info({ availableOps: availableOps.map((qop) => qop.userOperationHash) }, "submitted user operations from nonce queue");
|
|
45
|
-
}
|
|
46
|
-
add(userOperation, entryPoint) {
|
|
47
|
-
const [nonceKey, nonceSequence] = (0, utils_1.getNonceKeyAndSequence)(userOperation.nonce);
|
|
48
|
-
const userOperationHash = (0, utils_1.getUserOperationHash)(userOperation, entryPoint, this.config.publicClient.chain.id);
|
|
49
|
-
this.queuedUserOperations.push({
|
|
50
|
-
entryPoint,
|
|
51
|
-
userOperationHash,
|
|
52
|
-
userOperation,
|
|
53
|
-
nonceKey,
|
|
54
|
-
nonceSequence,
|
|
55
|
-
addedAt: Date.now()
|
|
56
|
-
});
|
|
57
|
-
this.eventManager.emitQueued(userOperationHash);
|
|
58
|
-
}
|
|
59
|
-
resubmitUserOperation(userOperation, entryPoint) {
|
|
60
|
-
this.logger.info({ userOperation: userOperation }, "submitting user operation from nonce queue");
|
|
61
|
-
const result = this.mempool.add(userOperation, entryPoint);
|
|
62
|
-
if (result) {
|
|
63
|
-
this.logger.info({ userOperation: userOperation, result: result }, "added user operation");
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this.logger.error("error adding user operation");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async getAvailableUserOperations(publicClient) {
|
|
70
|
-
const queuedUserOperations = this.queuedUserOperations.slice();
|
|
71
|
-
let results;
|
|
72
|
-
try {
|
|
73
|
-
results = await publicClient.multicall({
|
|
74
|
-
contracts: queuedUserOperations.map((qop) => {
|
|
75
|
-
const userOperation = qop.userOperation;
|
|
76
|
-
const isUserOpV06 = (0, utils_1.isVersion06)(userOperation);
|
|
77
|
-
return {
|
|
78
|
-
address: qop.entryPoint,
|
|
79
|
-
abi: isUserOpV06 ? types_1.EntryPointV06Abi : types_1.EntryPointV07Abi,
|
|
80
|
-
functionName: "getNonce",
|
|
81
|
-
args: [userOperation.sender, qop.nonceKey]
|
|
82
|
-
};
|
|
83
|
-
}),
|
|
84
|
-
blockTag: this.config.blockTagSupport ? "latest" : undefined
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
this.logger.error({ error: JSON.stringify(error) }, "error fetching with multiCall");
|
|
89
|
-
results = await Promise.all(queuedUserOperations.map(async (qop) => {
|
|
90
|
-
const userOperation = qop.userOperation;
|
|
91
|
-
try {
|
|
92
|
-
const isUserOpV06 = (0, utils_1.isVersion06)(userOperation);
|
|
93
|
-
const entryPointContract = isUserOpV06
|
|
94
|
-
? (0, viem_1.getContract)({
|
|
95
|
-
abi: types_1.EntryPointV06Abi,
|
|
96
|
-
address: qop.entryPoint,
|
|
97
|
-
client: {
|
|
98
|
-
public: publicClient
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
: (0, viem_1.getContract)({
|
|
102
|
-
abi: types_1.EntryPointV07Abi,
|
|
103
|
-
address: qop.entryPoint,
|
|
104
|
-
client: {
|
|
105
|
-
public: publicClient
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
const nonce = await entryPointContract.read.getNonce([userOperation.sender, qop.nonceKey], { blockTag: "latest" });
|
|
109
|
-
return {
|
|
110
|
-
result: nonce,
|
|
111
|
-
status: "success"
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
return {
|
|
116
|
-
error: e,
|
|
117
|
-
status: "failure"
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
if (results.length !== queuedUserOperations.length) {
|
|
123
|
-
this.logger.error("error fetching nonces");
|
|
124
|
-
return [];
|
|
125
|
-
}
|
|
126
|
-
const currentOutstandingOps = [];
|
|
127
|
-
for (let i = 0; i < queuedUserOperations.length; i++) {
|
|
128
|
-
const qop = queuedUserOperations[i];
|
|
129
|
-
const result = results[i];
|
|
130
|
-
if (result.status !== "success") {
|
|
131
|
-
this.logger.error({ error: result.error }, "error fetching nonce");
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
const onchainNonce = result.result;
|
|
135
|
-
const qopNonce = (0, utils_1.encodeNonce)({
|
|
136
|
-
nonceSequence: qop.nonceSequence,
|
|
137
|
-
nonceKey: qop.nonceKey
|
|
138
|
-
});
|
|
139
|
-
if (onchainNonce === qopNonce) {
|
|
140
|
-
currentOutstandingOps.push(qop);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return currentOutstandingOps;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
exports.NonceQueuer = NonceQueuer;
|
|
147
|
-
//# sourceMappingURL=nonceQueuer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nonceQueuer.js","sourceRoot":"","sources":["../../mempool/nonceQueuer.ts"],"names":[],"mappings":";;;AAEA,uCAA+E;AAE/E,uCAKoB;AACpB,+BAMa;AAYb,MAAa,WAAW;IACpB,oBAAoB,GAA0B,EAAE,CAAA;IAEhD,MAAM,CAAY;IAClB,OAAO,CAAe;IACtB,MAAM,CAAQ;IACd,YAAY,CAAc;IAE1B,YAAY,EACR,MAAM,EACN,OAAO,EACP,YAAY,EAKf;QACG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,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C9B,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,EACvB,sBAAsB,CACzB,CAAA;gBACD,SAAQ;YACZ,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAA;YAClC,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC;gBACzB,aAAa,EAAE,GAAG,CAAC,aAAa;gBAChC,QAAQ,EAAE,GAAG,CAAC,QAAQ;aACzB,CAAC,CAAA;YAEF,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;gBAC5B,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACnC,CAAC;QACL,CAAC;QAED,OAAO,qBAAqB,CAAA;IAChC,CAAC;CACJ;AA3MD,kCA2MC"}
|
package/lib/mempool/store.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { HexData32, SubmittedUserOp, UserOpInfo } from "../types/index.js";
|
|
2
|
-
import type { Metrics } from "../utils/index.js";
|
|
3
|
-
import type { Logger } from "../utils/index.js";
|
|
4
|
-
export declare class MemoryStore {
|
|
5
|
-
private outstandingUserOperations;
|
|
6
|
-
private processingUserOperations;
|
|
7
|
-
private submittedUserOperations;
|
|
8
|
-
private logger;
|
|
9
|
-
private metrics;
|
|
10
|
-
constructor(logger: Logger, metrics: Metrics);
|
|
11
|
-
addOutstanding(userOpInfo: UserOpInfo): void;
|
|
12
|
-
addProcessing(userOpInfo: UserOpInfo): void;
|
|
13
|
-
addSubmitted(submittedInfo: SubmittedUserOp): void;
|
|
14
|
-
removeOutstanding(userOpHash: HexData32): void;
|
|
15
|
-
removeProcessing(userOpHash: HexData32): void;
|
|
16
|
-
removeSubmitted(userOpHash: HexData32): void;
|
|
17
|
-
dumpOutstanding(): UserOpInfo[];
|
|
18
|
-
dumpProcessing(): UserOpInfo[];
|
|
19
|
-
dumpSubmitted(): SubmittedUserOp[];
|
|
20
|
-
clear(from: "outstanding" | "processing" | "submitted"): void;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=store.d.ts.map
|
package/lib/mempool/store.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemoryStore = void 0;
|
|
4
|
-
class MemoryStore {
|
|
5
|
-
// private monitoredTransactions: Map<HexData32, TransactionInfo> = new Map() // tx hash to info
|
|
6
|
-
outstandingUserOperations = [];
|
|
7
|
-
processingUserOperations = [];
|
|
8
|
-
submittedUserOperations = [];
|
|
9
|
-
logger;
|
|
10
|
-
metrics;
|
|
11
|
-
constructor(logger, metrics) {
|
|
12
|
-
this.logger = logger;
|
|
13
|
-
this.metrics = metrics;
|
|
14
|
-
}
|
|
15
|
-
addOutstanding(userOpInfo) {
|
|
16
|
-
const store = this.outstandingUserOperations;
|
|
17
|
-
store.push(userOpInfo);
|
|
18
|
-
this.logger.debug({ userOpHash: userOpInfo.userOpHash, store: "outstanding" }, "added user op to mempool");
|
|
19
|
-
this.metrics.userOperationsInMempool
|
|
20
|
-
.labels({
|
|
21
|
-
status: "outstanding"
|
|
22
|
-
})
|
|
23
|
-
.inc();
|
|
24
|
-
}
|
|
25
|
-
addProcessing(userOpInfo) {
|
|
26
|
-
const store = this.processingUserOperations;
|
|
27
|
-
store.push(userOpInfo);
|
|
28
|
-
this.logger.debug({ userOpHash: userOpInfo.userOpHash, store: "processing" }, "added user op to mempool");
|
|
29
|
-
this.metrics.userOperationsInMempool
|
|
30
|
-
.labels({
|
|
31
|
-
status: "processing"
|
|
32
|
-
})
|
|
33
|
-
.inc();
|
|
34
|
-
}
|
|
35
|
-
addSubmitted(submittedInfo) {
|
|
36
|
-
const { userOpHash } = submittedInfo;
|
|
37
|
-
const store = this.submittedUserOperations;
|
|
38
|
-
store.push(submittedInfo);
|
|
39
|
-
this.logger.debug({
|
|
40
|
-
userOpHash,
|
|
41
|
-
store: "submitted"
|
|
42
|
-
}, "added user op to submitted mempool");
|
|
43
|
-
this.metrics.userOperationsInMempool
|
|
44
|
-
.labels({
|
|
45
|
-
status: "submitted"
|
|
46
|
-
})
|
|
47
|
-
.inc();
|
|
48
|
-
}
|
|
49
|
-
removeOutstanding(userOpHash) {
|
|
50
|
-
const index = this.outstandingUserOperations.findIndex((userOpInfo) => userOpInfo.userOpHash === userOpHash);
|
|
51
|
-
if (index === -1) {
|
|
52
|
-
this.logger.warn({ userOpHash, store: "outstanding" }, "tried to remove non-existent user op from mempool");
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
this.outstandingUserOperations.splice(index, 1);
|
|
56
|
-
this.logger.debug({ userOpHash, store: "outstanding" }, "removed user op from mempool");
|
|
57
|
-
this.metrics.userOperationsInMempool
|
|
58
|
-
.labels({
|
|
59
|
-
status: "outstanding"
|
|
60
|
-
})
|
|
61
|
-
.dec();
|
|
62
|
-
}
|
|
63
|
-
removeProcessing(userOpHash) {
|
|
64
|
-
const index = this.processingUserOperations.findIndex((userOpInfo) => userOpInfo.userOpHash === userOpHash);
|
|
65
|
-
if (index === -1) {
|
|
66
|
-
this.logger.warn({ userOpHash, store: "outstanding" }, "tried to remove non-existent user op from mempool");
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
this.processingUserOperations.splice(index, 1);
|
|
70
|
-
this.logger.debug({ userOpHash, store: "processing" }, "removed user op from mempool");
|
|
71
|
-
this.metrics.userOperationsInMempool
|
|
72
|
-
.labels({
|
|
73
|
-
status: "processing"
|
|
74
|
-
})
|
|
75
|
-
.dec();
|
|
76
|
-
}
|
|
77
|
-
removeSubmitted(userOpHash) {
|
|
78
|
-
const index = this.submittedUserOperations.findIndex((userOpInfo) => userOpInfo.userOpHash === userOpHash);
|
|
79
|
-
if (index === -1) {
|
|
80
|
-
this.logger.warn({ userOpHash, store: "submitted" }, "tried to remove non-existent user op from mempool");
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
this.submittedUserOperations.splice(index, 1);
|
|
84
|
-
this.logger.debug({ userOpHash, store: "submitted" }, "removed user op from mempool");
|
|
85
|
-
this.metrics.userOperationsInMempool
|
|
86
|
-
.labels({
|
|
87
|
-
status: "submitted"
|
|
88
|
-
})
|
|
89
|
-
.dec();
|
|
90
|
-
}
|
|
91
|
-
dumpOutstanding() {
|
|
92
|
-
this.logger.trace({
|
|
93
|
-
store: "outstanding",
|
|
94
|
-
length: this.outstandingUserOperations.length
|
|
95
|
-
}, "dumping mempool");
|
|
96
|
-
return this.outstandingUserOperations;
|
|
97
|
-
}
|
|
98
|
-
dumpProcessing() {
|
|
99
|
-
this.logger.trace({
|
|
100
|
-
store: "processing",
|
|
101
|
-
length: this.processingUserOperations.length
|
|
102
|
-
}, "dumping mempool");
|
|
103
|
-
return this.processingUserOperations;
|
|
104
|
-
}
|
|
105
|
-
dumpSubmitted() {
|
|
106
|
-
this.logger.trace({ store: "submitted", length: this.submittedUserOperations.length }, "dumping mempool");
|
|
107
|
-
return this.submittedUserOperations;
|
|
108
|
-
}
|
|
109
|
-
clear(from) {
|
|
110
|
-
if (from === "outstanding") {
|
|
111
|
-
this.outstandingUserOperations = [];
|
|
112
|
-
this.logger.debug({ store: from, length: this.outstandingUserOperations.length }, "clearing mempool");
|
|
113
|
-
}
|
|
114
|
-
else if (from === "processing") {
|
|
115
|
-
this.processingUserOperations = [];
|
|
116
|
-
this.logger.debug({ store: from, length: this.processingUserOperations.length }, "clearing mempool");
|
|
117
|
-
}
|
|
118
|
-
else if (from === "submitted") {
|
|
119
|
-
this.submittedUserOperations = [];
|
|
120
|
-
this.logger.debug({ store: from, length: this.submittedUserOperations.length }, "clearing mempool");
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
throw new Error("unreachable");
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.MemoryStore = MemoryStore;
|
|
128
|
-
//# sourceMappingURL=store.js.map
|
package/lib/mempool/store.js.map
DELETED
|
@@ -1 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