From 5cd8e6fa085bb7c9a497934f490005ab73269904 Mon Sep 17 00:00:00 2001 From: adaki2004 Date: Wed, 24 May 2023 22:02:07 +0200 Subject: [PATCH 1/3] Scale up damping factor and flatten curve --- packages/protocol/contracts/L1/TaikoConfig.sol | 2 +- packages/protocol/contracts/L1/TaikoData.sol | 2 +- packages/protocol/script/DeployOnL1.s.sol | 2 +- .../script/DetermineNewProofTimeIssued.s.sol | 2 +- packages/protocol/test/LibLn.sol | 2 +- packages/protocol/test/TaikoL1.sim.sol | 18 +++++++++--------- packages/protocol/test/TaikoL1TestBase.t.sol | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/protocol/contracts/L1/TaikoConfig.sol b/packages/protocol/contracts/L1/TaikoConfig.sol index 86778a24dff..b680ee19909 100644 --- a/packages/protocol/contracts/L1/TaikoConfig.sol +++ b/packages/protocol/contracts/L1/TaikoConfig.sol @@ -41,7 +41,7 @@ library TaikoConfig { ethDepositGas: 21000, ethDepositMaxFee: 1 ether / 10, txListCacheExpiry: 0, - adjustmentQuotient: 16, + adjustmentQuotient: 16000, relaySignalRoot: false }); } diff --git a/packages/protocol/contracts/L1/TaikoData.sol b/packages/protocol/contracts/L1/TaikoData.sol index 44928070fe5..93955b38730 100644 --- a/packages/protocol/contracts/L1/TaikoData.sol +++ b/packages/protocol/contracts/L1/TaikoData.sol @@ -27,7 +27,7 @@ library TaikoData { uint64 maxEthDepositsPerBlock; uint96 maxEthDepositAmount; uint96 minEthDepositAmount; - uint8 adjustmentQuotient; + uint16 adjustmentQuotient; bool relaySignalRoot; } diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/DeployOnL1.s.sol index 1453df45ad8..e1f4d24083c 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/DeployOnL1.s.sol @@ -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( diff --git a/packages/protocol/script/DetermineNewProofTimeIssued.s.sol b/packages/protocol/script/DetermineNewProofTimeIssued.s.sol index b498096b9e4..5fdd4e4deca 100644 --- a/packages/protocol/script/DetermineNewProofTimeIssued.s.sol +++ b/packages/protocol/script/DetermineNewProofTimeIssued.s.sol @@ -6,7 +6,7 @@ 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 ADJUSTMENT_QUOTIENT = 16000; contract DetermineProofTimeIssued is Script { function run() public view { diff --git a/packages/protocol/test/LibLn.sol b/packages/protocol/test/LibLn.sol index 2bb67091c37..cc1ad45fdd4 100644 --- a/packages/protocol/test/LibLn.sol +++ b/packages/protocol/test/LibLn.sol @@ -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 diff --git a/packages/protocol/test/TaikoL1.sim.sol b/packages/protocol/test/TaikoL1.sim.sol index 086458aa137..9576037b441 100644 --- a/packages/protocol/test/TaikoL1.sim.sol +++ b/packages/protocol/test/TaikoL1.sim.sol @@ -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` @@ -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; } } @@ -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 // @@ -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 @@ -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 diff --git a/packages/protocol/test/TaikoL1TestBase.t.sol b/packages/protocol/test/TaikoL1TestBase.t.sol index 73dfe75b2ce..1921eb69631 100644 --- a/packages/protocol/test/TaikoL1TestBase.t.sol +++ b/packages/protocol/test/TaikoL1TestBase.t.sol @@ -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 = 16000; function deployTaikoL1() internal virtual returns (TaikoL1 taikoL1); From 9b29d881590d851f4ac7ef1c487fad7078d3c943 Mon Sep 17 00:00:00 2001 From: adaki2004 Date: Wed, 24 May 2023 20:17:51 +0000 Subject: [PATCH 2/3] Add auto-generated contract documentation --- .../pages/docs/reference/contract-documentation/L1/TaikoData.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md index 6f0c1cd1204..cc9f5141bbe 100644 --- a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoData.md @@ -25,7 +25,7 @@ struct Config { uint64 maxEthDepositsPerBlock; uint96 maxEthDepositAmount; uint96 minEthDepositAmount; - uint8 adjustmentQuotient; + uint16 adjustmentQuotient; bool relaySignalRoot; } ``` From bfbda56300e4e485b5bedf3cee2515e3fb2769c1 Mon Sep 17 00:00:00 2001 From: adaki2004 Date: Wed, 24 May 2023 22:55:06 +0200 Subject: [PATCH 3/3] Adjust factor to quicker block time --- packages/protocol/contracts/L1/TaikoConfig.sol | 2 +- packages/protocol/script/DetermineNewProofTimeIssued.s.sol | 4 ++-- packages/protocol/test/TaikoL1TestBase.t.sol | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/protocol/contracts/L1/TaikoConfig.sol b/packages/protocol/contracts/L1/TaikoConfig.sol index b680ee19909..90efaf09629 100644 --- a/packages/protocol/contracts/L1/TaikoConfig.sol +++ b/packages/protocol/contracts/L1/TaikoConfig.sol @@ -41,7 +41,7 @@ library TaikoConfig { ethDepositGas: 21000, ethDepositMaxFee: 1 ether / 10, txListCacheExpiry: 0, - adjustmentQuotient: 16000, + adjustmentQuotient: 32000, relaySignalRoot: false }); } diff --git a/packages/protocol/script/DetermineNewProofTimeIssued.s.sol b/packages/protocol/script/DetermineNewProofTimeIssued.s.sol index 5fdd4e4deca..2c5f35d17c5 100644 --- a/packages/protocol/script/DetermineNewProofTimeIssued.s.sol +++ b/packages/protocol/script/DetermineNewProofTimeIssued.s.sol @@ -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; -uint16 constant ADJUSTMENT_QUOTIENT = 16000; +uint16 constant DESIRED_PROOF_TIME_TARGET = 160; +uint16 constant ADJUSTMENT_QUOTIENT = 32000; contract DetermineProofTimeIssued is Script { function run() public view { diff --git a/packages/protocol/test/TaikoL1TestBase.t.sol b/packages/protocol/test/TaikoL1TestBase.t.sol index 1921eb69631..e228918880c 100644 --- a/packages/protocol/test/TaikoL1TestBase.t.sol +++ b/packages/protocol/test/TaikoL1TestBase.t.sol @@ -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; - uint16 public constant ADJUSTMENT_QUOTIENT = 16000; + uint16 public constant ADJUSTMENT_QUOTIENT = 32000; function deployTaikoL1() internal virtual returns (TaikoL1 taikoL1);