Skip to content

Commit 9b14c5b

Browse files
authored
feat: ancient8 l1 fees (#178)
1 parent 7dc9399 commit 9b14c5b

File tree

15 files changed

+109
-38
lines changed

15 files changed

+109
-38
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
],
55
"npmClient": "yarn",
66
"useWorkspaces": true,
7-
"version": "1.5.5",
7+
"version": "1.5.6",
88
"stream": "true",
99
"command": {
1010
"version": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "root",
33
"private": true,
4-
"version": "1.5.5",
4+
"version": "1.5.6",
55
"engines": {
66
"node": ">=18.0.0"
77
},

packages/api/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "api",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "The API module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -33,14 +33,14 @@
3333
"class-transformer": "0.5.1",
3434
"class-validator": "0.14.1",
3535
"ethers": "5.7.2",
36-
"executor": "^1.5.5",
36+
"executor": "^1.5.6",
3737
"fastify": "4.25.2",
38-
"monitoring": "^1.5.5",
38+
"monitoring": "^1.5.6",
3939
"pino": "8.11.0",
4040
"pino-pretty": "10.0.0",
4141
"reflect-metadata": "0.1.13",
42-
"types": "^1.5.5",
43-
"utils": "^1.5.5",
42+
"types": "^1.5.6",
43+
"utils": "^1.5.6",
4444
"ws": "8.16.0"
4545
},
4646
"devDependencies": {

packages/cli/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cli",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "> TODO: description",
55
"author": "zincoshine <[email protected]>",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -36,15 +36,15 @@
3636
"@libp2p/peer-id-factory": "2.0.1",
3737
"@libp2p/prometheus-metrics": "1.1.3",
3838
"@multiformats/multiaddr": "12.1.3",
39-
"api": "^1.5.5",
40-
"db": "^1.5.5",
41-
"executor": "^1.5.5",
39+
"api": "^1.5.6",
40+
"db": "^1.5.6",
41+
"executor": "^1.5.6",
4242
"find-up": "5.0.0",
4343
"got": "12.5.3",
4444
"js-yaml": "4.1.0",
45-
"monitoring": "^1.5.5",
46-
"node": "^1.5.5",
47-
"types": "^1.5.5",
45+
"monitoring": "^1.5.6",
46+
"node": "^1.5.6",
47+
"types": "^1.5.6",
4848
"yargs": "17.6.2"
4949
},
5050
"devDependencies": {

packages/contracts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "contracts",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "Smart contracts of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",

packages/db/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "db",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "The DB module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
@@ -30,7 +30,7 @@
3030
"dependencies": {
3131
"@chainsafe/ssz": "0.10.1",
3232
"@farcaster/rocksdb": "5.5.0",
33-
"types": "^1.5.5"
33+
"types": "^1.5.6"
3434
},
3535
"devDependencies": {
3636
"@types/rocksdb": "3.0.1",

packages/executor/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "executor",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "The Relayer module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -33,11 +33,11 @@
3333
"@flashbots/ethers-provider-bundle": "0.6.2",
3434
"async-mutex": "0.4.0",
3535
"ethers": "5.7.2",
36-
"monitoring": "^1.5.5",
37-
"params": "^1.5.5",
36+
"monitoring": "^1.5.6",
37+
"params": "^1.5.6",
3838
"strict-event-emitter-types": "2.0.0",
39-
"types": "^1.5.5",
40-
"utils": "^1.5.5",
39+
"types": "^1.5.6",
40+
"utils": "^1.5.6",
4141
"ws": "8.16.0"
4242
},
4343
"devDependencies": {

packages/executor/src/modules/eth.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
estimateArbitrumPVG,
2121
ECDSA_DUMMY_SIGNATURE,
2222
estimateMantlePVG,
23+
estimateAncient8PVG,
2324
} from "params/lib";
2425
import { Logger } from "types/lib";
2526
import { PerChainMetrics } from "monitoring/lib";
@@ -62,6 +63,10 @@ export class Eth {
6263
if ([5000, 5001].includes(this.chainId)) {
6364
this.pvgEstimator = estimateMantlePVG(this.provider);
6465
}
66+
67+
if ([888888888].includes(this.chainId)) {
68+
this.pvgEstimator = estimateAncient8PVG(this.provider);
69+
}
6570
}
6671

6772
/**

packages/monitoring/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monitoring",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "The Monitoring module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
@@ -29,6 +29,6 @@
2929
},
3030
"dependencies": {
3131
"prom-client": "^14.2.0",
32-
"types": "^1.5.5"
32+
"types": "^1.5.6"
3333
}
3434
}

packages/node/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "The bundler node module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -54,24 +54,24 @@
5454
"@multiformats/multiaddr": "11.4.0",
5555
"@types/varint": "6.0.1",
5656
"abstract-leveldown": "7.2.0",
57-
"api": "^1.5.5",
57+
"api": "^1.5.6",
5858
"datastore-core": "8.0.1",
59-
"db": "^1.5.5",
59+
"db": "^1.5.6",
6060
"ethers": "5.7.2",
61-
"executor": "^1.5.5",
61+
"executor": "^1.5.6",
6262
"it-filter": "1.0.2",
6363
"it-map": "1.0.5",
6464
"it-sort": "1.0.0",
6565
"it-take": "1.0.1",
6666
"libp2p": "0.42.2",
67-
"monitoring": "^1.5.5",
68-
"params": "^1.5.5",
67+
"monitoring": "^1.5.6",
68+
"params": "^1.5.6",
6969
"snappy": "7.2.2",
7070
"snappyjs": "0.7.0",
7171
"stream-to-it": "0.2.4",
7272
"strict-event-emitter-types": "2.0.0",
73-
"types": "^1.5.5",
74-
"utils": "^1.5.5",
73+
"types": "^1.5.6",
74+
"utils": "^1.5.6",
7575
"varint": "6.0.0",
7676
"xxhash-wasm": "1.0.2"
7777
},

packages/params/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "params",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "Various bundler parameters",
55
"author": "Etherspot",
66
"homepage": "https://github.com/etherspot/skandha#readme",
@@ -26,8 +26,8 @@
2626
"@eth-optimism/sdk": "3.2.3",
2727
"@mantleio/sdk": "0.2.1",
2828
"ethers": "5.7.2",
29-
"types": "^1.5.5",
30-
"utils": "^1.5.5"
29+
"types": "^1.5.6",
30+
"utils": "^1.5.6"
3131
},
3232
"scripts": {
3333
"clean": "rm -rf lib && rm -f *.tsbuildinfo",
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { BigNumber, BigNumberish, ethers, Contract } from "ethers";
2+
import { UserOperationStruct } from "types/lib/executor/contracts/EntryPoint";
3+
import { IEntryPoint__factory } from "types/lib/executor/contracts";
4+
import { serializeTransaction } from "ethers/lib/utils";
5+
import { IPVGEstimatorWrapper, IPVGEstimator } from "../types/IPVGEstimator";
6+
7+
export const estimateAncient8PVG: IPVGEstimatorWrapper = (
8+
provider
9+
): IPVGEstimator => {
10+
const dummyWallet = ethers.Wallet.createRandom();
11+
return async (
12+
entryPointAddr: string,
13+
userOp: UserOperationStruct,
14+
initial: BigNumberish
15+
): Promise<BigNumber> => {
16+
const { chainId } = await provider.getNetwork();
17+
const latestBlock = await provider.getBlock("latest");
18+
if (latestBlock.baseFeePerGas == null) {
19+
throw new Error("no base fee");
20+
}
21+
const entryPoint = IEntryPoint__factory.connect(entryPointAddr, provider);
22+
const handleOpsData = entryPoint.interface.encodeFunctionData("handleOps", [
23+
[userOp],
24+
dummyWallet.address,
25+
]);
26+
27+
const serializedTx = serializeTransaction(
28+
{
29+
to: entryPointAddr,
30+
chainId: chainId,
31+
nonce: 999999,
32+
gasLimit: BigNumber.from(2).pow(64).sub(1), // maxUint64
33+
gasPrice: BigNumber.from(2).pow(64).sub(1), // maxUint64
34+
data: handleOpsData,
35+
},
36+
{
37+
r: "0x123451234512345123451234512345123451234512345123451234512345",
38+
s: "0x123451234512345123451234512345123451234512345123451234512345",
39+
v: 28,
40+
}
41+
);
42+
const gasOracle = new Contract(GAS_ORACLE, GasOracleABI, provider);
43+
const l1GasCost = BigNumber.from(
44+
await gasOracle.callStatic.getL1Fee(serializedTx)
45+
);
46+
const l2MaxFee = BigNumber.from(userOp.maxFeePerGas);
47+
const l2PriorityFee = latestBlock.baseFeePerGas.add(
48+
userOp.maxPriorityFeePerGas
49+
);
50+
const l2Price = l2MaxFee.lt(l2PriorityFee) ? l2MaxFee : l2PriorityFee;
51+
return l1GasCost.div(l2Price).add(initial);
52+
};
53+
};
54+
55+
const GAS_ORACLE = "0x420000000000000000000000000000000000000F";
56+
57+
const GasOracleABI = [
58+
{
59+
inputs: [{ internalType: "bytes", name: "_data", type: "bytes" }],
60+
name: "getL1Fee",
61+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
62+
stateMutability: "view",
63+
type: "function",
64+
},
65+
];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from "./arbitrum";
22
export * from "./optimism";
33
export * from "./mantle";
4+
export * from "./ancient8";

packages/types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "types",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "The types of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",

packages/utils/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "utils",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "utils of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -35,6 +35,6 @@
3535
"ethers": "5.7.2",
3636
"pino": "8.11.0",
3737
"pino-pretty": "10.0.0",
38-
"types": "^1.5.5"
38+
"types": "^1.5.6"
3939
}
4040
}

0 commit comments

Comments
 (0)