Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrust committed Oct 8, 2024
1 parent 53f3ce8 commit 4888f95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions contracts/EthStorageContractL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ contract EthStorageContractL2 is EthStorageContract2 {
/// @notice The rate limit to update blobs per block
uint256 internal immutable UPDATE_LIMIT;

/// @notice Bitmap to store blobsUpdated (left 32) and blockLastUpdate (right 224)
uint256 internal updateStateBitmap;
/// @notice A slot to store both `blobsUpdated` (left 32) and `blockLastUpdate` (right 224)
uint256 internal updateState;

/// @notice Constructs the EthStorageContractL2 contract.
constructor(
Expand Down Expand Up @@ -68,15 +68,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 = updateStateBitmap & type(uint224).max;
uint256 blockLastUpdate = updateState & type(uint224).max;
if (blockLastUpdate == currentBlock) {
uint256 blobsUpdated = updateStateBitmap >> 224;
uint256 blobsUpdated = updateState >> 224;
blobsUpdated += _blobs;
require(blobsUpdated <= UPDATE_LIMIT, "EthStorageContractL2: exceeds update rate limit");
updateStateBitmap = (blobsUpdated << 224) | currentBlock;
updateState = (blobsUpdated << 224) | currentBlock;
} else {
require(_blobs <= UPDATE_LIMIT, "EthStorageContractL2: exceeds update rate limit");
updateStateBitmap = (_blobs << 224) | currentBlock;
updateState = (_blobs << 224) | currentBlock;
}
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/test/TestEthStorageContractL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ contract TestEthStorageContractL2 is EthStorageContractL2 {

/// @notice Get the number of blobs updated within the current block.
function getBlobsUpdated() public view returns (uint256) {
return updateStateBitmap >> 224;
return updateState >> 224;
}

/// @notice Get the block number of the last update.
function getBlockLastUpdate() public view returns (uint256) {
return updateStateBitmap & type(uint224).max;
return updateState & type(uint224).max;
}

function _blockNumber() internal view virtual override returns (uint256) {
Expand Down

0 comments on commit 4888f95

Please sign in to comment.