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

WIP: ⚗️ Adding a validator benchmark contract #75

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
Open
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: 2 additions & 0 deletions .env.exemple
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Is benchmark write result allowed?
WRITE_BENCHMARK_RESULT=true
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
[submodule "lib/forge-gas-metering"]
path = lib/forge-gas-metering
url = https://github.com/emo-eth/forge-gas-metering
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cbor_metadata = false
optimize = true
via-ir = false
runs = 1000000
fs_permissions = [{ access = "read-write", path = "./gas"}]

[profile.deploy]
via-ir = true
Expand Down
18 changes: 18 additions & 0 deletions gas/validator/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"global": {
"disable": 0,
"enable": 0,
"fullDeployment": 0
},
"signature": {
"ko_viaKernel": 0,
"ko_viaValidator": 0,
"viaKernel": 0,
"viaValidator": 0
},
"userOp": {
"viaEntryPoint": 0,
"validationViaKernel": 0,
"validationViaValidator": 0
}
}
18 changes: 18 additions & 0 deletions gas/validator/mainnet_ECDSA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"global": {
"disable": 2418,
"enable": 44714,
"fullDeployment": 24858
},
"signature": {
"ko_viaKernel": 40973,
"ko_viaValidator": 31224,
"viaKernel": 40953,
"viaValidator": 31214
},
"userOp": {
"viaEntryPoint": 192331,
"validationViaKernel": 43195,
"validationViaValidator": 31543
}
}
18 changes: 18 additions & 0 deletions gas/validator/mainnet_FclWebAuthN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"global": {
"disable": 115792089237316195423570985008687907853269984665640564039457584007913129622417,
"enable": 64936,
"fullDeployment": 25514
},
"signature": {
"ko_viaKernel": 428301,
"ko_viaValidator": 412774,
"viaKernel": 425055,
"viaValidator": 408794
},
"userOp": {
"viaEntryPoint": 576427,
"validationViaKernel": 427216,
"validationViaValidator": 414308
}
}
1 change: 0 additions & 1 deletion index.ts

This file was deleted.

1 change: 1 addition & 0 deletions lib/forge-gas-metering
Submodule forge-gas-metering added at 37d9f8
3 changes: 2 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
solady/=lib/solady/src/
FreshCryptoLib/=lib/FreshCryptoLib/solidity/src/
FreshCryptoLib/=lib/FreshCryptoLib/solidity/src/
gas-metering/=lib/forge-gas-metering/src/
9 changes: 9 additions & 0 deletions src/utils/ERC4337Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {IEntryPoint} from "I4337/interfaces/IEntryPoint.sol";
import {UserOperation} from "I4337/interfaces/UserOperation.sol";
import "solady/utils/ECDSA.sol";
import {Vm} from "forge-std/Test.sol";
import {Kernel} from "../Kernel.sol";

library ERC4337Utils {
function test() public {}
Expand Down Expand Up @@ -68,4 +69,12 @@ library ERC4337Utils {

return keccak256(abi.encode(typeHash, hashedName, hashedVersion, block.chainid, address(verifyingContract)));
}

/// @dev Returns the EIP-712 domain separator for the given kernel account.
function getDomainSeparator(Kernel kernel) internal view returns (bytes32 domainSeparator) {
// Extract a few infos from the kernel
(, string memory name, string memory version,,,,) = kernel.eip712Domain();
// Build the domain separator
domainSeparator = _buildDomainSeparator(name, version, address(kernel));
}
}
5 changes: 3 additions & 2 deletions src/utils/KernelTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {TestERC721} from "../mock/TestERC721.sol";
import {TestERC1155} from "../mock/TestERC1155.sol";

using ERC4337Utils for IEntryPoint;
using ERC4337Utils for Kernel;

abstract contract KernelTestBase is Test {
// to support 0.8.19
Expand Down Expand Up @@ -201,7 +202,7 @@ abstract contract KernelTestBase is Test {
bytes32 hash = ECDSA.toEthSignedMessageHash(bytes(message));
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01", ERC4337Utils._buildDomainSeparator(KERNEL_NAME, KERNEL_VERSION, address(kernel)), hash
"\x19\x01", ERC4337Utils.getDomainSeparator(kernel), hash
)
);
bytes memory sig = signHash(digest);
Expand Down Expand Up @@ -455,7 +456,7 @@ abstract contract KernelTestBase is Test {
return keccak256(
abi.encodePacked(
"\x19\x01",
ERC4337Utils._buildDomainSeparator(KERNEL_NAME, KERNEL_VERSION, address(kernel)),
kernel.getDomainSeparator(),
ERC4337Utils.getStructHash(sig, validUntil, validAfter, validator, executor, enableData)
)
);
Expand Down
Loading
Loading