-
Notifications
You must be signed in to change notification settings - Fork 0
add batch authenticator deployment script #399
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.25; | ||
|
|
||
| import {Script, console} from "forge-std/Script.sol"; | ||
| import {IBatchAuthenticator} from "interfaces/L1/IBatchAuthenticator.sol"; | ||
| import {ISystemConfig} from "interfaces/L1/ISystemConfig.sol"; | ||
| import {IEspressoTEEVerifier} from "@espresso-tee-contracts/interface/IEspressoTEEVerifier.sol"; | ||
| import {ProxyAdmin} from "src/universal/ProxyAdmin.sol"; | ||
| import {Proxy} from "src/universal/Proxy.sol"; | ||
| import {BatchAuthenticator} from "src/L1/BatchAuthenticator.sol"; | ||
|
|
||
| /// @notice Deploys only the BatchAuthenticator (proxy + impl) against an existing TEEVerifier. | ||
| /// | ||
| /// Usage: | ||
| /// forge script scripts/deploy/DeployBatchAuthenticator.s.sol:DeployBatchAuthenticator \ | ||
| /// --rpc-url <L1_RPC_URL> \ | ||
| /// --broadcast \ | ||
| /// --private-key <DEPLOYER_KEY> \ | ||
| /// --verify \ | ||
| /// --etherscan-api-key <API_KEY> \ | ||
| /// --sig "run(address,address,address,address)" \ | ||
| /// <ESPRESSO_BATCHER_ADDRESS> \ | ||
| /// <SYSTEM_CONFIG_ADDRESS> \ | ||
| /// <TEE_VERIFIER_ADDRESS> \ | ||
| /// <PROXY_ADMIN_OWNER> | ||
| contract DeployBatchAuthenticator is Script { | ||
| function run( | ||
| address espressoBatcher, | ||
| address systemConfig, | ||
| address teeVerifier, | ||
| address proxyAdminOwner | ||
| ) public { | ||
| require(espressoBatcher != address(0), "espressoBatcher required"); | ||
| require(systemConfig != address(0), "systemConfig required"); | ||
| require(teeVerifier != address(0), "teeVerifier required"); | ||
|
|
||
| if (proxyAdminOwner == address(0)) { | ||
| proxyAdminOwner = msg.sender; | ||
| console.log("WARN: proxyAdminOwner not set, defaulting to msg.sender"); | ||
| } | ||
|
|
||
| vm.startBroadcast(msg.sender); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The This works because One subtle issue: if the caller intends |
||
| ProxyAdmin proxyAdmin = new ProxyAdmin(msg.sender); | ||
| vm.label(address(proxyAdmin), "BatchAuthenticatorProxyAdmin"); | ||
| Proxy proxy = new Proxy(address(proxyAdmin)); | ||
| vm.label(address(proxy), "BatchAuthenticatorProxy"); | ||
| proxyAdmin.setProxyType(address(proxy), ProxyAdmin.ProxyType.ERC1967); | ||
| BatchAuthenticator impl = new BatchAuthenticator(); | ||
|
jjeangal marked this conversation as resolved.
|
||
| vm.label(address(impl), "BatchAuthenticatorImpl"); | ||
|
|
||
| bytes memory initData = abi.encodeCall( | ||
| BatchAuthenticator.initialize, | ||
| ( | ||
| IEspressoTEEVerifier(teeVerifier), | ||
| espressoBatcher, | ||
| ISystemConfig(systemConfig), | ||
| proxyAdminOwner | ||
| ) | ||
| ); | ||
| proxyAdmin.upgradeAndCall( | ||
| payable(address(proxy)), | ||
| address(impl), | ||
| initData | ||
| ); | ||
|
|
||
| if (proxyAdminOwner != msg.sender) { | ||
| proxyAdmin.transferOwnership(proxyAdminOwner); | ||
| } | ||
|
|
||
| vm.stopBroadcast(); | ||
|
|
||
| console.log("BatchAuthenticator (proxy):", address(proxy)); | ||
| console.log("BatchAuthenticator (impl): ", address(impl)); | ||
| console.log("ProxyAdmin: ", address(proxyAdmin)); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.