Skip to content

Commit

Permalink
Merge pull request #717 from bcnmy/feature/new-ep-v07
Browse files Browse the repository at this point in the history
Feature/new ep v07
  • Loading branch information
veljkovranic authored Oct 14, 2024
2 parents e4bfa49 + 0a3adf3 commit 6a715e7
Show file tree
Hide file tree
Showing 62 changed files with 5,333 additions and 194 deletions.
23 changes: 22 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
5003, 100, 10200, 195, 196, 2810, 997, 713715, 3799, 167009, 80084, 5845,
167000, 1328, 1329, 995, 28882, 288, 1802203764, 1740, 1750, 4202, 1135
],
"supportedNetworksV07": [
84532, 8453
],
"EIP1559SupportedNetworks": [
1, 137, 42161, 10, 43114, 43113, 8453, 59140, 59144, 204, 5611, 421614,
11155111, 84532, 168587773, 80085, 81457, 42170, 169, 56400, 11155420,
Expand Down Expand Up @@ -129,6 +132,12 @@
"url": "https://rpc.ankr.com/blast_testnet_sepolia/0f2ac70eb2e86d935951e9d3874deeb44525123a1ce2a7cf609cf1f0a098d2d6",
"type": "private"
}
],
"84532": [
{
"url": "https://sepolia.base.org",
"type": "public"
}
]
},
"currency": {
Expand Down Expand Up @@ -1001,6 +1010,11 @@
"supportedChainIds": [88888, 88882]
}
},
"entryPointV07Data": {
"0x0000000071727De22E5E9d8BAf0edAc6f37da032": {
"supportedChainIds": [84532, 8453]
}
},
"zeroAddress": "0x0000000000000000000000000000000000000000",
"l2Networks": [42161, 42170],
"polygonZKEvmNetworks": [1101, 2442, 195, 196],
Expand Down Expand Up @@ -1096,5 +1110,12 @@
}
},
"disableFeeValidation": [],
"adminAddresses": []
"adminAddresses": [],
"hardcodedGasLimits": {
"84532": {
"verificationGasLimit": 2000000,
"callGasLimit": 2000000,
"preVerificationGas": 45000000
}
}
}
5 changes: 5 additions & 0 deletions k8s/relayer/values.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ affinity_tolerations:
key: "app"
values: "relayer-server"

# make sure pods are deployed in different nodes
affinity:
antiAffinity:
topologyKey: "kubernetes.io/hostname"

secret_encrypted:
projectID: biconomy-staging
key: sdk-staging-relayer-node-service
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"crypto-js": "^4.1.1",
"dd-trace": "^4.17.0",
"dotenv": "^16.0.3",
"entry-point-gas-estimations": "0.0.26",
"entry-point-gas-estimations": "1.0.2",
"ethereumjs-util": "^7.1.5",
"express": "^4.18.2",
"express-handlebars": "^6.0.6",
Expand Down
99 changes: 99 additions & 0 deletions src/common/db/dao/UserOperationV07DAO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import {
FinalUserOperationDataType,
IUserOperationV07DAO,
InitialUserOperationV07DataType,
} from "../interface";
import { IUserOperationV07, Mongo } from "../mongo";

export class UserOperationV07DAO implements IUserOperationV07DAO {
private _db: Mongo;

constructor() {
this._db = Mongo.getInstance();
}

async save(
chainId: number,
userOperationData: InitialUserOperationV07DataType,
): Promise<void> {
await this._db.getUserOperationV07(chainId).insertMany([userOperationData]);
}

async getUserOperationsDataByApiKey(
chainId: number,
apiKey: string,
startTime: number,
endTime: number,
limit: number,
offSet: number,
): Promise<Array<IUserOperationV07>> {
const data = await this._db
.getUserOperationV07(chainId)
.aggregate([
{
$match: {
$and: [
{ "metaData.apiKey": apiKey },
{ creationTime: { $gte: startTime } },
{ creationTime: { $lte: endTime } },
],
},
},
])
.skip(offSet)
.limit(limit);
return data;
}

async getUserOperationDataByUserOpHash(
chainId: number,
userOpHash: string,
): Promise<IUserOperationV07 | null> {
const data = await this._db
.getUserOperationV07(chainId)
.findOne({ userOpHash });
return data;
}

async updateUserOpDataToDatabaseByTransactionIdAndUserOpHash(
chainId: number,
transactionId: string,
userOpHash: string,
userOperationData: FinalUserOperationDataType,
): Promise<void> {
await this._db.getUserOperationV07(chainId).updateOne(
{
transactionId,
userOpHash,
},
userOperationData,
);
}

async getUserOpsByTransactionId(
chainId: number,
transactionId: string,
): Promise<IUserOperationV07[]> {
const data = await this._db
.getUserOperationV07(chainId)
.find({
transactionId,
})
.sort({ _id: -1 })
.lean();
return data;
}

async getUserOperationsCountByApiKey(
chainId: number,
apiKey: string,
startTime: number,
endTime: number,
): Promise<number> {
const data = await this._db.getUserOperationV07(chainId).count({
"metaData.apiKey": apiKey,
creationTime: { $gte: startTime, $lte: endTime },
});
return data;
}
}
1 change: 1 addition & 0 deletions src/common/db/dao/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./TransactionDAO";
export * from "./UserOperationDAO";
export * from "./UserOperationStateDAO";
export * from "./UserOperationV07DAO";
4 changes: 2 additions & 2 deletions src/common/db/interface/IUserOperationDAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ export type InitialUserOperationDataType = {
dappAPIKey?: string;
entryPoint: string;
sender: string;
nonce: number;
initCode: string;
nonce: number;
callData: string;
callGasLimit: number;
verificationGasLimit: number;
preVerificationGas: number;
maxFeePerGas: number;
maxPriorityFeePerGas: number;
paymasterAndData: string;
signature: string;
userOpHash: string;
chainId: number;
status: string;
paymaster: string;
paymasterAndData: string;
creationTime: number;
metaData?: object;
};
Expand Down
75 changes: 75 additions & 0 deletions src/common/db/interface/IUserOperationV07DAO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { IUserOperationV07 } from "../mongo/interface";

