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

add missing test cases for signatures checks #362

Merged
merged 4 commits into from
Nov 25, 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
15 changes: 11 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contracts/lib/account-abstraction"]
path = contracts/lib/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
branch = releases/v0.6
[submodule "contracts/lib/openzeppelin-contracts"]
path = contracts/lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "contracts/lib/bulk"]
path = contracts/lib/bulk
url = https://github.com/daimo-eth/bulk
[submodule "contracts/lib/account-abstraction-v6"]
path = contracts/lib/account-abstraction-v6
url = https://github.com/eth-infinitism/account-abstraction
branch = releases/v0.6
[submodule "contracts/lib/account-abstraction-v7"]
path = contracts/lib/account-abstraction-v7
url = https://github.com/eth-infinitism/account-abstraction
branch = releases/v0.7
[submodule "contracts/lib/solady"]
path = contracts/lib/solady
url = https://github.com/vectorized/solady
22 changes: 13 additions & 9 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ libs = ["lib"]
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

remappings = [
'forge-std/=lib/forge-std/src/',
'ds-test/=lib/forge-std/lib/ds-test/src/',
'account-abstraction/=lib/account-abstraction/contracts/',
'@openzeppelin/=lib/openzeppelin-contracts/',
'@openzeppelin/contracts/=lib/bulk/lib/openzeppelin-contracts/contracts/',
'bulk/=lib/bulk/',
'erc4626-tests/=lib/bulk/lib/p256-verifier/lib/openzeppelin-contracts/lib/erc4626-tests/',
'openzeppelin-contracts/=lib/bulk/lib/openzeppelin-contracts/',
'p256-verifier/=lib/bulk/lib/p256-verifier/',
"forge-std/=lib/forge-std/src/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@openzeppelin/contracts/=lib/bulk/lib/openzeppelin-contracts/contracts/",
"bulk/=lib/bulk/",
"erc4626-tests/=lib/bulk/lib/p256-verifier/lib/openzeppelin-contracts/lib/erc4626-tests/",
"openzeppelin-contracts/=lib/bulk/lib/openzeppelin-contracts/",
"p256-verifier/=lib/bulk/lib/p256-verifier/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"solady/=lib/solady/src/",
"account-abstraction/=lib/account-abstraction-v6/contracts/",
"account-abstraction-v7/=lib/account-abstraction-v7/contracts/",
"account-abstraction-v6/=lib/account-abstraction-v6/contracts/"
]
1 change: 1 addition & 0 deletions contracts/lib/account-abstraction-v7
Submodule account-abstraction-v7 added at abff2a
1 change: 1 addition & 0 deletions contracts/lib/bulk
Submodule bulk added at f56b52
1 change: 1 addition & 0 deletions contracts/lib/solady
Submodule solady added at 1dd896
2 changes: 1 addition & 1 deletion contracts/src/Compression/PerOpInflator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.8;
import "bulk/src/IInflator.sol";
import "bulk/src/IOpInflator.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "account-abstraction/interfaces/IEntryPoint.sol";
import "account-abstraction-v6/interfaces/IEntryPoint.sol";
import "./IBeneficiarySetter.sol";

/// Inflates a bundle containing n ops, each with their own inflator specified.
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/Compression/SimpleInflator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8;
pragma abicoder v2;

import "bulk/src/IOpInflator.sol";
import {LibZip} from "solady/src/utils/LibZip.sol";
import {LibZip} from "solady/utils/LibZip.sol";

contract SimpleInflator is IOpInflator {
function inflate(bytes calldata compressed) external pure override returns (UserOperation memory op) {
Expand Down
14 changes: 4 additions & 10 deletions contracts/src/ExecuteSimulator.sol
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "@account-abstraction/core/EntryPoint.sol";
import "account-abstraction-v6/core/EntryPoint.sol";

contract ExecuteSimulator is EntryPoint {
error CallExecuteResult(bool success, bytes data, uint256 gasUsed);

function callExecute(
address sender,
bytes calldata callData,
uint256 gas
) external {
function callExecute(address sender, bytes calldata callData, uint256 gas) external {
require(msg.sender == 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789);
uint256 initialGas = gasleft();
(bool success, bytes memory returnData) = sender.call{gas: gas}(
callData
);
uint gasUsed = initialGas - gasleft();
(bool success, bytes memory returnData) = sender.call{gas: gas}(callData);
uint256 gasUsed = initialGas - gasleft();
bytes memory data = success ? bytes("") : returnData;
revert CallExecuteResult(success, data, gasUsed);
}
Expand Down
35 changes: 35 additions & 0 deletions contracts/src/TestUtils/paymasterV06.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;

import {UserOperation} from "account-abstraction-v6/interfaces/UserOperation.sol";
import {_packValidationData} from "account-abstraction-v6/core/Helpers.sol";
import {IPaymaster} from "account-abstraction-v6/interfaces/IPaymaster.sol";
import {IEntryPoint} from "account-abstraction-v6/interfaces/IEntryPoint.sol";

contract TestPaymasterV06 is IPaymaster {
IEntryPoint public immutable entryPoint;

constructor(IEntryPoint _entryPoint) {
entryPoint = _entryPoint;
}

function deposit() public payable {
entryPoint.depositTo{value: msg.value}(address(this));
}

function validatePaymasterUserOp(
UserOperation calldata userOp,
bytes32, /*userOpHash*/
uint256 /*requiredPreFund*/
) public pure override returns (bytes memory context, uint256 validationData) {
// Return false if there are paymasterData bytes (this allows us to test failing conditions).
if (userOp.paymasterAndData.length > 20) {
return ("", _packValidationData(true, 0, 0));
}

// By default sponsor all userOperations.
return ("", _packValidationData(false, 0, 0));
}

function postOp(PostOpMode, bytes calldata, uint256) public {}
}
37 changes: 37 additions & 0 deletions contracts/src/TestUtils/paymasterV07.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "account-abstraction-v7/core/UserOperationLib.sol";
import "account-abstraction-v7/core/Helpers.sol";
import {IPaymaster} from "account-abstraction-v7/interfaces/IPaymaster.sol";
import {IEntryPoint} from "account-abstraction-v7/interfaces/IEntryPoint.sol";

contract TestPaymasterV07 is IPaymaster {
using UserOperationLib for PackedUserOperation;

IEntryPoint public immutable entryPoint;

constructor(IEntryPoint _entryPoint) {
entryPoint = _entryPoint;
}

function deposit() public payable {
entryPoint.depositTo{value: msg.value}(address(this));
}

function validatePaymasterUserOp(
PackedUserOperation calldata userOp,
bytes32, /*userOpHash*/
uint256 /*requiredPreFund*/
) public view override returns (bytes memory context, uint256 validationData) {
// Return false if there are paymasterData bytes (this allows us to test failing conditions).
if (userOp.paymasterAndData.length > (20 + 16 + 16)) {
return ("", _packValidationData(true, 0, 0));
}

// By default sponsor all userOperations.
return ("", _packValidationData(false, 0, 0));
}

function postOp(PostOpMode, bytes calldata, uint256, uint256) external {}
}
Loading
Loading