@pimlico/alto 0.0.19 → 0.0.20
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/contracts/EIP712.sol/EIP712.json +1 -1
- package/contracts/ERC165.sol/ERC165.json +1 -1
- package/contracts/ERC20.sol/ERC20.json +1 -1
- package/contracts/Eip7702Support.sol/Eip7702Support.json +1 -1
- package/contracts/EntryPoint.sol/EntryPoint.json +1 -1
- package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride06.json +1 -1
- package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride07.json +1 -1
- package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride08.json +1 -1
- package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride09.json +1 -0
- package/contracts/EntryPointGasEstimationOverride.sol/EntryPointGasEstimationOverride06.json +1 -1
- package/contracts/EntryPointSimulations.sol/EntryPointSimulations07.json +1 -1
- package/contracts/EntryPointSimulations.sol/EntryPointSimulations08.json +1 -1
- package/contracts/EntryPointSimulations.sol/EntryPointSimulations09.json +1 -0
- package/contracts/Exec.sol/Exec.json +1 -1
- package/contracts/IAccount.sol/IAccount.json +1 -1
- package/contracts/IAccountExecute.sol/IAccountExecute.json +1 -1
- package/contracts/IAggregator.sol/IAggregator.json +1 -1
- package/contracts/IERC165.sol/IERC165.json +1 -1
- package/contracts/IERC5267.sol/IERC5267.json +1 -1
- package/contracts/IEntryPoint.sol/IEntryPoint.json +1 -1
- package/contracts/IEntryPointFilterOpsOverride.sol/IEntryPointFilterOpsOverride08.json +1 -0
- package/contracts/IEntryPointFilterOpsOverride.sol/IEntryPointFilterOpsOverride09.json +1 -0
- package/contracts/IEntryPointSimulations.sol/IEntryPointSimulations.json +1 -1
- package/contracts/INonceManager.sol/INonceManager.json +1 -1
- package/contracts/IPaymaster.sol/IPaymaster.json +1 -1
- package/contracts/ISenderCreator.sol/ISenderCreator.json +1 -1
- package/contracts/IStakeManager.sol/IStakeManager.json +1 -1
- package/contracts/LibBytes.sol/LibBytes.json +1 -1
- package/contracts/Math.sol/Math.json +1 -1
- package/contracts/MessageHashUtils.sol/MessageHashUtils.json +1 -1
- package/contracts/NonceManager.sol/NonceManager.json +1 -1
- package/contracts/Panic.sol/Panic.json +1 -1
- package/contracts/PimlicoSimulations.sol/PimlicoSimulations.json +1 -1
- package/contracts/ReentrancyGuard.sol/ReentrancyGuard.json +1 -1
- package/contracts/ReentrancyGuardTransient.sol/ReentrancyGuardTransient.json +1 -1
- package/contracts/SafeCast.sol/SafeCast.json +1 -1
- package/contracts/SenderCreator.sol/SenderCreator.json +1 -1
- package/contracts/ShortStrings.sol/ShortStrings.json +1 -1
- package/contracts/SignedMath.sol/SignedMath.json +1 -1
- package/contracts/SimulationOverrideHelper.sol/SimulationOverrideHelper.json +1 -0
- package/contracts/StakeManager.sol/StakeManager.json +1 -1
- package/contracts/StorageSlot.sol/StorageSlot.json +1 -1
- package/contracts/Strings.sol/Strings.json +1 -1
- package/contracts/TransientSlot.sol/TransientSlot.json +1 -1
- package/contracts/UserOperation.sol/UserOperationLib.json +1 -1
- package/contracts/UserOperationLib.sol/UserOperationLib.json +1 -1
- package/contracts/account-abstraction-v9/contracts/interfaces/IAggregator.sol/IAggregator.json +1 -0
- package/contracts/account-abstraction-v9/contracts/interfaces/IEntryPoint.sol/IEntryPoint.json +1 -0
- package/contracts/account-abstraction-v9/contracts/interfaces/INonceManager.sol/INonceManager.json +1 -0
- package/contracts/account-abstraction-v9/contracts/interfaces/IStakeManager.sol/IStakeManager.json +1 -0
- package/contracts/build-info/338795fc743ca612.json +1 -0
- package/contracts/build-info/44a9648cfe32a468.json +1 -0
- package/contracts/build-info/{880955d5786bfdae.json → 8dbf8a4ad39019b5.json} +1 -1
- package/contracts/contracts/interfaces/IAggregator.sol/IAggregator.json +1 -1
- package/contracts/contracts/interfaces/IEntryPoint.sol/IEntryPoint.json +1 -1
- package/contracts/contracts/interfaces/INonceManager.sol/INonceManager.json +1 -1
- package/contracts/contracts/interfaces/IStakeManager.sol/IStakeManager.json +1 -1
- package/contracts/core/Eip7702Support.sol/Eip7702Support.json +1 -0
- package/contracts/core/NonceManager.sol/NonceManager.json +1 -0
- package/contracts/core/SenderCreator.sol/SenderCreator.json +1 -0
- package/contracts/core/StakeManager.sol/StakeManager.json +1 -0
- package/contracts/core/UserOperationLib.sol/UserOperationLib.json +1 -0
- package/contracts/interfaces/IAccount.sol/IAccount.json +1 -0
- package/contracts/interfaces/IAccountExecute.sol/IAccountExecute.json +1 -0
- package/contracts/interfaces/IAggregator.sol/IAggregator.json +1 -1
- package/contracts/interfaces/IEntryPoint.sol/IEntryPoint.json +1 -1
- package/contracts/interfaces/INonceManager.sol/INonceManager.json +1 -1
- package/contracts/interfaces/IPaymaster.sol/IPaymaster.json +1 -0
- package/contracts/interfaces/ISenderCreator.sol/ISenderCreator.json +1 -0
- package/contracts/interfaces/IStakeManager.sol/IStakeManager.json +1 -1
- package/contracts/overrides/Eip7702Support.sol/Eip7702Support.json +1 -0
- package/contracts/overrides/NonceManager.sol/NonceManager.json +1 -0
- package/contracts/overrides/SenderCreator.sol/SenderCreator.json +1 -0
- package/contracts/overrides/StakeManager.sol/StakeManager.json +1 -0
- package/contracts/overrides/UserOperationLib.sol/UserOperationLib.json +1 -0
- package/contracts/utils/Exec.sol/Exec.json +1 -1
- package/contracts/utils/StorageSlot.sol/StorageSlot.json +1 -0
- package/contracts/v09/EntryPoint.sol/EntryPoint.json +1 -0
- package/esm/cli/alto.js +13 -6
- package/esm/cli/alto.js.map +1 -1
- package/esm/cli/config/bundler.d.ts +190 -148
- package/esm/cli/config/bundler.js +72 -83
- package/esm/cli/config/bundler.js.map +1 -1
- package/esm/cli/config/options.d.ts +2 -1
- package/esm/cli/config/options.js +105 -68
- package/esm/cli/config/options.js.map +1 -1
- package/esm/cli/customTransport.d.ts +3 -3
- package/esm/cli/deploySimulationsContract.d.ts +1 -0
- package/esm/cli/deploySimulationsContract.js +41 -5
- package/esm/cli/deploySimulationsContract.js.map +1 -1
- package/esm/cli/handler.js +48 -52
- package/esm/cli/handler.js.map +1 -1
- package/esm/cli/setupServer.js +46 -47
- package/esm/cli/setupServer.js.map +1 -1
- package/esm/cli/shutDown.d.ts +20 -0
- package/esm/cli/shutDown.js +260 -0
- package/esm/cli/shutDown.js.map +1 -0
- package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride06.json +1 -1
- package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride07.json +1 -1
- package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride08.json +1 -1
- package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride09.json +1 -0
- package/esm/contracts/EntryPointGasEstimationOverride.sol/EntryPointGasEstimationOverride06.json +1 -1
- package/esm/contracts/EntryPointSimulations.sol/EntryPointSimulations07.json +1 -1
- package/esm/contracts/EntryPointSimulations.sol/EntryPointSimulations08.json +1 -1
- package/esm/contracts/EntryPointSimulations.sol/EntryPointSimulations09.json +1 -0
- package/esm/contracts/PimlicoSimulations.sol/PimlicoSimulations.json +1 -1
- package/esm/createConfig.d.ts +9 -2
- package/esm/createConfig.js.map +1 -1
- package/esm/executor/{userOpMonitor.d.ts → bundleManager.d.ts} +38 -32
- package/esm/executor/{userOpMonitor.js → bundleManager.js} +127 -99
- package/esm/executor/bundleManager.js.map +1 -0
- package/esm/executor/executor.d.ts +4 -3
- package/esm/executor/executor.js +33 -20
- package/esm/executor/executor.js.map +1 -1
- package/esm/executor/executorManager.d.ts +17 -15
- package/esm/executor/executorManager.js +130 -55
- package/esm/executor/executorManager.js.map +1 -1
- package/esm/executor/filterOpsAndEstimateGas.d.ts +17 -2
- package/esm/executor/filterOpsAndEstimateGas.js +100 -77
- package/esm/executor/filterOpsAndEstimateGas.js.map +1 -1
- package/esm/executor/index.d.ts +1 -0
- package/esm/executor/index.js +1 -0
- package/esm/executor/index.js.map +1 -1
- package/esm/executor/senderManager/createMemorySenderManager.js +13 -0
- package/esm/executor/senderManager/createMemorySenderManager.js.map +1 -1
- package/esm/executor/senderManager/createRedisSenderManager.d.ts +2 -1
- package/esm/executor/senderManager/createRedisSenderManager.js +3 -6
- package/esm/executor/senderManager/createRedisSenderManager.js.map +1 -1
- package/esm/executor/senderManager/flushOnStartUp.js +4 -4
- package/esm/executor/senderManager/flushOnStartUp.js.map +1 -1
- package/esm/executor/senderManager/index.d.ts +1 -0
- package/esm/executor/senderManager/index.js +6 -2
- package/esm/executor/senderManager/index.js.map +1 -1
- package/esm/executor/senderManager/validateAndRefill.js +2 -2
- package/esm/executor/senderManager/validateAndRefill.js.map +1 -1
- package/esm/executor/utilityWalletMonitor.d.ts +4 -4
- package/esm/executor/utilityWalletMonitor.js +1 -1
- package/esm/executor/utilityWalletMonitor.js.map +1 -1
- package/esm/executor/utils.d.ts +7 -2
- package/esm/executor/utils.js +57 -26
- package/esm/executor/utils.js.map +1 -1
- package/esm/handlers/arbitrumGasPriceManager.d.ts +3 -2
- package/esm/handlers/arbitrumGasPriceManager.js +6 -2
- package/esm/handlers/arbitrumGasPriceManager.js.map +1 -1
- package/esm/handlers/eventManager.d.ts +9 -9
- package/esm/handlers/eventManager.js +59 -60
- package/esm/handlers/eventManager.js.map +1 -1
- package/esm/handlers/gasPriceManager.d.ts +8 -9
- package/esm/handlers/gasPriceManager.js +68 -80
- package/esm/handlers/gasPriceManager.js.map +1 -1
- package/esm/handlers/mantleGasPriceManager.d.ts +4 -4
- package/esm/handlers/mantleGasPriceManager.js +4 -4
- package/esm/handlers/mantleGasPriceManager.js.map +1 -1
- package/esm/handlers/optimismManager.d.ts +1 -1
- package/esm/handlers/optimismManager.js +1 -1
- package/esm/handlers/optimismManager.js.map +1 -1
- package/esm/mempool/index.d.ts +1 -1
- package/esm/mempool/index.js +1 -1
- package/esm/mempool/index.js.map +1 -1
- package/esm/mempool/mempool.d.ts +57 -22
- package/esm/mempool/mempool.js +180 -134
- package/esm/mempool/mempool.js.map +1 -1
- package/esm/mempool/reputationManager.d.ts +14 -14
- package/esm/mempool/reputationManager.js +36 -39
- package/esm/mempool/reputationManager.js.map +1 -1
- package/esm/mempool/statusManager.d.ts +20 -0
- package/esm/mempool/statusManager.js +143 -0
- package/esm/mempool/statusManager.js.map +1 -0
- package/esm/receiptCache/createMemoryReceiptCache.d.ts +3 -0
- package/esm/receiptCache/createMemoryReceiptCache.js +30 -0
- package/esm/receiptCache/createMemoryReceiptCache.js.map +1 -0
- package/esm/receiptCache/createRedisReceiptCache.d.ts +10 -0
- package/esm/receiptCache/createRedisReceiptCache.js +56 -0
- package/esm/receiptCache/createRedisReceiptCache.js.map +1 -0
- package/esm/receiptCache/index.d.ts +11 -0
- package/esm/receiptCache/index.js +21 -0
- package/esm/receiptCache/index.js.map +1 -0
- package/esm/rpc/createMethodHandler.js.map +1 -1
- package/esm/rpc/estimation/gasEstimationHandler.d.ts +2 -4
- package/esm/rpc/estimation/gasEstimationHandler.js.map +1 -1
- package/esm/rpc/estimation/gasEstimations06.d.ts +6 -7
- package/esm/rpc/estimation/gasEstimations06.js +1 -5
- package/esm/rpc/estimation/gasEstimations06.js.map +1 -1
- package/esm/rpc/estimation/gasEstimations07.d.ts +13 -41
- package/esm/rpc/estimation/gasEstimations07.js +27 -34
- package/esm/rpc/estimation/gasEstimations07.js.map +1 -1
- package/esm/{utils/preVerificationGasCalulator.d.ts → rpc/estimation/preVerificationGasCalculator.d.ts} +20 -6
- package/esm/{utils/preVerificationGasCalulator.js → rpc/estimation/preVerificationGasCalculator.js} +95 -47
- package/esm/rpc/estimation/preVerificationGasCalculator.js.map +1 -0
- package/esm/rpc/estimation/types.d.ts +4 -2
- package/esm/rpc/estimation/utils.d.ts +10 -8
- package/esm/rpc/estimation/utils.js +54 -48
- package/esm/rpc/estimation/utils.js.map +1 -1
- package/esm/rpc/methods/boost_sendUserOperation.d.ts +304 -0
- package/esm/rpc/methods/debug_bundler_clearReputation.js +1 -1
- package/esm/rpc/methods/debug_bundler_clearReputation.js.map +1 -1
- package/esm/rpc/methods/debug_bundler_clearState.js +1 -1
- package/esm/rpc/methods/debug_bundler_clearState.js.map +1 -1
- package/esm/rpc/methods/debug_bundler_dumpMempool.d.ts +338 -0
- package/esm/rpc/methods/debug_bundler_dumpReputation.js +1 -1
- package/esm/rpc/methods/debug_bundler_dumpReputation.js.map +1 -1
- package/esm/rpc/methods/eth_estimateUserOperationGas.d.ts +622 -14
- package/esm/rpc/methods/eth_estimateUserOperationGas.js +50 -29
- package/esm/rpc/methods/eth_estimateUserOperationGas.js.map +1 -1
- package/esm/rpc/methods/eth_getUserOperationByHash.d.ts +621 -11
- package/esm/rpc/methods/eth_getUserOperationByHash.js.map +1 -1
- package/esm/rpc/methods/eth_getUserOperationReceipt.d.ts +26 -26
- package/esm/rpc/methods/eth_getUserOperationReceipt.js +1 -1
- package/esm/rpc/methods/eth_sendUserOperation.d.ts +305 -1
- package/esm/rpc/methods/eth_sendUserOperation.js +132 -36
- package/esm/rpc/methods/eth_sendUserOperation.js.map +1 -1
- package/esm/rpc/methods/pimlico_getUserOperationStatus.js +1 -1
- package/esm/rpc/methods/pimlico_getUserOperationStatus.js.map +1 -1
- package/esm/rpc/methods/pimlico_sendUserOperationNow.d.ts +330 -26
- package/esm/rpc/methods/pimlico_sendUserOperationNow.js +15 -27
- package/esm/rpc/methods/pimlico_sendUserOperationNow.js.map +1 -1
- package/esm/rpc/methods/pimlico_simulateAssetChange.d.ts +620 -12
- package/esm/rpc/methods/pimlico_simulateAssetChange.js +14 -19
- package/esm/rpc/methods/pimlico_simulateAssetChange.js.map +1 -1
- package/esm/rpc/rpcHandler.d.ts +21 -22
- package/esm/rpc/rpcHandler.js +15 -17
- package/esm/rpc/rpcHandler.js.map +1 -1
- package/esm/rpc/server.d.ts +5 -5
- package/esm/rpc/server.js +15 -11
- package/esm/rpc/server.js.map +1 -1
- package/esm/rpc/validation/BundlerCollectorTracerV06.js +1 -1
- package/esm/rpc/validation/BundlerCollectorTracerV06.js.map +1 -1
- package/esm/rpc/validation/BundlerCollectorTracerV07.js +1 -1
- package/esm/rpc/validation/BundlerCollectorTracerV07.js.map +1 -1
- package/esm/rpc/validation/SafeValidator.d.ts +13 -14
- package/esm/rpc/validation/SafeValidator.js +24 -24
- package/esm/rpc/validation/SafeValidator.js.map +1 -1
- package/esm/rpc/validation/TracerResultParserV06.d.ts +2 -2
- package/esm/rpc/validation/TracerResultParserV06.js +11 -11
- package/esm/rpc/validation/TracerResultParserV06.js.map +1 -1
- package/esm/rpc/validation/TracerResultParserV07.d.ts +2 -2
- package/esm/rpc/validation/TracerResultParserV07.js +13 -13
- package/esm/rpc/validation/TracerResultParserV07.js.map +1 -1
- package/esm/rpc/validation/UnsafeValidator.d.ts +18 -14
- package/esm/rpc/validation/UnsafeValidator.js +71 -40
- package/esm/rpc/validation/UnsafeValidator.js.map +1 -1
- package/esm/store/createMempoolStore.d.ts +1 -1
- package/esm/store/createMempoolStore.js +63 -139
- package/esm/store/createMempoolStore.js.map +1 -1
- package/esm/store/index.d.ts +4 -75
- package/esm/store/index.js +4 -1
- package/esm/store/index.js.map +1 -1
- package/esm/store/outstanding/index.d.ts +13 -0
- package/esm/store/outstanding/index.js +16 -0
- package/esm/store/outstanding/index.js.map +1 -0
- package/esm/store/{createMemoryOutstandingStore.d.ts → outstanding/memory.d.ts} +14 -13
- package/esm/store/outstanding/memory.js +263 -0
- package/esm/store/outstanding/memory.js.map +1 -0
- package/esm/store/outstanding/redis.d.ts +11 -0
- package/esm/store/outstanding/redis.js +229 -0
- package/esm/store/outstanding/redis.js.map +1 -0
- package/esm/store/outstanding/types.d.ts +19 -0
- package/esm/store/outstanding/types.js +2 -0
- package/esm/store/outstanding/types.js.map +1 -0
- package/esm/store/processing/index.d.ts +11 -0
- package/esm/store/processing/index.js +17 -0
- package/esm/store/processing/index.js.map +1 -0
- package/esm/store/processing/memory.d.ts +16 -0
- package/esm/store/processing/memory.js +58 -0
- package/esm/store/processing/memory.js.map +1 -0
- package/esm/store/processing/redis.d.ts +23 -0
- package/esm/store/processing/redis.js +85 -0
- package/esm/store/processing/redis.js.map +1 -0
- package/esm/store/processing/types.d.ts +10 -0
- package/esm/store/processing/types.js +2 -0
- package/esm/store/processing/types.js.map +1 -0
- package/esm/store/types.d.ts +50 -0
- package/esm/store/types.js +2 -0
- package/esm/store/types.js.map +1 -0
- package/esm/types/contracts/PimlicoSimulations.d.ts +81 -0
- package/esm/types/contracts/PimlicoSimulations.js +105 -0
- package/esm/types/contracts/PimlicoSimulations.js.map +1 -1
- package/esm/types/gasPrice.js +0 -18
- package/esm/types/gasPrice.js.map +1 -1
- package/esm/types/interfaces.d.ts +15 -10
- package/esm/types/mempool.d.ts +3 -0
- package/esm/types/schemas.d.ts +13174 -4732
- package/esm/types/schemas.js +113 -25
- package/esm/types/schemas.js.map +1 -1
- package/esm/types/utils.d.ts +2 -5
- package/esm/types/utils.js +16 -18
- package/esm/types/utils.js.map +1 -1
- package/esm/types/validation.d.ts +7646 -6912
- package/esm/types/validation.js +122 -152
- package/esm/types/validation.js.map +1 -1
- package/esm/utils/eip7702.d.ts +2 -1
- package/esm/utils/eip7702.js +14 -8
- package/esm/utils/eip7702.js.map +1 -1
- package/esm/utils/entryPointOverrides.js +18 -4
- package/esm/utils/entryPointOverrides.js.map +1 -1
- package/esm/utils/helpers.d.ts +2 -1
- package/esm/utils/helpers.js +30 -11
- package/esm/utils/helpers.js.map +1 -1
- package/esm/utils/index.d.ts +0 -1
- package/esm/utils/index.js +0 -1
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/metrics.d.ts +2 -1
- package/esm/utils/metrics.js +15 -8
- package/esm/utils/metrics.js.map +1 -1
- package/esm/utils/minMaxQueue/createMemoryMinMaxQueue.js +8 -9
- package/esm/utils/minMaxQueue/createMemoryMinMaxQueue.js.map +1 -1
- package/esm/utils/minMaxQueue/createRedisMinMaxQueue.d.ts +24 -2
- package/esm/utils/minMaxQueue/createRedisMinMaxQueue.js +85 -64
- package/esm/utils/minMaxQueue/createRedisMinMaxQueue.js.map +1 -1
- package/esm/utils/minMaxQueue/index.d.ts +2 -2
- package/esm/utils/minMaxQueue/index.js +4 -3
- package/esm/utils/minMaxQueue/index.js.map +1 -1
- package/esm/utils/rpc-reply.d.ts +3 -3
- package/esm/utils/rpc-reply.js.map +1 -1
- package/esm/utils/toViemStateOverrides.js +7 -7
- package/esm/utils/toViemStateOverrides.js.map +1 -1
- package/esm/utils/userop.d.ts +87 -55
- package/esm/utils/userop.js +138 -248
- package/esm/utils/userop.js.map +1 -1
- package/package.json +4 -2
- package/contracts/build-info/7710b5a048396e70.json +0 -1
- package/esm/executor/userOpMonitor.js.map +0 -1
- package/esm/mempool/monitoring.d.ts +0 -15
- package/esm/mempool/monitoring.js +0 -118
- package/esm/mempool/monitoring.js.map +0 -1
- package/esm/store/createMemoryOutstandingStore.js +0 -240
- package/esm/store/createMemoryOutstandingStore.js.map +0 -1
- package/esm/store/createRedisOutstandingStore.d.ts +0 -27
- package/esm/store/createRedisOutstandingStore.js +0 -344
- package/esm/store/createRedisOutstandingStore.js.map +0 -1
- package/esm/store/createRedisStore.d.ts +0 -9
- package/esm/store/createRedisStore.js +0 -131
- package/esm/store/createRedisStore.js.map +0 -1
- package/esm/store/createStore.d.ts +0 -6
- package/esm/store/createStore.js +0 -66
- package/esm/store/createStore.js.map +0 -1
- package/esm/utils/preVerificationGasCalulator.js.map +0 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { userOpInfoSchema } from "../../types/index.js";
|
|
2
|
+
import { getNonceKeyAndSequence, isDeployment } from "../../utils/index.js";
|
|
3
|
+
import { Redis } from "ioredis";
|
|
4
|
+
import { toHex } from "viem/utils";
|
|
5
|
+
const serialize = (userOpInfo) => {
|
|
6
|
+
return JSON.stringify(userOpInfo, (_, value) => typeof value === "bigint" ? toHex(value) : value);
|
|
7
|
+
};
|
|
8
|
+
const deserialize = (data) => {
|
|
9
|
+
const parsed = JSON.parse(data);
|
|
10
|
+
return userOpInfoSchema.parse(parsed);
|
|
11
|
+
};
|
|
12
|
+
class RedisOutstandingQueue {
|
|
13
|
+
redis;
|
|
14
|
+
senderNonceKeyPrefix; // sender + nonceKey -> userOpHash
|
|
15
|
+
readyQueue; // Queue of userOpHashes (sorted by composite of userOp.nonceSeq + userOp.maxFeePerGas)
|
|
16
|
+
userOpHashMap; // userOpHash -> boolean
|
|
17
|
+
deploymentHashMap; // sender -> deployment userOpHash
|
|
18
|
+
eip7702AuthHashMap; // sender -> eip7702Auth userOpHash
|
|
19
|
+
senderNonceQueueTtl; // TTL for sender nonce queues in seconds
|
|
20
|
+
constructor({ config, entryPoint, redisEndpoint, logger }) {
|
|
21
|
+
this.redis = new Redis(redisEndpoint, {});
|
|
22
|
+
// Initialize Redis key names
|
|
23
|
+
const redisPrefix = `${config.redisKeyPrefix}:${config.chainId}:${entryPoint}:outstanding`;
|
|
24
|
+
this.readyQueue = `${redisPrefix}:ready-queue`;
|
|
25
|
+
this.senderNonceKeyPrefix = `${redisPrefix}:sender`;
|
|
26
|
+
this.userOpHashMap = `${redisPrefix}:userop-hash`;
|
|
27
|
+
this.deploymentHashMap = `${redisPrefix}:deployment-senders`;
|
|
28
|
+
this.eip7702AuthHashMap = `${redisPrefix}:eip7702-auth-senders`;
|
|
29
|
+
// Calculate TTL for sender nonce queues (10 blocks worth of time)
|
|
30
|
+
this.senderNonceQueueTtl = config.blockTime * 10;
|
|
31
|
+
logger.info({
|
|
32
|
+
readyQueueKey: this.readyQueue
|
|
33
|
+
}, "Using redis for outstanding mempool.");
|
|
34
|
+
}
|
|
35
|
+
// Returns queue index for this sender + nonceKey.
|
|
36
|
+
getSenderNonceQueue(userOp) {
|
|
37
|
+
const [nonceKey] = getNonceKeyAndSequence(userOp.nonce);
|
|
38
|
+
return `${this.senderNonceKeyPrefix}:${userOp.sender}:${nonceKey}`;
|
|
39
|
+
}
|
|
40
|
+
// OutstandingStore methods
|
|
41
|
+
async contains(userOpHash) {
|
|
42
|
+
const exists = await this.redis.hexists(this.userOpHashMap, userOpHash);
|
|
43
|
+
return exists === 1;
|
|
44
|
+
}
|
|
45
|
+
async popConflicting(userOp) {
|
|
46
|
+
const { sender, nonce } = userOp;
|
|
47
|
+
const [nonceSeq] = getNonceKeyAndSequence(nonce);
|
|
48
|
+
const senderNonceQueue = this.getSenderNonceQueue(userOp);
|
|
49
|
+
const isDeploymentOp = isDeployment(userOp);
|
|
50
|
+
const hasEip7702Auth = !!userOp.eip7702Auth;
|
|
51
|
+
// Check all conflicts in a single round trip
|
|
52
|
+
const pipeline = this.redis.pipeline();
|
|
53
|
+
pipeline.zrangebyscore(senderNonceQueue, Number(nonceSeq), Number(nonceSeq));
|
|
54
|
+
pipeline.hget(this.deploymentHashMap, sender);
|
|
55
|
+
pipeline.hget(this.eip7702AuthHashMap, sender);
|
|
56
|
+
const results = await pipeline.exec();
|
|
57
|
+
if (!results)
|
|
58
|
+
return undefined;
|
|
59
|
+
const [nonceResult, deploymentResult, eip7702AuthResult] = results;
|
|
60
|
+
const conflictingNonceHashes = nonceResult?.[1] || [];
|
|
61
|
+
const existingDeploymentHash = deploymentResult?.[1];
|
|
62
|
+
const existingEip7702AuthHash = eip7702AuthResult?.[1];
|
|
63
|
+
// Check for conflicting nonce
|
|
64
|
+
if (conflictingNonceHashes.length > 0) {
|
|
65
|
+
const conflictingHash = conflictingNonceHashes[0];
|
|
66
|
+
const removedUserOps = await this.remove([conflictingHash]);
|
|
67
|
+
if (removedUserOps.length > 0) {
|
|
68
|
+
return {
|
|
69
|
+
conflictReason: "conflicting_nonce",
|
|
70
|
+
userOpInfo: removedUserOps[0]
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Check for conflicting deployment
|
|
75
|
+
if (isDeploymentOp && existingDeploymentHash) {
|
|
76
|
+
const removedUserOps = await this.remove([existingDeploymentHash]);
|
|
77
|
+
if (removedUserOps.length > 0) {
|
|
78
|
+
return {
|
|
79
|
+
conflictReason: "conflicting_deployment",
|
|
80
|
+
userOpInfo: removedUserOps[0]
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Check for conflicting EIP-7702 auth
|
|
85
|
+
if (hasEip7702Auth && existingEip7702AuthHash) {
|
|
86
|
+
const removedUserOps = await this.remove([existingEip7702AuthHash]);
|
|
87
|
+
if (removedUserOps.length > 0) {
|
|
88
|
+
return {
|
|
89
|
+
conflictReason: "conflicting_7702_auth",
|
|
90
|
+
userOpInfo: removedUserOps[0]
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
async add(userOpInfos) {
|
|
97
|
+
if (userOpInfos.length === 0)
|
|
98
|
+
return;
|
|
99
|
+
// Use pipeline for atomic operations
|
|
100
|
+
const pipeline = this.redis.pipeline();
|
|
101
|
+
for (const userOpInfo of userOpInfos) {
|
|
102
|
+
const { userOp } = userOpInfo;
|
|
103
|
+
const [, nonceSequence] = getNonceKeyAndSequence(userOp.nonce);
|
|
104
|
+
const userOpHash = userOpInfo.userOpHash;
|
|
105
|
+
// Create composite score: nonceSequence in upper 32 bits, maxFeePerGas in lower 32 bits.
|
|
106
|
+
const score = (nonceSequence << 32n) | (userOp.maxFeePerGas & 0xffffffffn);
|
|
107
|
+
// Serialize userOpInfo for storage.
|
|
108
|
+
const serializedUserOp = serialize(userOpInfo);
|
|
109
|
+
// Add to main ready queue.
|
|
110
|
+
pipeline.zadd(this.readyQueue, Number(score), userOpHash);
|
|
111
|
+
// Add to sender+nonceKey index for fast lookup.
|
|
112
|
+
const senderNonceQueue = this.getSenderNonceQueue(userOp);
|
|
113
|
+
pipeline.zadd(senderNonceQueue, Number(nonceSequence), userOpHash);
|
|
114
|
+
pipeline.expire(senderNonceQueue, this.senderNonceQueueTtl);
|
|
115
|
+
// Add to userOpHash map.
|
|
116
|
+
pipeline.hset(this.userOpHashMap, userOpHash, serializedUserOp);
|
|
117
|
+
// Add sender to deployment hash if this is a deployment.
|
|
118
|
+
if (isDeployment(userOp)) {
|
|
119
|
+
pipeline.hset(this.deploymentHashMap, userOp.sender, userOpHash);
|
|
120
|
+
}
|
|
121
|
+
// Add sender to eip7702Auth hash if this has eip7702Auth.
|
|
122
|
+
if (userOp.eip7702Auth) {
|
|
123
|
+
pipeline.hset(this.eip7702AuthHashMap, userOp.sender, userOpHash);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
await pipeline.exec();
|
|
127
|
+
}
|
|
128
|
+
// Removes userOps given their hashes and returns the userOpInfo objects.
|
|
129
|
+
async remove(userOpHashes) {
|
|
130
|
+
if (userOpHashes.length === 0)
|
|
131
|
+
return [];
|
|
132
|
+
// Get all serialized data in parallel.
|
|
133
|
+
const pipeline = this.redis.pipeline();
|
|
134
|
+
for (const hash of userOpHashes) {
|
|
135
|
+
pipeline.hget(this.userOpHashMap, hash);
|
|
136
|
+
}
|
|
137
|
+
const serializedResults = await pipeline.exec();
|
|
138
|
+
const removedUserOps = [];
|
|
139
|
+
const removalPipeline = this.redis.pipeline();
|
|
140
|
+
// Process each userOp that exists.
|
|
141
|
+
for (let i = 0; i < userOpHashes.length; i++) {
|
|
142
|
+
const serialized = serializedResults?.[i]?.[1];
|
|
143
|
+
if (!serialized)
|
|
144
|
+
continue;
|
|
145
|
+
const userOpHash = userOpHashes[i];
|
|
146
|
+
const userOpInfo = deserialize(serialized);
|
|
147
|
+
const { userOp } = userOpInfo;
|
|
148
|
+
const [, nonceSequence] = getNonceKeyAndSequence(userOp.nonce);
|
|
149
|
+
const senderNonceQueue = this.getSenderNonceQueue(userOp);
|
|
150
|
+
const isDeploymentOp = isDeployment(userOp);
|
|
151
|
+
// Remove from ready queue.
|
|
152
|
+
removalPipeline.zrem(this.readyQueue, userOpHash);
|
|
153
|
+
// Remove from sender nonceKey queue.
|
|
154
|
+
removalPipeline.zremrangebyscore(senderNonceQueue, Number(nonceSequence), Number(nonceSequence));
|
|
155
|
+
// Remove from hash lookup.
|
|
156
|
+
removalPipeline.hdel(this.userOpHashMap, userOpHash);
|
|
157
|
+
// Remove sender from deployment hash if this was a deployment.
|
|
158
|
+
if (isDeploymentOp) {
|
|
159
|
+
removalPipeline.hdel(this.deploymentHashMap, userOp.sender);
|
|
160
|
+
}
|
|
161
|
+
// Remove sender from eip7702Auth hash if this had eip7702Auth.
|
|
162
|
+
if (userOp.eip7702Auth) {
|
|
163
|
+
removalPipeline.hdel(this.eip7702AuthHashMap, userOp.sender);
|
|
164
|
+
}
|
|
165
|
+
removedUserOps.push(userOpInfo);
|
|
166
|
+
}
|
|
167
|
+
// Execute all removals.
|
|
168
|
+
await removalPipeline.exec();
|
|
169
|
+
return removedUserOps;
|
|
170
|
+
}
|
|
171
|
+
async pop(count) {
|
|
172
|
+
// Pop from ready queue
|
|
173
|
+
const results = await this.redis.zpopmax(this.readyQueue, count);
|
|
174
|
+
if (!results || results.length === 0) {
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
// Extract hashes from results (zpopmax returns [member, score, member, score, ...])
|
|
178
|
+
const userOpHashes = [];
|
|
179
|
+
for (let i = 0; i < results.length; i += 2) {
|
|
180
|
+
userOpHashes.push(results[i]);
|
|
181
|
+
}
|
|
182
|
+
// Remove all userOps in batch
|
|
183
|
+
return await this.remove(userOpHashes);
|
|
184
|
+
}
|
|
185
|
+
async getQueuedUserOps(userOp) {
|
|
186
|
+
const [, nonceSequence] = getNonceKeyAndSequence(userOp.nonce);
|
|
187
|
+
const senderNonceQueue = this.getSenderNonceQueue(userOp);
|
|
188
|
+
// Get all userOpHashes with nonce sequence lower than the input
|
|
189
|
+
// ZRANGEBYSCORE returns elements with scores between min and max
|
|
190
|
+
// We want scores from 0 to (nonceSequence - 1)
|
|
191
|
+
const userOpHashes = await this.redis.zrangebyscore(senderNonceQueue, 0, Number(nonceSequence) - 1);
|
|
192
|
+
if (userOpHashes.length === 0)
|
|
193
|
+
return [];
|
|
194
|
+
// Fetch serialized data for each hash
|
|
195
|
+
const pipeline = this.redis.pipeline();
|
|
196
|
+
for (const hash of userOpHashes) {
|
|
197
|
+
pipeline.hget(this.userOpHashMap, hash);
|
|
198
|
+
}
|
|
199
|
+
const results = await pipeline.exec();
|
|
200
|
+
// Deserialize and extract userOps
|
|
201
|
+
return (results || [])
|
|
202
|
+
.map((result) => result?.[1])
|
|
203
|
+
.filter((serialized) => serialized !== null)
|
|
204
|
+
.map((serialized) => deserialize(serialized).userOp);
|
|
205
|
+
}
|
|
206
|
+
// These methods aren't implemented
|
|
207
|
+
async dumpLocal() {
|
|
208
|
+
return []; // We can't dump from redis as the latency is too high
|
|
209
|
+
}
|
|
210
|
+
clear() {
|
|
211
|
+
throw new Error("Not implemented: clear");
|
|
212
|
+
}
|
|
213
|
+
// Skip limit checks when using Redis
|
|
214
|
+
validateQueuedLimit() {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
validateParallelLimit() {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
export const createRedisOutstandingQueue = ({ config, entryPoint, redisEndpoint, logger }) => {
|
|
222
|
+
return new RedisOutstandingQueue({
|
|
223
|
+
config,
|
|
224
|
+
entryPoint,
|
|
225
|
+
redisEndpoint,
|
|
226
|
+
logger
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=redis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../../store/outstanding/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,gBAAgB,EACnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAIlC,MAAM,SAAS,GAAG,CAAC,UAAsB,EAAU,E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C;QACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAErC,kCAAkC;QAClC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;aACjB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAkB,CAAC;aAC7C,MAAM,CAAC,CAAC,UAAU,EAAwB,EAAE,CAAC,UAAU,KAAK,IAAI,CAAC;aACjE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;IAC5D,CAAC;IAED,mCAAmC;IACnC,KAAK,CAAC,SAAS;QACX,OAAO,EAAE,CAAA,CAAC,sDAAsD;IACpE,CAAC;IAED,KAAK;QACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAC7C,CAAC;IAED,qCAAqC;IACrC,mBAAmB;QACf,OAAO,IAAI,CAAA;IACf,CAAC;IAED,qBAAqB;QACjB,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,EACxC,MAAM,EACN,UAAU,EACV,aAAa,EACb,MAAM,EAMT,EAAoB,EAAE;IACnB,OAAO,IAAI,qBAAqB,CAAC;QAC7B,MAAM;QACN,UAAU;QACV,aAAa;QACb,MAAM;KACT,CAAC,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HexData32, UserOpInfo, UserOperation } from "../../types/index.js";
|
|
2
|
+
import type { ConflictType } from "../types.js";
|
|
3
|
+
export type ConflictingOutstandingType = {
|
|
4
|
+
conflictReason: ConflictType;
|
|
5
|
+
userOpInfo: UserOpInfo;
|
|
6
|
+
} | undefined;
|
|
7
|
+
export interface OutstandingStore {
|
|
8
|
+
contains(userOpHash: HexData32): Promise<boolean>;
|
|
9
|
+
pop(count: number): Promise<UserOpInfo[]>;
|
|
10
|
+
popConflicting(userOp: UserOperation): Promise<ConflictingOutstandingType>;
|
|
11
|
+
add(userOpInfos: UserOpInfo[]): Promise<void>;
|
|
12
|
+
remove(userOpHash: HexData32[]): Promise<UserOpInfo[]>;
|
|
13
|
+
getQueuedUserOps(userOp: UserOperation): Promise<UserOperation[]>;
|
|
14
|
+
dumpLocal(): Promise<UserOpInfo[]>;
|
|
15
|
+
clear(): Promise<void>;
|
|
16
|
+
validateQueuedLimit(userOp: UserOperation): boolean;
|
|
17
|
+
validateParallelLimit(userOp: UserOperation): boolean;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../store/outstanding/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { AltoConfig } from "../../createConfig.js";
|
|
3
|
+
import { type ProcessingStore } from "../index.js";
|
|
4
|
+
export declare function createProcessingStore({ config, entryPoint }: {
|
|
5
|
+
config: AltoConfig;
|
|
6
|
+
entryPoint: Address;
|
|
7
|
+
}): ProcessingStore;
|
|
8
|
+
export * from "./types.js";
|
|
9
|
+
export * from "./memory.js";
|
|
10
|
+
export * from "./redis.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InMemoryProcessingStore, RedisProcessingStore } from "../index.js";
|
|
2
|
+
// Holds all userOps that have been removed from outstanding pool and are being processed.
|
|
3
|
+
// UserOps are are removed from this store when they have successfully landed onchain or when they are cancelled.
|
|
4
|
+
export function createProcessingStore({ config, entryPoint }) {
|
|
5
|
+
if (config.enableHorizontalScaling && config.redisEndpoint) {
|
|
6
|
+
return new RedisProcessingStore({
|
|
7
|
+
config,
|
|
8
|
+
entryPoint,
|
|
9
|
+
redisEndpoint: config.redisEndpoint
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return new InMemoryProcessingStore();
|
|
13
|
+
}
|
|
14
|
+
export * from "./types.js";
|
|
15
|
+
export * from "./memory.js";
|
|
16
|
+
export * from "./redis.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../store/processing/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,uBAAuB,EAEvB,oBAAoB,EACvB,MAAM,aAAa,CAAA;AAEpB,0FAA0F;AAC1F,iHAAiH;AACjH,MAAM,UAAU,qBAAqB,CAAC,EAClC,MAAM,EACN,UAAU,EAIb;IACG,IAAI,MAAM,CAAC,uBAAuB,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;QACzD,OAAO,IAAI,oBAAoB,CAAC;YAC5B,MAAM;YACN,UAAU;YACV,aAAa,EAAE,MAAM,CAAC,aAAa;SACtC,CAAC,CAAA;IACN,CAAC;IACD,OAAO,IAAI,uBAAuB,EAAE,CAAA;AACxC,CAAC;AAED,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { UserOpInfo, UserOperation } from "../../types/index.js";
|
|
2
|
+
import type { Hex } from "viem";
|
|
3
|
+
import type { ConflictType } from "../types.js";
|
|
4
|
+
import type { ProcessingStore } from "./types.js";
|
|
5
|
+
export declare class InMemoryProcessingStore implements ProcessingStore {
|
|
6
|
+
private readonly processingUserOpsSet;
|
|
7
|
+
private readonly processingSenderNonceSet;
|
|
8
|
+
private readonly processingDeploymentSet;
|
|
9
|
+
private readonly processingEip7702AuthSet;
|
|
10
|
+
private encodeSenderNonceId;
|
|
11
|
+
addProcessing(userOpInfo: UserOpInfo): Promise<void>;
|
|
12
|
+
removeProcessing(userOpInfo: UserOpInfo): Promise<void>;
|
|
13
|
+
isProcessing(userOpHash: Hex): Promise<boolean>;
|
|
14
|
+
wouldConflict(userOp: UserOperation): Promise<ConflictType | undefined>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isDeployment } from "../../utils/index.js";
|
|
2
|
+
export class InMemoryProcessingStore {
|
|
3
|
+
// Use Sets for boolean membership tracking (matching Redis store)
|
|
4
|
+
processingUserOpsSet = new Set();
|
|
5
|
+
processingSenderNonceSet = new Set();
|
|
6
|
+
processingDeploymentSet = new Set();
|
|
7
|
+
processingEip7702AuthSet = new Set();
|
|
8
|
+
encodeSenderNonceId(sender, nonce) {
|
|
9
|
+
return `${sender}:${nonce}`;
|
|
10
|
+
}
|
|
11
|
+
async addProcessing(userOpInfo) {
|
|
12
|
+
const { userOpHash, userOp } = userOpInfo;
|
|
13
|
+
const isDeploymentOp = isDeployment(userOp);
|
|
14
|
+
const senderNonceId = this.encodeSenderNonceId(userOp.sender, userOp.nonce);
|
|
15
|
+
// Add to processing sets
|
|
16
|
+
this.processingUserOpsSet.add(userOpHash);
|
|
17
|
+
this.processingSenderNonceSet.add(senderNonceId);
|
|
18
|
+
if (isDeploymentOp) {
|
|
19
|
+
this.processingDeploymentSet.add(userOp.sender);
|
|
20
|
+
}
|
|
21
|
+
if (userOp.eip7702Auth) {
|
|
22
|
+
this.processingEip7702AuthSet.add(userOp.sender);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async removeProcessing(userOpInfo) {
|
|
26
|
+
const { userOpHash, userOp } = userOpInfo;
|
|
27
|
+
const senderNonceId = this.encodeSenderNonceId(userOp.sender, userOp.nonce);
|
|
28
|
+
// Remove from all sets
|
|
29
|
+
this.processingUserOpsSet.delete(userOpHash);
|
|
30
|
+
this.processingSenderNonceSet.delete(senderNonceId);
|
|
31
|
+
this.processingDeploymentSet.delete(userOp.sender);
|
|
32
|
+
if (userOp.eip7702Auth) {
|
|
33
|
+
this.processingEip7702AuthSet.delete(userOp.sender);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async isProcessing(userOpHash) {
|
|
37
|
+
return this.processingUserOpsSet.has(userOpHash);
|
|
38
|
+
}
|
|
39
|
+
async wouldConflict(userOp) {
|
|
40
|
+
const isDeploymentOp = isDeployment(userOp);
|
|
41
|
+
const senderNonceId = this.encodeSenderNonceId(userOp.sender, userOp.nonce);
|
|
42
|
+
// Check deployment conflict first
|
|
43
|
+
if (isDeploymentOp && this.processingDeploymentSet.has(userOp.sender)) {
|
|
44
|
+
return "conflicting_deployment";
|
|
45
|
+
}
|
|
46
|
+
// Check EIP-7702 auth conflict
|
|
47
|
+
if (userOp.eip7702Auth &&
|
|
48
|
+
this.processingEip7702AuthSet.has(userOp.sender)) {
|
|
49
|
+
return "conflicting_7702_auth";
|
|
50
|
+
}
|
|
51
|
+
// Check nonce conflict
|
|
52
|
+
if (this.processingSenderNonceSet.has(senderNonceId)) {
|
|
53
|
+
return "conflicting_nonce";
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../store/processing/memory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK1C,MAAM,OAAO,uBAAuB;IAChC,kEAAkE;IACjD,oBAAoB,GAAG,IAAI,GAAG,EAAO,CAAA;IACrC,wBAAwB,GAAG,IAAI,GAAG,EAAU,CAAA;IAC5C,uBAAuB,GAAG,IAAI,GAAG,EAAW,CAAA;IAC5C,wBAAwB,GAAG,IAAI,GAAG,EAAW,CAAA;IAEtD,mBAAmB,CAAC,MAAe,EAAE,KAAa;QACtD,OAAO,GAAG,MAAM,IAAI,KAAK,EAAE,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,UAAsB;QACtC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,UAAU,CAA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,KAAK,CAAC,aAAa,CACf,MAAqB;QAErB,MAAM,cAAc,GAAG,YAAY,CAAC,MAAM,CAAC,CAAA;QAC3C,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAC1C,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,KAAK,CACf,CAAA;QAED,kCAAkC;QAClC,IAAI,cAAc,IAAI,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACpE,OAAO,wBAAwB,CAAA;QACnC,CAAC;QAED,+BAA+B;QAC/B,IACI,MAAM,CAAC,WAAW;YAClB,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAClD,CAAC;YACC,OAAO,uBAAuB,CAAA;QAClC,CAAC;QAED,uBAAuB;QACvB,IAAI,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YACnD,OAAO,mBAAmB,CAAA;QAC9B,CAAC;QAED,OAAO,SAAS,CAAA;IACpB,CAAC;CACJ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UserOpInfo, UserOperation } from "../../types/index.js";
|
|
2
|
+
import type { Address, Hex } from "viem";
|
|
3
|
+
import type { AltoConfig } from "../../createConfig.js";
|
|
4
|
+
import type { ConflictType } from "../types.js";
|
|
5
|
+
import type { ProcessingStore } from "./types.js";
|
|
6
|
+
export declare class RedisProcessingStore implements ProcessingStore {
|
|
7
|
+
private readonly redis;
|
|
8
|
+
private readonly processingUserOpsSet;
|
|
9
|
+
private readonly processingSenderNonceSet;
|
|
10
|
+
private readonly processingDeploymentSet;
|
|
11
|
+
private readonly processingEip7702AuthSet;
|
|
12
|
+
private encodeSenderNonceId;
|
|
13
|
+
constructor({ config, entryPoint, redisEndpoint }: {
|
|
14
|
+
config: AltoConfig;
|
|
15
|
+
entryPoint: Address;
|
|
16
|
+
redisEndpoint: string;
|
|
17
|
+
});
|
|
18
|
+
addProcessing(userOpInfo: UserOpInfo): Promise<void>;
|
|
19
|
+
removeProcessing(userOpInfo: UserOpInfo): Promise<void>;
|
|
20
|
+
isProcessing(userOpHash: Hex): Promise<boolean>;
|
|
21
|
+
wouldConflict(userOp: UserOperation): Promise<ConflictType | undefined>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=redis.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isDeployment } from "../../utils/index.js";
|
|
2
|
+
import { Redis } from "ioredis";
|
|
3
|
+
export class RedisProcessingStore {
|
|
4
|
+
redis;
|
|
5
|
+
processingUserOpsSet; // set of userOpHashes being processed
|
|
6
|
+
processingSenderNonceSet; // set of "sender:nonce" being processed
|
|
7
|
+
processingDeploymentSet; // set of senders with deployments being processed
|
|
8
|
+
processingEip7702AuthSet; // set of senders with eip7702Auth being processed
|
|
9
|
+
encodeSenderNonceId(sender, nonce) {
|
|
10
|
+
return `${sender}:${nonce}`;
|
|
11
|
+
}
|
|
12
|
+
constructor({ config, entryPoint, redisEndpoint }) {
|
|
13
|
+
this.redis = new Redis(redisEndpoint);
|
|
14
|
+
const redisPrefix = `${config.redisKeyPrefix}:${config.chainId}:${entryPoint}:processing`;
|
|
15
|
+
this.processingUserOpsSet = `${redisPrefix}:userOps`;
|
|
16
|
+
this.processingSenderNonceSet = `${redisPrefix}:senderNonce`;
|
|
17
|
+
this.processingDeploymentSet = `${redisPrefix}:deployment`;
|
|
18
|
+
this.processingEip7702AuthSet = `${redisPrefix}:eip7702Auth`;
|
|
19
|
+
}
|
|
20
|
+
async addProcessing(userOpInfo) {
|
|
21
|
+
const { userOpHash, userOp } = userOpInfo;
|
|
22
|
+
const isDeploymentOp = isDeployment(userOp);
|
|
23
|
+
const senderNonceId = this.encodeSenderNonceId(userOp.sender, userOp.nonce);
|
|
24
|
+
// Use MULTI for atomic operation in single round trip
|
|
25
|
+
const multi = this.redis.multi();
|
|
26
|
+
multi.sadd(this.processingUserOpsSet, userOpHash);
|
|
27
|
+
multi.sadd(this.processingSenderNonceSet, senderNonceId);
|
|
28
|
+
if (isDeploymentOp) {
|
|
29
|
+
multi.sadd(this.processingDeploymentSet, userOp.sender);
|
|
30
|
+
}
|
|
31
|
+
if (userOp.eip7702Auth) {
|
|
32
|
+
multi.sadd(this.processingEip7702AuthSet, userOp.sender);
|
|
33
|
+
}
|
|
34
|
+
await multi.exec();
|
|
35
|
+
}
|
|
36
|
+
async removeProcessing(userOpInfo) {
|
|
37
|
+
const { userOpHash, userOp } = userOpInfo;
|
|
38
|
+
const isDeploymentOp = isDeployment(userOp);
|
|
39
|
+
const senderNonceId = this.encodeSenderNonceId(userOp.sender, userOp.nonce);
|
|
40
|
+
// Use MULTI for atomic removal in single round trip
|
|
41
|
+
const multi = this.redis.multi();
|
|
42
|
+
multi.srem(this.processingUserOpsSet, userOpHash);
|
|
43
|
+
multi.srem(this.processingSenderNonceSet, senderNonceId);
|
|
44
|
+
if (isDeploymentOp) {
|
|
45
|
+
multi.srem(this.processingDeploymentSet, userOp.sender);
|
|
46
|
+
}
|
|
47
|
+
if (userOp.eip7702Auth) {
|
|
48
|
+
multi.srem(this.processingEip7702AuthSet, userOp.sender);
|
|
49
|
+
}
|
|
50
|
+
await multi.exec();
|
|
51
|
+
}
|
|
52
|
+
async isProcessing(userOpHash) {
|
|
53
|
+
const isMember = await this.redis.sismember(this.processingUserOpsSet, userOpHash);
|
|
54
|
+
return isMember === 1;
|
|
55
|
+
}
|
|
56
|
+
async wouldConflict(userOp) {
|
|
57
|
+
const senderNonceId = this.encodeSenderNonceId(userOp.sender, userOp.nonce);
|
|
58
|
+
// Use MULTI for atomic read in single round trip
|
|
59
|
+
const multi = this.redis.multi();
|
|
60
|
+
multi.sismember(this.processingDeploymentSet, userOp.sender);
|
|
61
|
+
multi.sismember(this.processingEip7702AuthSet, userOp.sender);
|
|
62
|
+
multi.sismember(this.processingSenderNonceSet, senderNonceId);
|
|
63
|
+
const results = await multi.exec();
|
|
64
|
+
if (!results)
|
|
65
|
+
return undefined;
|
|
66
|
+
const [deploymentResult, eip7702AuthResult, nonceResult] = results;
|
|
67
|
+
const hasDeployment = deploymentResult?.[1] === 1;
|
|
68
|
+
const hasEip7702Auth = eip7702AuthResult?.[1] === 1;
|
|
69
|
+
const hasNonce = nonceResult?.[1] === 1;
|
|
70
|
+
// Check deployment conflict
|
|
71
|
+
if (isDeployment(userOp) && hasDeployment) {
|
|
72
|
+
return "conflicting_deployment";
|
|
73
|
+
}
|
|
74
|
+
// Check EIP-7702 auth conflict
|
|
75
|
+
if (userOp.eip7702Auth && hasEip7702Auth) {
|
|
76
|
+
return "conflicting_7702_auth";
|
|
77
|
+
}
|
|
78
|
+
// Check nonce conflict
|
|
79
|
+
if (hasNonce) {
|
|
80
|
+
return "conflicting_nonce";
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=redis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../../store/processing/redis.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAM/B,MAAM,OAAO,oBAAoB;IACZ,KAAK,CAAO;IAEZ,oBAAoB,CAAQ,CAAC,sCAAsC;IACnE,wBAAwB,CAAQ,CAAC,wCAAwC;IACzE,uBAAuB,CAAQ,CAAC,kDAAkD;IAClF,wBAAwB,CAAQ,CAAC,kDAAkD;IAE5F,mBAAmB,CAAC,MAAe,EAAE,KAAa;QACtD,OAAO,GAAG,MAAM,IAAI,KAAK,EAAE,CAAA;IAC/B,CAAC;IAED,YAAY,EACR,MAAM,EACN,UAAU,EACV,aAAa,EAKhB;QACG,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;QAErC,MAAM,WAAW,GAAG,GAAG,M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,wBAAwB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QAC7D,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,wBAAwB,EAAE,aAAa,CAAC,CAAA;QAE7D,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAClC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAS,CAAA;QAE9B,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,CAAC,GAAG,OAAO,CAAA;QAClE,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;QACjD,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;QACnD,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;QAEvC,4BAA4B;QAC5B,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,aAAa,EAAE,CAAC;YACxC,OAAO,wBAAwB,CAAA;QACnC,CAAC;QAED,+BAA+B;QAC/B,IAAI,MAAM,CAAC,WAAW,IAAI,cAAc,EAAE,CAAC;YACvC,OAAO,uBAAuB,CAAA;QAClC,CAAC;QAED,uBAAuB;QACvB,IAAI,QAAQ,EAAE,CAAC;YACX,OAAO,mBAAmB,CAAA;QAC9B,CAAC;QAED,OAAO,SAAS,CAAA;IACpB,CAAC;CACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { UserOpInfo, UserOperation } from "../../types/index.js";
|
|
2
|
+
import type { Hex } from "viem";
|
|
3
|
+
import type { ConflictType } from "../types.js";
|
|
4
|
+
export interface ProcessingStore {
|
|
5
|
+
addProcessing(userOp: UserOpInfo): Promise<void>;
|
|
6
|
+
removeProcessing(userOp: UserOpInfo): Promise<void>;
|
|
7
|
+
isProcessing(userOpHash: Hex): Promise<boolean>;
|
|
8
|
+
wouldConflict(userOp: UserOperation): Promise<ConflictType | undefined>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../store/processing/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Address } from "abitype";
|
|
2
|
+
import type { HexData32, UserOpInfo, UserOperation } from "../types/schemas.js";
|
|
3
|
+
import type { ConflictingOutstandingType } from "./outstanding/index.js";
|
|
4
|
+
export type ConflictType = "conflicting_nonce" | "conflicting_deployment" | "conflicting_7702_auth";
|
|
5
|
+
export type StoreType = "outstanding" | "processing";
|
|
6
|
+
export type ValidationResult = {
|
|
7
|
+
valid: true;
|
|
8
|
+
} | {
|
|
9
|
+
valid: false;
|
|
10
|
+
reason: string;
|
|
11
|
+
};
|
|
12
|
+
export type EntryPointUserOpInfoParam = {
|
|
13
|
+
entryPoint: Address;
|
|
14
|
+
userOpInfo: UserOpInfo;
|
|
15
|
+
};
|
|
16
|
+
export type EntryPointUserOpInfosParam = {
|
|
17
|
+
entryPoint: Address;
|
|
18
|
+
userOpInfos: UserOpInfo[];
|
|
19
|
+
};
|
|
20
|
+
export type EntryPointUserOpHashParam = {
|
|
21
|
+
entryPoint: Address;
|
|
22
|
+
userOpHash: HexData32;
|
|
23
|
+
};
|
|
24
|
+
export type MempoolStore = {
|
|
25
|
+
popOutstanding: (entryPoint: Address, count: number) => Promise<UserOpInfo[]>;
|
|
26
|
+
addOutstanding: (args: EntryPointUserOpInfosParam) => Promise<void>;
|
|
27
|
+
removeOutstanding: (args: EntryPointUserOpHashParam) => Promise<void>;
|
|
28
|
+
dumpOutstanding: (entryPoint: Address) => Promise<UserOpInfo[]>;
|
|
29
|
+
addProcessing: (args: EntryPointUserOpInfoParam) => Promise<void>;
|
|
30
|
+
removeProcessing: (args: EntryPointUserOpInfoParam) => Promise<void>;
|
|
31
|
+
checkDuplicatesAndConflicts: (args: {
|
|
32
|
+
entryPoint: Address;
|
|
33
|
+
userOp: UserOperation;
|
|
34
|
+
userOpHash: HexData32;
|
|
35
|
+
}) => Promise<ValidationResult>;
|
|
36
|
+
popConflictingOustanding: (args: {
|
|
37
|
+
entryPoint: Address;
|
|
38
|
+
userOp: UserOperation;
|
|
39
|
+
}) => Promise<ConflictingOutstandingType>;
|
|
40
|
+
validateSenderLimits: (args: {
|
|
41
|
+
entryPoint: Address;
|
|
42
|
+
userOp: UserOperation;
|
|
43
|
+
}) => Promise<ValidationResult>;
|
|
44
|
+
getQueuedOutstandingUserOps: (args: {
|
|
45
|
+
userOp: UserOperation;
|
|
46
|
+
entryPoint: Address;
|
|
47
|
+
}) => Promise<UserOperation[]>;
|
|
48
|
+
clearOutstanding: (entryPoint: Address) => Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../store/types.ts"],"names":[],"mappings":""}
|