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
40 changes: 40 additions & 0 deletions scripts/DeployDeterministic.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
pragma solidity ^0.8.0;

import "src/factory/KernelFactory.sol";
import "forge-std/Script.sol";

import "./deterministic/ECDSAValidator.s.sol";
import "./deterministic/Factory.s.sol";
import "./deterministic/SessionKey.s.sol";
import "./deterministic/Kernel2_2.s.sol";
import "./deterministic/Kernel2_3.s.sol";

contract DeployDeterministic is Script {
address constant DEPLOYER = 0x9775137314fE595c943712B0b336327dfa80aE8A;
function run() external {
uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(key);
KernelFactory factory = KernelFactory(payable(FactoryDeploy.deploy()));

ECDSAValidatorDeploy.deploy();
SessionKeyDeploy.deploy();

(address k22, address k22lite) = Kernel_2_2_Deploy.deploy();

if(!factory.isAllowedImplementation(k22)) {
factory.setImplementation(k22, true);
}
if(!factory.isAllowedImplementation(k22lite)) {
factory.setImplementation(k22lite, true);
}

(address k23, address k23lite) = Kernel_2_3_Deploy.deploy();
if(!factory.isAllowedImplementation(k23)) {
factory.setImplementation(k23, true);
}
if(!factory.isAllowedImplementation(k23lite)) {
factory.setImplementation(k23lite, true);
}
vm.stopBroadcast();
}
}
51 changes: 51 additions & 0 deletions scripts/DeployKernelInitial.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
pragma solidity ^0.8.0;

import "src/factory/KernelFactory.sol";
import "I4337/interfaces/IStakeManager.sol";
import "src/Kernel.sol";
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));
console.log("KernelFactory address: %s", address(factory));
} else {
factory = KernelFactory(EXPECTED_KERNEL_FACTORY_ADDRESS);
}
//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));
// console.log("Kernel Lite address: %s", address(kernellite));
// if(factory.isAllowedImplementation(address(kernellite)) == false) {
// console.log("Registering kernellite implementation");
// factory.setImplementation(address(kernellite), true);
// }
//}
Kernel kernel;
kernel = new Kernel{salt:0}(IEntryPoint(ENTRYPOINT_0_6));
console.log("Kernel address: %s", address(kernel));
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) {
console.log("Need to stake to factory");
}
vm.stopBroadcast();
}
}

17 changes: 17 additions & 0 deletions scripts/deterministic/DeterministicDeploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pragma solidity ^0.8.0;

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) {
(bool success, bytes memory addr) = DETERMINISTIC_DEPLOYER.call(_code);
require(success, "DeterministicDeploy: failed to deploy");
require(address(bytes20(addr)) == _expectedAddress, "DeterministicDeploy: address mismatch");
console.log(string.concat(tag, ": deployed at %s"), _expectedAddress);
} else {
console.log(string.concat(tag, ": already deployed"));
}
}
}
13 changes: 13 additions & 0 deletions scripts/deterministic/ECDSAValidator.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pragma solidity ^0.8.0;

import "./DeterministicDeploy.s.sol";

