Skip to content

Commit

Permalink
feat(protocol): add a new tier B_TIER_GUARDIAN_MINORITY (#16790)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik committed Apr 22, 2024
1 parent 8e12210 commit cab4071
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
5 changes: 4 additions & 1 deletion packages/protocol/contracts/L1/tiers/ITierProvider.sol
Expand Up @@ -44,6 +44,9 @@ library LibTiers {
/// @notice SGX + ZKVM tier ID.
uint16 public constant TIER_SGX_ZKVM = 300;

/// @notice Guardian tier ID.
/// @notice Guardian tier ID with minority approval.
uint16 public constant TIER_GUARDIAN_MINORITY = 900;

/// @notice Guardian tier ID with majority approval.
uint16 public constant TIER_GUARDIAN = 1000;
}
16 changes: 14 additions & 2 deletions packages/protocol/contracts/L1/tiers/TierProviderV2.sol
Expand Up @@ -41,6 +41,17 @@ contract TierProviderV2 is EssentialContract, ITierProvider {
});
}

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,
Expand All @@ -57,10 +68,11 @@ contract TierProviderV2 is EssentialContract, ITierProvider {

/// @inheritdoc ITierProvider
function getTierIds() public pure override returns (uint16[] memory tiers_) {
tiers_ = new uint16[](3);
tiers_ = new uint16[](4);
tiers_[0] = LibTiers.TIER_SGX;
tiers_[1] = LibTiers.TIER_SGX_ZKVM;
tiers_[2] = LibTiers.TIER_GUARDIAN;
tiers_[2] = LibTiers.TIER_GUARDIAN_MINORITY;
tiers_[3] = LibTiers.TIER_GUARDIAN;
}

/// @inheritdoc ITierProvider
Expand Down
19 changes: 16 additions & 3 deletions packages/protocol/script/DeployOnL1.s.sol
Expand Up @@ -327,18 +327,31 @@ contract DeployOnL1 is DeployCapability {
registerTo: rollupAddressManager
});

address guardianProverImpl = address(new GuardianProver());

address guardianProverMinority = deployProxy({
name: "guardian_prover_minority",
impl: guardianProverImpl,
data: abi.encodeCall(GuardianProver.init, (address(0), rollupAddressManager)),
registerTo: rollupAddressManager
});

address guardianProver = deployProxy({
name: "guardian_prover",
impl: address(new GuardianProver()),
impl: guardianProverImpl,
data: abi.encodeCall(GuardianProver.init, (address(0), rollupAddressManager)),
registerTo: rollupAddressManager
});

register(rollupAddressManager, "tier_guardian_minority", guardianProverMinority);
register(rollupAddressManager, "tier_guardian", guardianProver);

address[] memory guardians = vm.envAddress("GUARDIAN_PROVERS", ",");
uint8 minGuardians = uint8(vm.envUint("MIN_GUARDIANS"));
GuardianProver(guardianProver).setGuardians(guardians, minGuardians);

GuardianProver(guardianProverMinority).setGuardians(guardians, 1);
GuardianProver(guardianProverMinority).transferOwnership(timelock);

GuardianProver(guardianProver).setGuardians(guardians, uint8(vm.envUint("MIN_GUARDIANS")));
GuardianProver(guardianProver).transferOwnership(timelock);

// No need to proxy these, because they are 3rd party. If we want to modify, we simply
Expand Down

0 comments on commit cab4071

Please sign in to comment.