From d5f8674af8a0d7a2996d062738fa57cd958b1e84 Mon Sep 17 00:00:00 2001 From: adaki2004 Date: Thu, 25 May 2023 10:24:41 +0200 Subject: [PATCH 1/3] Add a setter where all fee calc params can be set with one go --- .../protocol/contracts/L1/TaikoConfig.sol | 1 - packages/protocol/contracts/L1/TaikoData.sol | 4 +- .../protocol/contracts/L1/TaikoEvents.sol | 4 +- packages/protocol/contracts/L1/TaikoL1.sol | 32 ++- .../contracts/L1/libs/LibTokenomics.sol | 15 +- .../contracts/L1/libs/LibVerifying.sol | 11 +- packages/protocol/script/DeployOnL1.s.sol | 5 +- packages/protocol/script/test_deploy_on_l1.sh | 1 + packages/protocol/test/TaikoL1.sim.sol | 184 +++++++++++++++++- .../test/TaikoL1LibTokenomicsTestnet.t.sol | 4 +- packages/protocol/test/TaikoL1TestBase.t.sol | 7 +- 11 files changed, 231 insertions(+), 37 deletions(-) diff --git a/packages/protocol/contracts/L1/TaikoConfig.sol b/packages/protocol/contracts/L1/TaikoConfig.sol index 90efaf0962..071954821c 100644 --- a/packages/protocol/contracts/L1/TaikoConfig.sol +++ b/packages/protocol/contracts/L1/TaikoConfig.sol @@ -41,7 +41,6 @@ library TaikoConfig { ethDepositGas: 21000, ethDepositMaxFee: 1 ether / 10, txListCacheExpiry: 0, - adjustmentQuotient: 32000, relaySignalRoot: false }); } diff --git a/packages/protocol/contracts/L1/TaikoData.sol b/packages/protocol/contracts/L1/TaikoData.sol index 93955b3873..956690766b 100644 --- a/packages/protocol/contracts/L1/TaikoData.sol +++ b/packages/protocol/contracts/L1/TaikoData.sol @@ -27,7 +27,6 @@ library TaikoData { uint64 maxEthDepositsPerBlock; uint96 maxEthDepositAmount; uint96 minEthDepositAmount; - uint16 adjustmentQuotient; bool relaySignalRoot; } @@ -136,7 +135,8 @@ library TaikoData { // Slot 7: never or rarely changed uint64 genesisHeight; uint64 genesisTimestamp; - uint64 __reserved71; + uint16 adjustmentQuotient; + uint48 __reserved71; uint64 __reserved72; // Slot 8 uint64 accProposedAt; diff --git a/packages/protocol/contracts/L1/TaikoEvents.sol b/packages/protocol/contracts/L1/TaikoEvents.sol index 8b62a08ab0..3ddcaa9930 100644 --- a/packages/protocol/contracts/L1/TaikoEvents.sol +++ b/packages/protocol/contracts/L1/TaikoEvents.sol @@ -25,5 +25,7 @@ abstract contract TaikoEvents { event EthDeposited(TaikoData.EthDeposit deposit); - event ProofTimeTargetChanged(uint64 proofTimeTarget); + event ProofParamsChanged( + uint64 proofTimeTarget, uint64 proofTimeIssued, uint64 blockFee, uint16 adjustmentQuotient + ); } diff --git a/packages/protocol/contracts/L1/TaikoL1.sol b/packages/protocol/contracts/L1/TaikoL1.sol index a94c6889a8..1e97c9d75d 100644 --- a/packages/protocol/contracts/L1/TaikoL1.sol +++ b/packages/protocol/contracts/L1/TaikoL1.sol @@ -47,7 +47,8 @@ contract TaikoL1 is EssentialContract, ICrossChainSync, TaikoEvents, TaikoErrors bytes32 _genesisBlockHash, uint64 _initBlockFee, uint64 _initProofTimeTarget, - uint64 _initProofTimeIssued + uint64 _initProofTimeIssued, + uint16 _adjustmentQuotient ) external initializer { EssentialContract._init(_addressManager); LibVerifying.init({ @@ -56,7 +57,8 @@ contract TaikoL1 is EssentialContract, ICrossChainSync, TaikoEvents, TaikoErrors genesisBlockHash: _genesisBlockHash, initBlockFee: _initBlockFee, initProofTimeTarget: _initProofTimeTarget, - initProofTimeIssued: _initProofTimeIssued + initProofTimeIssued: _initProofTimeIssued, + adjustmentQuotient: _adjustmentQuotient }); } @@ -138,11 +140,15 @@ contract TaikoL1 is EssentialContract, ICrossChainSync, TaikoEvents, TaikoErrors * Change proof parameters (time target and time issued) - to avoid complex/risky upgrades in case need to change relatively frequently. * @param newProofTimeTarget New proof time target. * @param newProofTimeIssued New proof time issued. If set to type(uint64).max, let it be unchanged. + * @param newBlockFee New blockfee. If set to type(uint64).max, let it be unchanged. + * @param newAdjustmentQuotient New adjustment quotient. If set to type(uint16).max, let it be unchanged. */ - function setProofParams(uint64 newProofTimeTarget, uint64 newProofTimeIssued) - external - onlyOwner - { + function setProofParams( + uint64 newProofTimeTarget, + uint64 newProofTimeIssued, + uint64 newBlockFee, + uint16 newAdjustmentQuotient + ) external onlyOwner { if (newProofTimeTarget == 0 || newProofTimeIssued == 0) { revert L1_INVALID_PARAM(); } @@ -153,8 +159,20 @@ contract TaikoL1 is EssentialContract, ICrossChainSync, TaikoEvents, TaikoErrors if (newProofTimeIssued != type(uint64).max) { state.proofTimeIssued = newProofTimeIssued; } + // Special case in a way - that we leave the blockFee unchanged + // because the level we are at is fine. + if (newBlockFee != type(uint64).max) { + state.blockFee = newBlockFee; + } + // Special case in a way - that we leave the adjustmentQuotient unchanged + // because we the 'slowlyness' of the curve is fine. + if (newAdjustmentQuotient != type(uint16).max) { + state.adjustmentQuotient = newAdjustmentQuotient; + } - emit ProofTimeTargetChanged(newProofTimeTarget); + emit ProofParamsChanged( + newProofTimeTarget, newProofTimeIssued, newBlockFee, newAdjustmentQuotient + ); } function depositTaikoToken(uint256 amount) external nonReentrant { diff --git a/packages/protocol/contracts/L1/libs/LibTokenomics.sol b/packages/protocol/contracts/L1/libs/LibTokenomics.sol index d1fbf31ab8..7ba81fbc9b 100644 --- a/packages/protocol/contracts/L1/libs/LibTokenomics.sol +++ b/packages/protocol/contracts/L1/libs/LibTokenomics.sol @@ -78,30 +78,29 @@ library LibTokenomics { * Calculate the newProofTimeIssued and blockFee * * @param state The actual state data - * @param config Config data * @param proofTime The actual proof time * @return newProofTimeIssued Accumulated proof time * @return blockFee New block fee */ - function getNewBlockFeeAndProofTimeIssued( - TaikoData.State storage state, - TaikoData.Config memory config, - uint64 proofTime - ) internal view returns (uint64 newProofTimeIssued, uint64 blockFee) { + function getNewBlockFeeAndProofTimeIssued(TaikoData.State storage state, uint64 proofTime) + internal + view + returns (uint64 newProofTimeIssued, uint64 blockFee) + { newProofTimeIssued = (state.proofTimeIssued > state.proofTimeTarget) ? state.proofTimeIssued - state.proofTimeTarget : uint64(0); newProofTimeIssued += proofTime; uint256 x = (newProofTimeIssued * Math.SCALING_FACTOR_1E18) - / (state.proofTimeTarget * config.adjustmentQuotient); + / (state.proofTimeTarget * state.adjustmentQuotient); if (Math.MAX_EXP_INPUT <= x) { x = Math.MAX_EXP_INPUT; } uint256 result = (uint256(Math.exp(int256(x))) / Math.SCALING_FACTOR_1E18) - / (state.proofTimeTarget * config.adjustmentQuotient); + / (state.proofTimeTarget * state.adjustmentQuotient); blockFee = uint64(result.min(type(uint64).max)); } diff --git a/packages/protocol/contracts/L1/libs/LibVerifying.sol b/packages/protocol/contracts/L1/libs/LibVerifying.sol index aa9f93a471..f69ac1ca51 100644 --- a/packages/protocol/contracts/L1/libs/LibVerifying.sol +++ b/packages/protocol/contracts/L1/libs/LibVerifying.sol @@ -30,7 +30,8 @@ library LibVerifying { bytes32 genesisBlockHash, uint64 initBlockFee, uint64 initProofTimeTarget, - uint64 initProofTimeIssued + uint64 initProofTimeIssued, + uint16 adjustmentQuotient ) internal { if ( config.chainId <= 1 || config.maxNumProposedBlocks == 1 @@ -43,8 +44,7 @@ library LibVerifying { // EIP-4844 blob deleted after 30 days || config.txListCacheExpiry > 30 * 24 hours || config.ethDepositGas == 0 || config.ethDepositMaxFee == 0 || config.ethDepositMaxFee >= type(uint96).max - || config.adjustmentQuotient == 0 || initProofTimeTarget == 0 - || initProofTimeIssued == 0 + || adjustmentQuotient == 0 || initProofTimeTarget == 0 || initProofTimeIssued == 0 ) revert L1_INVALID_CONFIG(); uint64 timeNow = uint64(block.timestamp); @@ -54,6 +54,7 @@ library LibVerifying { state.blockFee = initBlockFee; state.proofTimeIssued = initProofTimeIssued; state.proofTimeTarget = initProofTimeTarget; + state.adjustmentQuotient = adjustmentQuotient; state.numBlocks = 1; TaikoData.Block storage blk = state.blocks[0]; @@ -113,7 +114,6 @@ library LibVerifying { _markBlockVerified({ state: state, - config: config, blk: blk, fcId: uint24(fcId), fc: fc, @@ -143,7 +143,6 @@ library LibVerifying { function _markBlockVerified( TaikoData.State storage state, - TaikoData.Config memory config, TaikoData.Block storage blk, TaikoData.ForkChoice storage fc, uint24 fcId, @@ -157,7 +156,7 @@ library LibVerifying { uint64 reward = LibTokenomics.getProofReward(state, proofTime); (state.proofTimeIssued, state.blockFee) = - LibTokenomics.getNewBlockFeeAndProofTimeIssued(state, config, proofTime); + LibTokenomics.getNewBlockFeeAndProofTimeIssued(state, proofTime); unchecked { state.accBlockFees -= reward; diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/DeployOnL1.s.sol index e1f4d24083..ed38b0c588 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/DeployOnL1.s.sol @@ -50,6 +50,7 @@ contract DeployOnL1 is Script { // For mainnet it could be around 1800 s (30mins) // Can be adjusted later with setters uint64 public INITIAL_PROOF_TIME_TARGET = uint64(vm.envUint("INITIAL_PROOF_TIME_TARGET")); + uint16 public ADJUSTMENT_QUOTIENT = uint16(vm.envUint("ADJUSTMENT_QUOTIENT")); TaikoL1 taikoL1; address public addressManagerProxy; @@ -120,9 +121,7 @@ contract DeployOnL1 is Script { } uint64 initProofTimeIssued = LibLn.calcInitProofTimeIssued( - feeBase, - uint16(INITIAL_PROOF_TIME_TARGET), - uint16(taikoL1.getConfig().adjustmentQuotient) + feeBase, uint16(INITIAL_PROOF_TIME_TARGET), uint16(ADJUSTMENT_QUOTIENT) ); address taikoL1Proxy = deployProxy( diff --git a/packages/protocol/script/test_deploy_on_l1.sh b/packages/protocol/script/test_deploy_on_l1.sh index 763df60eeb..314e2246d5 100755 --- a/packages/protocol/script/test_deploy_on_l1.sh +++ b/packages/protocol/script/test_deploy_on_l1.sh @@ -15,6 +15,7 @@ TAIKO_TOKEN_PREMINT_AMOUNT=0xffff \ TREASURY=0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 \ L2_GENESIS_HASH=0xee1950562d42f0da28bd4550d88886bc90894c77c9c9eaefef775d4c8223f259 \ INITIAL_PROOF_TIME_TARGET=101 \ +ADJUSTMENT_QUOTIENT=32000 \ forge script script/DeployOnL1.s.sol:DeployOnL1 \ --fork-url http://localhost:8545 \ --broadcast \ diff --git a/packages/protocol/test/TaikoL1.sim.sol b/packages/protocol/test/TaikoL1.sim.sol index 9576037b44..725f72aa12 100644 --- a/packages/protocol/test/TaikoL1.sim.sol +++ b/packages/protocol/test/TaikoL1.sim.sol @@ -12,7 +12,12 @@ 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 = 70; //sec. Approx mainnet scenario +uint16 constant INITIAL_PROOF_TIME_TARGET = 160; + +// Need to test (solve) the problem where in the middle of the testnet, the fee is low already - like our internal devnet now - +// but we dont want to lose data with redeploying the contract. Upgrade also does not work because we need to change all +// proof reward / prover fee related variable with one go. +uint16 constant READJUSTED_ADJUSTMENT_QUOTIENT = 32000; /// @dev Warning: this test will take 7-10 minutes and require 1GB memory. /// `pnpm sim` @@ -54,7 +59,7 @@ contract TaikoL1Simulation is TaikoL1TestBase { uint256 minDiffToBlockPropTime = 8 seconds; // This means block provings will be averaged out (long term if random function is random enough) to 200s - uint256 startBlockProposeTime = 100 seconds; + uint256 startBlockProposeTime = 70 seconds; uint256 upperDevToBlockProveTime = 40 seconds; uint256 secondsToSimulate = blocksToSimulate * 18; //Because of the expected average blocktimestamp - we can tweak it obv. ////////////////////////////////////////// @@ -87,8 +92,7 @@ contract TaikoL1Simulation is TaikoL1TestBase { function setUp() public override { proofTimeTarget = INITIAL_PROOF_TIME_TARGET; // Approx. value which close to what is in the simulation - initProofTimeIssued = - LibLn.calcInitProofTimeIssued(feeBase, proofTimeTarget, ADJUSTMENT_QUOTIENT); + initProofTimeIssued = LibLn.calcInitProofTimeIssued(feeBase, proofTimeTarget, 16); // This 16 is a low value (=quick curve)! Will re-adjust at the middle of the simulation, to test update scenario! TaikoL1TestBase.setUp(); @@ -96,7 +100,7 @@ contract TaikoL1Simulation is TaikoL1TestBase { } // A real world scenario - function testGeneratingManyRandomBlocksNonConsecutive() external { + function xtestGeneratingManyRandomBlocksNonConsecutive() external { uint256 time = block.timestamp; assertEq(time, 1); @@ -255,6 +259,176 @@ contract TaikoL1Simulation is TaikoL1TestBase { console2.log("-----------------------------!"); } + function test_scenario_where_blockfee_dumped_but_we_reset_parameters() external { + uint256 time = block.timestamp; + + assertEq(time, 1); + + depositTaikoToken(Alice, 1e9 * 1e8, 10000 ether); + + TaikoData.BlockMetadata[] memory metas = new TaikoData.BlockMetadata[]( + blocksToSimulate + ); + + // Determine every timestamp of the block we want to simulate + console2.log("BlockId, ProofTime"); + for (uint256 i = 0; i < blocksToSimulate; i++) { + newRandomWithoutSalt = uint256( + keccak256( + abi.encodePacked( + block.difficulty, msg.sender, block.timestamp, i, newRandomWithoutSalt, salt + ) + ) + ); + blocksProposedTimestamp[i] = uint64( + pickRandomNumber(newRandomWithoutSalt, nextBlockTime, (minDiffToBlockPropTime + 1)) + ); + nextBlockTime = blocksProposedTimestamp[i] + minDiffToBlockPropTime; + + // Avg. calculation + if (lastTimestampProp > 0) { + totalDiffsProp += blocksProposedTimestamp[i] - lastTimestampProp; + } + + lastTimestampProp = blocksProposedTimestamp[i]; + // We need this info to extract / export !! + //console2.log("Time of PROPOSAL is:", blocksProposedTimestamp[i]); + salt = + uint256(keccak256(abi.encodePacked(nextBlockTime, salt, i, newRandomWithoutSalt))); + + uint64 proofTimePerBlockI = uint64( + pickRandomNumber( + newRandomWithoutSalt, + (nextBlockTime + startBlockProposeTime), + (upperDevToBlockProveTime + 1) + ) + ); + + if (proofTimePerBlockI > maxTime) { + maxTime = proofTimePerBlockI; + } + + if (lastTimestampProve > 0) { + totalDiffsProve += proofTimePerBlockI - lastTimestampProp; + } + lastTimestampProve = proofTimePerBlockI; + // It is possible that proof for block N+1 comes before N, so we need to keep track of that. Because + // the proofs per block is related to propose of that same block (index). + _proofTimeToBlockIndexes[proofTimePerBlockI].push(i); + + // We need this info to extract / export !! + console2.log(i + 1, ";", proofTimePerBlockI - lastTimestampProp); + salt = uint256(keccak256(abi.encodePacked(proofTimePerBlockI, salt))); + } + + uint256 proposedIndex; + + console2.log("Last second:", maxTime); + console2.log("Proof time target:", INITIAL_PROOF_TIME_TARGET); + console2.log("Average proposal time: ", totalDiffsProp / blocksToSimulate); + console2.log("Average proof time: ", totalDiffsProve / blocksToSimulate); + printVariableHeaders(); + //It is a divider / marker for the parser + console2.log("!-----------------------------"); + printVariables(); + // This is a way we can de-couple proposing from proving + for (uint256 secondsElapsed = 0; secondsElapsed <= maxTime; secondsElapsed++) { + if (secondsElapsed == maxTime / 3) { + //console2.log("MIkor jovok be ide?:", i); + //Reset the parameters + initProofTimeIssued = LibLn.calcInitProofTimeIssued( + feeBase, proofTimeTarget, READJUSTED_ADJUSTMENT_QUOTIENT + ); + L1.setProofParams( + proofTimeTarget, initProofTimeIssued, feeBase, READJUSTED_ADJUSTMENT_QUOTIENT + ); + } + + newRandomWithoutSalt = uint256( + keccak256( + abi.encodePacked( + newRandomWithoutSalt, + block.difficulty, + secondsElapsed, + msg.sender, + block.timestamp, + salt + ) + ) + ); + + // We are proposing here + if ( + secondsElapsed == blocksProposedTimestamp[proposedIndex] + && proposedIndex < blocksToSimulate + ) { + //console2.log("FOR CYCLE: Time of PROPOSAL is:", blocksProposedTimestamp[proposedIndex]); + uint32 gasLimit = + uint32(pickRandomNumber(newRandomWithoutSalt, 100e3, (3000000 - 100000 + 1))); // 100K to 30M + salt = uint256(keccak256(abi.encodePacked(gasLimit, salt))); + + if (proposedIndex == 0) { + parentGasUsed[proposedIndex] = 0; + parentHashes[proposedIndex] = GENESIS_BLOCK_HASH; + } else { + parentGasUsed[proposedIndex] = gasUsed[proposedIndex - 1]; + parentHashes[proposedIndex] = blockHashes[proposedIndex - 1]; + } + + gasUsed[proposedIndex] = uint32( + pickRandomNumber(newRandomWithoutSalt, (gasLimit / 2), ((gasLimit / 2) + 1)) + ); + salt = uint256(keccak256(abi.encodePacked(gasUsed, salt))); + + uint24 txListSize = uint24( + pickRandomNumber(newRandomWithoutSalt, 1, conf.maxBytesPerTxList) //Actually (conf.maxBytesPerTxList-1)+1 but that's the same + ); + salt = uint256(keccak256(abi.encodePacked(txListSize, salt))); + + blockHashes[proposedIndex] = + bytes32(pickRandomNumber(newRandomWithoutSalt, 0, type(uint256).max)); + salt = uint256(keccak256(abi.encodePacked(blockHashes[proposedIndex], salt))); + + signalRoots[proposedIndex] = + bytes32(pickRandomNumber(newRandomWithoutSalt, 0, type(uint256).max)); + salt = uint256(keccak256(abi.encodePacked(signalRoots[proposedIndex], salt))); + + metas[proposedIndex] = proposeBlock(Alice, gasLimit, txListSize); + + if (proposedIndex < blocksToSimulate - 1) proposedIndex++; + + printVariables(); + } + + // We are proving here + if (_proofTimeToBlockIndexes[secondsElapsed].length > 0) { + //console2.log("Duplicates check"); + for (uint256 i; i < _proofTimeToBlockIndexes[secondsElapsed].length; i++) { + uint256 blockId = _proofTimeToBlockIndexes[secondsElapsed][i]; + + proveBlock( + Bob, + Bob, + metas[blockId], + parentHashes[blockId], + parentGasUsed[blockId], + gasUsed[blockId], + blockHashes[blockId], + signalRoots[blockId] + ); + } + } + + // Increment time with 1 seconds + vm.warp(block.timestamp + 1); + //Log every 12 sec + if (block.timestamp % 12 == 0) { + printVariables(); + } + } + console2.log("-----------------------------!"); + } + // 90% slow proofs (around 30 mins or so) and 10% (around 1-5 mins ) function xtest_90percent_slow_10percent_quick() external { uint256 time = block.timestamp; diff --git a/packages/protocol/test/TaikoL1LibTokenomicsTestnet.t.sol b/packages/protocol/test/TaikoL1LibTokenomicsTestnet.t.sol index b6bc93b8ea..7a137bf58d 100644 --- a/packages/protocol/test/TaikoL1LibTokenomicsTestnet.t.sol +++ b/packages/protocol/test/TaikoL1LibTokenomicsTestnet.t.sol @@ -856,13 +856,13 @@ contract TaikoL1LibTokenomicsTestnet is TaikoL1TestBase { // See if proof reward decreases faster than usual if (blockId == 8) { // 500 sec has the proofTimeIssued of 219263 (Calculated with 'forge script script/DetermineNewProofTimeIssued.s.sol') - L1.setProofParams(500, 219263); + L1.setProofParams(500, 219263, feeBase, ADJUSTMENT_QUOTIENT); } // See if proof reward increases now if (blockId == 15) { // 10 sec has the proofTimeIssued of 3759 (Calculated with 'forge script script/DetermineNewProofTimeIssued.s.sol') - L1.setProofParams(10, 3759); + L1.setProofParams(10, 3759, feeBase, ADJUSTMENT_QUOTIENT); } printVariables("before propose"); diff --git a/packages/protocol/test/TaikoL1TestBase.t.sol b/packages/protocol/test/TaikoL1TestBase.t.sol index e228918880..fb38a0bff3 100644 --- a/packages/protocol/test/TaikoL1TestBase.t.sol +++ b/packages/protocol/test/TaikoL1TestBase.t.sol @@ -50,7 +50,9 @@ 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 = 32000; + // As we know this is value which will make the curve 'quick' this is fine for testing and + // will readjust during simulation to test devnet, where we need to reset everything blockfee calculation related. + uint16 public constant ADJUSTMENT_QUOTIENT = 16; function deployTaikoL1() internal virtual returns (TaikoL1 taikoL1); @@ -97,7 +99,8 @@ abstract contract TaikoL1TestBase is Test { GENESIS_BLOCK_HASH, feeBase, proofTimeTarget, - initProofTimeIssued + initProofTimeIssued, + ADJUSTMENT_QUOTIENT ); printVariables("init "); } From 6fe1b0568a28a3f39016daa6ca39039b2ba8d1e4 Mon Sep 17 00:00:00 2001 From: adaki2004 Date: Thu, 25 May 2023 12:00:54 +0200 Subject: [PATCH 2/3] Adjustment quotient to deployment script --- packages/protocol/contracts/L1/TaikoL1.sol | 1 + packages/protocol/script/DeployOnL1.s.sol | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/protocol/contracts/L1/TaikoL1.sol b/packages/protocol/contracts/L1/TaikoL1.sol index 1e97c9d75d..0e7302a2da 100644 --- a/packages/protocol/contracts/L1/TaikoL1.sol +++ b/packages/protocol/contracts/L1/TaikoL1.sol @@ -41,6 +41,7 @@ contract TaikoL1 is EssentialContract, ICrossChainSync, TaikoEvents, TaikoErrors * @param _initProofTimeTarget Initial (reasonable) proof submission time target. * @param _initProofTimeIssued Initial proof time issued corresponding * with the initial block fee. + * @param _adjustmentQuotient Block fee calculation adjustment quotient. */ function init( address _addressManager, diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/DeployOnL1.s.sol index ed38b0c588..e3e940b159 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/DeployOnL1.s.sol @@ -134,7 +134,8 @@ contract DeployOnL1 is Script { genesisHash, feeBase, INITIAL_PROOF_TIME_TARGET, - initProofTimeIssued + initProofTimeIssued, + uint16(ADJUSTMENT_QUOTIENT) ) ) ); From 33732e2f93436ef826eac46603e092e6c6b24797 Mon Sep 17 00:00:00 2001 From: adaki2004 Date: Thu, 25 May 2023 10:05:48 +0000 Subject: [PATCH 3/3] Add auto-generated contract documentation --- .../contract-documentation/L1/TaikoData.md | 4 ++-- .../contract-documentation/L1/TaikoEvents.md | 4 ++-- .../contract-documentation/L1/TaikoL1.md | 15 +++++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) 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 cc9f5141bb..37abc79bd7 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,6 @@ struct Config { uint64 maxEthDepositsPerBlock; uint96 maxEthDepositAmount; uint96 minEthDepositAmount; - uint16 adjustmentQuotient; bool relaySignalRoot; } ``` @@ -153,7 +152,8 @@ struct State { struct TaikoData.EthDeposit[] ethDeposits; uint64 genesisHeight; uint64 genesisTimestamp; - uint64 __reserved71; + uint16 adjustmentQuotient; + uint48 __reserved71; uint64 __reserved72; uint64 accProposedAt; uint64 accBlockFees; diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoEvents.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoEvents.md index 1f0ea94cc1..fffc3e653f 100644 --- a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoEvents.md +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoEvents.md @@ -28,8 +28,8 @@ event BlockVerified(uint256 id, bytes32 blockHash, uint64 reward) event EthDeposited(struct TaikoData.EthDeposit deposit) ``` -### ProofTimeTargetChanged +### ProofParamsChanged ```solidity -event ProofTimeTargetChanged(uint64 proofTimeTarget) +event ProofParamsChanged(uint64 proofTimeTarget, uint64 proofTimeIssued, uint64 blockFee, uint16 adjustmentQuotient) ``` diff --git a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md index ba94b1d767..bf6d15f392 100644 --- a/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md +++ b/packages/website/pages/docs/reference/contract-documentation/L1/TaikoL1.md @@ -19,7 +19,7 @@ receive() external payable ### init ```solidity -function init(address _addressManager, bytes32 _genesisBlockHash, uint64 _initBlockFee, uint64 _initProofTimeTarget, uint64 _initProofTimeIssued) external +function init(address _addressManager, bytes32 _genesisBlockHash, uint64 _initBlockFee, uint64 _initProofTimeTarget, uint64 _initProofTimeIssued, uint16 _adjustmentQuotient) external ``` Initialize the rollup. @@ -33,6 +33,7 @@ Initialize the rollup. | \_initBlockFee | uint64 | Initial (reasonable) block fee value. | | \_initProofTimeTarget | uint64 | Initial (reasonable) proof submission time target. | | \_initProofTimeIssued | uint64 | Initial proof time issued corresponding with the initial block fee. | +| \_adjustmentQuotient | uint16 | Block fee calculation adjustment quotient. | ### proposeBlock @@ -81,17 +82,19 @@ Verify up to N blocks. ### setProofParams ```solidity -function setProofParams(uint64 newProofTimeTarget, uint64 newProofTimeIssued) external +function setProofParams(uint64 newProofTimeTarget, uint64 newProofTimeIssued, uint64 newBlockFee, uint16 newAdjustmentQuotient) external ``` Change proof parameters (time target and time issued) - to avoid complex/risky upgrades in case need to change relatively frequently. #### Parameters -| Name | Type | Description | -| ------------------ | ------ | ----------------------------------------------------------------------- | -| newProofTimeTarget | uint64 | New proof time target. | -| newProofTimeIssued | uint64 | New proof time issued. If set to type(uint64).max, let it be unchanged. | +| Name | Type | Description | +| --------------------- | ------ | ------------------------------------------------------------------------- | +| newProofTimeTarget | uint64 | New proof time target. | +| newProofTimeIssued | uint64 | New proof time issued. If set to type(uint64).max, let it be unchanged. | +| newBlockFee | uint64 | New blockfee. If set to type(uint64).max, let it be unchanged. | +| newAdjustmentQuotient | uint16 | New adjustment quotient. If set to type(uint16).max, let it be unchanged. | ### depositTaikoToken