Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
3617f83
chore: forge init
leekt Feb 14, 2025
460f329
forge install: forge-std
leekt Feb 14, 2025
4472974
removed counter
leekt May 1, 2025
335eb4f
temp - install module signature
leekt May 12, 2025
788512a
execution manager done
leekt May 16, 2025
23c3017
Execution done
leekt May 21, 2025
784bf62
removed coverage
leekt May 21, 2025
bb98f28
removed lcov
leekt May 21, 2025
f923659
updated gitignore
leekt May 21, 2025
f71d3e3
fmt
leekt May 21, 2025
5344bb4
temporary validator for validateUserOp
leekt May 21, 2025
5affa76
fmt with 1.2
leekt May 21, 2025
d4737c6
module test cases
leekt May 23, 2025
828fa8f
userop test case
leekt May 23, 2025
a9fe29a
uninstall policy/signer
leekt May 27, 2025
3023d7e
preparing execute with signature
leekt May 27, 2025
8a4d14a
no more via ir
leekt May 27, 2025
44c35f6
instalAndExecute
leekt May 27, 2025
3f8acd8
install and execute
leekt May 27, 2025
5b6bf04
test done with factory, todo:7702 and ecdsa
leekt May 27, 2025
a449911
updated readme to show coverage command
leekt May 27, 2025
fb541da
erc7579 helper functions done
leekt May 27, 2025
8ceebf0
fmt
leekt May 27, 2025
4a82d11
fix: typehash for individual hash
leekt May 28, 2025
47c5c91
fix kernel helper same hash
leekt May 28, 2025
7200ea5
todo: working on 7702
leekt May 28, 2025
965ca65
7702 tested
leekt May 28, 2025
a7b95ff
erc1271 flow tested
leekt May 28, 2025
a76e494
personal sign done
leekt May 28, 2025
d8c959c
fmt
leekt May 28, 2025
611b1d0
erc1271 tests
leekt May 28, 2025
c63e35b
fmt
leekt May 28, 2025
8504a5f
erc1271 replayable
leekt May 28, 2025
1c36237
readme update
leekt May 28, 2025
60fe5e5
feat: added nonce invalidation feature
leekt May 28, 2025
a3f2838
fmt
leekt May 28, 2025
4262e35
removed unused functions
leekt May 28, 2025
f82f3ae
left comment
leekt May 28, 2025
d833b24
optimizing
leekt May 29, 2025
7ec15c0
nonce setting
leekt Jun 13, 2025
92c73be
signature fixes on tests
leekt Jul 8, 2025
41d507d
updated replayable sig
leekt Jul 31, 2025
6520b70
step for adding validation hook support
leekt Jul 31, 2025
f4c3fc4
validation hook
leekt Jul 31, 2025
0bd6517
updated
leekt Jul 31, 2025
6956820
Merge pull request #1 from zerodevapp/feat/replayable_sig
leekt Aug 6, 2025
19c971a
remote push
leekt Aug 7, 2025
13d202c
ecdsa optimized impl
leekt Aug 7, 2025
89779fe
updated to get implementation as args
leekt Aug 7, 2025
9a81b95
check
leekt Aug 8, 2025
e50a846
Merge pull request #2 from zerodevapp/feat/optimized_imple
leekt Aug 8, 2025
1013f04
fix: use isModuleInstalled properly
leekt Aug 14, 2025
4b7c389
fmt
leekt Aug 14, 2025
b85e195
Merge pull request #3 from zerodevapp/feat/optimized_imple
leekt Aug 14, 2025
b8e5837
fix: use proper boolean
leekt Aug 14, 2025
0dd219a
Merge pull request #4 from zerodevapp/feat/optimized_imple
leekt Aug 14, 2025
e1c51b2
test: added erc1271 for 7702
leekt Sep 24, 2025
2a2a6a7
separated kernel test base
leekt Sep 24, 2025
3971eee
kernel hook test
leekt Sep 25, 2025
077af47
lint
leekt Sep 25, 2025
47d3119
fmt
leekt Sep 25, 2025
89dd160
Merge pull request #8 from zerodevapp/refactor/test_separate_files
leekt Sep 25, 2025
c2a1786
Merge pull request #5 from zerodevapp/test/add_erc1271_7702
leekt Sep 25, 2025
ef3cfe2
fmt
leekt Sep 29, 2025
a8e064a
temp: remove mock contract eth
leekt Oct 6, 2025
b11d1e7
fix: renamed MockContractEth to MockContractETH
leekt Oct 6, 2025
a8cec2c
fix: initializer in kernel uups
leekt Sep 29, 2025
4557481
fmt
leekt Sep 29, 2025
3937389
test: added initialize revert test
leekt Sep 29, 2025
041bb87
fix: removed meaningless codes
leekt Oct 6, 2025
a220cf9
code separation done
leekt Sep 29, 2025
2ab6a13
fmt
leekt Sep 29, 2025
14f6aad
fix: batchcall return data checks
leekt Oct 2, 2025
c1d6ccb
fix: do not allow bytes20(0) on setRoot
leekt Sep 25, 2025
7750c81
fix: remove validationId check from setRoot
leekt Oct 6, 2025
5695f19
fix: setRoot with package reverts if vId == 0
leekt Oct 6, 2025
960943c
fix: different path for implementation with fallback and
leekt Oct 6, 2025
8b3e9f2
fix: append msg.sender to fallback call
leekt Sep 25, 2025
ec30499
fix: map transient storage slot for hooks
leekt Sep 24, 2025
3a35cba
fmt
leekt Oct 6, 2025
5425179
Merge pull request #6 from zerodevapp/fix/hook_mapping
leekt Oct 14, 2025
9c455aa
Merge pull request #9 from zerodevapp/fix/TOB-KERNELV4-11
leekt Oct 14, 2025
1fedb88
Merge pull request #10 from zerodevapp/fix/TOB-KERNELV4-8
leekt Oct 14, 2025
563a991
Merge branch 'master' into fix/TOB-KERNELV4-13
leekt Oct 14, 2025
23feac4
Merge pull request #11 from zerodevapp/fix/TOB-KERNELV4-13
leekt Oct 14, 2025
4f22e42
Merge branch 'master' into fix/TOB-KERNELV4-14
leekt Oct 14, 2025
69e12fb
remove initializer
leekt Oct 14, 2025
75e788b
fix
leekt Oct 14, 2025
e850e7a
fix: signer cannot be address(0)
leekt Sep 25, 2025
ddfae9d
Merge pull request #17 from zerodevapp/fix/TOB-KERNELV4-14
leekt Oct 14, 2025
73a61ed
fix: return false on moduleTypeId 0
leekt Sep 29, 2025
36654aa
Merge pull request #13 from zerodevapp/fix/TOB-KERNELV4-03
leekt Oct 14, 2025
35f65fe
fix: removed install and execute
leekt Sep 30, 2025
7f55374
fix: check if executor is installed when executeFromExecutor is called
leekt Sep 30, 2025
eff6542
fmt
leekt Sep 30, 2025
ff20f6c
fix: added back the invalidSigner error
leekt Oct 14, 2025
dcec72e
Merge pull request #15 from zerodevapp/fix/TOB-KERNELV4-09-12
leekt Oct 14, 2025
a3e7872
Merge pull request #18 from zerodevapp/fix/TOB-KERNELV4-6
leekt Oct 14, 2025
a691aad
feat: setRoot to allow installing and removing previous root validator
leekt Sep 24, 2025
a4213c2
fmt
leekt Sep 24, 2025
6b490e6
merged
leekt Sep 25, 2025
f646dec
feat: add explicit setRoot(validationId)
leekt Oct 14, 2025
ffe4d58
Merge pull request #7 from zerodevapp/feat/setRoot_install_packages
leekt Oct 14, 2025
b6e1ee4
bytes21 attempt1
leekt Oct 14, 2025
f67e36c
feat: removed vType from storage
leekt Oct 14, 2025
6e3a5f5
update: use vId 21 bytes as kernel v3
leekt Oct 15, 2025
59deb90
make functions payable
leekt Oct 15, 2025
52265ac
fmt
leekt Oct 15, 2025
e4431db
feat: staker
leekt Oct 15, 2025
5ee7a26
Merge pull request #20 from zerodevapp/feat/factory_staker
leekt Oct 15, 2025
da94f9a
Merge pull request #19 from zerodevapp/feat/vId_21bytes
leekt Oct 15, 2025
6e3273d
added simple account comparison data
leekt Oct 16, 2025
cdf738b
feat: hook use check
leekt Oct 17, 2025
fed6ddd
forge-std in soldeer
leekt Oct 17, 2025
a80d181
forge-std remapping
leekt Oct 17, 2025
8999222
test erc1271
leekt Oct 17, 2025
776fe04
erc1271 test done
leekt Oct 17, 2025
83d6e32
erc1271 test renamed
leekt Oct 17, 2025
ea57984
using via_ir false
leekt Oct 17, 2025
413aa41
optimial run = 7500
leekt Oct 17, 2025
053797e
Merge pull request #21 from zerodevapp/test/add_simpleaccount_compare
leekt Oct 17, 2025
fa6a1bd
Merge pull request #22 from zerodevapp/feat/hook_execution_check
leekt Oct 17, 2025
40b0ff6
Merge pull request #24 from zerodevapp/feat/raw_erc1271
leekt Oct 17, 2025
7a578c2
Feat/enablemode signature (#25)
leekt Oct 20, 2025
a5029ae
Test/cleanup (#26)
leekt Oct 21, 2025
25e51e1
removed checkInitialized
leekt Oct 21, 2025
216b034
changelog (#27)
leekt Nov 6, 2025
b0edee2
ep v9 support (#28)
leekt Nov 10, 2025
abf2b60
fix: LIFO for setRoot (#31)
leekt Feb 3, 2026
c3ec2b1
fix: added nonce to prevent signature replay (#29)
leekt Feb 3, 2026
8705be4
Remove `deployWithCall` variants (#33)
leekt Feb 3, 2026
f164bc7
fix: policy does not accept hook/selector info when being installed a…
leekt Feb 3, 2026
9d820af
fix: _checkNonce reverts (#39)
leekt Feb 3, 2026
20cce05
fix: signature bypass update (#30)
leekt Feb 3, 2026
de0f834
used nonce to clear out the validator (#35)
leekt Feb 3, 2026
023da85
fix: root cannot be uninstalled, test_uninstall_policy will be fixed …
leekt Feb 3, 2026
36db289
chore: update foundry solidity runs to lower the contract size
leekt Feb 3, 2026
5fbfcaa
fix: _setRoot to check vType (#38)
leekt Feb 3, 2026
d4a0df3
fix: forward the msg.value to factory (#34)
leekt Feb 3, 2026
a836274
fix: intersectValidationData to not override the aggregator (#32)
leekt Feb 4, 2026
560f15d
v0.4.0 release (#50)
leekt Apr 26, 2026
3779635
chore: remove ep 0.8 (#51)
leekt Jun 15, 2026
3ec9fcd
fix: audit batch 1 - 3 HIGH / 1 MEDIUM / 3 LOW (kernel side) (#54)
leekt Jun 18, 2026
5bd75a5
chore: stitch kernel v3 dev history into release/v4 for mergeability
leekt Jun 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
271 changes: 0 additions & 271 deletions .gas-snapshot

This file was deleted.

90 changes: 28 additions & 62 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,43 @@
name: ci
name: CI

on:
pull_request:
branches: [dev,fix/ci]
paths:
- '**.sol'
- '**.yml'
push:
branches: [dev,fix/ci]
paths:
- '**.sol'
- '**.yml'
jobs:
tests:
name: Forge Testing
runs-on: ubuntu-latest
env:
FOUNDRY_DISABLE_NIGHTLY_WARNING: true
pull_request:
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
matrix:
profile: [post-prague,post-prague-via-ir,via-ir,min-solc,min-solc-via-ir]
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install Dependencies
run: forge install

- name: show list
run: ls
- name: Show Forge version
run: |
forge --version

- name : pwd
run: pwd
- name: Run Forge fmt
run: |
forge fmt --check
id: fmt

- name: Run Tests with ${{ matrix.profile }}
run: >
( [ "${{ matrix.profile }}" = "post-prague" ] &&
forge test --use 0.8.28 --evm-version "prague"
) ||
( [ "${{ matrix.profile }}" = "post-prague-via-ir" ] &&
forge test --use 0.8.28 --evm-version "prague" --via-ir
) ||
( [ "${{ matrix.profile }}" = "via-ir" ] &&
forge test --via-ir
) ||
( [ "${{ matrix.profile }}" = "min-solc" ] &&
forge fmt --check &&
forge test --use 0.8.28
) ||
( [ "${{ matrix.profile }}" = "min-solc-via-ir" ] &&
forge test --use 0.8.28 --via-ir
)

codespell:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- name: Run Forge build
run: |
forge build --sizes --skip MockKernel
id: build

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run codespell
uses: codespell-project/actions-codespell@v2.0
with:
check_filenames: true
ignore_words_list: usera
skip: ./.git,package-lock.json,ackee-blockchain-solady-report.pdf,EIP712Mock.sol,yarn.lock
- name: Run Forge tests
run: |
forge test -vvv
id: test
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@ log/
.envrc

**/.DS_Store

# Certora
.certora_internal/
.certora_recent_jobs.json
.last_confs/

# Kontrol
.kontrol/

# Claude Code local state
.claude/

# FV research scratch
audit/formal-verification-research.html
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/ExcessivelySafeCall"]
path = lib/ExcessivelySafeCall
url = https://github.com/nomad-xyz/ExcessivelySafeCall
32 changes: 0 additions & 32 deletions .npmignore

This file was deleted.

173 changes: 173 additions & 0 deletions CHANGELOG_AUDIT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Kernel v4 Audit Changelog

**Commit Range:** `ff20f6c` to `3e72921` (HEAD)
**Date Range:** October 14, 2025 - November 6, 2025
**Files Changed:** 21 files in `src/` (+625, -500 lines)

---

## Added Features

### EntryPoint v0.9 Support
Added support for ERC-4337 EntryPoint version 0.9.
- Updated account-abstraction dependency from v0.8.0 to v0.9.0 (branch: release-v09)
- Updated EntryPoint deployment bytecode constant in test utilities
- Modified test suite to include `vm.startPrank(beneficiary, beneficiary)` calls before `ep.handleOps()` for v0.9 compatibility
- Updated remappings to support both v0.8.0 and v0.9.0 dependencies
- Gas snapshot updates reflecting v0.9 optimizations (reduced gas costs across all test scenarios)
- **Breaking Change:** UserOperation hash calculation has been changed in EntryPoint v0.9
- **Files:** `foundry.toml`, `remappings.txt`, `soldeer.lock`, `test/utils/EntryPointLib.sol`, `test/KernelUserOpTest.sol`, `test/KernelValidatorTest.sol`
- **EntryPoint Address:** `0x43370900c8de573dB349BEd8DD53b4Ebd3Cce709`
- **Commits:** 977ca07, aa91ef1, 110c7af, 3e72921
- **Note:** The module type ID was updated from 8 to 10 for `MODULE_TYPE_STATELESS_VALIDATOR_WITH_SENDER` as part of this upgrade
- you can find the release docs in [here](https://docs.google.com/document/d/1RKkKZsP1eYkOoBEkzJ1vWRK_bcWXaewoGPzawMjsleM/edit?usp=drivesdk), please do note that this document is not in public yet

### Staker Contract (`src/Staker.sol`) - NEW
Factory staking management contract for ERC-4337 EntryPoint compliance.
- Factory approval whitelist (owner-controlled or EIP-712 signature-based)
- EntryPoint stake/unstake/withdraw functions
- `deployWithFactory()` - Deploy accounts through approved factories
- `approveFactory()` - Owner approves/disapproves factory
- `approveFactoryWithSignature()` - EIP-712 signature-based approval (chain-agnostic)
- **Commits:** e4431db, 52265ac
- **PR:** #20

### Enable Mode Signature Support
Added support for installing modules via signature in UserOp flow (enable mode).
- Allows users to install validators/modules atomically with their first UserOp
- Uses `EnableModeSignature` struct containing: nonce, packages to install, enable signature, and userOp signature
- EIP-712 signature verification with nonce replay protection
- Nonce is checked and incremented to prevent replay attacks
- **Files:** `src/Kernel.sol` (validateUserOp), `src/core/ModuleManager.sol`
- **Commits:** 7a578c2
- **PR:** #25

### Root Validator Replacement
New `setRoot()` overload allows replacing root validator with automatic cleanup of previous root.
- **Function:** `setRoot(Install[] calldata pkg, bool removeCurrent, bytes calldata uninstallData)`
- Supports uninstalling validators and permissions (including policies and signers)
- Calls `onUninstall()` on removed modules
- **Commits:** a691aad, f646dec, ffe4d58
- **PR:** #7

### Validator/Permission Management Functions
New internal functions for module lifecycle management:
- `_uninstallValidator()` - Uninstall validator with ValidationInfo cleanup
- `_uninstallPolicyWithVid()` - Remove policy from specific permission
- `_uninstallSignerWithVid()` - Remove signer from specific permission
- **Files:** `src/core/ModuleManager.sol`, `src/core/ValidationManager.sol`
- **Commits:** a691aad

### ValidationId Utility Functions
Helper functions for ValidationId type extraction and creation in `lib/Utils.sol`:
- `parseNonce()` - Extract validation mode, type, and ID from nonce (moved from ValidationManager)
- `getType()` - Extract validation type from ValidationId
- `getValidator()` - Extract validator address from ValidationId
- `validatorToIdentifier()` - Create ValidationId from validator address
- `permissionToIdentifier()` - Create ValidationId from PermissionId
- `isPermissionType()` - Check if validation type is permission variant
- `calldataKeccak()` - Efficient calldata hashing for EIP-712
- **Commits:** 5ee7a26, b6e1ee4, f67e36c, 6e3a5f5
- **PR:** #19

### ERC-1271 Raw Hash Signing
Support for raw hash signing in EIP-7702 accounts (without EIP-712 wrapping).
- **Hook:** `_erc1271RawAllowed()` - Override to enable raw signing
- Enabled by default in `Kernel7702` contract
- **Files:** `src/Kernel7702.sol`, `src/lib/ERC1271.sol`
- **Commits:** 40b0ff6, 83d6e32, 776fe04, 8999222
- **PR:** #24

---

## Changed Features

### ValidationId Encoding (BREAKING CHANGE)
ValidationId changed from 20 bytes to 21 bytes to embed validation type in first byte.
- **Before:** `bytes20` (address only)
- **After:** `bytes21` (1 byte type + 20 bytes address/permissionId)
- **Encoding:** Byte 0 = ValidationType (ROOT=0, VALIDATOR=1, PERMISSION=2), Bytes 1-21 = address/permissionId
- **Impact:** Type checking no longer requires storage reads, eliminates `vType` field from ValidationInfo struct
- **Migration:** Use `validatorToIdentifier()` and `permissionToIdentifier()` utility functions
- **Storage Optimization:** Removed `vType` field from ValidationInfo struct
- **Commits:** 5ee7a26, b6e1ee4, f67e36c, 6e3a5f5
- **PR:** #19

### Initialization Pattern Refactor
- `Kernel.initialize()` is now `virtual` and `payable` - implementation moved to derived contracts
- `KernelUUPS.initialize()` has `initializer` modifier and properly initializes in constructor
- `KernelUUPS` constructor calls `_disableInitializers()` to prevent implementation initialization
- `Kernel7702.initialize()` is NO-OP (stateless accounts don't need initialization)
- `KernelImmutableECDSA._initialize()` removed `initializer` modifier (protection at UUPS level)
- **Files:** `src/Kernel.sol`, `src/KernelUUPS.sol`, `src/Kernel7702.sol`, `src/KernelImmutableECDSA.sol`
- **Commits:** 75e788b, 69e12fb, 041bb87, a8cec2c
- **PR:** #17

### Factory Deployment Protection
Factory now checks if account is already deployed before calling initialize.
- Prevents re-initialization of already deployed accounts
- **Files:** `src/KernelFactory.sol`
- **Functions:** `deployImmutableECDSA()`, `deployImmutableECDSAWithExtraCall()`
- **Commits:** 75e788b
- **PR:** #17

### Factory Salt Calculation Optimization
Optimized to use `EfficientHashLib` instead of `keccak256(abi.encode())`.
- **File:** `src/KernelFactory.sol`
- **Function:** `_calculateSalt()` - NEW internal function using EfficientHashLib
- **Commits:** e4431db

### Executor Authorization Check
Added installation verification in `executeFromExecutor()` flow via `executorHook` modifier.
- **Change:** Added `require(address(hook) != address(0), Unauthorized())` in `executorHook` modifier
- Prevents uninstalled executors from executing transactions
- **File:** `src/core/ModuleManager.sol`
- **Commits:** 7f55374, eff6542, dcec72e
- **PR:** #18

### Module Type Validation
`supportsModule()` now returns false for moduleTypeId == 0 (invalid/undefined type).
- **File:** `src/Kernel.sol`
- **Commits:** 73a61ed
- **PR:** #13

### Enable Mode Nonce Replay Protection
Added nonce check and increment in `validateUserOp()` enable mode flow.
- **Change:** Added `_checkAndIncrementNonce(sig.nonce)` after signature verification
- Prevents signature replay attacks
- **File:** `src/Kernel.sol`
- **Commits:** 7a578c2
- **PR:** #25

### Hook Validation Logic Enhancement
Optimized hook validation check in UserOp flow.
- **Change:** Reordered conditional logic for gas optimization (root or hookless paths first)
- **File:** `src/Kernel.sol`
- **Commits:** fa6a1bd, cdf738b
- **PR:** #22

### Signature Verification Optimization
Use `ECDSA.tryRecoverCalldata()` instead of `ECDSA.tryRecover()` when signature is in calldata.
- **Files:** `src/KernelImmutableECDSA.sol`, `src/Kernel7702.sol`
- **Impact:** Gas savings for signature verification

### Access Control Modifier Optimization
Changed `_onlyEntryPointOrSelf()` and `_authorizeUpgrade()` to `view` functions.
- Prevents accidental state changes in authorization checks
- **Files:** `src/Kernel.sol`, `src/KernelUUPS.sol`

---

## Removed Features

### KernelHelper.sol - DELETED
EIP-712 digest generation moved inline to `ModuleManager.sol`.
- Reduces external dependencies
- Functions moved: `installDigest()`, `_installHash()`, `_hashTypedData()`, `_hashTypedDataSansChainId()`
- Now implemented as internal functions in ModuleManager

### Removed Functions
- `ExecutorManager.installAndExecute()` - Removed unused and potentially dangerous function
- `KernelImmutableECDSA._statelessInitializeCheck()` - Removed unused hook
- `KernelImmutableECDSA` EthSign prefix handling - Simplified to use only standard ECDSA recovery
- **Commits:** 35f65fe
33 changes: 0 additions & 33 deletions CLAUDE.md

This file was deleted.

7 changes: 0 additions & 7 deletions LICENSE.txt

This file was deleted.

Loading
Loading