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): rename config providers and add ZKRollupConfigProvider #14829

Merged
merged 1 commit into from
Sep 27, 2023
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
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