Skip to content

Commit

Permalink
Restructure - move plugin to separate repo (#70)
Browse files Browse the repository at this point in the history
* restructured to seprate plugins folder

* removed via-ir based plugins, todo: remove all plugins to kernel-plugins
  • Loading branch information
leekt authored Jan 22, 2024
1 parent b4e8996 commit c79d855
Show file tree
Hide file tree
Showing 28 changed files with 80 additions and 1,350 deletions.
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,3 @@
[submodule "lib/I4337"]
path = lib/I4337
url = https://github.com/leekt/I4337
[submodule "lib/p256-verifier"]
path = lib/p256-verifier
url = https://github.com/daimo-eth/p256-verifier
[submodule "lib/FreshCryptoLib"]
path = lib/FreshCryptoLib
url = https://github.com/rdubois-crypto/FreshCryptoLib
37 changes: 5 additions & 32 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,11 @@ evm_version = 'paris'
bytecode_hash = "none"
cbor_metadata = false
optimize = true
via-ir = true
via-ir = false
runs = 1000000
[fuzz]
runs = 1024

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}" }
goerli = { key = "${ETHERSCAN_API_KEY}" }
sepolia = { key = "${ETHERSCAN_API_KEY}" }

polygon = { key = "${POLYGONSCAN_API_KEY}" }
mumbai = { key = "${POLYGONSCAN_API_KEY}" }

base = { key = "${BASESCAN_API_KEY}" }
base-goerli = { key = "${BASESCAN_API_KEY}" }
base-sepolia = { key = "${BASESCAN_API_KEY}" }

arbitrum = { key = "${ARBISCAN_API_KEY}" }
arbitrum-goerli = { key = "${ARBISCAN_API_KEY}" }
arbitrum-sepolia = { key = "${ARBISCAN_API_KEY}" }

optimism = { key = "${OPTIMISMSCAN_API_KEY}" }
optimism-goerli = { key = "${OPTIMISMSCAN_API_KEY}" }
optimism-sepolia = { key = "${OPTIMISMSCAN_API_KEY}" }

avalanche = { key = "${AVALANCHE_API_KEY}" }
fuji = { key = "${AVALANCHE_API_KEY}" }

linea = { key = "${LINEASCAN_API_KEY}" }
linea-testnet = { key = "${LINEASCAN_API_KEY}" }

bsc = { key = "${BSCSCAN_API_KEY}" }
opbnb = { key = "${BSCSCAN_API_KEY}" }
[profile.deploy]
via-ir = true

# astar-testnet = { key = "${BSCSCAN_API_KEY}" }
[fuzz]
runs = 1024
1 change: 0 additions & 1 deletion lib/FreshCryptoLib
Submodule FreshCryptoLib deleted from e2830c
1 change: 0 additions & 1 deletion lib/p256-verifier
Submodule p256-verifier deleted from 29475a
5 changes: 3 additions & 2 deletions script/DeployDeterministic.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "./deterministic/Kernel2_3.s.sol";

