Skip to content

Commit

Permalink
Merge branch 'main' into ontake_cleanup2
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Nov 2, 2024
2 parents 9a3c5ab + 9748ae5 commit acaaaaa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
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 @@ -34,7 +34,7 @@ contract RollupAddressCache is AddressCache {
return (true, 0x06a9Ab27c7e2255df1815E6CC0168d7755Feb19a);
}
if (_name == LibStrings.B_TIER_ROUTER) {
return (true, 0x2Ae89453c6c79Add793db7B9d23c275b90C26065);
return (true, 0x8f1C1D58C858e9a9eeCc587d7D51AECfd16b5542);
}
if (_name == LibStrings.B_TIER_SGX) {
return (true, 0xb0f3186FC1963f774f52ff455DC86aEdD0b31F81);
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 // DEPRECATED
});
Expand Down

0 comments on commit acaaaaa

Please sign in to comment.