-
Notifications
You must be signed in to change notification settings - Fork 11
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
Feature/update deployment logic using factory #52
Merged
SoraSuegami
merged 25 commits into
feat/audit-fix-2024-08
from
feature/update-deployment-logic-using-factory
Sep 10, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
0177f5e
Add ZKSyncCreate2Factory, EmailAccountRecovery test casees split by f…
wshino 68c5399
Failed: update integration testing with foundry-zksync.
wshino e50c303
Update integration testing command with foundry-zksync.
wshino 6ea336e
Failed: update integration testing with foundry.
wshino 39b43a0
Add DeployEmailAuthWithCreate2.s.sol.
wshino 7427a96
Merge commit '39b43a055ace204bfd3450496a87ca5ba363e61e' into feature/…
wshino 7b0235f
Disable DeployEmailAuthWIthCreate2.s.sol.
wshino 2769102
Merge branch 'feat/audit-fix-2024-08' into feature/update-deployment-…
wshino 2fb6e3e
Fix integration test for foundry
wshino 68119bc
Fail: integration testing for foundry zksync.
wshino 9f6b16d
Fix integration testing for foundry zksync
wshino e7255a3
Tweak README.md
wshino fd6b30f
Add EmailAccountRecoveryZkSync
wshino cc8e115
Uncomment some contracts which are used for foundry zksync
wshino e2640ec
make deployEmailAuthProxy as internal function
wshino 564bb55
Update yarn build, yarn test
wshino a36cf98
Remove specific foundry version
wshino 6857cfa
Update foundry version
wshino 5a0c283
chore: git rm --cached
wshino e0e1b53
chore: Update after git rm --cached
wshino 39905c2
chore: git rm --cached
wshino 3a61642
chore: Update after git rm --cached
wshino 618ed4f
Fix build-test-fmt on github action
wshino 14f0626
Rename DeployEmailAuthWIthCreate2
wshino 0069604
Update deployment files in docs
wshino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
306 changes: 153 additions & 153 deletions
306
packages/contracts/script/DeployRecoveryControllerZkSync.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,164 +1,164 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
// // SPDX-License-Identifier: UNLICENSED | ||
// pragma solidity ^0.8.13; | ||
|
||
import "forge-std/Script.sol"; | ||
// import "forge-std/Script.sol"; | ||
|
||
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; | ||
import "../test/helpers/SimpleWallet.sol"; | ||
import "../test/helpers/RecoveryControllerZkSync.sol"; | ||
import "../src/utils/Verifier.sol"; | ||
import "../src/utils/ECDSAOwnedDKIMRegistry.sol"; | ||
// import "../src/utils/ForwardDKIMRegistry.sol"; | ||
import "../src/EmailAuth.sol"; | ||
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import {ZKSyncCreate2Factory} from "../src/utils/ZKSyncCreate2Factory.sol"; | ||
// import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; | ||
// import "../test/helpers/SimpleWallet.sol"; | ||
// import "../test/helpers/RecoveryControllerZkSync.sol"; | ||
// import "../src/utils/Verifier.sol"; | ||
// import "../src/utils/ECDSAOwnedDKIMRegistry.sol"; | ||
// // import "../src/utils/ForwardDKIMRegistry.sol"; | ||
// import "../src/EmailAuth.sol"; | ||
// import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
// import {ZKSyncCreate2Factory} from "../src/utils/ZKSyncCreate2Factory.sol"; | ||
|
||
contract Deploy is Script { | ||
using ECDSA for *; | ||
// contract Deploy is Script { | ||
// using ECDSA for *; | ||
|
||
ECDSAOwnedDKIMRegistry dkim; | ||
Verifier verifier; | ||
EmailAuth emailAuthImpl; | ||
SimpleWallet simpleWallet; | ||
RecoveryControllerZkSync recoveryControllerZkSync; | ||
ZKSyncCreate2Factory factoryImpl; | ||
// ECDSAOwnedDKIMRegistry dkim; | ||
// Verifier verifier; | ||
// EmailAuth emailAuthImpl; | ||
// SimpleWallet simpleWallet; | ||
// RecoveryControllerZkSync recoveryControllerZkSync; | ||
// ZKSyncCreate2Factory factoryImpl; | ||
|
||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
if (deployerPrivateKey == 0) { | ||
console.log("PRIVATE_KEY env var not set"); | ||
return; | ||
} | ||
address signer = vm.envAddress("SIGNER"); | ||
if (signer == address(0)) { | ||
console.log("SIGNER env var not set"); | ||
return; | ||
} | ||
// function run() external { | ||
// uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
// if (deployerPrivateKey == 0) { | ||
// console.log("PRIVATE_KEY env var not set"); | ||
// return; | ||
// } | ||
// address signer = vm.envAddress("SIGNER"); | ||
// if (signer == address(0)) { | ||
// console.log("SIGNER env var not set"); | ||
// return; | ||
// } | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
address initialOwner = msg.sender; | ||
// vm.startBroadcast(deployerPrivateKey); | ||
// address initialOwner = msg.sender; | ||
|
||
// Deploy ECDSAOwned DKIM registry | ||
dkim = ECDSAOwnedDKIMRegistry(vm.envOr("ECDSA_DKIM", address(0))); | ||
if (address(dkim) == address(0)) { | ||
ECDSAOwnedDKIMRegistry ecdsaDkimImpl = new ECDSAOwnedDKIMRegistry(); | ||
console.log( | ||
"ECDSAOwnedDKIMRegistry implementation deployed at: %s", | ||
address(ecdsaDkimImpl) | ||
); | ||
ERC1967Proxy ecdsaDkimProxy = new ERC1967Proxy( | ||
address(ecdsaDkimImpl), | ||
abi.encodeCall(ecdsaDkimImpl.initialize, (initialOwner, signer)) | ||
); | ||
dkim = ECDSAOwnedDKIMRegistry(address(ecdsaDkimProxy)); | ||
console.log( | ||
"ECDSAOwnedDKIMRegistry deployed at: %s", | ||
address(dkim) | ||
); | ||
vm.setEnv("ECDSA_DKIM", vm.toString(address(dkim))); | ||
// dkimImpl = new ForwardDKIMRegistry(); | ||
// console.log( | ||
// "ForwardDKIMRegistry implementation deployed at: %s", | ||
// address(dkimImpl) | ||
// ); | ||
// ERC1967Proxy dkimProxy = new ERC1967Proxy( | ||
// address(dkimImpl), | ||
// abi.encodeCall(dkimImpl.initialize, (initialOwner, signer)) | ||
// ); | ||
// dkim = ForwardDKIMRegistry(address(dkimProxy)); | ||
// console.log("ForwardDKIMRegistry deployed at: %s", address(dkim)); | ||
// vm.setEnv("DKIM", vm.toString(address(dkim))); | ||
} | ||
// Deploy Verifier | ||
verifier = Verifier(vm.envOr("VERIFIER", address(0))); | ||
if (address(verifier) == address(0)) { | ||
Verifier verifierImpl = new Verifier(); | ||
console.log( | ||
"Verifier implementation deployed at: %s", | ||
address(verifierImpl) | ||
); | ||
ERC1967Proxy verifierProxy = new ERC1967Proxy( | ||
address(verifierImpl), | ||
abi.encodeCall(verifierImpl.initialize, (initialOwner)) | ||
); | ||
verifier = Verifier(address(verifierProxy)); | ||
console.log("Verifier deployed at: %s", address(verifier)); | ||
vm.setEnv("VERIFIER", vm.toString(address(verifier))); | ||
} | ||
// // Deploy ECDSAOwned DKIM registry | ||
// dkim = ECDSAOwnedDKIMRegistry(vm.envOr("ECDSA_DKIM", address(0))); | ||
// if (address(dkim) == address(0)) { | ||
// ECDSAOwnedDKIMRegistry ecdsaDkimImpl = new ECDSAOwnedDKIMRegistry(); | ||
// console.log( | ||
// "ECDSAOwnedDKIMRegistry implementation deployed at: %s", | ||
// address(ecdsaDkimImpl) | ||
// ); | ||
// ERC1967Proxy ecdsaDkimProxy = new ERC1967Proxy( | ||
// address(ecdsaDkimImpl), | ||
// abi.encodeCall(ecdsaDkimImpl.initialize, (initialOwner, signer)) | ||
// ); | ||
// dkim = ECDSAOwnedDKIMRegistry(address(ecdsaDkimProxy)); | ||
// console.log( | ||
// "ECDSAOwnedDKIMRegistry deployed at: %s", | ||
// address(dkim) | ||
// ); | ||
// vm.setEnv("ECDSA_DKIM", vm.toString(address(dkim))); | ||
// // dkimImpl = new ForwardDKIMRegistry(); | ||
// // console.log( | ||
// // "ForwardDKIMRegistry implementation deployed at: %s", | ||
// // address(dkimImpl) | ||
// // ); | ||
// // ERC1967Proxy dkimProxy = new ERC1967Proxy( | ||
// // address(dkimImpl), | ||
// // abi.encodeCall(dkimImpl.initialize, (initialOwner, signer)) | ||
// // ); | ||
// // dkim = ForwardDKIMRegistry(address(dkimProxy)); | ||
// // console.log("ForwardDKIMRegistry deployed at: %s", address(dkim)); | ||
// // vm.setEnv("DKIM", vm.toString(address(dkim))); | ||
// } | ||
// // Deploy Verifier | ||
// verifier = Verifier(vm.envOr("VERIFIER", address(0))); | ||
// if (address(verifier) == address(0)) { | ||
// Verifier verifierImpl = new Verifier(); | ||
// console.log( | ||
// "Verifier implementation deployed at: %s", | ||
// address(verifierImpl) | ||
// ); | ||
// ERC1967Proxy verifierProxy = new ERC1967Proxy( | ||
// address(verifierImpl), | ||
// abi.encodeCall(verifierImpl.initialize, (initialOwner)) | ||
// ); | ||
// verifier = Verifier(address(verifierProxy)); | ||
// console.log("Verifier deployed at: %s", address(verifier)); | ||
// vm.setEnv("VERIFIER", vm.toString(address(verifier))); | ||
// } | ||
|
||
// Deploy EmailAuth Implementation | ||
emailAuthImpl = EmailAuth(vm.envOr("EMAIL_AUTH_IMPL", address(0))); | ||
if (address(emailAuthImpl) == address(0)) { | ||
emailAuthImpl = new EmailAuth(); | ||
console.log( | ||
"EmailAuth implementation deployed at: %s", | ||
address(emailAuthImpl) | ||
); | ||
vm.setEnv("EMAIL_AUTH_IMPL", vm.toString(address(emailAuthImpl))); | ||
} | ||
// // Deploy EmailAuth Implementation | ||
// emailAuthImpl = EmailAuth(vm.envOr("EMAIL_AUTH_IMPL", address(0))); | ||
// if (address(emailAuthImpl) == address(0)) { | ||
// emailAuthImpl = new EmailAuth(); | ||
// console.log( | ||
// "EmailAuth implementation deployed at: %s", | ||
// address(emailAuthImpl) | ||
// ); | ||
// vm.setEnv("EMAIL_AUTH_IMPL", vm.toString(address(emailAuthImpl))); | ||
// } | ||
|
||
// Deploy Factory | ||
factoryImpl = ZKSyncCreate2Factory(vm.envOr("FACTORY", address(0))); | ||
if (address(factoryImpl) == address(0)) { | ||
factoryImpl = new ZKSyncCreate2Factory(); | ||
console.log( | ||
"Factory implementation deployed at: %s", | ||
address(factoryImpl) | ||
); | ||
vm.setEnv("FACTORY", vm.toString(address(factoryImpl))); | ||
} | ||
// // Deploy Factory | ||
// factoryImpl = ZKSyncCreate2Factory(vm.envOr("FACTORY", address(0))); | ||
// if (address(factoryImpl) == address(0)) { | ||
// factoryImpl = new ZKSyncCreate2Factory(); | ||
// console.log( | ||
// "Factory implementation deployed at: %s", | ||
// address(factoryImpl) | ||
// ); | ||
// vm.setEnv("FACTORY", vm.toString(address(factoryImpl))); | ||
// } | ||
|
||
// Create RecoveryControllerZkSync as EmailAccountRecovery implementation | ||
{ | ||
RecoveryControllerZkSync recoveryControllerZkSyncImpl = new RecoveryControllerZkSync(); | ||
ERC1967Proxy recoveryControllerZkSyncProxy = new ERC1967Proxy( | ||
address(recoveryControllerZkSyncImpl), | ||
abi.encodeCall( | ||
recoveryControllerZkSyncImpl.initialize, | ||
( | ||
signer, | ||
address(verifier), | ||
address(dkim), | ||
address(emailAuthImpl), | ||
address(factoryImpl) | ||
) | ||
) | ||
); | ||
recoveryControllerZkSync = RecoveryControllerZkSync( | ||
payable(address(recoveryControllerZkSyncProxy)) | ||
); | ||
console.log( | ||
"RecoveryControllerZkSync deployed at: %s", | ||
address(recoveryControllerZkSync) | ||
); | ||
vm.setEnv( | ||
"RECOVERY_CONTROLLER_ZKSYNC", | ||
vm.toString(address(recoveryControllerZkSync)) | ||
); | ||
} | ||
// // Create RecoveryControllerZkSync as EmailAccountRecovery implementation | ||
// { | ||
// RecoveryControllerZkSync recoveryControllerZkSyncImpl = new RecoveryControllerZkSync(); | ||
// ERC1967Proxy recoveryControllerZkSyncProxy = new ERC1967Proxy( | ||
// address(recoveryControllerZkSyncImpl), | ||
// abi.encodeCall( | ||
// recoveryControllerZkSyncImpl.initialize, | ||
// ( | ||
// signer, | ||
// address(verifier), | ||
// address(dkim), | ||
// address(emailAuthImpl), | ||
// address(factoryImpl) | ||
// ) | ||
// ) | ||
// ); | ||
// recoveryControllerZkSync = RecoveryControllerZkSync( | ||
// payable(address(recoveryControllerZkSyncProxy)) | ||
// ); | ||
// console.log( | ||
// "RecoveryControllerZkSync deployed at: %s", | ||
// address(recoveryControllerZkSync) | ||
// ); | ||
// vm.setEnv( | ||
// "RECOVERY_CONTROLLER_ZKSYNC", | ||
// vm.toString(address(recoveryControllerZkSync)) | ||
// ); | ||
// } | ||
|
||
// Deploy SimpleWallet Implementation | ||
{ | ||
SimpleWallet simpleWalletImpl = new SimpleWallet(); | ||
console.log( | ||
"SimpleWallet implementation deployed at: %s", | ||
address(simpleWalletImpl) | ||
); | ||
vm.setEnv( | ||
"SIMPLE_WALLET_IMPL", | ||
vm.toString(address(simpleWalletImpl)) | ||
); | ||
ERC1967Proxy simpleWalletProxy = new ERC1967Proxy( | ||
address(simpleWalletImpl), | ||
abi.encodeCall( | ||
simpleWalletImpl.initialize, | ||
(signer, address(recoveryControllerZkSync)) | ||
) | ||
); | ||
simpleWallet = SimpleWallet(payable(address(simpleWalletProxy))); | ||
console.log("SimpleWallet deployed at: %s", address(simpleWallet)); | ||
vm.setEnv("SIMPLE_WALLET", vm.toString(address(simpleWallet))); | ||
} | ||
vm.stopBroadcast(); | ||
} | ||
} | ||
// // Deploy SimpleWallet Implementation | ||
// { | ||
// SimpleWallet simpleWalletImpl = new SimpleWallet(); | ||
// console.log( | ||
// "SimpleWallet implementation deployed at: %s", | ||
// address(simpleWalletImpl) | ||
// ); | ||
// vm.setEnv( | ||
// "SIMPLE_WALLET_IMPL", | ||
// vm.toString(address(simpleWalletImpl)) | ||
// ); | ||
// ERC1967Proxy simpleWalletProxy = new ERC1967Proxy( | ||
// address(simpleWalletImpl), | ||
// abi.encodeCall( | ||
// simpleWalletImpl.initialize, | ||
// (signer, address(recoveryControllerZkSync)) | ||
// ) | ||
// ); | ||
// simpleWallet = SimpleWallet(payable(address(simpleWalletProxy))); | ||
// console.log("SimpleWallet deployed at: %s", address(simpleWallet)); | ||
// vm.setEnv("SIMPLE_WALLET", vm.toString(address(simpleWallet))); | ||
// } | ||
// vm.stopBroadcast(); | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to avoid commenting out those zksync files by adding an option to the command of
yarn build
that excludes zksync files?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SoraSuegami Maybe we can use --skip flag, let me try it.