Skip to content

Commit

Permalink
Echo integration (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSulpiride committed Apr 1, 2024
1 parent 9a69813 commit 0082b2b
Show file tree
Hide file tree
Showing 29 changed files with 373 additions and 130 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ For a video tutorial on the above, you can [view this here.](https://www.youtube
"account": []
},
"bundleGasLimitMarkup": 25000, # optional, adds some amount of additional gas to a bundle tx
"relayingMode": "classic"; # optional, "flashbots" for Flashbots Builder API, "merkle" for Merkle.io, "kolibri" for kolibr.io
"relayingMode": "classic"; # optional, "flashbots" for Flashbots Builder API, "merkle" for Merkle.io, "kolibri" for kolibr.io, "echo" for Chainbound's Echo
"bundleInterval": 10000, # bundle creation interval
"bundleSize": 4, # optional, max size of a bundle, 4 userops by default
"pvgMarkup": 0 # optional, adds some gas on top of estimated PVG
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "1.0.47-alpha",
"version": "1.0.48-alpha",
"stream": "true",
"command": {
"version": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "root",
"private": true,
"version": "1.0.47-alpha",
"version": "1.0.48-alpha",
"engines": {
"node": ">=18.0.0"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api",
"version": "1.0.47-alpha",
"version": "1.0.48-alpha",
"description": "The API module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -35,13 +35,13 @@
"class-transformer": "0.5.1",
"class-validator": "0.14.0",
"ethers": "5.7.2",
"executor": "^1.0.47-alpha",
"executor": "^1.0.48-alpha",
"fastify": "4.14.1",
"monitoring": "^1.0.47-alpha",
"monitoring": "^1.0.48-alpha",
"pino": "8.11.0",
"pino-pretty": "10.0.0",
"reflect-metadata": "0.1.13",
"types": "^1.0.47-alpha"
"types": "^1.0.48-alpha"
},
"devDependencies": {
"@types/connect": "3.4.35"
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/modules/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Debug } from "executor/lib/modules";
import { IsEthereumAddress } from "class-validator";
import { BundlingMode } from "types/lib/api/interfaces";
import { GetStakeStatus } from "executor/lib/interfaces";
import { MempoolEntrySerialized } from "executor/src/entities/interfaces";
import { MempoolEntrySerialized } from "executor/lib/entities/interfaces";
import { RpcMethodValidator } from "../utils/RpcMethodValidator";
import {
SetReputationArgs,
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cli",
"version": "1.0.47-alpha",
"version": "1.0.48-alpha",
"description": "> TODO: description",
"author": "zincoshine <psramanuj@gmail.com>",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -38,15 +38,15 @@
"@libp2p/peer-id-factory": "2.0.1",
"@libp2p/prometheus-metrics": "1.1.3",
"@multiformats/multiaddr": "12.1.3",
"api": "^1.0.47-alpha",
"db": "^1.0.47-alpha",
"executor": "^1.0.47-alpha",
"api": "^1.0.48-alpha",
"db": "^1.0.48-alpha",
"executor": "^1.0.48-alpha",
"find-up": "5.0.0",
"got": "12.5.3",
"js-yaml": "4.1.0",
"monitoring": "^1.0.47-alpha",
"node": "^1.0.47-alpha",
"types": "^1.0.47-alpha",
"monitoring": "^1.0.48-alpha",
"node": "^1.0.48-alpha",
"types": "^1.0.48-alpha",
"yargs": "17.6.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contracts",
"version": "1.0.47-alpha",
"version": "1.0.48-alpha",
"description": "Smart contracts of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down
4 changes: 2 additions & 2 deletions packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "db",
"version": "1.0.47-alpha",
"version": "1.0.48-alpha",
"description": "The DB module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
Expand Down Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@chainsafe/ssz": "0.10.1",
"@farcaster/rocksdb": "5.5.0",
"types": "^1.0.47-alpha"
"types": "^1.0.48-alpha"
},
"devDependencies": {
"@types/rocksdb": "3.0.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/executor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "executor",
"version": "1.0.47-alpha",
"version": "1.0.48-alpha",
"description": "The Relayer module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -34,8 +34,8 @@
"@flashbots/ethers-provider-bundle": "0.6.2",
"async-mutex": "0.4.0",
"ethers": "5.7.2",
"monitoring": "^1.0.47-alpha",
"params": "^1.0.47-alpha",
"types": "^1.0.47-alpha"
"monitoring": "^1.0.48-alpha",
"params": "^1.0.48-alpha",
"types": "^1.0.48-alpha"
}
}
1 change: 1 addition & 0 deletions packages/executor/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ const bundlerDefaultConfigs: BundlerConfig = {
bundleGasLimit: 25000000,
kolibriAuthKey: "",
entryPointForwarder: "",
echoAuthKey: "",
};

const NETWORKS_ENV = (): string[] | undefined => {
Expand Down
19 changes: 1 addition & 18 deletions packages/executor/src/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,28 +157,11 @@ export class Executor {
this.bundlingService.setBundlingMode("manual");
this.logger.info(`${this.networkName}: [X] MANUAL BUNDLING`);
}

if (this.config.testingMode) {
this.bundlingService.setMaxBundleSize(10);
}

if (this.networkConfig.relayingMode === "flashbots") {
if (!this.networkConfig.rpcEndpointSubmit)
throw Error(
"If you want to use Flashbots Builder API, please set API url in 'rpcEndpointSubmit' in config file"
);
this.logger.info(`${this.networkName}: [X] FLASHBOTS BUIDLER API`);
}
if (this.networkConfig.relayingMode === "merkle") {
if (
!this.networkConfig.rpcEndpointSubmit ||
!this.networkConfig.merkleApiURL
)
throw Error(
"If you want to use Merkle API, please set RPC url in 'rpcEndpointSubmit' and API url in `merkleApiURL` in config file"
);
this.logger.info(`${this.networkName}: [X] Merkle API`);
}

if (this.networkConfig.conditionalTransactions) {
this.logger.info(`${this.networkName}: [x] CONDITIONAL TRANSACTIONS`);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/executor/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ export interface NetworkConfig {
kolibriAuthKey: string;
// catches EntryPoint v6 simulation reverts and returns them without revert
entryPointForwarder: string;
// api auth key for echo: https://echo.chainbound.io/docs/usage/api-interface#authentication
echoAuthKey: string;
}

export type BundlerConfig = Omit<
Expand Down
31 changes: 19 additions & 12 deletions packages/executor/src/modules/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export class Eth {
.add(this.config.vglMarkup)
.toNumber();

let preVerificationGas: BigNumberish = this.calcPreVerificationGas(userOp);
let preVerificationGas: BigNumberish =
this.calcPreVerificationGas(userOpComplemented);
userOpComplemented.preVerificationGas = preVerificationGas;
let callGasLimit: BigNumber = BigNumber.from(0);

Expand All @@ -202,14 +203,6 @@ export class Eth {
});
//>

// Binary search gas limits
const userOpToEstimate: UserOperationStruct = {
...userOpComplemented,
preVerificationGas,
verificationGasLimit,
callGasLimit,
};

const gasFee = await this.skandhaModule.getGasPrice();

if (this.pvgEstimator) {
Expand All @@ -226,11 +219,11 @@ export class Eth {

return {
preVerificationGas,
verificationGasLimit: userOpToEstimate.verificationGasLimit,
verificationGas: userOpToEstimate.verificationGasLimit,
verificationGasLimit: verificationGasLimit,
verificationGas: verificationGasLimit,
validAfter: validAfter ? BigNumber.from(validAfter) : undefined,
validUntil: validUntil ? BigNumber.from(validUntil) : undefined,
callGasLimit: userOpToEstimate.callGasLimit,
callGasLimit: callGasLimit,
maxFeePerGas: gasFee.maxFeePerGas,
maxPriorityFeePerGas: gasFee.maxPriorityFeePerGas,
};
Expand Down Expand Up @@ -314,6 +307,20 @@ export class Eth {
async getUserOperationByHash(
hash: string
): Promise<UserOperationByHashResponse | null> {
const entry = await this.mempoolService.getEntryByHash(hash);
if (entry) {
let transaction: Partial<ethers.providers.TransactionResponse> = {};
if (entry.transaction) {
transaction = await this.provider.getTransaction(entry.transaction);
}
return {
userOperation: entry.userOp,
entryPoint: entry.entryPoint,
transactionHash: transaction.hash,
blockHash: transaction.blockHash,
blockNumber: transaction.blockNumber,
};
}
const [entryPoint, event] = await this.getUserOperationEvent(hash);
if (!entryPoint || !event) {
return null;
Expand Down
1 change: 1 addition & 0 deletions packages/executor/src/modules/skandha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class Skandha {
throw new Error("No network config");
}
this.networkConfig = networkConfig;
void this.getConfig().then((config) => this.logger.debug(config));
}

async getGasPrice(): Promise<GetGasPriceResponse> {
Expand Down

0 comments on commit 0082b2b

Please sign in to comment.