Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete optimism sdk #193

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.12",
"version": "1.5.13",
"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.12",
"version": "1.5.13",
"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.12",
"version": "1.5.13",
"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.12",
"@skandha/monitoring": "^1.5.12",
"@skandha/types": "^1.5.12",
"@skandha/utils": "^1.5.12",
"@skandha/executor": "^1.5.13",
"@skandha/monitoring": "^1.5.13",
"@skandha/types": "^1.5.13",
"@skandha/utils": "^1.5.13",
"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.12",
"version": "1.5.13",
"description": "> TODO: description",
"author": "zincoshine <[email protected]>",
"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.12",
"@skandha/db": "^1.5.12",
"@skandha/executor": "^1.5.12",
"@skandha/monitoring": "^1.5.12",
"@skandha/node": "^1.5.12",
"@skandha/types": "^1.5.12",
"@skandha/api": "^1.5.13",
"@skandha/db": "^1.5.13",
"@skandha/executor": "^1.5.13",
"@skandha/monitoring": "^1.5.13",
"@skandha/node": "^1.5.13",
"@skandha/types": "^1.5.13",
"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.12",
"version": "1.5.13",
"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.12",
"version": "1.5.13",
"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.12"
"@skandha/types": "^1.5.13"
},
"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.12",
"version": "1.5.13",
"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.12",
"@skandha/params": "^1.5.12",
"@skandha/types": "^1.5.12",
"@skandha/utils": "^1.5.12",
"@skandha/monitoring": "^1.5.13",
"@skandha/params": "^1.5.13",
"@skandha/types": "^1.5.13",
"@skandha/utils": "^1.5.13",
"async-mutex": "0.4.0",
"ethers": "5.7.2",
"strict-event-emitter-types": "2.0.0",
Expand Down
7 changes: 1 addition & 6 deletions packages/executor/src/modules/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
estimateArbitrumPVG,
ECDSA_DUMMY_SIGNATURE,
estimateMantlePVG,
estimateAncient8PVG,
} from "@skandha/params/lib";
import { Logger } from "@skandha/types/lib";
import { PerChainMetrics } from "@skandha/monitoring/lib";
Expand Down Expand Up @@ -55,18 +54,14 @@ export class Eth {
}

// ["optimism", "optimismGoerli", "base"]
if ([10, 420, 8453].includes(this.chainId)) {
if ([10, 420, 8453, 888888888].includes(this.chainId)) {
this.pvgEstimator = estimateOptimismPVG(this.provider);
}

// mantle
if ([5000, 5001, 5003].includes(this.chainId)) {
this.pvgEstimator = estimateMantlePVG(this.provider);
}

if ([888888888].includes(this.chainId)) {
this.pvgEstimator = estimateAncient8PVG(this.provider);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/monitoring/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.5.12",
"version": "1.5.13",
"description": "The Monitoring module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
Expand Down Expand Up @@ -32,7 +32,7 @@
"check-readme": "typescript-docs-verifier"
},
"dependencies": {
"@skandha/types": "^1.5.12",
"@skandha/types": "^1.5.13",
"prom-client": "^14.2.0"
}
}
16 changes: 8 additions & 8 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.5.12",
"version": "1.5.13",
"description": "The bundler node module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -56,13 +56,13 @@
"@libp2p/prometheus-metrics": "1.1.3",
"@libp2p/tcp": "6.1.0",
"@multiformats/multiaddr": "11.4.0",
"@skandha/api": "^1.5.12",
"@skandha/db": "^1.5.12",
"@skandha/executor": "^1.5.12",
"@skandha/monitoring": "^1.5.12",
"@skandha/params": "^1.5.12",
"@skandha/types": "^1.5.12",
"@skandha/utils": "^1.5.12",
"@skandha/api": "^1.5.13",
"@skandha/db": "^1.5.13",
"@skandha/executor": "^1.5.13",
"@skandha/monitoring": "^1.5.13",
"@skandha/params": "^1.5.13",
"@skandha/types": "^1.5.13",
"@skandha/utils": "^1.5.13",
"@types/varint": "6.0.1",
"abstract-leveldown": "7.2.0",
"datastore-core": "8.0.1",
Expand Down
7 changes: 3 additions & 4 deletions packages/params/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.5.12",
"version": "1.5.13",
"description": "Various bundler parameters",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/skandha#readme",
Expand All @@ -27,10 +27,9 @@
"dependencies": {
"@arbitrum/sdk": "3.1.4",
"@chainsafe/ssz": "0.10.1",
"@eth-optimism/sdk": "3.2.3",
"@mantleio/sdk": "0.2.1",
"@skandha/types": "^1.5.12",
"@skandha/utils": "^1.5.12",
"@skandha/types": "^1.5.13",
"@skandha/utils": "^1.5.13",
"ethers": "5.7.2"
},
"scripts": {
Expand Down
65 changes: 0 additions & 65 deletions packages/params/src/gas-estimation/ancient8.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/params/src/gas-estimation/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./arbitrum";
export * from "./optimism";
export * from "./mantle";
export * from "./ancient8";
64 changes: 43 additions & 21 deletions packages/params/src/gas-estimation/optimism.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BigNumber, BigNumberish, ethers, Contract } from "ethers";
import { UserOperationStruct } from "@skandha/types/lib/executor/contracts/EntryPoint";
import { BigNumber, BigNumberish, ethers } from "ethers";
import { IEntryPoint__factory } from "@skandha/types/lib/executor/contracts";
import { estimateL1GasCost } from "@eth-optimism/sdk";
import { IPVGEstimator, IPVGEstimatorWrapper } from "../types/IPVGEstimator";
import { serializeTransaction } from "ethers/lib/utils";
import { IPVGEstimatorWrapper, IPVGEstimator } from "../types/IPVGEstimator";

