From 81ca1cf396fccf1b34855db56f46c79f7f55d852 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 24 May 2023 13:53:39 +0800 Subject: [PATCH 1/4] chore(protocol): update Alpha-3 protocol configurations --- packages/protocol/contracts/L1/TaikoConfig.sol | 14 +++++++------- packages/protocol/script/DeployOnL1.s.sol | 4 ++-- .../script/DetermineNewProofTimeIssued.s.sol | 2 +- packages/protocol/test/genesis/test_config.json | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/protocol/contracts/L1/TaikoConfig.sol b/packages/protocol/contracts/L1/TaikoConfig.sol index 86778a24dff..f7cabc6f3d8 100644 --- a/packages/protocol/contracts/L1/TaikoConfig.sol +++ b/packages/protocol/contracts/L1/TaikoConfig.sol @@ -11,23 +11,23 @@ import {TaikoData} from "../L1/TaikoData.sol"; library TaikoConfig { function getConfig() internal pure returns (TaikoData.Config memory) { return TaikoData.Config({ - chainId: 167, - // Two weeks if avg block time is 10 seconds - maxNumProposedBlocks: 120960, - ringBufferSize: 120960 + 10, + chainId: 167005, + // Two weeks if avg block time is 3 seconds (is it reasonable?) + maxNumProposedBlocks: 403200, + ringBufferSize: 403200 + 10, // Each time one more block is verified, there will be ~20k // more gas cost. maxVerificationsPerTx: 10, - // Set it to 6M, since its the upper limit of the Alpha-2 + // Set it to 6M, since its the upper limit of the Alpha-3 // testnet's circuits. blockMaxGasLimit: 6000000, // Set it to 79 (+1 TaikoL2.anchor transaction = 80), - // and 80 is the upper limit of the Alpha-2 testnet's circuits. + // and 80 is the upper limit of the Alpha-3 testnet's circuits. maxTransactionsPerBlock: 79, minEthDepositsPerBlock: 8, maxEthDepositsPerBlock: 32, maxEthDepositAmount: 10000 ether, - minEthDepositAmount: 1 ether, + minEthDepositAmount: 0.1 ether, // Set it to 120KB, since 128KB is the upper size limit // of a geth transaction, so using 120KB for the proposed // transactions list calldata, 8K for the remaining tx fields. diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/DeployOnL1.s.sol index 1453df45ad8..1c3fd4f22d9 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/DeployOnL1.s.sol @@ -38,7 +38,7 @@ contract DeployOnL1 is Script { address public sharedSignalService = vm.envAddress("SHARED_SIGNAL_SERVICE"); - address public treasury = vm.envAddress("TREASURY"); + address public treasury = vm.envAddress("TREASURY"); // Q: which address will we use? address public taikoTokenPremintRecipient = vm.envAddress("TAIKO_TOKEN_PREMINT_RECIPIENT"); @@ -49,7 +49,7 @@ contract DeployOnL1 is Script { // For testnet it could be somewhere 85-100s // 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")); + uint64 public INITIAL_PROOF_TIME_TARGET = uint64(vm.envUint("INITIAL_PROOF_TIME_TARGET")); // Q: INITIAL_PROOF_TIME_TARGET=`120s`? => initProofTimeIssued will be `49883` TaikoL1 taikoL1; address public addressManagerProxy; diff --git a/packages/protocol/script/DetermineNewProofTimeIssued.s.sol b/packages/protocol/script/DetermineNewProofTimeIssued.s.sol index b498096b9e4..754bc7550ee 100644 --- a/packages/protocol/script/DetermineNewProofTimeIssued.s.sol +++ b/packages/protocol/script/DetermineNewProofTimeIssued.s.sol @@ -5,7 +5,7 @@ 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 DESIRED_PROOF_TIME_TARGET = 120; uint8 constant ADJUSTMENT_QUOTIENT = 16; contract DetermineProofTimeIssued is Script { diff --git a/packages/protocol/test/genesis/test_config.json b/packages/protocol/test/genesis/test_config.json index 7ff3aba8cbf..622801d6580 100644 --- a/packages/protocol/test/genesis/test_config.json +++ b/packages/protocol/test/genesis/test_config.json @@ -80,10 +80,10 @@ "SignalServiceProxy": "0x1000777700000000000000000000000000000007" }, "param1559": { - "yscale": "358298803609133338137582400989", - "xscale": "1488514844", - "gasIssuedPerSecond": "12500000", - "gasExcess": "45450000000" + "yscale": "358298803609133338137582400989", // Q: do we need to change this? + "xscale": "1488514844", // Q: do we need to change this? + "gasIssuedPerSecond": "2000000", // If we assume the avg block time is 3s (is it reasonable?) , and each block is full (block.gasLimit=6m) + "gasExcess": "45450000000" // Q: do we need to change this? }, "predeployERC20": true } From 1f6eed59db8e90e4554c539c5cb9a727b4453bc3 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 25 May 2023 13:09:14 +0800 Subject: [PATCH 2/4] chore: update configs --- .../protocol/contracts/L1/TaikoConfig.sol | 6 ++-- packages/protocol/script/DeployOnL1.s.sol | 4 +-- packages/protocol/test/Taiko1559Params.t.sol | 30 ++++++++++++------- .../protocol/test/genesis/test_config.json | 8 ++--- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/packages/protocol/contracts/L1/TaikoConfig.sol b/packages/protocol/contracts/L1/TaikoConfig.sol index f7cabc6f3d8..25b1c10887c 100644 --- a/packages/protocol/contracts/L1/TaikoConfig.sol +++ b/packages/protocol/contracts/L1/TaikoConfig.sol @@ -12,7 +12,7 @@ library TaikoConfig { function getConfig() internal pure returns (TaikoData.Config memory) { return TaikoData.Config({ chainId: 167005, - // Two weeks if avg block time is 3 seconds (is it reasonable?) + // Two weeks if avg block time is 3 seconds maxNumProposedBlocks: 403200, ringBufferSize: 403200 + 10, // Each time one more block is verified, there will be ~20k @@ -24,7 +24,7 @@ library TaikoConfig { // Set it to 79 (+1 TaikoL2.anchor transaction = 80), // and 80 is the upper limit of the Alpha-3 testnet's circuits. maxTransactionsPerBlock: 79, - minEthDepositsPerBlock: 8, + minEthDepositsPerBlock: 1, maxEthDepositsPerBlock: 32, maxEthDepositAmount: 10000 ether, minEthDepositAmount: 0.1 ether, @@ -41,7 +41,7 @@ library TaikoConfig { ethDepositGas: 21000, ethDepositMaxFee: 1 ether / 10, txListCacheExpiry: 0, - adjustmentQuotient: 16, + adjustmentQuotient: 16, // https://github.com/taikoxyz/taiko-mono/pull/13809 relaySignalRoot: false }); } diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/DeployOnL1.s.sol index 1c3fd4f22d9..ff04556ad71 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/DeployOnL1.s.sol @@ -38,7 +38,7 @@ contract DeployOnL1 is Script { address public sharedSignalService = vm.envAddress("SHARED_SIGNAL_SERVICE"); - address public treasury = vm.envAddress("TREASURY"); // Q: which address will we use? + address public treasury = vm.envAddress("TREASURY"); // 0xdf09A0afD09a63fb04ab3573922437e1e637dE8b address public taikoTokenPremintRecipient = vm.envAddress("TAIKO_TOKEN_PREMINT_RECIPIENT"); @@ -49,7 +49,7 @@ contract DeployOnL1 is Script { // For testnet it could be somewhere 85-100s // 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")); // Q: INITIAL_PROOF_TIME_TARGET=`120s`? => initProofTimeIssued will be `49883` + uint64 public INITIAL_PROOF_TIME_TARGET = uint64(vm.envUint("INITIAL_PROOF_TIME_TARGET")); // 160s TaikoL1 taikoL1; address public addressManagerProxy; diff --git a/packages/protocol/test/Taiko1559Params.t.sol b/packages/protocol/test/Taiko1559Params.t.sol index 512b0376094..e35387245fd 100644 --- a/packages/protocol/test/Taiko1559Params.t.sol +++ b/packages/protocol/test/Taiko1559Params.t.sol @@ -11,21 +11,23 @@ import {SafeCastUpgradeable} from contract TestTaiko1559Params is Test { using SafeCastUpgradeable for uint256; - function testAndVerifyTaiko1559Params() external { - // Assume we scale L1 throughput by 10 times. - uint64 scaleFactor = 10; + function run() external { + this.testAndVerifyTaiko1559Params(); + } + // We make gasIssuedPerSecond 2,000,000 gas/s == 4 L2 blocks of 6M gas/L1 block, + // and leave the costFactor as it is. + function testAndVerifyTaiko1559Params() external { // Assume we lower the L1 transaction cost by 25 times. uint64 costFactor = 25; // Calculate gas space issuance per second - uint64 ethereumBlockGasTarget = 15000000; uint64 ethereumBlockTime = 12; // https://ultrasound.money/ uint64 ethereumBasefeeNow = 28000000000; // 28Gwei - uint64 gasIssuedPerSecond = (scaleFactor * ethereumBlockGasTarget) / ethereumBlockTime; + uint64 gasIssuedPerSecond = 4 * 6000000 / ethereumBlockTime; // We make gasIssuedPerSecond 2,000,000 gas/s == 4 L2 blocks of 6M gas/L1 block // Tune this number manually so ratio2x1x is ~112.5%. uint64 maxSeconds = 7272; @@ -42,19 +44,25 @@ contract TestTaiko1559Params is Test { ratio2x1x: 11250 // ~12.5% increase }); + TaikoL2 L2 = new TaikoL2(); + L2.init(address(1), param1559); // Dummy address manager address. + console2.log("basefee :", param1559.basefee); console2.log("gasIssuedPerSecond:", param1559.gasIssuedPerSecond); console2.log("gasExcessMax :", param1559.gasExcessMax); console2.log("gasTarget :", param1559.gasTarget); console2.log("ratio2x1x :", param1559.ratio2x1x); + console2.log("yscale :", L2.yscale()); + console2.log("xscale :", L2.xscale()); + console2.log("gasExcess :", L2.gasExcess()); // basefee : 1120000000 - // gasIssuedPerSecond: 12500000 - // gasExcessMax : 90900000000 - // gasTarget : 150000000 + // gasIssuedPerSecond: 2000000 + // gasExcessMax : 14544000000 + // gasTarget : 24000000 // ratio2x1x : 11250 - - TaikoL2 L2 = new TaikoL2(); - L2.init(address(1), param1559); // Dummy address manager address. + // yscale : 2239367572216867291982809680751 + // xscale : 9303217778 + // gasExcess : 7272000000 } } diff --git a/packages/protocol/test/genesis/test_config.json b/packages/protocol/test/genesis/test_config.json index 622801d6580..24b4d40e18f 100644 --- a/packages/protocol/test/genesis/test_config.json +++ b/packages/protocol/test/genesis/test_config.json @@ -80,10 +80,10 @@ "SignalServiceProxy": "0x1000777700000000000000000000000000000007" }, "param1559": { - "yscale": "358298803609133338137582400989", // Q: do we need to change this? - "xscale": "1488514844", // Q: do we need to change this? - "gasIssuedPerSecond": "2000000", // If we assume the avg block time is 3s (is it reasonable?) , and each block is full (block.gasLimit=6m) - "gasExcess": "45450000000" // Q: do we need to change this? + "yscale": "2239367572216867291982809680751", + "xscale": "9303217778", + "gasIssuedPerSecond": "2000000", + "gasExcess": "7272000000" }, "predeployERC20": true } From 3c4415a2d22422f6d12f0b6c30bfa42482188fcd Mon Sep 17 00:00:00 2001 From: David Date: Fri, 26 May 2023 01:09:48 +0800 Subject: [PATCH 3/4] feat: update DeployOnL1 --- packages/protocol/script/DeployOnL1.s.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/DeployOnL1.s.sol index b0d2a1e02f6..7f227aa4079 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/DeployOnL1.s.sol @@ -50,7 +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")); // 160s - uint16 public ADJUSTMENT_QUOTIENT = uint16(vm.envUint("ADJUSTMENT_QUOTIENT")); + uint16 public ADJUSTMENT_QUOTIENT = uint16(vm.envUint("ADJUSTMENT_QUOTIENT")); // 32000 TaikoL1 taikoL1; address public addressManagerProxy; From 588595ec6341f5b2c8424052888c33d4b8e901bd Mon Sep 17 00:00:00 2001 From: David Date: Fri, 26 May 2023 01:14:45 +0800 Subject: [PATCH 4/4] fix: fix workflow issues --- packages/protocol/test/Taiko1559Params.t.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/protocol/test/Taiko1559Params.t.sol b/packages/protocol/test/Taiko1559Params.t.sol index e35387245fd..d449623c019 100644 --- a/packages/protocol/test/Taiko1559Params.t.sol +++ b/packages/protocol/test/Taiko1559Params.t.sol @@ -52,8 +52,8 @@ contract TestTaiko1559Params is Test { console2.log("gasExcessMax :", param1559.gasExcessMax); console2.log("gasTarget :", param1559.gasTarget); console2.log("ratio2x1x :", param1559.ratio2x1x); - console2.log("yscale :", L2.yscale()); - console2.log("xscale :", L2.xscale()); + console2.log("yscale :", L2.getEIP1559Config().yscale); + console2.log("xscale :", L2.getEIP1559Config().xscale); console2.log("gasExcess :", L2.gasExcess()); // basefee : 1120000000