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

feat: aa51 validation rule #151

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 .github/workflows/bundler-spec-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: eth-infinitism/bundler-spec-tests
ref: f01eb0f44287b981a953a742a42bcd6a719c8812
ref: 85f39e8d86afe616b885c1498e29dd71c5108a70
path: ./bundler-spec-tests
submodules: true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ export class ClassicRelayer extends BaseRelayer {
} else {
await relayer
.sendTransaction(transaction)
.then((response) => {
this.logger.debug(`Bundle submitted: ${response.hash}`);
})
.catch((err: any) => this.handleUserOpFail(entries, err));
await this.mempoolService.removeAll(entries);
}
Expand Down
13 changes: 13 additions & 0 deletions packages/executor/src/services/UserOpValidation/validators/safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ export class SafeValidationService {
}
}

const verificationCost = BigNumber.from(returnInfo.preOpGas).sub(
userOp.preVerificationGas
);
const extraGas = BigNumber.from(userOp.verificationGasLimit)
.sub(verificationCost)
.toNumber();
if (extraGas < 2000) {
throw new RpcError(
`verificationGas should have extra 2000 gas. has only ${extraGas}`,
RpcErrorCodes.VALIDATION_FAILED
);
}

let hash = "",
addresses: string[] = [];
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { IEntryPoint__factory } from "types/lib/executor/contracts";
import { UserOperationStruct } from "types/lib/executor/contracts/EntryPoint";
import { providers } from "ethers";
import { BigNumber, providers } from "ethers";
import { Logger } from "types/lib";
import * as RpcErrorCodes from "types/lib/api/errors/rpc-error-codes";
import RpcError from "types/lib/api/errors/rpc-error";
import { NetworkConfig, UserOpValidationResult } from "../../../interfaces";
import { nonGethErrorHandler, parseErrorResult } from "../utils";

Expand All @@ -26,6 +28,23 @@ export class UnsafeValidationService {
gasLimit: validationGasLimit,
})
.catch((e: any) => nonGethErrorHandler(entryPointContract, e));
return parseErrorResult(userOp, errorResult);
const validationResult = parseErrorResult(userOp, errorResult);

const { returnInfo } = validationResult;

const verificationCost = BigNumber.from(returnInfo.preOpGas).sub(
userOp.preVerificationGas
);
const extraGas = BigNumber.from(userOp.verificationGasLimit)
.sub(verificationCost)
.toNumber();
if (extraGas < 2000) {
throw new RpcError(
`verificationGas should have extra 2000 gas. has only ${extraGas}`,
RpcErrorCodes.VALIDATION_FAILED
);
}

return validationResult;
}
}
Loading