Skip to content
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

feat(protocol): add TIER_ZKVM_RISC0 tier and HeklaTierProvider #17913

Merged
merged 8 commits into from
Aug 15, 2024
3 changes: 3 additions & 0 deletions packages/protocol/contracts/L1/tiers/ITierProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ library LibTiers {
uint16 public constant TIER_SGX = 200;
uint16 public constant TIER_SGX2 = 200;

// @notice ZKVM risc0 tier ID
uint16 public constant TIER_ZKVM_RISC0 = 290;

/// @notice SGX + ZKVM tier ID.
uint16 public constant TIER_SGX_ZKVM = 300;

Expand Down
11 changes: 11 additions & 0 deletions packages/protocol/contracts/L1/tiers/TierProviderBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ abstract contract TierProviderBase is ITierProvider {
});
}

if (_tierId == LibTiers.TIER_ZKVM_RISC0) {
return ITierProvider.Tier({
verifierName: LibStrings.B_TIER_ZKVM_RISC0,
validityBond: 250 ether, // TKO
dantaik marked this conversation as resolved.
Show resolved Hide resolved
contestBond: 1640 ether, // =500TKO * 6.5625
dantaik marked this conversation as resolved.
Show resolved Hide resolved
cooldownWindow: 1440, //24 hours
provingWindow: GRACE_PERIOD + 240, // 4 hours
maxBlocksToVerifyPerProof: 0
});
}

if (_tierId == LibTiers.TIER_SGX_ZKVM) {
return ITierProvider.Tier({
verifierName: LibStrings.B_TIER_SGX_ZKVM,
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/contracts/common/LibStrings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ library LibStrings {
bytes32 internal constant B_TIER_ROUTER = bytes32("tier_router");
bytes32 internal constant B_TIER_SGX = bytes32("tier_sgx");
bytes32 internal constant B_TIER_SGX2 = bytes32("tier_sgx2");
bytes32 internal constant B_TIER_ZKVM_RISC0 = bytes32("tier_zkvm_risc0");
bytes32 internal constant B_TIER_SGX_ZKVM = bytes32("tier_sgx_zkvm");
bytes32 internal constant B_RISCZERO_GROTH16_VERIFIER = bytes32("risc0_groth16_verifier");
bytes32 internal constant B_WITHDRAWER = bytes32("withdrawer");
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/script/DeployOnL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ contract DeployOnL1 is DeployCapability {
register(rollupAddressManager, "risc0_groth16_verifier", address(verifier));

deployProxy({
name: "risc0_verifier",
name: "tier_zkvm_risc0",
impl: address(new RiscZeroVerifier()),
data: abi.encodeCall(RiscZeroVerifier.init, (owner, rollupAddressManager)),
registerTo: rollupAddressManager
Expand Down
28 changes: 28 additions & 0 deletions packages/protocol/script/DeployRisc0Verifier.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.24;

import "@risc0/contracts/groth16/RiscZeroGroth16Verifier.sol";
import "../test/DeployCapability.sol";
import "../contracts/verifiers/RiscZeroVerifier.sol";

contract DeployRisc0Verifier is DeployCapability {
uint256 public deployerPrivKey = vm.envUint("PRIVATE_KEY");
address public rollupAddressManager = vm.envAddress("ROLLUP_ADDRESS_MANAGER");

function run() external {
require(deployerPrivKey != 0, "invalid deployer priv key");
require(rollupAddressManager != address(0), "invalid rollup address manager address");

vm.startBroadcast(deployerPrivKey);
RiscZeroGroth16Verifier verifier =
new RiscZeroGroth16Verifier(ControlID.CONTROL_ROOT, ControlID.BN254_CONTROL_ID);
register(rollupAddressManager, "risc0_groth16_verifier", address(verifier));
deployProxy({
name: "tier_zkvm_risc0",
impl: address(new RiscZeroVerifier()),
data: abi.encodeCall(RiscZeroVerifier.init, (address(0), rollupAddressManager)),
registerTo: rollupAddressManager
});
vm.stopBroadcast();
}
}