-
Notifications
You must be signed in to change notification settings - Fork 0
feat(deploy): add state oracle v2 flow #48
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
base: frederik/eng-4229-fixcontracts-scope-executor-event-guard-by-key
Are you sure you want to change the base?
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 |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| .PHONY: check-storage-layout update-storage-layout | ||
| .PHONY: check-storage-layout update-storage-layout check-v2-size | ||
|
|
||
| check-storage-layout: | ||
| @bash shell/check_storage_layout.sh | ||
|
|
||
| update-storage-layout: | ||
| forge inspect StateOracle storage-layout --json > .storage-layout | ||
| @echo "Storage layout snapshot updated." | ||
|
|
||
| check-v2-size: | ||
| FOUNDRY_PROFILE=v2 forge build --sizes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // SPDX-License-Identifier: CC0-1.0 | ||
| pragma solidity ^0.8.28; | ||
|
|
||
| import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
| import {console2} from "forge-std/console2.sol"; | ||
|
|
||
| import {StateOracleV2} from "../src/StateOracleV2.sol"; | ||
| import {IAdminVerifier} from "../src/interfaces/IAdminVerifier.sol"; | ||
| import {IDAVerifier} from "../src/interfaces/IDAVerifier.sol"; | ||
| import {ITriggerManifestValidator} from "../src/interfaces/ITriggerManifestValidator.sol"; | ||
| import {TriggerManifestValidatorV1} from "../src/verification/TriggerManifestValidatorV1.sol"; | ||
| import {DeployCore} from "./DeployCore.s.sol"; | ||
|
|
||
| /// @notice Production-only fresh deployment for StateOracleV2. | ||
| contract DeployCoreV2 is DeployCore { | ||
| uint256 internal eventConfirmationDepth; | ||
|
|
||
| function setUp() public override { | ||
| assertionTimelockBlocks = vm.envUint("STATE_ORACLE_ASSERTION_TIMELOCK_BLOCKS"); | ||
| eventConfirmationDepth = vm.envUint("STATE_ORACLE_EVENT_CONFIRMATION_DEPTH"); | ||
| admin = vm.envAddress("STATE_ORACLE_ADMIN_ADDRESS"); | ||
| daProver = vm.envAddress("DA_PROVER_ADDRESS"); | ||
| deployOwnerVerifier = vm.envBool("DEPLOY_ADMIN_VERIFIER_OWNER"); | ||
| deployWhitelistVerifier = vm.envBool("DEPLOY_ADMIN_VERIFIER_WHITELIST"); | ||
| whitelistAdmin = vm.envOr("ADMIN_VERIFIER_WHITELIST_ADMIN_ADDRESS", address(0)); | ||
|
|
||
| assert(daProver != address(0)); | ||
| assert(admin != address(0)); | ||
| assert(assertionTimelockBlocks > 0); | ||
| assert(_validEventTiming(assertionTimelockBlocks, eventConfirmationDepth)); | ||
| assert(deployWhitelistVerifier && whitelistAdmin != address(0) || !deployWhitelistVerifier); | ||
| } | ||
|
|
||
| function _validEventTiming(uint256 timelockBlocks, uint256 confirmationDepth) internal pure returns (bool) { | ||
| return confirmationDepth != 0 && confirmationDepth < type(uint256).max && confirmationDepth + 1 < timelockBlocks; | ||
| } | ||
|
|
||
| function run() public override broadcast { | ||
| _fundPersistentAccounts(); | ||
| address[] memory adminVerifierAddresses = _deployAdminVerifiers(); | ||
| address[] memory daVerifierAddresses = new address[](2); | ||
| daVerifierAddresses[0] = _deployDAVerifierECDSA(); | ||
| daVerifierAddresses[1] = _deployDAVerifierOnChain(); | ||
|
|
||
| TriggerManifestValidatorV1 validator = new TriggerManifestValidatorV1(admin); | ||
| StateOracleV2 implementation = new StateOracleV2(assertionTimelockBlocks); | ||
|
|
||
| IAdminVerifier[] memory adminVfrs = new IAdminVerifier[](adminVerifierAddresses.length); | ||
|
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. This script silently uses whichever Foundry profile the caller has selected. With the default profile StateOracleV2 is 25,556 bytes and cannot be deployed under EIP 170, while only the v2 profile makes it deployable. Can the script reject a nonoptimized build or provide a deployment entrypoint that always selects the v2 profile? |
||
| for (uint256 i; i < adminVerifierAddresses.length; ++i) { | ||
| adminVfrs[i] = IAdminVerifier(adminVerifierAddresses[i]); | ||
| } | ||
| IDAVerifier[] memory daVfrs = new IDAVerifier[](daVerifierAddresses.length); | ||
| for (uint256 i; i < daVerifierAddresses.length; ++i) { | ||
| daVfrs[i] = IDAVerifier(daVerifierAddresses[i]); | ||
| } | ||
|
|
||
| bytes memory initData = abi.encodeCall( | ||
| StateOracleV2.initialize, | ||
| (admin, adminVfrs, daVfrs, validator.SCHEMA_ID(), ITriggerManifestValidator(address(validator))) | ||
| ); | ||
| address proxy = address(new TransparentUpgradeableProxy(address(implementation), admin, initData)); | ||
|
|
||
| console2.log("Trigger Manifest Validator V1 deployed at", address(validator)); | ||
| console2.log("State Oracle V2 Implementation deployed at", address(implementation)); | ||
| console2.log("State Oracle V2 Proxy deployed at", proxy); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // SPDX-License-Identifier: CC0-1.0 | ||
| pragma solidity ^0.8.28; | ||
|
|
||
| import {DeployCoreV2} from "../script/DeployCoreV2.s.sol"; | ||
|
|
||
| contract DeployCoreV2Harness is DeployCoreV2 { | ||
| function validEventTiming(uint256 timelockBlocks, uint256 confirmationDepth) external pure returns (bool) { | ||
| return _validEventTiming(timelockBlocks, confirmationDepth); | ||
| } | ||
| } | ||
|
|
||
| contract DeployCoreV2Test { | ||
| function test_confirmationDepthLeavesProcessingBlock() public { | ||
| assert(new DeployCoreV2Harness().validEventTiming(66, 64)); | ||
| } | ||
|
|
||
| function test_rejectsConfirmationDepthWithoutProcessingBlock() public { | ||
| assert(!new DeployCoreV2Harness().validEventTiming(65, 64)); | ||
| } | ||
| } |
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.
Both verifier flags can be false here, which lets a production deployment initialize with no admin verifier. That proxy cannot register any adopter until a follow up governance transaction, so it misses ENG 4099's ready for normal operations requirement. Can we require at least one production admin verifier before broadcasting?