export const estimateOptimismPVG: IPVGEstimatorWrapper = (
provider
Expand All @@ -13,31 +13,53 @@ export const estimateOptimismPVG: IPVGEstimatorWrapper = (
userOp: UserOperationStruct,
initial: BigNumberish
): Promise<BigNumber> => {
const { chainId } = await provider.getNetwork();
const latestBlock = await provider.getBlock("latest");
if (latestBlock.baseFeePerGas == null) {
throw new Error("no base fee");
}
const entryPoint = IEntryPoint__factory.connect(entryPointAddr, provider);
const handleOpsData = entryPoint.interface.encodeFunctionData("handleOps", [
[userOp],
dummyWallet.address,
]);

try {
const latestBlock = await provider.getBlock("latest");
if (latestBlock.baseFeePerGas == null) {
throw new Error("no base fee");
}
const l1GasCost = await estimateL1GasCost(provider, {
const serializedTx = serializeTransaction(
{
to: entryPointAddr,
chainId: chainId,
nonce: 999999,
gasLimit: BigNumber.from(2).pow(64).sub(1), // maxUint64
gasPrice: BigNumber.from(2).pow(64).sub(1), // maxUint64
data: handleOpsData,
});
const l2MaxFee = BigNumber.from(userOp.maxFeePerGas);
const l2PriorityFee = latestBlock.baseFeePerGas.add(
userOp.maxPriorityFeePerGas
);
const l2Price = l2MaxFee.lt(l2PriorityFee) ? l2MaxFee : l2PriorityFee;
return l1GasCost.div(l2Price).add(initial);
} catch (err) {
// eslint-disable-next-line no-console
console.error("Error while estimating optimism PVG", err);
return BigNumber.from(initial);
}
},
{
r: "0x123451234512345123451234512345123451234512345123451234512345",
s: "0x123451234512345123451234512345123451234512345123451234512345",
v: 28,
}
);
const gasOracle = new Contract(GAS_ORACLE, GasOracleABI, provider);
const l1GasCost = BigNumber.from(
await gasOracle.callStatic.getL1Fee(serializedTx)
);
const l2MaxFee = BigNumber.from(userOp.maxFeePerGas);
const l2PriorityFee = latestBlock.baseFeePerGas.add(
userOp.maxPriorityFeePerGas
);
const l2Price = l2MaxFee.lt(l2PriorityFee) ? l2MaxFee : l2PriorityFee;
return l1GasCost.div(l2Price).add(initial);
};
};

const GAS_ORACLE = "0x420000000000000000000000000000000000000F";

const GasOracleABI = [
{
inputs: [{ internalType: "bytes", name: "_data", type: "bytes" }],
name: "getL1Fee",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
];
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.5.12",
"version": "1.5.13",
"description": "The types of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down
Loading
Loading