export type InitialUserOperationV07DataType = {
transactionId: string;
apiKey?: string;
entryPoint: string;
sender: string;
nonce: number;
callData: string;
callGasLimit: number;
verificationGasLimit: number;
preVerificationGas: number;
maxFeePerGas: number;
maxPriorityFeePerGas: number;
signature: string;
userOpHash: string;
chainId: number;
status: string;
paymaster: string;
paymasterVerificationGasLimit: number;
paymasterPostOpGasLimit: number;
factory: string;
factoryData: string;
paymasterData: string;
creationTime: number;
metaData?: object;
};

export type FinalUserOperationV07DataType = {
transactionHash?: string;
receipt: object;
status: string;
success: string;
blockNumber: number;
blockHash: string;
actualGasCost: number;
actualGasUsed: number;
reason: string;
logs: any;
};

export interface IUserOperationV07DAO {
save(
chainId: number,
initialUserOperationData: InitialUserOperationV07DataType,
): Promise<void>;
getUserOperationDataByUserOpHash(
chainId: number,
userOpHash: string,
): Promise<IUserOperationV07 | null>;
updateUserOpDataToDatabaseByTransactionIdAndUserOpHash(
chainId: number,
userOpHash: string,
transactionId: string,
initialUserOperationData: FinalUserOperationV07DataType,
): Promise<void>;
getUserOpsByTransactionId(
chainId: number,
transactionId: string,
): Promise<IUserOperationV07[]>;
getUserOperationsDataByApiKey(
chainId: number,
apiKey: string,
startTime: number,
endTime: number,
limit: number,
offSet: number,
): Promise<Array<IUserOperationV07>>;
getUserOperationsCountByApiKey(
chainId: number,
apiKey: string,
startTime: number,
endTime: number,
): Promise<number>;
}
1 change: 1 addition & 0 deletions src/common/db/interface/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./IDBService";
export * from "./ITransactionDAO";
export * from "./IUserOperationDAO";
export * from "./IUserOperationV07DAO";
export * from "./IUserOperationStateDAO";
20 changes: 18 additions & 2 deletions src/common/db/mongo/Mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
UserOperationsMapType,
UserOperationsStateMap,
UserOperationsStateMapType,
UserOperationsV07Map,
UserOperationsV07MapType,
} from "./models";

const log = logger.child({
Expand Down Expand Up @@ -103,7 +105,7 @@ export class Mongo implements IDBService {
.map(([key, value]) => `${key}_${value}`)
.join("_");

log.info(`Compund index key name ${compoundIndexKeyTwo}`);
log.info(`Compound index key name ${compoundIndexKeyTwo}`);
const compoundIndexExistsTwo = indexes.some(
(index: any) => index.name === compoundIndexKeyTwo,
);
Expand Down Expand Up @@ -147,7 +149,6 @@ export class Mongo implements IDBService {
dbName: "relayer-node-service",
});
}
log.info("Connected to db");
} catch (error) {
log.error("error while connecting to mongo db");
log.error(error);
Expand Down Expand Up @@ -186,6 +187,21 @@ export class Mongo implements IDBService {
return UserOperationsMap[networkId];
}

/**
* Method returns user operation model for a given chain id
* @param networkId
* @returns user operation model for a given chain id
*/
getUserOperationV07(networkId: number): UserOperationsV07MapType[number] {
if (!this.client) {
throw new Error("Not connected to db");
}
const supportedNetworksV07: number[] = config.supportedNetworksV07 || [];
if (!supportedNetworksV07.includes(networkId))
throw new Error(`Network Id ${networkId} is not supported`);
return UserOperationsV07Map[networkId];
}

/**
* Method returns user operation state model for a given chain id
* @param networkId
Expand Down
31 changes: 31 additions & 0 deletions src/common/db/mongo/interface/IUserOperationV07.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export interface IUserOperationV07 {
transactionId: string;
transactionHash: string;
entryPoint: string;
sender: string;
nonce: number;
factory: string;
factoryData: string;
callData: string;
callGasLimit: number;
verificationGasLimit: number;
preVerificationGas: number;
maxFeePerGas: number;
maxPriorityFeePerGas: number;
signature: string;
userOpHash: string;
receipt: object;
chainId: number;
status: string;
success: string;
blockNumber: number;
blockHash: string;
paymaster: string;
actualGasCost: number;
actualGasUsed: number;
reason: string;
logs: object;
creationTime: number;
metaData: object;
apiKey: string;
}
1 change: 1 addition & 0 deletions src/common/db/mongo/interface/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./IBlockchainTransaction";
export * from "./IUserOperation";
export * from "./IUserOperationState";
export * from "./IUserOperationV07";
Loading

0 comments on commit 6a715e7

Please sign in to comment.