library ECDSAValidatorDeploy {
address constant EXPECTED_ECDSA_VALIDATOR_ADDRESS = 0xd9AB5096a832b9ce79914329DAEE236f8Eea0390;
bytes constant VALIDATOR_CODE = hex"000000000000000000000000000000000000000000000000000000000000000060808060405234610016576104ee908161001c8239f35b600080fdfe60406080815260048036101561001457600080fd5b600091823560e01c80630c959556146101d557806320709efc1461019b578063333daf921461015b5780633a871cdd1461010d578381638fc925aa146100c85750639ea9bd591461006457600080fd5b346100c457806003193601126100c45761007c610296565b9160243567ffffffffffffffff81116100c057936100a08392602096369101610263565b5050338152808552205490516001600160a01b0392831691909216148152f35b8480fd5b8280fd5b92905060203660031901126101095780359067ffffffffffffffff8211610104576100f591369101610263565b50503382528160205281205580f35b505050fd5b5050fd5b50600319836060368301126101545783359167ffffffffffffffff831161015757610160908336030112610154575060209261014d916024359101610348565b9051908152f35b80fd5b5080fd5b5082346101545781600319360112610154576024359067ffffffffffffffff8211610154575060209261019461014d9236908301610263565b9135610464565b838234610157576020366003190112610157576020916001600160a01b03908290826101c5610296565b1681528085522054169051908152f35b509060203660031901126100c45780359067ffffffffffffffff821161025f5761020191369101610263565b6014116100c4573560601c90338352826020528220805490826bffffffffffffffffffffffff60a01b831617905560018060a01b0316337f381c0d11398486654573703c51ee8210ce9461764d133f9f0e53b6a5397053318480a480f35b8380fd5b9181601f840112156102915782359167ffffffffffffffff8311610291576020838186019501011161029157565b600080fd5b600435906001600160a01b038216820361029157565b903590601e1981360301821215610291570180359067ffffffffffffffff82116102915760200191813603831361029157565b92919267ffffffffffffffff918281116103325760405192601f8201601f19908116603f011684019081118482101761033257604052829481845281830111610291578281602093846000960137010152565b634e487b7160e01b600052604160045260246000fd5b600092916001600160a01b039084833583811690819003610157578152806020528260408220541693826020527b19457468657265756d205369676e6564204d6573736167653a0a33328252603c60042091846103be6101408401946103b86103b187876102ac565b36916102df565b906103ee565b1686146103e557506103b16103d793926103b8926102ac565b16036103df57565b60019150565b96505050505050565b60207f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a19392608060405193838301516040526040830151928360605260416000988995869485526060840151851a885210915114165afa508251923d1561045757606052604052565b638baa579f90526004601cfd5b3360009081526020819052604081205490936001600160a01b03918216939192836104996104933685876102df565b836103ee565b1685146104e6576104d7926103b8916020527b19457468657265756d205369676e6564204d6573736167653a0a33328752603c6004209236916102df565b16036104e05790565b50600190565b50505050509056";

function deploy() internal returns(address) {
DeterministicDeploy.checkDeploy("ECDSAValidator", EXPECTED_ECDSA_VALIDATOR_ADDRESS, VALIDATOR_CODE);
return EXPECTED_ECDSA_VALIDATOR_ADDRESS;
}
}
12 changes: 12 additions & 0 deletions scripts/deterministic/Factory.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pragma solidity ^0.8.0;

import "./DeterministicDeploy.s.sol";

