Skip to content

Commit

Permalink
feat(protocol): add OptimisticTierProvider for client testing (#15645)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Feb 2, 2024
1 parent 15f6995 commit 6569264
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
51 changes: 51 additions & 0 deletions packages/protocol/contracts/L1/tiers/OptimisticTierProvider.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/
//
// Email: security@taiko.xyz
// Website: https://taiko.xyz
// GitHub: https://github.com/taikoxyz
// Discord: https://discord.gg/taikoxyz
// Twitter: https://twitter.com/taikoxyz
// Blog: https://mirror.xyz/labs.taiko.eth
// Youtube: https://www.youtube.com/@taikoxyz

pragma solidity 0.8.24;

import "../../common/EssentialContract.sol";
import "./ITierProvider.sol";

contract OptimisticTierProvider is EssentialContract, ITierProvider {
error TIER_NOT_FOUND();

/// @notice Initializes the contract with the provided address manager.
function init() external initializer {
__Essential_init();
}

function getTier(uint16 tierId) public pure override returns (ITierProvider.Tier memory) {
if (tierId == LibTiers.TIER_OPTIMISTIC) {
return ITierProvider.Tier({
verifierName: "tier_optimistic",
validityBond: 250 ether, // TKO
contestBond: 500 ether, // TKO
cooldownWindow: 24 hours,
provingWindow: 2 hours,
maxBlocksToVerifyPerProof: 10
});
}

revert TIER_NOT_FOUND();
}

function getTierIds() public pure override returns (uint16[] memory tiers) {
tiers = new uint16[](1);
tiers[0] = LibTiers.TIER_OPTIMISTIC;
}

function getMinTier(uint256 rand) public pure override returns (uint16) {
return LibTiers.TIER_OPTIMISTIC;
}
}
10 changes: 9 additions & 1 deletion packages/protocol/script/DeployOnL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import "../contracts/L1/verifiers/SgxVerifier.sol";
import "../contracts/L1/verifiers/SgxAndZkVerifier.sol";
import "../contracts/L1/verifiers/GuardianVerifier.sol";
import "../contracts/L1/tiers/TaikoA6TierProvider.sol";
import "../contracts/L1/tiers/OptimisticTierProvider.sol";
import "../contracts/L1/hooks/AssignmentHook.sol";
import "../contracts/L1/gov/TaikoTimelockController.sol";
import "../contracts/L1/gov/TaikoGovernor.sol";
Expand Down Expand Up @@ -311,9 +312,16 @@ contract DeployOnL1 is DeployCapability {
owner: timelock
});

address tierProvider;
if (vm.envBool("OPTIMISTIC_TIER_PROVIDER")) {
tierProvider = address(new OptimisticTierProvider());
} else {
tierProvider = address(new TaikoA6TierProvider());
}

deployProxy({
name: "tier_provider",
impl: address(new TaikoA6TierProvider()),
impl: tierProvider,
data: abi.encodeCall(TaikoA6TierProvider.init, ()),
registerTo: rollupAddressManager,
owner: timelock
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/script/test_deploy_on_l1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ TAIKO_TOKEN_NAME="Taiko Token Katla" \
TAIKO_TOKEN_SYMBOL=TTKOk \
SHARED_ADDRESS_MANAGER=0x0000000000000000000000000000000000000000 \
L2_GENESIS_HASH=0xee1950562d42f0da28bd4550d88886bc90894c77c9c9eaefef775d4c8223f259 \
OPTIMISTIC_TIER_PROVIDER=false \
forge script script/DeployOnL1.s.sol:DeployOnL1 \
--fork-url http://localhost:8545 \
--broadcast \
Expand Down

0 comments on commit 6569264

Please sign in to comment.