contract DeployDeterministic is Script {
address constant DEPLOYER = 0x9775137314fE595c943712B0b336327dfa80aE8A;

function run() external {
vm.startBroadcast(DEPLOYER);
KernelFactory factory = KernelFactory(payable(FactoryDeploy.deploy()));
Expand All @@ -28,10 +29,10 @@ contract DeployDeterministic is Script {
//}

(address k23, address k23lite) = Kernel_2_3_Deploy.deploy();
if(!factory.isAllowedImplementation(k23)) {
if (!factory.isAllowedImplementation(k23)) {
factory.setImplementation(k23, true);
}
if(!factory.isAllowedImplementation(k23lite)) {
if (!factory.isAllowedImplementation(k23lite)) {
factory.setImplementation(k23lite, true);
}
vm.stopBroadcast();
Expand Down
7 changes: 4 additions & 3 deletions script/DeployECDSAValidator.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ import "src/factory/KernelFactory.sol";
import "src/validator/ECDSAValidator.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";

contract DeployKernel is Script {
address constant DEPLOYER = 0x9775137314fE595c943712B0b336327dfa80aE8A;
address constant ENTRYPOINT_0_6 = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;
address constant EXPECTED_VALIDATOR_ADDRESS = 0xd9AB5096a832b9ce79914329DAEE236f8Eea0390;

function run() public {
uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(key);
if(EXPECTED_VALIDATOR_ADDRESS.code.length == 0) {
ECDSAValidator validator = new ECDSAValidator{salt:0}();
if (EXPECTED_VALIDATOR_ADDRESS.code.length == 0) {
ECDSAValidator validator = new ECDSAValidator{salt: 0}();
console.log("validator address: %s", address(validator));
} else {
console.log("validator address: %s", EXPECTED_VALIDATOR_ADDRESS);
}
vm.stopBroadcast();
}
}

23 changes: 12 additions & 11 deletions script/DeployKernel.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,52 @@ import "src/lite/KernelLiteECDSA.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";
import "src/validator/ECDSAValidator.sol";

contract DeployKernel is Script {
address constant DEPLOYER = 0x9775137314fE595c943712B0b336327dfa80aE8A;
address constant ENTRYPOINT_0_6 = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;
address constant ECDSAVALIDATOR = 0xd9AB5096a832b9ce79914329DAEE236f8Eea0390;
address constant EXPECTED_KERNEL_ADDRESS = 0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5;
address constant EXPECTED_KERNEL_LITE_ADDRESS = 0xbEdb61Be086F3f15eE911Cc9AB3EEa945DEbFa96;
address payable constant EXPECTED_KERNEL_FACTORY_ADDRESS = payable(0x5de4839a76cf55d0c90e2061ef4386d962E15ae3);

function run() public {
uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(key);
KernelFactory factory;
if(EXPECTED_KERNEL_FACTORY_ADDRESS.code.length == 0){
factory = new KernelFactory{salt:0}(DEPLOYER, IEntryPoint(ENTRYPOINT_0_6));
if (EXPECTED_KERNEL_FACTORY_ADDRESS.code.length == 0) {
factory = new KernelFactory{salt: 0}(DEPLOYER, IEntryPoint(ENTRYPOINT_0_6));
console.log("KernelFactory address: %s", address(factory));
} else {
factory = KernelFactory(EXPECTED_KERNEL_FACTORY_ADDRESS);
}
if(EXPECTED_KERNEL_LITE_ADDRESS.code.length == 0) {
if(address(ECDSAVALIDATOR).code.length == 0) {
if (EXPECTED_KERNEL_LITE_ADDRESS.code.length == 0) {
if (address(ECDSAVALIDATOR).code.length == 0) {
console.log("ECDSAVALIDATOR NOT DEPLOYED");
} else {
KernelLiteECDSA kernellite;
kernellite = new KernelLiteECDSA{salt:0}(IEntryPoint(ENTRYPOINT_0_6), IKernelValidator(ECDSAVALIDATOR));
kernellite = new KernelLiteECDSA{salt: 0}(IEntryPoint(ENTRYPOINT_0_6), IKernelValidator(ECDSAVALIDATOR));
console.log("Kernel Lite address: %s", address(kernellite));
}
}
if(factory.isAllowedImplementation(EXPECTED_KERNEL_LITE_ADDRESS) == false) {
if (factory.isAllowedImplementation(EXPECTED_KERNEL_LITE_ADDRESS) == false) {
console.log("Registering kernellite implementation");
factory.setImplementation(EXPECTED_KERNEL_LITE_ADDRESS, true);
}
if(EXPECTED_KERNEL_ADDRESS.code.length == 0) {
if (EXPECTED_KERNEL_ADDRESS.code.length == 0) {
Kernel kernel;
kernel = new Kernel{salt:0}(IEntryPoint(ENTRYPOINT_0_6));
kernel = new Kernel{salt: 0}(IEntryPoint(ENTRYPOINT_0_6));
console.log("Kernel address: %s", address(kernel));
}
if(factory.isAllowedImplementation(EXPECTED_KERNEL_ADDRESS) == false) {
if (factory.isAllowedImplementation(EXPECTED_KERNEL_ADDRESS) == false) {
console.log("Registering kernel implementation");
factory.setImplementation(EXPECTED_KERNEL_ADDRESS, true);
}
IEntryPoint entryPoint = IEntryPoint(ENTRYPOINT_0_6);
IStakeManager.DepositInfo memory info = entryPoint.getDepositInfo(address(factory));
if(info.stake == 0) {
if (info.stake == 0) {
console.log("Need to stake to factory");
}
vm.stopBroadcast();
}
}

13 changes: 7 additions & 6 deletions script/DeployKernelInitial.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ import "src/lite/KernelLiteECDSA.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";
import "src/validator/ECDSAValidator.sol";

contract DeployKernelInitial is Script {
address constant DEPLOYER = 0x9775137314fE595c943712B0b336327dfa80aE8A;
address constant ENTRYPOINT_0_6 = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;
address constant ECDSAVALIDATOR = 0xd9AB5096a832b9ce79914329DAEE236f8Eea0390;
address payable constant EXPECTED_KERNEL_FACTORY_ADDRESS = payable(0x5de4839a76cf55d0c90e2061ef4386d962E15ae3);

function run() public {
uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(key);
KernelFactory factory;
if(EXPECTED_KERNEL_FACTORY_ADDRESS.code.length == 0){
factory = new KernelFactory{salt:0}(DEPLOYER, IEntryPoint(ENTRYPOINT_0_6));
if (EXPECTED_KERNEL_FACTORY_ADDRESS.code.length == 0) {
factory = new KernelFactory{salt: 0}(DEPLOYER, IEntryPoint(ENTRYPOINT_0_6));
console.log("KernelFactory address: %s", address(factory));
} else {
factory = KernelFactory(EXPECTED_KERNEL_FACTORY_ADDRESS);
Expand All @@ -34,18 +36,17 @@ contract DeployKernelInitial is Script {
// }
//}
Kernel kernel;
kernel = new Kernel{salt:0}(IEntryPoint(ENTRYPOINT_0_6));
kernel = new Kernel{salt: 0}(IEntryPoint(ENTRYPOINT_0_6));
console.log("Kernel address: %s", address(kernel));
if(factory.isAllowedImplementation(address(kernel)) == false) {
if (factory.isAllowedImplementation(address(kernel)) == false) {
console.log("Registering kernel implementation");
factory.setImplementation(address(kernel), true);
}
IEntryPoint entryPoint = IEntryPoint(ENTRYPOINT_0_6);
IStakeManager.DepositInfo memory info = entryPoint.getDepositInfo(address(factory));
if(info.stake == 0) {
if (info.stake == 0) {
console.log("Need to stake to factory");
}
vm.stopBroadcast();
}
}

4 changes: 2 additions & 2 deletions script/DeployKillSwitch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ contract DeployKillSwitch is Script {
KillSwitchValidator validator;
if (EXPECTED_ADDRESS_KILL_SWITCH_VALIDATOR.code.length == 0) {
console.log("deploying KillSwitchValidator");
validator = new KillSwitchValidator{salt:0}();
validator = new KillSwitchValidator{salt: 0}();
console.log("validator address: %s", address(validator));
} else {
validator = KillSwitchValidator(EXPECTED_ADDRESS_KILL_SWITCH_VALIDATOR);
console.log("validator address: %s", address(EXPECTED_ADDRESS_KILL_SWITCH_VALIDATOR));
}
if (EXPECTED_ADDRESS_KILL_SWITCH_ACTION.code.length == 0) {
console.log("deploying KillSwitchAction");
KillSwitchAction action = new KillSwitchAction{salt:0}(validator);
KillSwitchAction action = new KillSwitchAction{salt: 0}(validator);
console.log("KillSwitchAction address: %s", address(action));
} else {
console.log("KillSwitchAction address: %s", address(EXPECTED_ADDRESS_KILL_SWITCH_ACTION));
Expand Down
8 changes: 5 additions & 3 deletions script/DeployMulticall.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ contract DeployMultiCall is Script {
address constant DEPLOYER = 0x9775137314fE595c943712B0b336327dfa80aE8A;
address constant EXPECTED_MULTICALL_ADDRESS = 0x8ae01fCF7c655655fF2c6Ef907b8B4718Ab4e17c;
address constant DETERMINISTIC_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C;

function run() public {
uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(key);
if(EXPECTED_MULTICALL_ADDRESS.code.length == 0) {
(bool success, bytes memory ret) = DETERMINISTIC_DEPLOYER.call(hex"000000000000000000000000000000000000000000000000000000000000000060a060405234801561001057600080fd5b50306080526080516102bd61002f6000396000604f01526102bd6000f3fe60806040526004361061001e5760003560e01c80638d80ff0a14610023575b600080fd5b6100366100313660046101b8565b610038565b005b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163003610101576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f4d756c746953656e642073686f756c64206f6e6c792062652063616c6c65642060448201527f7669612064656c656761746563616c6c00000000000000000000000000000000606482015260840160405180910390fd5b805160205b81811015610184578083015160f81c6001820184015160601c60158301850151603584018601516055850187016000856000811461014b576001811461015b57610166565b6000808585888a5af19150610166565b6000808585895af491505b508061017157600080fd5b5050806055018501945050505050610106565b505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000602082840312156101ca57600080fd5b813567ffffffffffffffff808211156101e257600080fd5b818401915084601f8301126101f657600080fd5b81358181111561020857610208610189565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561024e5761024e610189565b8160405282815287602084870101111561026757600080fd5b82602086016020830137600092810160200192909252509594505050505056fea2646970667358221220aee0f2dd047c52784b9c7806e4078197141e146ec66587d8610576db5f8ad20e64736f6c634300080f0033");
if (EXPECTED_MULTICALL_ADDRESS.code.length == 0) {
(bool success, bytes memory ret) = DETERMINISTIC_DEPLOYER.call(
hex"000000000000000000000000000000000000000000000000000000000000000060a060405234801561001057600080fd5b50306080526080516102bd61002f6000396000604f01526102bd6000f3fe60806040526004361061001e5760003560e01c80638d80ff0a14610023575b600080fd5b6100366100313660046101b8565b610038565b005b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163003610101576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f4d756c746953656e642073686f756c64206f6e6c792062652063616c6c65642060448201527f7669612064656c656761746563616c6c00000000000000000000000000000000606482015260840160405180910390fd5b805160205b81811015610184578083015160f81c6001820184015160601c60158301850151603584018601516055850187016000856000811461014b576001811461015b57610166565b6000808585888a5af19150610166565b6000808585895af491505b508061017157600080fd5b5050806055018501945050505050610106565b505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000602082840312156101ca57600080fd5b813567ffffffffffffffff808211156101e257600080fd5b818401915084601f8301126101f657600080fd5b81358181111561020857610208610189565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561024e5761024e610189565b8160405282815287602084870101111561026757600080fd5b82602086016020830137600092810160200192909252509594505050505056fea2646970667358221220aee0f2dd047c52784b9c7806e4078197141e146ec66587d8610576db5f8ad20e64736f6c634300080f0033"
);
} else {
console.log("validator address: %s", EXPECTED_MULTICALL_ADDRESS);
}
vm.stopBroadcast();
}
}

4 changes: 2 additions & 2 deletions script/DeployRecovery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import "src/executor/RecoveryAction.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";

contract DeployRecovery is Script {
contract DeployRecovery is Script {
function run() public {
address deployer = vm.envAddress("DEPLOYER");
vm.startBroadcast(deployer);
console.log("Deployer address: ", deployer);
//RecoveryAction action = new RecoveryAction{salt:0}();
//console.log("Deploying RecoveryAction at address: ", address(action));
WeightedECDSAValidator validator = new WeightedECDSAValidator{salt:0}();
WeightedECDSAValidator validator = new WeightedECDSAValidator{salt: 0}();
console.log("Deploying WeightedECDSAValidator at address: ", address(validator));
vm.stopBroadcast();
}
Expand Down
5 changes: 3 additions & 2 deletions script/DeploySessionKey.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ pragma solidity ^0.8.0;
import "src/validator/SessionKeyValidator.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";

contract DeploySessionKey is Script {
address constant EXPECTED_ADDRESS = 0x5C06CE2b673fD5E6e56076e40DD46aB67f5a72A5;

function run() public {
address deployer = vm.envAddress("DEPLOYER");
vm.startBroadcast(deployer);
console.log("deploying SessionKeyValidator");
SessionKeyValidator validator = new SessionKeyValidator{salt:0}();
SessionKeyValidator validator = new SessionKeyValidator{salt: 0}();
console.log("validator address: %s", address(validator));
vm.stopBroadcast();
}
}

4 changes: 2 additions & 2 deletions script/DeployWeightedECDSA.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ contract DeployWeightedECDSA is Script {
vm.startBroadcast(key);
if (EXPECTED_ADDRESS_WEIGHTED_ECDSA_VALIDATOR.code.length == 0) {
console.log("deploying WeightedECDSAValidator");
WeightedECDSAValidator validator = new WeightedECDSAValidator{salt:0}();
WeightedECDSAValidator validator = new WeightedECDSAValidator{salt: 0}();
console.log("validator address: %s", address(validator));
} else {
console.log("validator address: %s", address(EXPECTED_ADDRESS_WEIGHTED_ECDSA_VALIDATOR));
}
if (EXPECTED_ADDRESS_RECOVERY_ACTION.code.length == 0) {
console.log("deploying RecoveryAction");
RecoveryAction action = new RecoveryAction{salt:0}();
RecoveryAction action = new RecoveryAction{salt: 0}();
console.log("RecoveryAction address: %s", address(action));
} else {
console.log("RecoveryAction address: %s", address(EXPECTED_ADDRESS_RECOVERY_ACTION));
Expand Down
4 changes: 3 additions & 1 deletion script/StakeToFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import "src/factory/KernelFactory.sol";
import "I4337/interfaces/IStakeManager.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";

contract StakeToFactory is Script {
address constant DEPLOYER = 0x9775137314fE595c943712B0b336327dfa80aE8A;
address constant ENTRYPOINT_0_6 = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;
address payable constant EXPECTED_KERNEL_ADDRESS = payable(0xf048AD83CB2dfd6037A43902a2A5Be04e53cd2Eb);
address payable constant EXPECTED_KERNEL_FACTORY_ADDRESS = payable(0x5de4839a76cf55d0c90e2061ef4386d962E15ae3);

function run() public {
vm.startBroadcast(DEPLOYER);
KernelFactory factory = KernelFactory(EXPECTED_KERNEL_FACTORY_ADDRESS);
IEntryPoint entryPoint = IEntryPoint(ENTRYPOINT_0_6);
IStakeManager.DepositInfo memory info = entryPoint.getDepositInfo(address(factory));
if(info.stake < 1e17) {
if (info.stake < 1e17) {
factory.addStake{value: 1e17 - info.stake}(86400);
}
vm.stopBroadcast();
Expand Down
3 changes: 2 additions & 1 deletion script/deterministic/DeterministicDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import "forge-std/console.sol";

library DeterministicDeploy {
address constant DETERMINISTIC_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C;

function checkDeploy(string memory tag, address _expectedAddress, bytes memory _code) internal {
if(_expectedAddress.code.length == 0) {
if (_expectedAddress.code.length == 0) {
(bool success, bytes memory addr) = DETERMINISTIC_DEPLOYER.call(_code);
require(success, "DeterministicDeploy: failed to deploy");
require(address(bytes20(addr)) == _expectedAddress, "DeterministicDeploy: address mismatch");
Expand Down
Loading

0 comments on commit c79d855

Please sign in to comment.