-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding tenderly simulation for userop validation (#277)
- Loading branch information
1 parent
e0c3fb2
commit d9ac381
Showing
23 changed files
with
249 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "root", | ||
"private": true, | ||
"version": "1.5.34", | ||
"version": "1.5.35", | ||
"engines": { | ||
"node": ">=18.0.0" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"version": "1.5.34", | ||
"version": "1.5.35", | ||
"description": "> TODO: description", | ||
"author": "zincoshine <[email protected]>", | ||
"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.34", | ||
"@skandha/db": "^1.5.34", | ||
"@skandha/executor": "^1.5.34", | ||
"@skandha/monitoring": "^1.5.34", | ||
"@skandha/node": "^1.5.34", | ||
"@skandha/types": "^1.5.34", | ||
"@skandha/api": "^1.5.35", | ||
"@skandha/db": "^1.5.35", | ||
"@skandha/executor": "^1.5.35", | ||
"@skandha/monitoring": "^1.5.35", | ||
"@skandha/node": "^1.5.35", | ||
"@skandha/types": "^1.5.35", | ||
"find-up": "5.0.0", | ||
"got": "12.5.3", | ||
"js-yaml": "4.1.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/executor/src/services/UserOpValidation/validators/tenderly.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { UserOperationStruct } from "@skandha/types/lib/executor/contracts/EntryPoint"; | ||
import { IEntryPoint } from "@skandha/types/src/executor/contracts"; | ||
import axios from "axios"; | ||
import { BigNumber, constants } from "ethers"; | ||
import { Logger } from "@skandha/types/lib"; | ||
|
||
export class TenderlyValidationService { | ||
constructor( | ||
private tenderlyApiUrl: string, | ||
private tenderlyAccessKey: string, | ||
private chainId: number, | ||
private logger: Logger | ||
) {} | ||
|
||
async validate( | ||
userOp: UserOperationStruct, | ||
entryPoint: IEntryPoint, | ||
gasLimit?: BigNumber | ||
): Promise<any> { | ||
const config = { | ||
method: "post", | ||
url: `${this.tenderlyApiUrl}/simulate`, | ||
headers: { | ||
"Content-Type": "application/json", | ||
"X-Access-Key": this.tenderlyAccessKey, | ||
}, | ||
data: JSON.stringify({ | ||
network_id: `${this.chainId}`, | ||
from: constants.AddressZero, | ||
to: entryPoint.address, | ||
input: entryPoint.interface.encodeFunctionData("simulateValidation", [ | ||
userOp, | ||
]), | ||
gas: gasLimit?.toNumber(), | ||
}), | ||
}; | ||
return await axios | ||
.request(config) | ||
.then((response) => { | ||
const parsed = entryPoint.interface.parseError( | ||
response.data.transaction.call_trace[0].output | ||
); | ||
return { | ||
...parsed, | ||
errorName: parsed.name, | ||
errorArgs: parsed.args, | ||
}; | ||
}) | ||
.catch((err) => { | ||
this.logger.error(`Tenderly validation failed: ${err}`); | ||
}); | ||
} | ||
} |
Oops, something went wrong.