From b16fd55b7e1d6b8a215b320d397ac85918024621 Mon Sep 17 00:00:00 2001 From: syntrust Date: Tue, 8 Oct 2024 15:00:40 +0800 Subject: [PATCH] use 2 sec --- contracts/EthStorageContractL2.sol | 7 +++---- scripts/deployL2-it.js | 8 +++++--- scripts/deployL2.js | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/contracts/EthStorageContractL2.sol b/contracts/EthStorageContractL2.sol index 0b2849e..fe61e96 100644 --- a/contracts/EthStorageContractL2.sol +++ b/contracts/EthStorageContractL2.sol @@ -67,16 +67,15 @@ contract EthStorageContractL2 is EthStorageContract2 { /// @notice Check the update rate limit of blobs put. function _checkUpdateLimit(uint256 _blobs) internal override { - uint256 currentBlock = _blockNumber(); uint256 blockLastUpdate = updateState & type(uint224).max; - if (blockLastUpdate == currentBlock) { + if (blockLastUpdate == block.number) { uint256 blobsUpdated = updateState >> 224; blobsUpdated += _blobs; require(blobsUpdated <= UPDATE_LIMIT, "EthStorageContractL2: exceeds update rate limit"); - updateState = (blobsUpdated << 224) | currentBlock; + updateState = (blobsUpdated << 224) | block.number; } else { require(_blobs <= UPDATE_LIMIT, "EthStorageContractL2: exceeds update rate limit"); - updateState = (_blobs << 224) | currentBlock; + updateState = (_blobs << 224) | block.number; } } diff --git a/scripts/deployL2-it.js b/scripts/deployL2-it.js index 4135eca..b71545a 100644 --- a/scripts/deployL2-it.js +++ b/scripts/deployL2-it.js @@ -20,6 +20,7 @@ const config = [ ]; const storageCost = 1500000000000000; // storageCost - 1,500,000Gwei forever per blob - https://ethresear.ch/t/ethstorage-scaling-ethereum-storage-via-l2-and-da/14223/6#incentivization-for-storing-m-physical-replicas-1 const dcfFactor = 340282366367469178095360967382638002176n; // dcfFactor, it mean 0.95 for yearly discount +const updateLimit = 90; // 45 blobs/s according to sync/encoding test, times block interval of L2 async function verifyContract(contract, args) { // if (!process.env.ETHERSCAN_API_KEY) { @@ -45,6 +46,7 @@ async function deployContract() { startTime, // startTime storageCost, dcfFactor, + updateLimit, { gasPrice: gasPrice } ); await implContract.deployed(); @@ -85,7 +87,7 @@ async function deployContract() { await verifyContract(impl, [config, startTime, storageCost, dcfFactor]); // wait for contract finalized - var intervalId = setInterval(async function (){ + var intervalId = setInterval(async function () { try { const block = await hre.ethers.provider.getBlock("finalized"); console.log( @@ -93,13 +95,13 @@ async function deployContract() { block.number, "at", new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" }) - ); + ); if (receipt.blockNumber < block.number) { fs.writeFileSync(".caddr", ethStorageProxy.address); clearInterval(intervalId); } } catch (e) { - console.error(`EthStorage: get finalized block failed!`, e.message);g + console.error(`EthStorage: get finalized block failed!`, e.message); } }, 60000); } diff --git a/scripts/deployL2.js b/scripts/deployL2.js index 0971190..50fa5c3 100644 --- a/scripts/deployL2.js +++ b/scripts/deployL2.js @@ -19,7 +19,7 @@ const config = [ ]; const storageCost = 1500000000000000; // storageCost - 1,500,000Gwei forever per blob - https://ethresear.ch/t/ethstorage-scaling-ethereum-storage-via-l2-and-da/14223/6#incentivization-for-storing-m-physical-replicas-1 const dcfFactor = 340282366367469178095360967382638002176n; // dcfFactor, it mean 0.95 for yearly discount -const updateLimit = 512; +const updateLimit = 90; // 45 blobs/s according to sync/encoding test, times block interval of L2 async function verifyContract(contract, args) { // if (!process.env.ETHERSCAN_API_KEY) {