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

Ep7 p2p #225

Merged
merged 4 commits into from
Aug 1, 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
32 changes: 17 additions & 15 deletions P2P.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
2. run `yarn deploy --network localhost`

We should have deployments in the following addresses.
- Entrypoint addr: 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789
- SimpleAccountFactory addr: 0x9406Cc6185a346906296840746125a0E44976454
- SimpleAccount addr: 0xbba97eC4fFF328d485382DfD5A9bf9653c6018Af // sample address, deployed address could be different
- Entrypoint addr: 0x9b5d240EF1bc8B4930346599cDDFfBD7d7D56db9
- SimpleAccountFactory addr: 0xE759fdEAC26252feFd31a044493154ABDd709344
- Private key: 0x23398902aa812ba66ad424cd4793aa758e9805795927ec3fdbcc80f5bb6c9ba1
- SimpleAccount addr: 0x786D081d3e156c8B7c26229C899228DE53EB9a5e

### Top up account

Expand All @@ -23,7 +24,8 @@ go to docker console
```
Inside geth terminal
```
> eth.sendTransaction({ from: eth.accounts[0], to: "0xbba97eC4fFF328d485382DfD5A9bf9653c6018Af", value: 1000000000000000000 })
> eth.sendTransaction({ from: eth.accounts[0], to: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", value: 1000000000000000000 })
> eth.sendTransaction({ from: eth.accounts[0], to: "0x786D081d3e156c8B7c26229C899228DE53EB9a5e", value: 1000000000000000000 })
```

### Modify the
Expand All @@ -35,17 +37,17 @@ Inside geth terminal
Example:
```
{
"sender":"0xbba97eC4fFF328d485382DfD5A9bf9653c6018Af",
"nonce":"0x0",
"initCode":"0x9406cc6185a346906296840746125a0e449764545fbfb9cf00000000000000000000000005449b55b91e9ebdd099ed584cb6357234f2ab3b0000000000000000000000000000000000000000000000000000000000000000",
"callData":"0xb61d27f60000000000000000000000009406cc6185a346906296840746125a0e4497645400000000000000000000000000000000000000000000000000000000000f424000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000",
"callGasLimit":"0x5568",
"verificationGasLimit":"0x5ea0c",
"preVerificationGas":"0xb820",
"maxFeePerGas":"0x4ac312de",
"maxPriorityFeePerGas":"0xed2ba9a",
"paymasterAndData":"0x",
"signature":"0xecdc2665d72b04bf133e39a3849d3eedc4913550d17f839eda442db2ea175e906750b860ba0e3ac1d3de068c2e16183a1e430f77fae2ec94e44298083576033e1c"
"sender": "0x786D081d3e156c8B7c26229C899228DE53EB9a5e",
"nonce": "0x0",
"factory": "0xE759fdEAC26252feFd31a044493154ABDd709344",
"factoryData": "0x5fbfb9cf00000000000000000000000043372949942c4828e6ce0edf53f4205aa27bcddb0000000000000000000000000000000000000000000000000000000000000000",
"callData": "0xb61d27f600000000000000000000000043372949942c4828e6ce0edf53f4205aa27bcddb00000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000",
"callGasLimit": "0xdcb4",
"verificationGasLimit": "0x481da",
"preVerificationGas": "0xa378",
"maxFeePerGas": "0x173a244bc6",
"maxPriorityFeePerGas": "0x171ad0e500",
"signature": "0x05bbd6102a8cbcf376d01afeb7f8b96fbdcb9b344699c7b98b8de8f2d7c5803613b395b9b8cad66a64ef69133f1d0ff17a5edf72a021c1de3b69921756ece0291b"
}
```

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": "2.0.9",
"version": "2.0.10",
"stream": "true",
"command": {
"version": {
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": "2.0.9",
"version": "2.0.10",
"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": "^2.0.9",
"@skandha/monitoring": "^2.0.9",
"@skandha/types": "^2.0.9",
"@skandha/utils": "^2.0.9",
"@skandha/executor": "^2.0.10",
"@skandha/monitoring": "^2.0.10",
"@skandha/types": "^2.0.10",
"@skandha/utils": "^2.0.10",
"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": "2.0.9",
"version": "2.0.10",
"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": "^2.0.9",
"@skandha/db": "^2.0.9",
"@skandha/executor": "^2.0.9",
"@skandha/monitoring": "^2.0.9",
"@skandha/node": "^2.0.9",
"@skandha/types": "^2.0.9",
"@skandha/api": "^2.0.10",
"@skandha/db": "^2.0.10",
"@skandha/executor": "^2.0.10",
"@skandha/monitoring": "^2.0.10",
"@skandha/node": "^2.0.10",
"@skandha/types": "^2.0.10",
"find-up": "5.0.0",
"got": "12.5.3",
"js-yaml": "4.1.0",
Expand Down
138 changes: 74 additions & 64 deletions packages/cli/src/cmds/node/handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import { Config } from "@skandha/executor/lib/config";
import { Namespace, getNamespaceByValue, RocksDbController } from "@skandha/db/lib";
import {
Namespace,
getNamespaceByValue,
RocksDbController,
} from "@skandha/db/lib";
import { NetworkConfig } from "@skandha/executor/lib/interfaces";
import { BundlerNode, IBundlerNodeOptions, defaultOptions } from "@skandha/node/lib";
import {
BundlerNode,
IBundlerNodeOptions,
defaultOptions,
} from "@skandha/node/lib";
import { initNetworkOptions } from "@skandha/node/lib";
import logger from "@skandha/api/lib/logger";
import { ExecutorOptions, ApiOptions, P2POptions } from "@skandha/types/lib/options";
import {
ExecutorOptions,
ApiOptions,
P2POptions,
} from "@skandha/types/lib/options";
import { MetricsOptions } from "@skandha/types/lib/options/metrics";
import { IGlobalArgs } from "../../options";
import { mkdir, readFile } from "../../util";
Expand All @@ -16,76 +28,74 @@ export async function nodeHandler(args: IGlobalArgs): Promise<void> {
logger.info(" (o o) (o o) ");
logger.info("( V ) Skandha - A modular typescript bundler ( V )");
logger.info("--m-m--------------------------------------------m-m--");
logger.info("P2P is not yet available for EntryPoint v7. Stay tuned");
return;

// const params = await getNodeConfigFromArgs(args);
const params = await getNodeConfigFromArgs(args);

// //create the necessary directories
// mkdir(params.dataDir);
//create the necessary directories
mkdir(params.dataDir);

// logger.info(`Using the configFile from ${params.configFile}`);
// logger.info(`Initialised the dataDir at ${params.dataDir}`);
// logger.info("Boot ENR: " + params.p2p["bootEnrs"].length);
logger.info(`Using the configFile from ${params.configFile}`);
logger.info(`Initialised the dataDir at ${params.dataDir}`);
logger.info("Boot ENR: " + params.p2p["bootEnrs"].length);

// let config: Config;
// try {
// const networkConfig = readFile(params.configFile) as NetworkConfig;
// config = await Config.init({
// config: networkConfig,
// testingMode: params.testingMode,
// unsafeMode: params.unsafeMode,
// redirectRpc: params.redirectRpc,
// });
// } catch (err) {
// if (err instanceof Error && err.message.indexOf("chain id") > -1) {
// logger.error(err.message);
// return;
// }
// logger.info("Config file not found. Proceeding with env vars...");
// config = await Config.init({
// config: null,
// testingMode: params.testingMode,
// unsafeMode: params.unsafeMode,
// redirectRpc: params.redirectRpc,
// });
// }
let config: Config;
try {
const networkConfig = readFile(params.configFile) as NetworkConfig;
config = await Config.init({
config: networkConfig,
testingMode: params.testingMode,
unsafeMode: params.unsafeMode,
redirectRpc: params.redirectRpc,
});
} catch (err) {
if (err instanceof Error && err.message.indexOf("chain id") > -1) {
logger.error(err.message);
return;
}
logger.info("Config file not found. Proceeding with env vars...");
config = await Config.init({
config: null,
testingMode: params.testingMode,
unsafeMode: params.unsafeMode,
redirectRpc: params.redirectRpc,
});
}

// const db = new RocksDbController(
// params.dataDir,
// getNamespaceByValue(Namespace.userOps)
// );
// await db.start();
const db = new RocksDbController(
params.dataDir,
getNamespaceByValue(Namespace.userOps)
);
await db.start();

// const { enr, peerId } = await initPeerIdAndEnr(args, logger);
const { enr, peerId } = await initPeerIdAndEnr(args, logger);

// const options: IBundlerNodeOptions = {
// ...defaultOptions,
// api: {
// port: params.api["port"],
// address: params.api["address"],
// cors: params.api["cors"],
// enableRequestLogging: params.api["enableRequestLogging"],
// ws: params.api["ws"],
// wsPort: params.api["wsPort"],
// },
// network: initNetworkOptions(enr, params.p2p, params.dataDir),
// };
const options: IBundlerNodeOptions = {
...defaultOptions,
api: {
port: params.api["port"],
address: params.api["address"],
cors: params.api["cors"],
enableRequestLogging: params.api["enableRequestLogging"],
ws: params.api["ws"],
wsPort: params.api["wsPort"],
},
network: initNetworkOptions(enr, params.p2p, params.dataDir),
};

// const version = getVersionData();
// const node = await BundlerNode.init({
// nodeOptions: options,
// relayersConfig: config,
// relayerDb: db,
// testingMode: params.testingMode,
// redirectRpc: params.redirectRpc,
// bundlingMode: params.executor.bundlingMode,
// peerId,
// metricsOptions: params.metrics,
// version,
// });
const version = getVersionData();
const node = await BundlerNode.init({
nodeOptions: options,
relayersConfig: config,
relayerDb: db,
testingMode: params.testingMode,
redirectRpc: params.redirectRpc,
bundlingMode: params.executor.bundlingMode,
peerId,
metricsOptions: params.metrics,
version,
});

// await node.start();
await node.start();
}

export async function getNodeConfigFromArgs(args: IGlobalArgs): Promise<{
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": "2.0.9",
"version": "2.0.10",
"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": "^2.0.9"
"@skandha/types": "^2.0.10"
},
"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": "2.0.9",
"version": "2.0.10",
"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": "^2.0.9",
"@skandha/params": "^2.0.9",
"@skandha/types": "^2.0.9",
"@skandha/utils": "^2.0.9",
"@skandha/monitoring": "^2.0.10",
"@skandha/params": "^2.0.10",
"@skandha/types": "^2.0.10",
"@skandha/utils": "^2.0.10",
"async-mutex": "0.4.0",
"ethers": "5.7.2",
"strict-event-emitter-types": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/executor/src/modules/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class Eth {
try {
if (
this.entryPointService.getEntryPointVersion(entryPoint) ===
EntryPointVersion.SIX
EntryPointVersion.SEVEN
) {
const nodeApi = this.getNodeAPI();
if (nodeApi) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
PackedUserOperation,
UserOperation,
} from "@skandha/types/lib/contracts/UserOperation";
import { AddressZero, BytesZero } from "@skandha/params/lib";
import { AddressZero } from "@skandha/params/lib";
import { StakeManager__factory } from "@skandha/types/lib/contracts/EPv7/factories/core";
import { IEntryPointSimulations } from "@skandha/types/lib/contracts/EPv7/interfaces";
import { IEntryPointSimulations__factory } from "@skandha/types/lib/contracts/EPv7/factories/interfaces";
Expand Down
20 changes: 9 additions & 11 deletions packages/executor/src/services/P2PService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserOperationStruct } from "@skandha/types/lib/contracts/EPv6/EntryPoint";
import { UserOperation } from "@skandha/types/lib/contracts/UserOperation";
import { MempoolService } from "./MempoolService";
import { EntryPointService } from "./EntryPointService";
import { EntryPointVersion } from "./EntryPointService/interfaces";
Expand All @@ -8,7 +8,7 @@ export type PooledUserOpHashesResponse = {
hashes: string[];
};

export type PooledUseropsByHashResponse = UserOperationStruct[];
export type PooledUseropsByHashResponse = UserOperation[];

export class P2PService {
constructor(
Expand All @@ -33,37 +33,35 @@ export class P2PService {
};
}

async getPooledUserOpsByHash(
hashes: string[]
): Promise<UserOperationStruct[]> {
async getPooledUserOpsByHash(hashes: string[]): Promise<UserOperation[]> {
const userOps = [];
for (const hash of hashes) {
const entry = await this.mempoolService.getEntryByHash(hash);
if (
entry &&
this.entryPointService.getEntryPointVersion(entry.entryPoint) ===
EntryPointVersion.SIX
EntryPointVersion.SEVEN
) {
userOps.push(entry.userOp as UserOperationStruct);
userOps.push(entry.userOp as UserOperation);
}
}
return userOps;
}

async userOpByHash(hash: string): Promise<UserOperationStruct | null> {
async userOpByHash(hash: string): Promise<UserOperation | null> {
const entry = await this.mempoolService.getEntryByHash(hash);
if (
entry &&
this.entryPointService.getEntryPointVersion(entry.entryPoint) ===
EntryPointVersion.SIX
EntryPointVersion.SEVEN
) {
return entry.userOp as UserOperationStruct;
return entry.userOp as UserOperation;
}
return null;
}

async isNewOrReplacingUserOp(
userOp: UserOperationStruct,
userOp: UserOperation,
entryPoint: string
): Promise<boolean> {
try {
Expand Down
Loading
Loading