Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): Scale up damping factor and flatten curve #13809

Merged
merged 4 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/TaikoConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ library TaikoConfig {
ethDepositGas: 21000,
ethDepositMaxFee: 1 ether / 10,
txListCacheExpiry: 0,
adjustmentQuotient: 16,
adjustmentQuotient: 32000,
relaySignalRoot: false
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ library TaikoData {
uint64 maxEthDepositsPerBlock;
uint96 maxEthDepositAmount;
uint96 minEthDepositAmount;
uint8 adjustmentQuotient;
uint16 adjustmentQuotient;
bool relaySignalRoot;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/script/DeployOnL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ contract DeployOnL1 is Script {
uint64 initProofTimeIssued = LibLn.calcInitProofTimeIssued(
feeBase,
uint16(INITIAL_PROOF_TIME_TARGET),
uint8(taikoL1.getConfig().adjustmentQuotient)
uint16(taikoL1.getConfig().adjustmentQuotient)
);

address taikoL1Proxy = deployProxy(
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/script/DetermineNewProofTimeIssued.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import "forge-std/Script.sol";
import "forge-std/console2.sol";
import {LibLn} from "../test/LibLn.sol";

uint16 constant DESIRED_PROOF_TIME_TARGET = 500;
uint8 constant ADJUSTMENT_QUOTIENT = 16;
uint16 constant DESIRED_PROOF_TIME_TARGET = 160;
uint16 constant ADJUSTMENT_QUOTIENT = 32000;

contract DetermineProofTimeIssued is Script {
function run() public view {
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/test/LibLn.sol
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ library LibLn {
function calcInitProofTimeIssued(
uint64 basefee,
uint16 proofTimeTarget,
uint8 adjustmentQuotient
uint16 adjustmentQuotient
) public pure returns (uint64 initProofTimeIssued) {
uint256 scale = uint256(proofTimeTarget) * adjustmentQuotient;
// ln_pub() expects 1e18 fixed format
Expand Down
18 changes: 9 additions & 9 deletions packages/protocol/test/TaikoL1.sim.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {LibLn} from "./LibLn.sol";

/// @dev Tweak this if you iwhs to set - the config and the calculation of the proofTimeIssued
/// @dev also originates from this
uint16 constant INITIAL_PROOF_TIME_TARGET = 375; //sec. Approx mainnet scenario
uint16 constant INITIAL_PROOF_TIME_TARGET = 70; //sec. Approx mainnet scenario

/// @dev Warning: this test will take 7-10 minutes and require 1GB memory.
/// `pnpm sim`
Expand All @@ -24,7 +24,7 @@ contract TaikoL1_b is TaikoL1 {
config.maxNumProposedBlocks = 1100;
config.ringBufferSize = 1200;
config.maxVerificationsPerTx = 10;
config.proofCooldownPeriod = 1 minutes;
config.proofCooldownPeriod = 5 minutes;
config.realProofSkipSize = 0;
}
}
Expand All @@ -50,12 +50,12 @@ contract TaikoL1Simulation is TaikoL1TestBase {
// This means block proposals will be averaged out (long term if random function is random enough) to 18s
// It is fine it simulates that we do not necessarily put Taiko block at every 12s, but on average around every x1.5 of ETH block
// Meaninig we have less blocks / sec. (We should test what happens if quicker!)
uint256 nextBlockTime = 12 seconds;
uint256 minDiffToBlockPropTime = 12 seconds;
uint256 nextBlockTime = 8 seconds;
uint256 minDiffToBlockPropTime = 8 seconds;

// This means block provings will be averaged out (long term if random function is random enough) to 200s
uint256 startBlockProposeTime = 1600 seconds;
uint256 upperDevToBlockProveTime = 800 seconds;
uint256 startBlockProposeTime = 100 seconds;
uint256 upperDevToBlockProveTime = 40 seconds;
uint256 secondsToSimulate = blocksToSimulate * 18; //Because of the expected average blocktimestamp - we can tweak it obv.
//////////////////////////////////////////
// TUNABLE PARAMS END //
Expand Down Expand Up @@ -96,12 +96,12 @@ contract TaikoL1Simulation is TaikoL1TestBase {
}

// A real world scenario
function xtestGeneratingManyRandomBlocksNonConsecutive() external {
function testGeneratingManyRandomBlocksNonConsecutive() external {
uint256 time = block.timestamp;

assertEq(time, 1);

depositTaikoToken(Alice, 1e6 * 1e8, 10000 ether);
depositTaikoToken(Alice, 1e9 * 1e8, 10000 ether);

TaikoData.BlockMetadata[] memory metas = new TaikoData.BlockMetadata[](
blocksToSimulate
Expand Down Expand Up @@ -434,7 +434,7 @@ contract TaikoL1Simulation is TaikoL1TestBase {
}

// 90% slow proofs (around 30 mins or so) and 10% (around 1-5 mins )
function test_90percent_quick_10percent_slow() external {
function xtest_90percent_quick_10percent_slow() external {
uint256 time = block.timestamp;
uint256 startBlockProposeTime_quick = 60 seconds; // For the 10% where it is 'quick'
uint256 upperDevToBlockProveTime_quick = 240 seconds; // For the 10% where it is quick
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/test/TaikoL1TestBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract contract TaikoL1TestBase is Test {
// Calculation shall be done in derived contracts - based on testnet or mainnet expected proof time
uint64 public initProofTimeIssued;
uint16 proofTimeTarget;
uint8 public constant ADJUSTMENT_QUOTIENT = 16;
uint16 public constant ADJUSTMENT_QUOTIENT = 32000;

function deployTaikoL1() internal virtual returns (TaikoL1 taikoL1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct Config {
uint64 maxEthDepositsPerBlock;
uint96 maxEthDepositAmount;
uint96 minEthDepositAmount;
uint8 adjustmentQuotient;
uint16 adjustmentQuotient;
bool relaySignalRoot;
}
```
Expand Down