diff --git a/packages/protocol/contracts/layer1/based/LibProving.sol b/packages/protocol/contracts/layer1/based/LibProving.sol index c568814ad4d..d5b26727daf 100644 --- a/packages/protocol/contracts/layer1/based/LibProving.sol +++ b/packages/protocol/contracts/layer1/based/LibProving.sol @@ -144,7 +144,7 @@ library LibProving { } // If batch verifier name is not empty, verify the batch proof. - if (batchVerifierName != "") { + if (batchVerifierName != LibStrings.B_TIER_OPTIMISTIC) { IVerifier(_resolver.resolve(batchVerifierName, false)).verifyBatchProof( ctxs, batchProof ); diff --git a/packages/protocol/contracts/layer1/tiers/TierProviderBase.sol b/packages/protocol/contracts/layer1/tiers/TierProviderBase.sol index 27415a361ef..b1eadb72334 100644 --- a/packages/protocol/contracts/layer1/tiers/TierProviderBase.sol +++ b/packages/protocol/contracts/layer1/tiers/TierProviderBase.sol @@ -10,80 +10,72 @@ import "./LibTiers.sol"; /// Ensure all modifications are reviewed by the devrel team. /// @custom:security-contact security@taiko.xyz abstract contract TierProviderBase is ITierProvider { - /// @dev Grace period for block proving service. - /// @notice This constant defines the time window (in minutes) during which the block proving - /// service may be paused if gas prices are excessively high. Since block proving is - /// asynchronous, this grace period allows provers to defer submissions until gas - /// prices become more favorable, potentially reducing transaction costs. - uint16 public constant GRACE_PERIOD = 240; // minutes - uint96 public constant BOND_UNIT = 75 ether; // TAIKO tokens + uint96 public constant BOND_UNIT = 50 ether; // TAIKO tokens /// @inheritdoc ITierProvider /// @notice Each tier, except the top tier, has a validity bond that is 75 TAIKO higher than the /// previous tier. Additionally, each tier's contest bond is 6.5625 times its validity bond. function getTier(uint16 _tierId) public pure virtual returns (ITierProvider.Tier memory) { if (_tierId == LibTiers.TIER_OPTIMISTIC) { - // cooldownWindow is 1440 minutes and provingWindow is 15 minutes - return _buildTier("", BOND_UNIT, 1440, 15); + return _buildTier(LibStrings.B_TIER_OPTIMISTIC, 1, 1440, 60); } // TEE Tiers - if (_tierId == LibTiers.TIER_SGX) return _buildTeeTier(LibStrings.B_TIER_SGX); - if (_tierId == LibTiers.TIER_TDX) return _buildTeeTier(LibStrings.B_TIER_TDX); - if (_tierId == LibTiers.TIER_TEE_ANY) return _buildTeeTier(LibStrings.B_TIER_TEE_ANY); + if (_tierId == LibTiers.TIER_SGX) { + // cooldownWindow is 240 minutes and provingWindow is 60 minutes + return _buildTier(LibStrings.B_TIER_SGX, 2, 240, 60); + } + if (_tierId == LibTiers.TIER_TDX) { + // cooldownWindow is 240 minutes and provingWindow is 60 minutes + return _buildTier(LibStrings.B_TIER_TDX, 2, 240, 60); + } + if (_tierId == LibTiers.TIER_TEE_ANY) { + // cooldownWindow is 240 minutes and provingWindow is 60 minutes + return _buildTier(LibStrings.B_TIER_TEE_ANY, 2, 240, 60); + } - // ZKVM Tiers - if (_tierId == LibTiers.TIER_ZKVM_RISC0) return _buildZkTier(LibStrings.B_TIER_ZKVM_RISC0); - if (_tierId == LibTiers.TIER_ZKVM_SP1) return _buildZkTier(LibStrings.B_TIER_ZKVM_SP1); - if (_tierId == LibTiers.TIER_ZKVM_ANY) return _buildZkTier(LibStrings.B_TIER_ZKVM_ANY); + // ZKVM Tiers: Allowing 120 minutes for proof aggregation. + if (_tierId == LibTiers.TIER_ZKVM_RISC0) { + // cooldownWindow is 240 minutes and provingWindow is 120 minutes + return _buildTier(LibStrings.B_TIER_ZKVM_RISC0, 3, 240, 120); + } + if (_tierId == LibTiers.TIER_ZKVM_SP1) { + // cooldownWindow is 240 minutes and provingWindow is 120 minutes + return _buildTier(LibStrings.B_TIER_ZKVM_SP1, 3, 240, 120); + } + if (_tierId == LibTiers.TIER_ZKVM_ANY) { + // cooldownWindow is 240 minutes and provingWindow is 90 minutes + return _buildTier(LibStrings.B_TIER_ZKVM_ANY, 3, 240, 120); + } if (_tierId == LibTiers.TIER_ZKVM_AND_TEE) { - return _buildZkTier(LibStrings.B_TIER_ZKVM_AND_TEE); + // cooldownWindow is 240 minutes and provingWindow is 90 minutes + return _buildTier(LibStrings.B_TIER_ZKVM_AND_TEE, 3, 240, 120); } // Guardian Minority Tiers if (_tierId == LibTiers.TIER_GUARDIAN_MINORITY) { - // cooldownWindow is 240 minutes and provingWindow is 2880 minutes - return _buildTier(LibStrings.B_TIER_GUARDIAN_MINORITY, BOND_UNIT * 3, 240, 0); + // cooldownWindow is 60 minutes and provingWindow is 120 minutes + return _buildTier(LibStrings.B_TIER_GUARDIAN_MINORITY, 4, 240, 120); } // Guardian Major Tiers if (_tierId == LibTiers.TIER_GUARDIAN) { - // cooldownWindow is 1440 minutes and provingWindow is 2880 minutes - return _buildTier(LibStrings.B_TIER_GUARDIAN, 0, 240, 0); + // cooldownWindow is 480 minutes + return _buildTier(LibStrings.B_TIER_GUARDIAN, 0, 480, 0); } revert TIER_NOT_FOUND(); } - /// @dev Builds a TEE tier with a specific verifier name. - /// @param _verifierName The name of the verifier. - /// @return A Tier struct with predefined parameters for TEE. - function _buildTeeTier(bytes32 _verifierName) - private - pure - returns (ITierProvider.Tier memory) - { - // cooldownWindow is 1440 minutes and provingWindow is 60 minutes - return _buildTier(_verifierName, BOND_UNIT * 2, 240, 60); - } - - /// @dev Builds a ZK tier with a specific verifier name. - /// @param _verifierName The name of the verifier. - /// @return A Tier struct with predefined parameters for ZK. - function _buildZkTier(bytes32 _verifierName) private pure returns (ITierProvider.Tier memory) { - // cooldownWindow is 1440 minutes and provingWindow is 180 minutes - return _buildTier(_verifierName, BOND_UNIT * 3, 240, 180); - } - /// @dev Builds a generic tier with specified parameters. /// @param _verifierName The name of the verifier. - /// @param _validityBond The validity bond amount. + /// @param _validityBondUnits The units of validity bonds. /// @param _cooldownWindow The cooldown window duration in minutes. /// @param _provingWindow The proving window duration in minutes. /// @return A Tier struct with the provided parameters. function _buildTier( bytes32 _verifierName, - uint96 _validityBond, + uint8 _validityBondUnits, uint16 _cooldownWindow, uint16 _provingWindow ) @@ -91,13 +83,14 @@ abstract contract TierProviderBase is ITierProvider { pure returns (ITierProvider.Tier memory) { + uint96 validityBond = BOND_UNIT * _validityBondUnits; return ITierProvider.Tier({ verifierName: _verifierName, - validityBond: _validityBond, - contestBond: _validityBond / 10_000 * 65_625, + validityBond: validityBond, + contestBond: validityBond / 10_000 * 65_625, cooldownWindow: _cooldownWindow, - provingWindow: GRACE_PERIOD + _provingWindow, - maxBlocksToVerifyPerProof: 0 // DEPRECATED - }); + provingWindow: _provingWindow, + maxBlocksToVerifyPerProof: 0 + }); } } diff --git a/packages/protocol/contracts/shared/common/LibStrings.sol b/packages/protocol/contracts/shared/common/LibStrings.sol index d7058f2de39..8437cf03fb9 100644 --- a/packages/protocol/contracts/shared/common/LibStrings.sol +++ b/packages/protocol/contracts/shared/common/LibStrings.sol @@ -26,6 +26,7 @@ library LibStrings { bytes32 internal constant B_TAIKO_TOKEN = bytes32("taiko_token"); bytes32 internal constant B_TIER_GUARDIAN = bytes32("tier_guardian"); bytes32 internal constant B_TIER_GUARDIAN_MINORITY = bytes32("tier_guardian_minority"); + bytes32 internal constant B_TIER_OPTIMISTIC = bytes32("tier_optimistic"); bytes32 internal constant B_TIER_ROUTER = bytes32("tier_router"); bytes32 internal constant B_TIER_SGX = bytes32("tier_sgx"); bytes32 internal constant B_TIER_TDX = bytes32("tier_tdx");