library FactoryDeploy {
address payable constant EXPECTED_KERNEL_FACTORY_ADDRESS = payable(0x5de4839a76cf55d0c90e2061ef4386d962E15ae3);
bytes constant KERNEL_FACTORY_CODE = hex"00000000000000000000000000000000000000000000000000000000000000006080346100b257601f610b2d38819003918201601f19168301916001600160401b038311848410176100b75780849260409485528339810103126100b25780516001600160a01b0391828216918290036100b257602001519182168092036100b25780638b78c6d8195560007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a3600080546001600160a01b031916919091179055604051610a5f90816100ce8239f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6040608081526004908136101561001557600080fd5b600091823560e01c9081630396cb60146107d45781632569296214610789578163296601cd1461059d5781634d6cb7001461052b5781635414dff0146104fa57816354d1f13d146104b4578163584465f2146104745781636544c82814610436578163715018a6146103f05781638da5cb5b146103c3578163b0d691fe1461039b578163bb30a9741461034557838263bb9fe6bf146102ec578263c23a5cea1461026157508163d7533f0214610243578163db4c545e14610219578163f04e283e14610199578163f2fde38b1461012c575063fee81cf4146100f657600080fd5b3461012857602036600319011261012857602091610112610845565b9063389a75e1600c525281600c20549051908152f35b5080fd5b8390602036600319011261012857610142610845565b9061014b61088e565b8160601b1561018e575060018060a01b0316638b78c6d8198181547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08580a35580f35b637448fbae8352601cfd5b83906020366003190112610128576101af610845565b906101b861088e565b63389a75e1600c528183526020600c20908154421161020e575082905560018060a01b0316638b78c6d8198181547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08580a35580f35b636f5e88188452601cfd5b5050346101285781600319360112610128576020906089601361023a6108d8565b01209051908152f35b505034610128578160031936011261012857602090516202a3008152f35b809184346102e85760203660031901126102e85781356001600160a01b0381811693918490036102e45761029361088e565b84541692833b156102e45760248592838551968794859363611d2e7560e11b85528401525af19081156102db57506102c85750f35b6102d190610a13565b6102d85780f35b80fd5b513d84823e3d90fd5b8480fd5b5050fd5b809184346102e857826003193601126102e85761030761088e565b82546001600160a01b031691823b1561034057815163bb9fe6bf60e01b81529284918491829084905af19081156102db57506102c85750f35b505050fd5b50503461012857806003193601126101285761035f610845565b90602435918215158093036103975761037661088e565b60018060a01b03168352600160205282209060ff8019835416911617905580f35b8380fd5b505034610128578160031936011261012857905490516001600160a01b039091168152602090f35b505034610128578160031936011261012857638b78c6d8195490516001600160a01b039091168152602090f35b83806003193601126102d85761040461088e565b80638b78c6d8198181547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a35580f35b5050346101285760203660031901126101285760209160ff9082906001600160a01b03610461610845565b1681526001855220541690519015158152f35b83903461012857602036600319011261012857356001600160a01b03811690819003610128576104a261088e565b81546001600160a01b03191617815580f35b83806003193601126102d85763389a75e1600c52338152806020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c928280a280f35b8284346102d85760203660031901126102d8575061051a602092356108ab565b90516001600160a01b039091168152f35b8284346102d857816003193601126102d85782359067ffffffffffffffff82116102d857506bffffffffffffffffffffffff61056f60209461051a93369101610860565b6105948580518381948a830196873781016024358a8201520388810184520182610a3d565b519020166108ab565b828460603660031901126102d8576105b3610845565b9160243567ffffffffffffffff8111610785576105d39036908601610860565b9360018060a01b039384821681526020966001885260ff858320541615610730576bffffffffffffffffffffffff8551898101908987833761062988828d8d82019060443590820152038d810184520182610a3d565b5190201696331560011715610724576106406108d8565b90601382019860898a2060ff86536035523060601b600152806015526055852099856035528a3b15610678575b8b8b8b8b5191168152f35b856089929394959697989b50f597881561071857918185939284938884527f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8d85015289840137870190348a5af1156106fe57507f09e48df7857bd0c1e0d31bb8a85d42cf1874817895f171c917f6ee2cea73ec20818692a3848080808080808061066d565b3d1561070d57503d81803e3d90fd5b63301164258252601cfd5b8363301164258652601cfd5b50632f6348368252601cfd5b845162461bcd60e51b8152908101889052602960248201527f4b65726e656c466163746f72793a20696d706c656d656e746174696f6e206e6f6044820152681d08185b1b1bddd95960ba1b6064820152608490fd5b8280fd5b83806003193601126102d85763389a75e1600c523381526202a30042016020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d8280a280f35b91905060203660031901126107855782823563ffffffff8116809103610128576107fc61088e565b81546001600160a01b031693843b156107855760249084519586938492621cb65b60e51b845283015234905af19081156102db5750610839575080f35b61084290610a13565b80f35b600435906001600160a01b038216820361085b57565b600080fd5b9181601f8401121561085b5782359167ffffffffffffffff831161085b576020838186019501011161085b57565b638b78c6d81954330361089d57565b6382b429006000526004601cfd5b608960136108b76108d8565b012060ff6000536035523060601b6001526015526055600020906000603552565b604051903060701c1561097c57666052573d6000fd607b8301527f3d356020355560408036111560525736038060403d373d3d355af43d6000803e60748301527f3735a920a3ca505d382bbc545af43d6000803e6052573d6000fd5b3d6000f35b60548301527f14605757363d3d37363d7f360894a13ba1a3210667c828492db98dca3e2076cc60348301523060148301526c607f3d8160093d39f33d3d33738252565b66604c573d6000fd60758301527f3d3560203555604080361115604c5736038060403d373d3d355af43d6000803e606e8301527f3735a920a3ca505d382bbc545af43d6000803e604c573d6000fd5b3d6000f35b604e8301527f14605157363d3d37363d7f360894a13ba1a3210667c828492db98dca3e2076cc602e83015230600e8301526c60793d8160093d39f33d3d336d8252565b67ffffffffffffffff8111610a2757604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff821117610a2757604052560000000000000000000000009775137314fe595c943712b0b336327dfa80ae8a0000000000000000000000005ff137d4b0fdcd49dca30c7cf57e578a026d2789";
function deploy() internal returns(address) {
DeterministicDeploy.checkDeploy("factory",EXPECTED_KERNEL_FACTORY_ADDRESS, KERNEL_FACTORY_CODE);
return EXPECTED_KERNEL_FACTORY_ADDRESS;
}
}
14 changes: 14 additions & 0 deletions scripts/deterministic/Kernel2_2.s.sol

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions scripts/deterministic/Kernel2_3.s.sol

Large diffs are not rendered by default.

Loading