Skip to content

Commit

Permalink
chore(protocol): restore proving window changes (#18368)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Nov 2, 2024
1 parent 9345f14 commit 9182fba
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/protocol/contracts/layer1/based/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
/// @return blockId_ The last verified block's ID.
/// @return blockHash_ The last verified block's blockHash.
/// @return stateRoot_ The last verified block's stateRoot.
/// @return verifiedAt_ The timestamp this block is verified at.
/// @return verifiedAt_ The timestamp this block is proven at.
function getLastVerifiedBlock()
external
view
Expand All @@ -260,7 +260,7 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
/// @return blockId_ The last verified block's ID.
/// @return blockHash_ The last verified block's blockHash.
/// @return stateRoot_ The last verified block's stateRoot.
/// @return verifiedAt_ The timestamp this block is verified at.
/// @return verifiedAt_ The timestamp this block is proven at.
function getLastSyncedBlock()
external
view
Expand Down
2 changes: 2 additions & 0 deletions packages/protocol/contracts/layer1/hekla/HeklaTierRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import "../tiers/TierProviderBase.sol";
import "../tiers/ITierRouter.sol";

/// @title HeklaTierRouter
/// @dev Any changes to the configuration in this file must be announced and documented on our site.
/// Ensure all modifications are reviewed by the devrel team.
/// @custom:security-contact [email protected]
contract HeklaTierRouter is TierProviderBase, ITierRouter {
address public immutable DAO_FALLBACK_PROPOSER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import "src/layer1/tiers/ITierRouter.sol";
import "src/layer1/tiers/TierProviderBase.sol";

/// @title MainnetTierRouter
/// @dev Any changes to the configuration in this file must be announced and documented on our site.
/// Ensure all modifications are reviewed by the devrel team.
/// @dev Labeled in AddressResolver as "tier_router"
/// @custom:security-contact [email protected]
contract MainnetTierRouter is ITierRouter, TierProviderBase {
Expand All @@ -29,6 +31,7 @@ contract MainnetTierRouter is ITierRouter, TierProviderBase {
}

/// @inheritdoc ITierProvider
// solhint-disable-next-line no-unused-vars
function getMinTier(address _proposer, uint256 _rand) public view override returns (uint16) {
return LibTiers.TIER_SGX;
}
Expand Down
31 changes: 15 additions & 16 deletions packages/protocol/contracts/layer1/tiers/TierProviderBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "./ITierProvider.sol";
import "./LibTiers.sol";

/// @title TierProviderBase
/// @dev Any changes to the configuration in this file must be announced and documented on our site.
/// Ensure all modifications are reviewed by the devrel team.
/// @custom:security-contact [email protected]
abstract contract TierProviderBase is ITierProvider {
/// @dev Grace period for block proving service.
Expand All @@ -21,8 +23,8 @@ abstract contract TierProviderBase is ITierProvider {
/// 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 24 hours and provingWindow is 15 minutes
return _buildTier("", BOND_UNIT, 24, 15);
// cooldownWindow is 1440 minutes and provingWindow is 15 minutes
return _buildTier("", BOND_UNIT, 1440, 15);
}

// TEE Tiers
Expand All @@ -34,23 +36,20 @@ abstract contract TierProviderBase is ITierProvider {
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+TEE Tier
if (_tierId == LibTiers.TIER_ZKVM_AND_TEE) {
// cooldownWindow is 2 hours and provingWindow is 3 hours
return _buildTier(LibStrings.B_TIER_ZKVM_AND_TEE, BOND_UNIT * 4, 2, 180);
return _buildZkTier(LibStrings.B_TIER_ZKVM_AND_TEE);
}

// Guardian Minority Tiers
if (_tierId == LibTiers.TIER_GUARDIAN_MINORITY) {
// cooldownWindow is 4 hours
return _buildTier(LibStrings.B_TIER_GUARDIAN_MINORITY, BOND_UNIT * 4, 4, 0);
// cooldownWindow is 240 minutes and provingWindow is 2880 minutes
return _buildTier(LibStrings.B_TIER_GUARDIAN_MINORITY, BOND_UNIT * 3, 240, 0);
}

// Guardian Major Tiers
if (_tierId == LibTiers.TIER_GUARDIAN) {
// cooldownWindow is 4 hours
return _buildTier(LibStrings.B_TIER_GUARDIAN, 0, 4, 0);
// cooldownWindow is 1440 minutes and provingWindow is 2880 minutes
return _buildTier(LibStrings.B_TIER_GUARDIAN, 0, 240, 0);
}

revert TIER_NOT_FOUND();
Expand All @@ -64,22 +63,22 @@ abstract contract TierProviderBase is ITierProvider {
pure
returns (ITierProvider.Tier memory)
{
// cooldownWindow is 4 hours and provingWindow is 60 minutes
return _buildTier(_verifierName, BOND_UNIT * 2, 4, 60);
// 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 4 hours and provingWindow is 3 hours
return _buildTier(_verifierName, BOND_UNIT * 3, 4, 180);
// 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 _cooldownWindow The cooldown window duration in hours.
/// @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(
Expand All @@ -96,7 +95,7 @@ abstract contract TierProviderBase is ITierProvider {
verifierName: _verifierName,
validityBond: _validityBond,
contestBond: _validityBond / 10_000 * 65_625,
cooldownWindow: _cooldownWindow * 60,
cooldownWindow: _cooldownWindow,
provingWindow: GRACE_PERIOD + _provingWindow,
maxBlocksToVerifyPerProof: 0
});
Expand Down

0 comments on commit 9182fba

Please sign in to comment.