Skip to content

Commit

Permalink
Mantle sepolia fix (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSulpiride committed May 22, 2024
1 parent cf3aa9c commit 603cff2
Show file tree
Hide file tree
Showing 38 changed files with 334 additions and 188 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ For a video tutorial on the above, you can [view this here.](https://www.youtube
"minUnstakeDelay": 0, # optional, min unstake delay of an entity
"minSignerBalance": 1, # optional, default is 0.1 ETH. If the relayer's balance drops lower than this, it will be selected as a fee collector
"multicall": "0xcA11bde05977b3631167028862bE2a173976CA11", # optional, multicall3 contract (see https://github.com/mds1/multicall#multicall3-contract-addresses)
"estimationStaticBuffer": 21000, # optional,adds certain amount of gas to callGasLimit on estimation
"validationGasLimit": 10e6, # optional,gas limit during simulateHandleOps and simulateValidation calls
"estimationGasLimit": 0, # optional,gas limit during simulateHandleOps and simulateValidation calls
"receiptLookupRange": 1024, # optional,limits the block range of getUserOperationByHash and getUserOperationReceipt
"etherscanApiKey": "", # optional,etherscan api is used to fetch gas prices
"conditionalTransactions": false, # optional,enable conditional transactions
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages/*"
],
"npmClient": "yarn",
"version": "1.5.10",
"version": "1.5.11",
"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.5.10",
"version": "1.5.11",
"engines": {
"node": ">=18.0.0"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.5.10",
"version": "1.5.11",
"description": "The API module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -34,10 +34,10 @@
"dependencies": {
"@fastify/cors": "9.0.1",
"@fastify/websocket": "10.0.1",
"@skandha/executor": "^1.5.10",
"@skandha/monitoring": "^1.5.10",
"@skandha/types": "^1.5.10",
"@skandha/utils": "^1.5.10",
"@skandha/executor": "^1.5.11",
"@skandha/monitoring": "^1.5.11",
"@skandha/types": "^1.5.11",
"@skandha/utils": "^1.5.11",
"class-transformer": "0.5.1",
"class-validator": "0.14.1",
"ethers": "5.7.2",
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.5.10",
"version": "1.5.11",
"description": "> TODO: description",
"author": "zincoshine <psramanuj@gmail.com>",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -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.10",
"@skandha/db": "^1.5.10",
"@skandha/executor": "^1.5.10",
"@skandha/monitoring": "^1.5.10",
"@skandha/node": "^1.5.10",
"@skandha/types": "^1.5.10",
"@skandha/api": "^1.5.11",
"@skandha/db": "^1.5.11",
"@skandha/executor": "^1.5.11",
"@skandha/monitoring": "^1.5.11",
"@skandha/node": "^1.5.11",
"@skandha/types": "^1.5.11",
"find-up": "5.0.0",
"got": "12.5.3",
"js-yaml": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.5.10",
"version": "1.5.11",
"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
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.5.10",
"version": "1.5.11",
"description": "The DB module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
Expand Down Expand Up @@ -34,7 +34,7 @@
"dependencies": {
"@chainsafe/ssz": "0.10.1",
"@farcaster/rocksdb": "5.5.0",
"@skandha/types": "^1.5.10"
"@skandha/types": "^1.5.11"
},
"devDependencies": {
"@types/rocksdb": "3.0.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/executor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.5.10",
"version": "1.5.11",
"description": "The Relayer module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -35,10 +35,10 @@
},
"dependencies": {
"@flashbots/ethers-provider-bundle": "0.6.2",
"@skandha/monitoring": "^1.5.10",
"@skandha/params": "^1.5.10",
"@skandha/types": "^1.5.10",
"@skandha/utils": "^1.5.10",
"@skandha/monitoring": "^1.5.11",
"@skandha/params": "^1.5.11",
"@skandha/types": "^1.5.11",
"@skandha/utils": "^1.5.11",
"async-mutex": "0.4.0",
"ethers": "5.7.2",
"strict-event-emitter-types": "2.0.0",
Expand Down
13 changes: 11 additions & 2 deletions packages/executor/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,19 @@ export class Config {

config.fastlaneValidators = fromEnvVar(
"FASTLANE_VALIDATOR",
config.fastlaneValidators || bundlerDefaultConfigs.fastlaneValidators,
config.fastlaneValidators != undefined
? config.fastlaneValidators
: bundlerDefaultConfigs.fastlaneValidators,
true
) as string[];

config.estimationGasLimit = Number(
fromEnvVar(
"ESTIMATION_GAS_LIMIT",
config.estimationGasLimit || bundlerDefaultConfigs.estimationGasLimit
)
);

// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (!config.whitelistedEntities) {
config.whitelistedEntities = bundlerDefaultConfigs.whitelistedEntities;
Expand Down Expand Up @@ -340,7 +349,7 @@ const bundlerDefaultConfigs: BundlerConfig = {
minUnstakeDelay: 0,
minSignerBalance: utils.parseEther("0.1"),
multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", // default multicall address
validationGasLimit: 10e6,
estimationGasLimit: 0,
receiptLookupRange: 1024,
etherscanApiKey: "",
conditionalTransactions: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/executor/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export interface NetworkConfig {
vglMarkup: number;
// gas limit during simulateHandleOps and simulateValidation calls
// default = 10e6
validationGasLimit: number;
estimationGasLimit: number;
// limits the block range of getUserOperationByHash and getUserOperationReceipt
// if requests to those endpoints are timing out, reduce this value
// default = 1024
Expand Down
4 changes: 2 additions & 2 deletions packages/executor/src/modules/skandha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ export class Skandha {
)} eth`,
minStake: `${ethers.utils.formatEther(this.networkConfig.minStake!)} eth`,
multicall: this.networkConfig.multicall,
validationGasLimit: BigNumber.from(
this.networkConfig.validationGasLimit
estimationGasLimit: BigNumber.from(
this.networkConfig.estimationGasLimit
).toNumber(),
receiptLookupRange: BigNumber.from(
this.networkConfig.receiptLookupRange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export class ClassicRelayer extends BaseRelayer {
...transactionRequest,
gasLimit: estimateBundleGasLimit(
this.networkConfig.bundleGasLimitMarkup,
bundle.entries
bundle.entries,
this.networkConfig.estimationGasLimit
),
chainId: this.provider._network.chainId,
nonce: await relayer.getTransactionCount(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export class EchoRelayer extends BaseRelayer {
maxFeePerGas: bundle.maxFeePerGas,
gasLimit: estimateBundleGasLimit(
this.networkConfig.bundleGasLimitMarkup,
bundle.entries
bundle.entries,
this.networkConfig.estimationGasLimit
),
chainId: this.provider._network.chainId,
nonce: await relayer.getTransactionCount(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ export class FastlaneRelayer extends BaseRelayer {
...transactionRequest,
gasLimit: estimateBundleGasLimit(
this.networkConfig.bundleGasLimitMarkup,
bundle.entries
bundle.entries,
this.networkConfig.estimationGasLimit
),
chainId: this.provider._network.chainId,
nonce: await relayer.getTransactionCount(),
Expand Down Expand Up @@ -200,7 +201,7 @@ export class FastlaneRelayer extends BaseRelayer {
const submitStart = now();
return new Promise((resolve, reject) => {
let lock = false;
const handler = async (blockNumber: number): Promise<void> => {
const handler = async (_: number): Promise<void> => {
if (now() - submitStart > this.submitTimeout) return reject("timeout");
if (lock) return;
lock = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export class FlashbotsRelayer extends BaseRelayer {
maxFeePerGas: bundle.maxFeePerGas,
gasLimit: estimateBundleGasLimit(
this.networkConfig.bundleGasLimitMarkup,
bundle.entries
bundle.entries,
this.networkConfig.estimationGasLimit
),
chainId: this.provider._network.chainId,
nonce: await relayer.getTransactionCount(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export class KolibriRelayer extends BaseRelayer {
maxFeePerGas: bundle.maxFeePerGas,
gasLimit: estimateBundleGasLimit(
this.networkConfig.bundleGasLimitMarkup,
bundle.entries
bundle.entries,
this.networkConfig.estimationGasLimit
),
chainId: this.provider._network.chainId,
nonce: await relayer.getTransactionCount(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export class MerkleRelayer extends BaseRelayer {
maxFeePerGas: bundle.maxFeePerGas,
gasLimit: estimateBundleGasLimit(
this.networkConfig.bundleGasLimitMarkup,
bundle.entries
bundle.entries,
this.networkConfig.estimationGasLimit
),
chainId: this.provider._network.chainId,
nonce: await relayer.getTransactionCount(),
Expand Down
6 changes: 5 additions & 1 deletion packages/executor/src/services/BundlingService/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
RelayingMode,
ReputationStatus,
} from "@skandha/types/lib/executor";
import { GasPriceMarkupOne, chainsWithoutEIP1559, getGasFee } from "@skandha/params/lib";
import {
GasPriceMarkupOne,
chainsWithoutEIP1559,
getGasFee,
} from "@skandha/params/lib";
import { IGetGasFeeResult } from "@skandha/params/lib/gas-price-oracles/oracles";
import { Mutex } from "async-mutex";
import { Config } from "../../config";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
import { BigNumber } from "ethers";
import { BigNumber, BigNumberish } from "ethers";
import { UserOperationStruct } from "@skandha/types/lib/executor/contracts/EntryPoint";
import { MempoolEntry } from "../../../entities/MempoolEntry";

export function estimateBundleGasLimit(
markup: number,
bundle: MempoolEntry[]
bundle: MempoolEntry[],
estimationGasLimit: BigNumberish = 0
): BigNumber {
let gasLimit = BigNumber.from(markup);
for (const { userOp } of bundle) {
gasLimit = getUserOpGasLimit(userOp, gasLimit);
gasLimit = getUserOpGasLimit(userOp, gasLimit, 0);
}
if (gasLimit.lt(1e5)) {
// gasLimit should at least be 1e5 to pass test in test-executor
gasLimit = BigNumber.from(1e5);
}
return gasLimit;
return gasLimit.gt(estimationGasLimit)
? gasLimit
: BigNumber.from(estimationGasLimit);
}

export function getUserOpGasLimit(
userOp: UserOperationStruct,
markup: BigNumber = BigNumber.from(0)
markup: BigNumber = BigNumber.from(0),
estimationGasLimit: BigNumberish = 0
): BigNumber {
return BigNumber.from(userOp.verificationGasLimit)
const gasLimit = BigNumber.from(userOp.verificationGasLimit)
.mul(3)
.add(200000) // instead of PVG
.add(userOp.callGasLimit)
.mul(11)
.div(10)
.add(markup);

return gasLimit.gt(estimationGasLimit)
? gasLimit
: BigNumber.from(estimationGasLimit);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { IEntryPoint__factory } from "@skandha/types/lib/executor/contracts";
import { UserOperationStruct } from "@skandha/types/lib/executor/contracts/EntryPoint";
import { BundlerCollectorReturn, ExitInfo } from "@skandha/types/lib/executor";
import * as RpcErrorCodes from "@skandha/types/lib/api/errors/rpc-error-codes";
import { BigNumber, Contract, providers } from "ethers";
import { BigNumber, Contract, providers, constants } from "ethers";
import { Logger } from "@skandha/types/lib";
import { nonGethErrorHandler } from "../utils";
import { ExecutionResult, NetworkConfig } from "../../../interfaces";
import { GethTracer } from "../GethTracer";
import { getUserOpGasLimit } from "../../BundlingService/utils";

const isVGLLow = (err: Error): boolean => {
const { message } = err;
Expand Down Expand Up @@ -52,14 +53,13 @@ export class EstimationService {
this.provider
);

const gasLimit = BigNumber.from(userOp.callGasLimit)
.add(userOp.verificationGasLimit)
.add(userOp.preVerificationGas)
.add(5000); // markup added by EP

const errorResult = await entryPointContract.callStatic
.simulateHandleOp(userOp, AddressZero, BytesZero, {
gasLimit,
gasLimit: getUserOpGasLimit(
userOp,
constants.Zero,
this.networkConfig.estimationGasLimit
),
})
.catch((e: any) => nonGethErrorHandler(entryPointContract, e));

Expand Down Expand Up @@ -87,11 +87,6 @@ export class EstimationService {
this.provider
);

const gasLimit = BigNumber.from(userOp.callGasLimit)
.add(userOp.verificationGasLimit)
.add(userOp.preVerificationGas)
.add(105000);

const simulateData = entryPointContract.interface.encodeFunctionData(
"simulateHandleOp",
[userOp, AddressZero, BytesZero]
Expand All @@ -108,7 +103,11 @@ export class EstimationService {
entryPoint,
simulateData,
]),
gasLimit,
gasLimit: getUserOpGasLimit(
userOp,
BigNumber.from(105000),
this.networkConfig.estimationGasLimit
),
});

const error = entryPointContract.interface.parseError(data);
Expand Down

0 comments on commit 603cff2

Please sign in to comment.