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
3 changes: 3 additions & 0 deletions deploy-config/hardhat.json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also have risc0VerifierRouter and risc0SetBuilderImageId.

Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"multiproofConfigHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"multiproofGameType": 621,
"teeProposer": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
"teeChallenger": "0x976EA74026E726554dB657fA54763abd0C3a0aa9",
"zkRangeHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"zkAggregationHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nitroEnclaveVerifier": "0x0000000000000000000000000000000000000000",
"multiproofGenesisOutputRoot": "0x0000000000000000000000000000000000000000000000000000000000000001",
"multiproofGenesisBlockNumber": 0,
Expand Down
7 changes: 5 additions & 2 deletions deploy-config/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion scripts/deploy/DeployConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
103 changes: 39 additions & 64 deletions scripts/multiproof/DeployDevNoNitro.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -113,14 +109,15 @@ 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.");

vm.startBroadcast();

_deployInfrastructure(gameType);
_deployTEEContracts(cfg.finalSystemOwner());
_deployTEEContracts(gameType);
_deployAggregateVerifier(gameType);

vm.stopBroadcast();
Expand All @@ -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 {
Expand All @@ -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);
Expand All @@ -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);
}
}
Loading
Loading