-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol): refactor tier providers and added minority-guardian p…
…rovers to all providers (#17169) Co-authored-by: Daniel Wang <[email protected]> Co-authored-by: dantaik <[email protected]> Co-authored-by: Daniel Wang <[email protected]>
- Loading branch information
1 parent
7cf6cfe
commit cd51442
Showing
20 changed files
with
219 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 5 additions & 41 deletions
46
packages/protocol/contracts/L1/tiers/DevnetTierProvider.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "../../common/EssentialContract.sol"; | ||
import "../../common/LibStrings.sol"; | ||
import "./ITierProvider.sol"; | ||
import "./TierProviderBase.sol"; | ||
|
||
/// @title DevnetTierProvider | ||
/// @dev Labeled in AddressResolver as "tier_provider" | ||
/// @custom:security-contact [email protected] | ||
contract DevnetTierProvider is EssentialContract, ITierProvider { | ||
uint256[50] private __gap; | ||
|
||
/// @notice Initializes the contract. | ||
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero. | ||
function init(address _owner) external initializer { | ||
__Essential_init(_owner); | ||
} | ||
|
||
/// @inheritdoc ITierProvider | ||
function getTier(uint16 _tierId) public pure override returns (ITierProvider.Tier memory) { | ||
if (_tierId == LibTiers.TIER_OPTIMISTIC) { | ||
return ITierProvider.Tier({ | ||
verifierName: "", | ||
validityBond: 250 ether, // TKO | ||
contestBond: 500 ether, // TKO | ||
cooldownWindow: 1440, //24 hours | ||
provingWindow: 120, // 2 hours | ||
maxBlocksToVerifyPerProof: 16 | ||
}); | ||
} | ||
|
||
if (_tierId == LibTiers.TIER_GUARDIAN) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_GUARDIAN, | ||
validityBond: 0, // must be 0 for top tier | ||
contestBond: 0, // must be 0 for top tier | ||
cooldownWindow: 60, //1 hours | ||
provingWindow: 2880, // 48 hours | ||
maxBlocksToVerifyPerProof: 16 | ||
}); | ||
} | ||
|
||
revert TIER_NOT_FOUND(); | ||
} | ||
|
||
contract DevnetTierProvider is TierProviderBase { | ||
/// @inheritdoc ITierProvider | ||
function getTierIds() public pure override returns (uint16[] memory tiers_) { | ||
tiers_ = new uint16[](2); | ||
tiers_ = new uint16[](3); | ||
tiers_[0] = LibTiers.TIER_OPTIMISTIC; | ||
tiers_[1] = LibTiers.TIER_GUARDIAN; | ||
tiers_[1] = LibTiers.TIER_GUARDIAN_MINORITY; | ||
tiers_[2] = LibTiers.TIER_GUARDIAN; | ||
} | ||
|
||
/// @inheritdoc ITierProvider | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,28 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "../../common/EssentialContract.sol"; | ||
import "../../common/LibStrings.sol"; | ||
import "./ITierProvider.sol"; | ||
|
||
/// @title HeklaTierProvider | ||
/// @dev Labeled in AddressResolver as "tier_provider" | ||
/// @title TierProviderBase | ||
/// @custom:security-contact [email protected] | ||
contract HeklaTierProvider is EssentialContract, ITierProvider { | ||
uint256[50] private __gap; | ||
|
||
/// @notice Initializes the contract. | ||
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero. | ||
function init(address _owner) external initializer { | ||
__Essential_init(_owner); | ||
} | ||
|
||
abstract contract TierProviderBase is ITierProvider { | ||
/// @inheritdoc ITierProvider | ||
function getTier(uint16 _tierId) public pure override returns (ITierProvider.Tier memory) { | ||
function getTier(uint16 _tierId) | ||
public | ||
pure | ||
virtual | ||
override | ||
returns (ITierProvider.Tier memory) | ||
{ | ||
if (_tierId == LibTiers.TIER_OPTIMISTIC) { | ||
return ITierProvider.Tier({ | ||
verifierName: "", | ||
validityBond: 250 ether, // TKO | ||
contestBond: 500 ether, // TKO | ||
cooldownWindow: 1440, //24 hours | ||
provingWindow: 30, // 0.5 hours | ||
maxBlocksToVerifyPerProof: 12 | ||
maxBlocksToVerifyPerProof: 16 | ||
}); | ||
} | ||
|
||
|
@@ -41,6 +37,28 @@ contract HeklaTierProvider is EssentialContract, ITierProvider { | |
}); | ||
} | ||
|
||
if (_tierId == LibTiers.TIER_SGX_ZKVM) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_SGX_ZKVM, | ||
validityBond: 500 ether, // TKO | ||
contestBond: 3280 ether, // =500TKO * 6.5625 | ||
cooldownWindow: 1440, //24 hours | ||
provingWindow: 240, // 4 hours | ||
maxBlocksToVerifyPerProof: 4 | ||
}); | ||
} | ||
|
||
if (_tierId == LibTiers.TIER_GUARDIAN_MINORITY) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_GUARDIAN_MINORITY, | ||
validityBond: 500 ether, // TKO | ||
contestBond: 3280 ether, // =500TKO * 6.5625 | ||
cooldownWindow: 1440, //24 hours | ||
provingWindow: 2880, // 48 hours | ||
maxBlocksToVerifyPerProof: 16 | ||
}); | ||
} | ||
|
||
if (_tierId == LibTiers.TIER_GUARDIAN) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_GUARDIAN, | ||
|
@@ -54,18 +72,4 @@ contract HeklaTierProvider is EssentialContract, ITierProvider { | |
|
||
revert TIER_NOT_FOUND(); | ||
} | ||
|
||
/// @inheritdoc ITierProvider | ||
function getTierIds() public pure override returns (uint16[] memory tiers_) { | ||
tiers_ = new uint16[](3); | ||
tiers_[0] = LibTiers.TIER_OPTIMISTIC; | ||
tiers_[1] = LibTiers.TIER_SGX; | ||
tiers_[2] = LibTiers.TIER_GUARDIAN; | ||
} | ||
|
||
/// @inheritdoc ITierProvider | ||
function getMinTier(uint256 _rand) public pure override returns (uint16) { | ||
// All blocks require SGX proofs. | ||
return LibTiers.TIER_SGX; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,12 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "../../common/EssentialContract.sol"; | ||
import "../../common/LibStrings.sol"; | ||
import "./ITierProvider.sol"; | ||
import "./TierProviderBase.sol"; | ||
|
||
/// @title TierProviderV2 | ||
/// @dev Labeled in AddressResolver as "tier_provider" | ||
/// @custom:security-contact [email protected] | ||
contract TierProviderV2 is EssentialContract, ITierProvider { | ||
uint256[50] private __gap; | ||
|
||
/// @notice Initializes the contract. | ||
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero. | ||
function init(address _owner) external initializer { | ||
__Essential_init(_owner); | ||
} | ||
|
||
/// @inheritdoc ITierProvider | ||
function getTier(uint16 _tierId) public pure override returns (ITierProvider.Tier memory) { | ||
if (_tierId == LibTiers.TIER_SGX) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_SGX, | ||
validityBond: 250 ether, // TKO | ||
contestBond: 1640 ether, // =250TKO * 6.5625 | ||
cooldownWindow: 1440, //24 hours | ||
provingWindow: 60, // 1 hours | ||
maxBlocksToVerifyPerProof: 8 | ||
}); | ||
} | ||
|
||
if (_tierId == LibTiers.TIER_GUARDIAN_MINORITY) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_GUARDIAN_MINORITY, | ||
validityBond: 500 ether, // TKO | ||
contestBond: 3280 ether, // =500TKO * 6.5625 | ||
cooldownWindow: 60, //1 hours | ||
provingWindow: 2880, // 48 hours | ||
maxBlocksToVerifyPerProof: 16 | ||
}); | ||
} | ||
|
||
if (_tierId == LibTiers.TIER_GUARDIAN) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_GUARDIAN, | ||
validityBond: 0, // must be 0 for top tier | ||
contestBond: 0, // must be 0 for top tier | ||
cooldownWindow: 60, //1 hours | ||
provingWindow: 2880, // 48 hours | ||
maxBlocksToVerifyPerProof: 16 | ||
}); | ||
} | ||
|
||
revert TIER_NOT_FOUND(); | ||
} | ||
|
||
contract TierProviderV2 is TierProviderBase { | ||
/// @inheritdoc ITierProvider | ||
function getTierIds() public pure override returns (uint16[] memory tiers_) { | ||
tiers_ = new uint16[](3); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,12 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "../../common/EssentialContract.sol"; | ||
import "../../common/LibStrings.sol"; | ||
import "./ITierProvider.sol"; | ||
import "./TierProviderBase.sol"; | ||
|
||
/// @title TierProviderV3 | ||
/// @dev Labeled in AddressResolver as "tier_provider" | ||
/// @custom:security-contact [email protected] | ||
contract TierProviderV3 is EssentialContract, ITierProvider { | ||
uint256[50] private __gap; | ||
|
||
/// @notice Initializes the contract. | ||
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero. | ||
function init(address _owner) external initializer { | ||
__Essential_init(_owner); | ||
} | ||
|
||
/// @inheritdoc ITierProvider | ||
function getTier(uint16 _tierId) public pure override returns (ITierProvider.Tier memory) { | ||
if (_tierId == LibTiers.TIER_SGX) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_SGX, | ||
validityBond: 250 ether, // TKO | ||
contestBond: 1640 ether, // =250TKO * 6.5625 | ||
cooldownWindow: 1440, //24 hours | ||
provingWindow: 60, // 1 hours | ||
maxBlocksToVerifyPerProof: 8 | ||
}); | ||
} | ||
|
||
if (_tierId == LibTiers.TIER_SGX_ZKVM) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_SGX_ZKVM, | ||
validityBond: 500 ether, // TKO | ||
contestBond: 3280 ether, // =500TKO * 6.5625 | ||
cooldownWindow: 1440, //24 hours | ||
provingWindow: 240, // 4 hours | ||
maxBlocksToVerifyPerProof: 4 | ||
}); | ||
} | ||
|
||
if (_tierId == LibTiers.TIER_GUARDIAN_MINORITY) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_GUARDIAN_MINORITY, | ||
validityBond: 500 ether, // TKO | ||
contestBond: 3280 ether, // =500TKO * 6.5625 | ||
cooldownWindow: 60, //1 hours | ||
provingWindow: 2880, // 48 hours | ||
maxBlocksToVerifyPerProof: 16 | ||
}); | ||
} | ||
|
||
if (_tierId == LibTiers.TIER_GUARDIAN) { | ||
return ITierProvider.Tier({ | ||
verifierName: LibStrings.B_TIER_GUARDIAN, | ||
validityBond: 0, // must be 0 for top tier | ||
contestBond: 0, // must be 0 for top tier | ||
cooldownWindow: 60, //1 hours | ||
provingWindow: 2880, // 48 hours | ||
maxBlocksToVerifyPerProof: 16 | ||
}); | ||
} | ||
|
||
revert TIER_NOT_FOUND(); | ||
} | ||
|
||
contract TierProviderV3 is TierProviderBase { | ||
/// @inheritdoc ITierProvider | ||
function getTierIds() public pure override returns (uint16[] memory tiers_) { | ||
tiers_ = new uint16[](4); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.