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 .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.5.2
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
branch = v4.8.2
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
[submodule "lib/aa-benchmark"]
path = lib/aa-benchmark
url = https://github.com/zerodevapp/aa-benchmark
1 change: 1 addition & 0 deletions lib/aa-benchmark
Submodule aa-benchmark added at 30fa97
2 changes: 1 addition & 1 deletion src/Kernel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ contract Kernel is EIP712, Compatibility, KernelStorage {
}
if (missingAccountFunds != 0) {
assembly {
pop(call(gas(), caller(), missingAccountFunds, 0, 0, 0, 0))
pop(call(gas(), caller(), add(missingAccountFunds,1), 0, 0, 0, 0))
}
//ignore failure (its EntryPoint's job to verify, not account.)
}
Expand Down
62 changes: 62 additions & 0 deletions test/foundry/Benchmark.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
pragma solidity ^0.8.0;

import "aa-benchmark/src/TestBase.sol";
import {Kernel,KernelStorage} from "src/Kernel.sol";
import {KernelFactory} from "src/factory/KernelFactory.sol";
import {ECDSAValidator} from "src/validator/ECDSAValidator.sol";
contract Benchmark is AAGasProfileBase {
Kernel kernelImpl;
KernelFactory factory;
ECDSAValidator validator;
address factoryOwner;

function setUp() external {
factoryOwner = address(0);
initializeTest("kernelv2_1");
factory = new KernelFactory(factoryOwner, entryPoint);
kernelImpl = new Kernel(entryPoint);
vm.startPrank(factoryOwner);
factory.setImplementation(address(kernelImpl), true);
vm.stopPrank();
validator = new ECDSAValidator();
setAccount();
}

function fillData(address _to, uint256 _value, bytes memory _data) internal override returns (bytes memory) {
return abi.encodeWithSelector(Kernel.execute.selector, _to, _value, _data, uint8(0));
}

function createAccount(address _owner) internal override {
if (address(account).code.length == 0) {
factory.createAccount(
address(kernelImpl),
abi.encodeWithSelector(KernelStorage.initialize.selector, validator, abi.encodePacked(_owner)),
0
);
}
}

function getAccountAddr(address _owner) internal override returns (IAccount) {
return IAccount(
factory.getAccountAddress(
abi.encodeWithSelector(KernelStorage.initialize.selector, validator, abi.encodePacked(_owner)), 0
)
);
}

function getInitCode(address _owner) internal override returns (bytes memory) {
return abi.encodePacked(
address(factory),
abi.encodeWithSelector(
factory.createAccount.selector,
kernelImpl,
abi.encodeWithSelector(KernelStorage.initialize.selector, validator, abi.encodePacked(_owner)),
0
)
);
}

function getSignature(UserOperation memory _op) internal override returns (bytes memory) {
return abi.encodePacked(bytes4(0x00000000), signUserOpHash(key, _op));
}
}