Skip to content
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
4 changes: 3 additions & 1 deletion src/modules/batcher/batcher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Logger } from "@/core/logger";
import { ExecutorService } from "@/executor";
import { gasEstimatorConfig } from "@/gas-estimator/gas-estimator.config";
import { SimulatorService } from "@/simulator";
import { StorageService } from "@/storage";
import { DEFAULT_GLOBAL_EXPIRATION_TIME, StorageService } from "@/storage";
import {
type MeeUserOpBatch,
getOverrideOrDefault,
Expand Down Expand Up @@ -144,6 +144,8 @@ export class BatcherService {
meeUserOpHash,
"error",
"Invalid maxGasLimit",
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);

continue;
Expand Down
13 changes: 9 additions & 4 deletions src/modules/entry-point/entry-point.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ContractsService } from "@/contracts";
import { Logger } from "@/core/logger";
import { NodeService } from "@/node";
import { RpcManagerService } from "@/rpc-manager";
import { StorageService } from "@/storage";
import { DEFAULT_GLOBAL_EXPIRATION_TIME, StorageService } from "@/storage";
import {
type EIP7702Auth,
type PackedUserOp,
Expand Down Expand Up @@ -672,9 +672,14 @@ export class EntryPointService {

if (options.useStorage) {
// Update error in background for improved latency
this.storageService.updateUserOpCustomFields(meeUserOpHash, {
revertReason: sanitizeUrl(errorMessage),
});
this.storageService.updateUserOpCustomFields(
meeUserOpHash,
{
revertReason: sanitizeUrl(errorMessage),
},
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
}

// If there is no retries left and err exists, it will return true with error
Expand Down
78 changes: 52 additions & 26 deletions src/modules/executor/executor.processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { NODE_ACCOUNT_TOKEN, type NodeAccount } from "@/node";
import { NonceManagerService } from "@/nonce-manager";
import { RpcManagerService } from "@/rpc-manager";
import { trackSimulationTransactionData } from "@/simulator/utils";
import { StorageService } from "@/storage";
import { DEFAULT_GLOBAL_EXPIRATION_TIME, StorageService } from "@/storage";
import {
type EIP7702Auth,
type SignedPackedMeeUserOp,
Expand Down Expand Up @@ -196,6 +196,8 @@ export class ExecutorProcessor implements Processor<ExecutorJob> {
// meeUserOpHash,
// "batchHash",
// batchHash,
// // 15 days expiration
// { ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
// ),
// {
// chainId,
Expand Down Expand Up @@ -263,6 +265,8 @@ export class ExecutorProcessor implements Processor<ExecutorJob> {
executionStartedAt: currentTime,
executionFinishedAt: currentTime,
},
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
}),
).catch((error) => {
Expand Down Expand Up @@ -337,6 +341,8 @@ export class ExecutorProcessor implements Processor<ExecutorJob> {
meeUserOpHash,
"executionStartedAt",
currentTime,
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);

meeUserOpHashes.push(meeUserOpHash);
Expand Down Expand Up @@ -585,10 +591,14 @@ export class ExecutorProcessor implements Processor<ExecutorJob> {
if (isLastExecutionAttempt) {
for (const meeUserOp of meeUserOps) {
const { meeUserOpHash } = meeUserOp;
this.storageService.updateUserOpCustomFields(meeUserOpHash, {
error: sanitizeUrl(errorMessage),
executionFinishedAt: Date.now(),
});
this.storageService.updateUserOpCustomFields(
meeUserOpHash,
{
error: sanitizeUrl(errorMessage),
executionFinishedAt: Date.now(),
}, // 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);

// Tracking in background to improve latency
trackSimulationTransactionData(meeUserOp);
Expand Down Expand Up @@ -1212,14 +1222,18 @@ export class ExecutorProcessor implements Processor<ExecutorJob> {
for (const { meeUserOpHash } of meeUserOps) {
// Update storage in background to improve latency
// TODO: Add redis transaction later
this.storageService.updateUserOpCustomFields(meeUserOpHash, {
txHash,
isConfirmed,
confirmations: isConfirmed
? BigInt(this.chainsService.chainSettings.waitConfirmations)
: 1n,
executionFinishedAt: Date.now(),
});
this.storageService.updateUserOpCustomFields(
meeUserOpHash,
{
txHash,
isConfirmed,
confirmations: isConfirmed
? BigInt(this.chainsService.chainSettings.waitConfirmations)
: 1n,
executionFinishedAt: Date.now(),
}, // 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
}
} else {
const events = parseEventLogs({
Expand Down Expand Up @@ -1264,6 +1278,8 @@ export class ExecutorProcessor implements Processor<ExecutorJob> {
error: "UserOperation reverted",
}),
},
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);

if (!success) {
Expand Down Expand Up @@ -1310,15 +1326,19 @@ export class ExecutorProcessor implements Processor<ExecutorJob> {
);

// Update storage in background to improve latency
this.storageService.updateUserOpCustomFields(meeUserOpHash, {
txHash,
isConfirmed,
confirmations: isConfirmed
? BigInt(this.chainsService.chainSettings.waitConfirmations)
: 1n,
executionFinishedAt: Date.now(),
error: "Failed to execute userOp",
});
this.storageService.updateUserOpCustomFields(
meeUserOpHash,
{
txHash,
isConfirmed,
confirmations: isConfirmed
? BigInt(this.chainsService.chainSettings.waitConfirmations)
: 1n,
executionFinishedAt: Date.now(),
error: "Failed to execute userOp",
}, // 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
}
}

Expand All @@ -1338,6 +1358,8 @@ export class ExecutorProcessor implements Processor<ExecutorJob> {
assetTransfers,
},
},
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
}
}
Expand Down Expand Up @@ -1649,10 +1671,14 @@ export class ExecutorProcessor implements Processor<ExecutorJob> {
// Reverted userOps is marked as failure for explorer
for (const { meeUserOpHash } of invalidMeeUserOps) {
// Redis is updated in background to achieve minimal latency
this.storageService.updateUserOpCustomFields(meeUserOpHash, {
error: "UserOperation reverted",
executionFinishedAt: Date.now(),
});
this.storageService.updateUserOpCustomFields(
meeUserOpHash,
{
error: "UserOperation reverted",
executionFinishedAt: Date.now(),
}, // 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
}

this.logger.trace(
Expand Down
20 changes: 15 additions & 5 deletions src/modules/quotes/quotes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
SimulationService,
SimulatorService,
} from "@/simulator";
import { StorageService } from "@/storage";
import { DEFAULT_GLOBAL_EXPIRATION_TIME, StorageService } from "@/storage";
import {
type SignedPackedMeeUserOp,
UserOpService,
Expand Down Expand Up @@ -1492,10 +1492,14 @@ export class QuotesService {
}

await withTrace("exec.createQuote", async () => {
return await this.storageService.createQuote({
...options,
userOps: signedPackedMeeUserOps,
});
return await this.storageService.createQuote(
{
...options,
userOps: signedPackedMeeUserOps,
},
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
})();

// grouping the userOps based on chainIds
Expand Down Expand Up @@ -1560,6 +1564,8 @@ export class QuotesService {
isConfirmed: true,
isExecutionSkipped: true,
},
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
}

Expand Down Expand Up @@ -1714,6 +1720,8 @@ export class QuotesService {
{
confirmations,
},
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
} catch (error) {
txReceiptError.isError = true;
Expand All @@ -1736,6 +1744,8 @@ export class QuotesService {
{
error: errorMessage,
},
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/quotes/utils/calculate-orchestration-fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function calculateOrchestrationFee(
chainsCount: 0,
isComposable: false,
totalWindowSize: 0,
totalOrchestrationFee: 0.01, // fixed 1c orch fee; leaving impl below for future reference.
totalOrchestrationFee: 0.0, // Orch fees is set to zero for now
};
/** ORIGINAL IMPLEMENTATION */
// try {
Expand Down
24 changes: 19 additions & 5 deletions src/modules/simulator/simulator.processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { Logger } from "@/core/logger";
import { type Processor, UnrecoverableError } from "@/core/queue";
import { type AccountValidationData, EntryPointService } from "@/entry-point";
import { StorageService } from "@/storage";
import { DEFAULT_GLOBAL_EXPIRATION_TIME, StorageService } from "@/storage";
import { USEROP_SAFE_WINDOW_BEFORE_EXEC_END } from "@/user-ops/userop.config";
import { Service } from "typedi";
import { type SimulatorJob } from "./interfaces";
Expand Down Expand Up @@ -41,6 +41,8 @@ export class SimulatorProcessor implements Processor<SimulatorJob> {
meeUserOpHash,
"simulationStartedAt",
Date.now(),
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);

let accountValidationData: AccountValidationData;
Expand Down Expand Up @@ -119,6 +121,8 @@ export class SimulatorProcessor implements Processor<SimulatorJob> {
sanitizeUrl(
(err as Error).message || "UserOp simulation validation failed",
),
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);

// Tracking in background to improve latency
Expand Down Expand Up @@ -147,6 +151,8 @@ export class SimulatorProcessor implements Processor<SimulatorJob> {
meeUserOpHash,
"error",
"Invalid signature",
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);

// Tracking in background to improve latency
Expand Down Expand Up @@ -199,6 +205,8 @@ export class SimulatorProcessor implements Processor<SimulatorJob> {
meeUserOpHash,
"error",
"Execution deadline limit exceeded",
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);

// Tracking in background to improve latency
Expand Down Expand Up @@ -311,6 +319,8 @@ export class SimulatorProcessor implements Processor<SimulatorJob> {
meeUserOpHash,
"error",
"Execution deadline limit exceeded",
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);

// Tracking in background to improve latency
Expand Down Expand Up @@ -365,10 +375,14 @@ export class SimulatorProcessor implements Processor<SimulatorJob> {
}

// Updating userOp in background to improve latency
this.storageService.updateUserOpCustomFields(meeUserOpHash, {
simulationAttempts,
simulationFinishedAt: Date.now(),
});
this.storageService.updateUserOpCustomFields(
meeUserOpHash,
{
simulationAttempts,
simulationFinishedAt: Date.now(),
}, // 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);

this.logger.trace(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StorageService } from "@/storage";
import { DEFAULT_GLOBAL_EXPIRATION_TIME, StorageService } from "@/storage";
import { SignedPackedMeeUserOp } from "@/user-ops";
import Container from "typedi";
import { getUserOpTransactionData } from "./get-simulation-transaction-data";
Expand All @@ -17,5 +17,7 @@ export const trackSimulationTransactionData = async (
meeUserOpHash,
"simulationTransactionData",
txData,
// 15 days expiration
{ ttl: DEFAULT_GLOBAL_EXPIRATION_TIME },
);
};
2 changes: 2 additions & 0 deletions src/modules/storage/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 15 days
export const DEFAULT_GLOBAL_EXPIRATION_TIME = 60 * 60 * 24 * 15;
1 change: 1 addition & 0 deletions src/modules/storage/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./storage.service";
export * from "./constants";
Loading
Loading