From d715f34c3e4580e7d5a348a59a2e87f8741655f1 Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Thu, 19 Sep 2024 17:48:27 +0500 Subject: [PATCH 1/3] fix: in case of errors fallback to blockscout --- packages/executor/src/modules/eth.ts | 94 +++++++++++++++------------- 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index 9785ab6c..b1113181 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -349,46 +349,32 @@ export class Eth { blockNumber: transaction.blockNumber, }; } - const [entryPoint, event] = await this.getUserOperationEvent(hash); - if (!entryPoint || !event) { - if (this.blockscoutApi) - return await this.blockscoutApi.getUserOperationByHash(hash); - return null; - } - const tx = await event.getTransaction(); - if (tx.to !== entryPoint.address) { - throw new Error("unable to parse transaction"); - } - const parsed = entryPoint.interface.parseTransaction(tx); - const ops: UserOperationStruct[] = parsed?.args.ops; - if (ops.length == 0) { - throw new Error("failed to parse transaction"); - } - const op = ops.find( - (o) => - o.sender === event.args.sender && - BigNumber.from(o.nonce).eq(event.args.nonce) - ); - if (!op) { - throw new Error("unable to find userOp in transaction"); - } - const { - sender, - nonce, - initCode, - callData, - callGasLimit, - verificationGasLimit, - preVerificationGas, - maxFeePerGas, - maxPriorityFeePerGas, - paymasterAndData, - signature, - } = op; + // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + const getUserOpFromRpc = async () => { + const [entryPoint, event] = await this.getUserOperationEvent(hash); + if (!entryPoint || !event) { + throw new Error("not found"); + } + const tx = await event.getTransaction(); + if (tx.to !== entryPoint.address) { + throw new Error("unable to parse transaction"); + } + const parsed = entryPoint.interface.parseTransaction(tx); + const ops: UserOperationStruct[] = parsed?.args.ops; + if (ops.length == 0) { + throw new Error("failed to parse transaction"); + } + const op = ops.find( + (o) => + o.sender === event.args.sender && + BigNumber.from(o.nonce).eq(event.args.nonce) + ); + if (!op) { + throw new Error("unable to find userOp in transaction"); + } - return deepHexlify({ - userOperation: { + const { sender, nonce, initCode, @@ -400,11 +386,33 @@ export class Eth { maxPriorityFeePerGas, paymasterAndData, signature, - }, - entryPoint: entryPoint.address, - transactionHash: tx.hash, - blockHash: tx.blockHash ?? "", - blockNumber: tx.blockNumber ?? 0, + } = op; + + return deepHexlify({ + userOperation: { + sender, + nonce, + initCode, + callData, + callGasLimit, + verificationGasLimit, + preVerificationGas, + maxFeePerGas, + maxPriorityFeePerGas, + paymasterAndData, + signature, + }, + entryPoint: entryPoint.address, + transactionHash: tx.hash, + blockHash: tx.blockHash ?? "", + blockNumber: tx.blockNumber ?? 0, + }); + }; + + return getUserOpFromRpc().catch((_) => { + if (this.blockscoutApi) + return this.blockscoutApi.getUserOperationByHash(hash); + return null; }); } From 3ce525df156201181e51207e52f5703cad92de7c Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Thu, 19 Sep 2024 17:48:41 +0500 Subject: [PATCH 2/3] chore(release): v1.5.26 --- lerna.json | 2 +- package.json | 2 +- packages/api/package.json | 10 +++++----- packages/cli/package.json | 14 +++++++------- packages/contracts/package.json | 2 +- packages/db/package.json | 4 ++-- packages/executor/package.json | 10 +++++----- packages/monitoring/package.json | 4 ++-- packages/node/package.json | 16 ++++++++-------- packages/params/package.json | 6 +++--- packages/types/package.json | 2 +- packages/utils/package.json | 4 ++-- 12 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lerna.json b/lerna.json index 2eeb1e88..f6c9f775 100644 --- a/lerna.json +++ b/lerna.json @@ -3,7 +3,7 @@ "packages/*" ], "npmClient": "yarn", - "version": "1.5.25", + "version": "1.5.26", "stream": "true", "command": { "version": { diff --git a/package.json b/package.json index aec533aa..0a47557f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "root", "private": true, - "version": "1.5.25", + "version": "1.5.26", "engines": { "node": ">=18.0.0" }, diff --git a/packages/api/package.json b/packages/api/package.json index 7d51d0d4..ba206c7a 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "1.5.25", + "version": "1.5.26", "description": "The API module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -34,10 +34,10 @@ "dependencies": { "@fastify/cors": "9.0.1", "@fastify/websocket": "10.0.1", - "@skandha/executor": "^1.5.25", - "@skandha/monitoring": "^1.5.25", - "@skandha/types": "^1.5.25", - "@skandha/utils": "^1.5.25", + "@skandha/executor": "^1.5.26", + "@skandha/monitoring": "^1.5.26", + "@skandha/types": "^1.5.26", + "@skandha/utils": "^1.5.26", "class-transformer": "0.5.1", "class-validator": "0.14.1", "ethers": "5.7.2", diff --git a/packages/cli/package.json b/packages/cli/package.json index 00cf008b..9ff053c8 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "1.5.25", + "version": "1.5.26", "description": "> TODO: description", "author": "zincoshine ", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -40,12 +40,12 @@ "@libp2p/peer-id-factory": "2.0.1", "@libp2p/prometheus-metrics": "1.1.3", "@multiformats/multiaddr": "12.1.3", - "@skandha/api": "^1.5.25", - "@skandha/db": "^1.5.25", - "@skandha/executor": "^1.5.25", - "@skandha/monitoring": "^1.5.25", - "@skandha/node": "^1.5.25", - "@skandha/types": "^1.5.25", + "@skandha/api": "^1.5.26", + "@skandha/db": "^1.5.26", + "@skandha/executor": "^1.5.26", + "@skandha/monitoring": "^1.5.26", + "@skandha/node": "^1.5.26", + "@skandha/types": "^1.5.26", "find-up": "5.0.0", "got": "12.5.3", "js-yaml": "4.1.0", diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 84c638b5..53b31fc1 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "1.5.25", + "version": "1.5.26", "description": "Smart contracts of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", diff --git a/packages/db/package.json b/packages/db/package.json index dccd3f68..ec8ee4e5 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "1.5.25", + "version": "1.5.26", "description": "The DB module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://github.com/etherspot/etherspot-bundler#readme", @@ -34,7 +34,7 @@ "dependencies": { "@chainsafe/ssz": "0.10.1", "@farcaster/rocksdb": "5.5.0", - "@skandha/types": "^1.5.25" + "@skandha/types": "^1.5.26" }, "devDependencies": { "@types/rocksdb": "3.0.1", diff --git a/packages/executor/package.json b/packages/executor/package.json index 38d4de78..a07aed0d 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "1.5.25", + "version": "1.5.26", "description": "The Relayer module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -35,10 +35,10 @@ }, "dependencies": { "@flashbots/ethers-provider-bundle": "0.6.2", - "@skandha/monitoring": "^1.5.25", - "@skandha/params": "^1.5.25", - "@skandha/types": "^1.5.25", - "@skandha/utils": "^1.5.25", + "@skandha/monitoring": "^1.5.26", + "@skandha/params": "^1.5.26", + "@skandha/types": "^1.5.26", + "@skandha/utils": "^1.5.26", "async-mutex": "0.4.0", "ethers": "5.7.2", "strict-event-emitter-types": "2.0.0", diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json index 617b413d..1883ba3f 100644 --- a/packages/monitoring/package.json +++ b/packages/monitoring/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "1.5.25", + "version": "1.5.26", "description": "The Monitoring module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://github.com/etherspot/etherspot-bundler#readme", @@ -32,7 +32,7 @@ "check-readme": "typescript-docs-verifier" }, "dependencies": { - "@skandha/types": "^1.5.25", + "@skandha/types": "^1.5.26", "prom-client": "^14.2.0" } } diff --git a/packages/node/package.json b/packages/node/package.json index 5ca244aa..62eaf757 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "1.5.25", + "version": "1.5.26", "description": "The bundler node module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -56,13 +56,13 @@ "@libp2p/prometheus-metrics": "1.1.3", "@libp2p/tcp": "6.1.0", "@multiformats/multiaddr": "11.4.0", - "@skandha/api": "^1.5.25", - "@skandha/db": "^1.5.25", - "@skandha/executor": "^1.5.25", - "@skandha/monitoring": "^1.5.25", - "@skandha/params": "^1.5.25", - "@skandha/types": "^1.5.25", - "@skandha/utils": "^1.5.25", + "@skandha/api": "^1.5.26", + "@skandha/db": "^1.5.26", + "@skandha/executor": "^1.5.26", + "@skandha/monitoring": "^1.5.26", + "@skandha/params": "^1.5.26", + "@skandha/types": "^1.5.26", + "@skandha/utils": "^1.5.26", "@types/varint": "6.0.1", "abstract-leveldown": "7.2.0", "datastore-core": "8.0.1", diff --git a/packages/params/package.json b/packages/params/package.json index 0156fc18..d058d646 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "1.5.25", + "version": "1.5.26", "description": "Various bundler parameters", "author": "Etherspot", "homepage": "https://github.com/etherspot/skandha#readme", @@ -28,8 +28,8 @@ "@arbitrum/sdk": "3.1.4", "@chainsafe/ssz": "0.10.1", "@mantleio/sdk": "0.2.1", - "@skandha/types": "^1.5.25", - "@skandha/utils": "^1.5.25", + "@skandha/types": "^1.5.26", + "@skandha/utils": "^1.5.26", "ethers": "5.7.2" }, "scripts": { diff --git a/packages/types/package.json b/packages/types/package.json index 65d7733e..1f372966 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "1.5.25", + "version": "1.5.26", "description": "The types of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", diff --git a/packages/utils/package.json b/packages/utils/package.json index 5c0fe301..23d414c8 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "1.5.25", + "version": "1.5.26", "description": "utils of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -33,7 +33,7 @@ }, "dependencies": { "@chainsafe/as-sha256": "0.3.1", - "@skandha/types": "^1.5.25", + "@skandha/types": "^1.5.26", "any-signal": "3.0.1", "bigint-buffer": "1.1.5", "case": "^1.6.3", From 9837be8a97c7a3564ce17e8127e5fa3e2739eba7 Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Thu, 19 Sep 2024 18:02:31 +0500 Subject: [PATCH 3/3] bubble up err --- packages/executor/src/modules/eth.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index b1113181..1fb80617 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -409,10 +409,10 @@ export class Eth { }); }; - return getUserOpFromRpc().catch((_) => { + return getUserOpFromRpc().catch((error) => { if (this.blockscoutApi) return this.blockscoutApi.getUserOperationByHash(hash); - return null; + throw error; }); }