Skip to content

Commit

Permalink
feat(protocol): rename config providers and add ZKRollupConfigProvider (
Browse files Browse the repository at this point in the history
#14829)

Co-authored-by: Daniel Wang <[email protected]>
  • Loading branch information
dantaik and dong77 authored Sep 27, 2023
1 parent 7274072 commit 90612d2
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 11 deletions.
7 changes: 4 additions & 3 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ library LibProposing {
internal
returns (TaikoData.BlockMetadata memory meta)
{
// Taiko, as a Based Rollup, enables permissionless block proposals. However,
// if the "proposer" address is set to a non-zero value, we ensure that
// only that specific address has the authority to propose blocks.
// Taiko, as a Based Rollup, enables permissionless block proposals.
// However, if the "proposer" address is set to a non-zero value, we
// ensure that only that specific address has the authority to propose
// blocks.
address proposer = resolver.resolve("proposer", true);
if (proposer != address(0) && msg.sender != proposer) {
revert L1_UNAUTHORIZED();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pragma solidity ^0.8.20;

import { ITierProvider, LibTiers } from "./ITierProvider.sol";

/// @title OPL2ConfigProvider
contract OPL2ConfigProvider is ITierProvider {
/// @title OptimisticRollupConfigProvider
contract OptimisticRollupConfigProvider is ITierProvider {
error TIER_NOT_FOUND();

function getTier(uint16 tierId)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;

import { ITierProvider, LibTiers } from "./ITierProvider.sol";

/// @title ValidityRollupConfigProvider
contract ValidityRollupConfigProvider is ITierProvider {
error TIER_NOT_FOUND();

function getTier(uint16 tierId)
public
pure
override
returns (ITierProvider.Tier memory)
{
if (tierId == LibTiers.TIER_SGX) {
return ITierProvider.Tier({
verifierName: "tier_sgx",
validityBond: 50_000 ether, // TKO
contestBond: 50_000 ether, // TKO
cooldownWindow: 3 hours,
provingWindow: 60 minutes
});
}

if (tierId == LibTiers.TIER_PSE_ZKEVM) {
return ITierProvider.Tier({
verifierName: "tier_pse_zkevm",
validityBond: 10_000 ether, // TKO
contestBond: 10_000 ether, // TKO
cooldownWindow: 2 hours,
provingWindow: 90 minutes
});
}

if (tierId == LibTiers.TIER_GUARDIAN) {
return ITierProvider.Tier({
verifierName: "tier_guardian",
validityBond: 0,
contestBond: 0, // not contestable
cooldownWindow: 1 hours,
provingWindow: 120 minutes
});
}

revert TIER_NOT_FOUND();
}

function getTierIds()
public
pure
override
returns (uint16[] memory tiers)
{
tiers = new uint16[](3);
tiers[0] = LibTiers.TIER_SGX;
tiers[1] = LibTiers.TIER_PSE_ZKEVM;
tiers[2] = LibTiers.TIER_GUARDIAN;
}

function getMinTier(uint256 rand) public pure override returns (uint16) {
if (rand % 100 == 0) return LibTiers.TIER_PSE_ZKEVM;
else return LibTiers.TIER_SGX;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pragma solidity ^0.8.20;

import { ITierProvider, LibTiers } from "./ITierProvider.sol";

/// @title ZKL2ConfigProvider
contract ZKL2ConfigProvider is ITierProvider {
/// @title ZKRollupConfigProvider
contract ZKRollupConfigProvider is ITierProvider {
error TIER_NOT_FOUND();

function getTier(uint16 tierId)
Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/test/L1/TaikoL1TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { TaikoL1 } from "../../contracts/L1/TaikoL1.sol";
import { TaikoToken } from "../../contracts/L1/TaikoToken.sol";
import { GuardianVerifier } from
"../../contracts/L1/verifiers/GuardianVerifier.sol";
import { OPL2ConfigProvider } from
"../../contracts/L1/tiers/OPL2ConfigProvider.sol";
import { OptimisticRollupConfigProvider } from
"../../contracts/L1/tiers/OptimisticRollupConfigProvider.sol";
import { PseZkVerifier } from "../../contracts/L1/verifiers/PseZkVerifier.sol";
import { SignalService } from "../../contracts/signal/SignalService.sol";
import { StringsUpgradeable as Strings } from
Expand All @@ -36,7 +36,7 @@ abstract contract TaikoL1TestBase is TestBase {
uint256 internal logCount;
PseZkVerifier public pv;
GuardianVerifier public gv;
OPL2ConfigProvider public cp;
OptimisticRollupConfigProvider public cp;

bytes32 public constant GENESIS_BLOCK_HASH = keccak256("GENESIS_BLOCK_HASH");
// 1 TKO --> it is to huge. It should be in 'wei' (?).
Expand Down Expand Up @@ -71,7 +71,7 @@ abstract contract TaikoL1TestBase is TestBase {
gv = new GuardianVerifier();
gv.init(address(addressManager));

cp = new OPL2ConfigProvider();
cp = new OptimisticRollupConfigProvider();

registerAddress("tier_pse_zkevm", address(pv));
registerAddress("tier_guardian", address(gv));
Expand Down

0 comments on commit 90612d2

Please sign in to comment.