Skip to content

Commit

Permalink
use 2 sec
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrust committed Oct 8, 2024
1 parent 4888f95 commit b16fd55
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 3 additions & 4 deletions contracts/EthStorageContractL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
8 changes: 5 additions & 3 deletions scripts/deployL2-it.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -45,6 +46,7 @@ async function deployContract() {
startTime, // startTime
storageCost,
dcfFactor,
updateLimit,
{ gasPrice: gasPrice }
);
await implContract.deployed();
Expand Down Expand Up @@ -85,21 +87,21 @@ 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(
"finalized block number is",
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);
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/deployL2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b16fd55

Please sign in to comment.