diff --git a/deploy-config/hardhat.json b/deploy-config/hardhat.json index c1c6714e..8b79cf11 100644 --- a/deploy-config/hardhat.json +++ b/deploy-config/hardhat.json @@ -77,6 +77,9 @@ "multiproofConfigHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "multiproofGameType": 621, "teeProposer": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc", + "teeChallenger": "0x976EA74026E726554dB657fA54763abd0C3a0aa9", + "zkRangeHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "zkAggregationHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nitroEnclaveVerifier": "0x0000000000000000000000000000000000000000", "multiproofGenesisOutputRoot": "0x0000000000000000000000000000000000000000000000000000000000000001", "multiproofGenesisBlockNumber": 0, diff --git a/deploy-config/sepolia.json b/deploy-config/sepolia.json index 979a81e5..6a9a6086 100644 --- a/deploy-config/sepolia.json +++ b/deploy-config/sepolia.json @@ -65,10 +65,13 @@ "gasPayingTokenSymbol": "", "nativeAssetLiquidityAmount": null, "liquidityControllerOwner": "0xfd1D2e729aE8eEe2E146c033bf4400fE75284301", - "teeImageHash": "0x0000000000000000000000000000000000000000000000000000000000000001", + "teeImageHash": "0x5e63d4bb943b8c1d049298d08fb0240cfe918606410b771a514901f06036dc23", "multiproofConfigHash": "0x12e9c45f19f9817c6d4385fad29e7a70c355502cf0883e76a9a7e478a85d1360", "multiproofGameType": 621, - "teeProposer": "0xb28E6890Cffa969dA9851c1BF1Ac34B76EbFEe98", + "teeProposer": "0x4A944b9629cbbd0f226859fa99500a48f35C1D0D", + "teeChallenger": "0x950926F3b71A891BfC340d6bFeB5972513306DF0", + "zkRangeHash": "0x2dd3dabb0214626e04b6c75837e4415a7810e5aa1ad3b2261e689c90314d469d", + "zkAggregationHash": "0x00e35e02dd3eb5870b2bfd2e672d70612fcfe98f233059684f9a302b8bba812f", "nitroEnclaveVerifier": "0x0000000000000000000000000000000000000000", "multiproofGenesisOutputRoot": "0xbc273d5876d1858ecd5aaf4ce4eaf16c73f0187ca4271b774ed5da7d2254ba79", "multiproofGenesisBlockNumber": 37223829, diff --git a/scripts/deploy/DeployConfig.s.sol b/scripts/deploy/DeployConfig.s.sol index 509c3f88..ddf13fad 100644 --- a/scripts/deploy/DeployConfig.s.sol +++ b/scripts/deploy/DeployConfig.s.sol @@ -98,6 +98,9 @@ contract DeployConfig is Script { bytes32 public multiproofConfigHash; uint256 public multiproofGameType; address public teeProposer; + address public teeChallenger; + bytes32 public zkRangeHash; + bytes32 public zkAggregationHash; address public nitroEnclaveVerifier; bytes32 public multiproofGenesisOutputRoot; uint256 public multiproofGenesisBlockNumber; @@ -215,7 +218,10 @@ contract DeployConfig is Script { teeImageHash = bytes32(_readOr(_json, "$.teeImageHash", 0)); multiproofConfigHash = bytes32(_readOr(_json, "$.multiproofConfigHash", 0)); multiproofGameType = _readOr(_json, "$.multiproofGameType", 621); - teeProposer = _readOr(_json, "$.teeProposer", finalSystemOwner); + teeProposer = stdJson.readAddress(_json, "$.teeProposer"); + teeChallenger = stdJson.readAddress(_json, "$.teeChallenger"); + zkRangeHash = stdJson.readBytes32(_json, "$.zkRangeHash"); + zkAggregationHash = stdJson.readBytes32(_json, "$.zkAggregationHash"); nitroEnclaveVerifier = _readOr(_json, "$.nitroEnclaveVerifier", address(0)); multiproofGenesisOutputRoot = bytes32(_readOr(_json, "$.multiproofGenesisOutputRoot", uint256(1))); multiproofGenesisBlockNumber = _readOr(_json, "$.multiproofGenesisBlockNumber", 0); diff --git a/scripts/multiproof/DeployDevNoNitro.s.sol b/scripts/multiproof/DeployDevNoNitro.s.sol index dffa8647..7eaa5dea 100644 --- a/scripts/multiproof/DeployDevNoNitro.s.sol +++ b/scripts/multiproof/DeployDevNoNitro.s.sol @@ -53,7 +53,7 @@ pragma solidity 0.8.15; */ import { INitroEnclaveVerifier } from "interfaces/multiproof/tee/INitroEnclaveVerifier.sol"; -import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { Proxy } from "src/universal/Proxy.sol"; import { Script } from "forge-std/Script.sol"; import { console2 as console } from "forge-std/console2.sol"; import { IAnchorStateRegistry } from "interfaces/dispute/IAnchorStateRegistry.sol"; @@ -82,9 +82,6 @@ import { MockDelayedWETH } from "./mocks/MockDelayedWETH.sol"; /// @notice Development deployment WITHOUT AWS Nitro attestation validation. /// @dev Uses DevTEEProverRegistry which allows addDevSigner() to bypass attestation. contract DeployDevNoNitro is Script { - /// @notice Constant from Optimism's Constants.sol - the storage slot for proxy admin. - bytes32 internal constant PROXY_OWNER_ADDRESS = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; - uint256 public constant BLOCK_INTERVAL = 100; uint256 public constant INTERMEDIATE_BLOCK_INTERVAL = 10; uint256 public constant PROOF_THRESHOLD = 1; @@ -93,11 +90,10 @@ contract DeployDevNoNitro is Script { DeployConfig public constant cfg = DeployConfig(address(uint160(uint256(keccak256(abi.encode("optimism.deployconfig")))))); - // Deployed addresses address public teeProverRegistryProxy; address public teeVerifier; address public disputeGameFactory; - address public mockAnchorRegistry; + IAnchorStateRegistry public mockAnchorRegistry; address public mockDelayedWETH; address public aggregateVerifier; @@ -113,6 +109,7 @@ contract DeployDevNoNitro is Script { console.log("Chain ID:", block.chainid); console.log("Owner:", cfg.finalSystemOwner()); console.log("TEE Proposer:", cfg.teeProposer()); + console.log("TEE Challenger:", cfg.teeChallenger()); console.log("Game Type:", cfg.multiproofGameType()); console.log(""); console.log("NOTE: Using DevTEEProverRegistry - NO attestation required."); @@ -120,7 +117,7 @@ contract DeployDevNoNitro is Script { vm.startBroadcast(); _deployInfrastructure(gameType); - _deployTEEContracts(cfg.finalSystemOwner()); + _deployTEEContracts(gameType); _deployAggregateVerifier(gameType); vm.stopBroadcast(); @@ -129,86 +126,71 @@ contract DeployDevNoNitro is Script { _writeOutput(); } - function _deployTEEContracts(address owner) internal { - address scgImpl = address( + function _deployTEEContracts(GameType gameType) internal { + address owner = cfg.finalSystemOwner(); + address teeRegistryImpl = address( new DevTEEProverRegistry(INitroEnclaveVerifier(address(0)), IDisputeGameFactory(disputeGameFactory)) ); - address[] memory initialProposers = new address[](1); + address[] memory initialProposers = new address[](2); initialProposers[0] = cfg.teeProposer(); - teeProverRegistryProxy = address( - new TransparentUpgradeableProxy( - scgImpl, - address(0xdead), - abi.encodeCall( - TEEProverRegistry.initialize, - (owner, owner, initialProposers, GameType.wrap(uint32(cfg.multiproofGameType()))) - ) - ) - ); - console.log("DevTEEProverRegistry:", teeProverRegistryProxy); - - teeVerifier = address( - new TEEVerifier(TEEProverRegistry(teeProverRegistryProxy), IAnchorStateRegistry(mockAnchorRegistry)) + initialProposers[1] = cfg.teeChallenger(); + Proxy teeProxy = new Proxy(msg.sender); + teeProxy.upgradeToAndCall( + teeRegistryImpl, abi.encodeCall(TEEProverRegistry.initialize, (owner, owner, initialProposers, gameType)) ); - console.log("TEEVerifier:", teeVerifier); - } + teeProxy.changeAdmin(address(0xdead)); + teeProverRegistryProxy = address(teeProxy); - function _registerProposer(address teeProposer) internal { - TEEProverRegistry(teeProverRegistryProxy).setProposer(teeProposer, true); - console.log("Registered TEE proposer:", teeProposer); + teeVerifier = address(new TEEVerifier(TEEProverRegistry(teeProverRegistryProxy), mockAnchorRegistry)); } function _deployInfrastructure(GameType gameType) internal { address factoryImpl = address(new DisputeGameFactory()); MinimalProxyAdmin proxyAdmin = new MinimalProxyAdmin(cfg.finalSystemOwner()); - TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(factoryImpl, address(proxyAdmin), ""); - - vm.store(address(proxy), PROXY_OWNER_ADDRESS, bytes32(uint256(uint160(address(proxyAdmin))))); + Proxy proxy = new Proxy(msg.sender); + proxy.upgradeTo(factoryImpl); + proxy.changeAdmin(address(proxyAdmin)); DisputeGameFactory(address(proxy)).initialize(cfg.finalSystemOwner()); - disputeGameFactory = address(proxy); - console.log("DisputeGameFactory:", disputeGameFactory); MockAnchorStateRegistry asr = new MockAnchorStateRegistry(); - mockAnchorRegistry = address(asr); + mockAnchorRegistry = IAnchorStateRegistry(address(asr)); asr.initialize( disputeGameFactory, Hash.wrap(cfg.multiproofGenesisOutputRoot()), cfg.multiproofGenesisBlockNumber(), gameType ); - console.log("AnchorStateRegistry (mock):", mockAnchorRegistry); } function _deployAggregateVerifier(GameType gameType) internal { - address zkVerifier = address(new MockVerifier(IAnchorStateRegistry(mockAnchorRegistry))); - console.log("MockVerifier (ZK):", zkVerifier); - + address zkVerifier = address(new MockVerifier(mockAnchorRegistry)); mockDelayedWETH = address(new MockDelayedWETH()); - console.log("MockDelayedWETH:", mockDelayedWETH); + + AggregateVerifier.ZkHashes memory zkHashes = + AggregateVerifier.ZkHashes({ rangeHash: cfg.zkRangeHash(), aggregateHash: cfg.zkAggregationHash() }); aggregateVerifier = address( new AggregateVerifier( gameType, - IAnchorStateRegistry(mockAnchorRegistry), + mockAnchorRegistry, IDelayedWETH(payable(mockDelayedWETH)), IVerifier(teeVerifier), IVerifier(zkVerifier), cfg.teeImageHash(), - AggregateVerifier.ZkHashes(bytes32(0), bytes32(0)), + zkHashes, cfg.multiproofConfigHash(), - 8453, + cfg.l2ChainID(), BLOCK_INTERVAL, INTERMEDIATE_BLOCK_INTERVAL, PROOF_THRESHOLD ) ); - console.log("AggregateVerifier:", aggregateVerifier); - DisputeGameFactory(disputeGameFactory).setImplementation(gameType, IDisputeGame(aggregateVerifier), ""); - DisputeGameFactory(disputeGameFactory).setInitBond(gameType, INIT_BOND); - console.log("Registered AggregateVerifier with factory"); + DisputeGameFactory factory = DisputeGameFactory(disputeGameFactory); + factory.setImplementation(gameType, IDisputeGame(aggregateVerifier), ""); + factory.setInitBond(gameType, INIT_BOND); } function _printSummary() internal view { @@ -220,7 +202,7 @@ contract DeployDevNoNitro is Script { console.log(" TEEVerifier:", teeVerifier); console.log("\nInfrastructure:"); console.log(" DisputeGameFactory:", disputeGameFactory); - console.log(" AnchorStateRegistry (mock):", mockAnchorRegistry); + console.log(" AnchorStateRegistry (mock):", address(mockAnchorRegistry)); console.log(" DelayedWETH (mock):", mockDelayedWETH); console.log("\nGame:"); console.log(" AggregateVerifier:", aggregateVerifier); @@ -237,23 +219,16 @@ contract DeployDevNoNitro is Script { } function _writeOutput() internal { + string memory key = "deployment"; + vm.serializeAddress(key, "TEEProverRegistry", teeProverRegistryProxy); + vm.serializeAddress(key, "TEEVerifier", teeVerifier); + vm.serializeAddress(key, "DisputeGameFactory", disputeGameFactory); + vm.serializeAddress(key, "AnchorStateRegistry", address(mockAnchorRegistry)); + vm.serializeAddress(key, "DelayedWETH", mockDelayedWETH); + string memory json = vm.serializeAddress(key, "AggregateVerifier", aggregateVerifier); + string memory outPath = string.concat("deployments/", vm.toString(block.chainid), "-dev-no-nitro.json"); - string memory output = string.concat( - '{"TEEProverRegistry":"', - vm.toString(teeProverRegistryProxy), - '","TEEVerifier":"', - vm.toString(teeVerifier), - '","DisputeGameFactory":"', - vm.toString(disputeGameFactory), - '","AnchorStateRegistry":"', - vm.toString(mockAnchorRegistry), - '","DelayedWETH":"', - vm.toString(mockDelayedWETH), - '","AggregateVerifier":"', - vm.toString(aggregateVerifier), - '"}' - ); - vm.writeFile(outPath, output); + vm.writeJson(json, outPath); console.log("Deployment saved to:", outPath); } } diff --git a/scripts/multiproof/DeployDevWithNitro.s.sol b/scripts/multiproof/DeployDevWithNitro.s.sol index 1c4abec1..5028c758 100644 --- a/scripts/multiproof/DeployDevWithNitro.s.sol +++ b/scripts/multiproof/DeployDevWithNitro.s.sol @@ -37,7 +37,7 @@ pragma solidity 0.8.15; */ import { INitroEnclaveVerifier } from "interfaces/multiproof/tee/INitroEnclaveVerifier.sol"; -import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { Proxy } from "src/universal/Proxy.sol"; import { Script } from "forge-std/Script.sol"; import { console2 as console } from "forge-std/console2.sol"; import { IAnchorStateRegistry } from "interfaces/dispute/IAnchorStateRegistry.sol"; @@ -66,9 +66,6 @@ import { MockDelayedWETH } from "./mocks/MockDelayedWETH.sol"; /// @dev Uses real TEEProverRegistry which requires registerSigner() with valid attestation. /// NitroEnclaveVerifier must be pre-deployed via DeployRiscZeroStack.s.sol. contract DeployDevWithNitro is Script { - /// @notice Constant from Optimism's Constants.sol - the storage slot for proxy admin. - bytes32 internal constant PROXY_OWNER_ADDRESS = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; - uint256 public constant BLOCK_INTERVAL = 100; uint256 public constant INTERMEDIATE_BLOCK_INTERVAL = 10; uint256 public constant PROOF_THRESHOLD = 1; @@ -77,12 +74,11 @@ contract DeployDevWithNitro is Script { DeployConfig public constant cfg = DeployConfig(address(uint160(uint256(keccak256(abi.encode("optimism.deployconfig")))))); - // Deployed addresses address public nitroEnclaveVerifierAddr; address public teeProverRegistryProxy; address public teeVerifier; address public disputeGameFactory; - address public mockAnchorRegistry; + IAnchorStateRegistry public mockAnchorRegistry; address public mockDelayedWETH; address public aggregateVerifier; @@ -105,6 +101,7 @@ contract DeployDevWithNitro is Script { console.log("Chain ID:", block.chainid); console.log("Owner:", cfg.finalSystemOwner()); console.log("TEE Proposer:", cfg.teeProposer()); + console.log("TEE Challenger:", cfg.teeChallenger()); console.log("Game Type:", cfg.multiproofGameType()); console.log("NitroEnclaveVerifier:", nitroEnclaveVerifierAddr); console.log(""); @@ -113,7 +110,7 @@ contract DeployDevWithNitro is Script { vm.startBroadcast(); _deployInfrastructure(gameType); - _deployTEEContracts(cfg.finalSystemOwner()); + _deployTEEContracts(gameType); _deployAggregateVerifier(gameType); vm.stopBroadcast(); @@ -122,83 +119,73 @@ contract DeployDevWithNitro is Script { _writeOutput(); } - function _deployTEEContracts(address owner) internal { - address scgImpl = address( + function _deployTEEContracts(GameType gameType) internal { + address owner = cfg.finalSystemOwner(); + address teeRegistryImpl = address( new TEEProverRegistry( INitroEnclaveVerifier(nitroEnclaveVerifierAddr), IDisputeGameFactory(disputeGameFactory) ) ); - address[] memory initialProposers = new address[](1); + address[] memory initialProposers = new address[](2); initialProposers[0] = cfg.teeProposer(); - teeProverRegistryProxy = address( - new TransparentUpgradeableProxy( - scgImpl, - address(0xdead), - abi.encodeCall( - TEEProverRegistry.initialize, - (owner, owner, initialProposers, GameType.wrap(uint32(cfg.multiproofGameType()))) - ) - ) + initialProposers[1] = cfg.teeChallenger(); + Proxy teeProxy = new Proxy(msg.sender); + teeProxy.upgradeToAndCall( + teeRegistryImpl, abi.encodeCall(TEEProverRegistry.initialize, (owner, owner, initialProposers, gameType)) ); - console.log("TEEProverRegistry:", teeProverRegistryProxy); + teeProxy.changeAdmin(address(0xdead)); + teeProverRegistryProxy = address(teeProxy); - teeVerifier = address( - new TEEVerifier(TEEProverRegistry(teeProverRegistryProxy), IAnchorStateRegistry(mockAnchorRegistry)) - ); - console.log("TEEVerifier:", teeVerifier); + teeVerifier = address(new TEEVerifier(TEEProverRegistry(teeProverRegistryProxy), mockAnchorRegistry)); } function _deployInfrastructure(GameType gameType) internal { address factoryImpl = address(new DisputeGameFactory()); MinimalProxyAdmin proxyAdmin = new MinimalProxyAdmin(cfg.finalSystemOwner()); - TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(factoryImpl, address(proxyAdmin), ""); - - vm.store(address(proxy), PROXY_OWNER_ADDRESS, bytes32(uint256(uint160(address(proxyAdmin))))); + Proxy proxy = new Proxy(msg.sender); + proxy.upgradeTo(factoryImpl); + proxy.changeAdmin(address(proxyAdmin)); DisputeGameFactory(address(proxy)).initialize(cfg.finalSystemOwner()); - disputeGameFactory = address(proxy); - console.log("DisputeGameFactory:", disputeGameFactory); MockAnchorStateRegistry asr = new MockAnchorStateRegistry(); - mockAnchorRegistry = address(asr); + mockAnchorRegistry = IAnchorStateRegistry(address(asr)); asr.initialize( disputeGameFactory, Hash.wrap(cfg.multiproofGenesisOutputRoot()), cfg.multiproofGenesisBlockNumber(), gameType ); - console.log("AnchorStateRegistry (mock):", mockAnchorRegistry); } function _deployAggregateVerifier(GameType gameType) internal { - address zkVerifier = address(new MockVerifier(IAnchorStateRegistry(mockAnchorRegistry))); - console.log("MockVerifier (ZK):", zkVerifier); - + address zkVerifier = address(new MockVerifier(mockAnchorRegistry)); mockDelayedWETH = address(new MockDelayedWETH()); - console.log("MockDelayedWETH:", mockDelayedWETH); + + AggregateVerifier.ZkHashes memory zkHashes = + AggregateVerifier.ZkHashes({ rangeHash: cfg.zkRangeHash(), aggregateHash: cfg.zkAggregationHash() }); aggregateVerifier = address( new AggregateVerifier( gameType, - IAnchorStateRegistry(mockAnchorRegistry), + mockAnchorRegistry, IDelayedWETH(payable(mockDelayedWETH)), IVerifier(teeVerifier), IVerifier(zkVerifier), cfg.teeImageHash(), - AggregateVerifier.ZkHashes(bytes32(0), bytes32(0)), + zkHashes, cfg.multiproofConfigHash(), - 8453, + cfg.l2ChainID(), BLOCK_INTERVAL, INTERMEDIATE_BLOCK_INTERVAL, PROOF_THRESHOLD ) ); - console.log("AggregateVerifier:", aggregateVerifier); - DisputeGameFactory(disputeGameFactory).setImplementation(gameType, IDisputeGame(aggregateVerifier), ""); - DisputeGameFactory(disputeGameFactory).setInitBond(gameType, INIT_BOND); - console.log("Registered AggregateVerifier with factory"); + DisputeGameFactory factory = DisputeGameFactory(disputeGameFactory); + factory.setImplementation(gameType, IDisputeGame(aggregateVerifier), ""); + factory.setInitBond(gameType, INIT_BOND); } function _printSummary() internal view { @@ -211,7 +198,7 @@ contract DeployDevWithNitro is Script { console.log(" TEEVerifier:", teeVerifier); console.log("\nInfrastructure:"); console.log(" DisputeGameFactory:", disputeGameFactory); - console.log(" AnchorStateRegistry (mock):", mockAnchorRegistry); + console.log(" AnchorStateRegistry (mock):", address(mockAnchorRegistry)); console.log(" DelayedWETH (mock):", mockDelayedWETH); console.log("\nGame:"); console.log(" AggregateVerifier:", aggregateVerifier); @@ -227,19 +214,17 @@ contract DeployDevWithNitro is Script { } function _writeOutput() internal { - // Build the JSON output with all deployed addresses - string memory json = ""; - json = string.concat(json, '{"TEEProverRegistry":"', vm.toString(teeProverRegistryProxy)); - json = string.concat(json, '","TEEVerifier":"', vm.toString(teeVerifier)); - json = string.concat(json, '","NitroEnclaveVerifier":"', vm.toString(nitroEnclaveVerifierAddr)); - json = string.concat(json, '","DisputeGameFactory":"', vm.toString(disputeGameFactory)); - json = string.concat(json, '","AnchorStateRegistry":"', vm.toString(mockAnchorRegistry)); - json = string.concat(json, '","DelayedWETH":"', vm.toString(mockDelayedWETH)); - json = string.concat(json, '","AggregateVerifier":"', vm.toString(aggregateVerifier)); - json = string.concat(json, '"}'); + string memory key = "deployment"; + vm.serializeAddress(key, "TEEProverRegistry", teeProverRegistryProxy); + vm.serializeAddress(key, "TEEVerifier", teeVerifier); + vm.serializeAddress(key, "NitroEnclaveVerifier", nitroEnclaveVerifierAddr); + vm.serializeAddress(key, "DisputeGameFactory", disputeGameFactory); + vm.serializeAddress(key, "AnchorStateRegistry", address(mockAnchorRegistry)); + vm.serializeAddress(key, "DelayedWETH", mockDelayedWETH); + string memory json = vm.serializeAddress(key, "AggregateVerifier", aggregateVerifier); string memory outPath = string.concat("deployments/", vm.toString(block.chainid), "-dev-with-nitro.json"); - vm.writeFile(outPath, json); + vm.writeJson(json, outPath); console.log("Deployment saved to:", outPath); } }