From 8b19ffc3ae126ff146dbffb5ede12ff59fc86a78 Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Tue, 2 Jan 2024 14:43:15 +0100 Subject: [PATCH] named mapings variables --- contracts/ImmutableSimulator.sol | 2 +- contracts/L2EthToken.sol | 2 +- contracts/NonceHolder.sol | 4 ++-- contracts/SystemContext.sol | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contracts/ImmutableSimulator.sol b/contracts/ImmutableSimulator.sol index a018c92a..8887b0fd 100644 --- a/contracts/ImmutableSimulator.sol +++ b/contracts/ImmutableSimulator.sol @@ -18,7 +18,7 @@ import {DEPLOYER_SYSTEM_CONTRACT} from "./Constants.sol"; contract ImmutableSimulator is IImmutableSimulator { /// @dev mapping (contract address) => (index of immutable variable) => value /// @notice that address uses `uint256` type to leave the option to introduce 32-byte address space in future. - mapping(uint256 => mapping(uint256 => bytes32)) internal immutableDataStorage; + mapping(uint256 contractAddress => mapping(uint256 index => bytes32 value)) internal immutableDataStorage; /// @notice Method that returns the immutable with a certain index for a user. /// @param _dest The address which the immutable belongs to. diff --git a/contracts/L2EthToken.sol b/contracts/L2EthToken.sol index fbd63ae2..71df9333 100644 --- a/contracts/L2EthToken.sol +++ b/contracts/L2EthToken.sol @@ -17,7 +17,7 @@ import {IMailbox} from "./interfaces/IMailbox.sol"; */ contract L2EthToken is IEthToken, ISystemContract { /// @notice The balances of the users. - mapping(address => uint256) internal balance; + mapping(address account => uint256 balance) internal balance; /// @notice The total amount of tokens that have been minted. uint256 public override totalSupply; diff --git a/contracts/NonceHolder.sol b/contracts/NonceHolder.sol index b2775f1c..2525dbc2 100644 --- a/contracts/NonceHolder.sol +++ b/contracts/NonceHolder.sol @@ -33,12 +33,12 @@ contract NonceHolder is INonceHolder, ISystemContract { /// RawNonces for accounts are stored in format /// minNonce + 2^128 * deploymentNonce, where deploymentNonce /// is the nonce used for deploying smart contracts. - mapping(uint256 => uint256) internal rawNonces; + mapping(uint256 account => uint256 packedMinAndDeploymentNonce) internal rawNonces; /// Mapping of values under nonces for accounts. /// The main key of the mapping is the 256-bit address of the account, while the /// inner mapping is a mapping from a nonce to the value stored there. - mapping(uint256 => mapping(uint256 => uint256)) internal nonceValues; + mapping(uint256 account => mapping(uint256 nonceKey => uint256 value)) internal nonceValues; /// @notice Returns the current minimal nonce for account. /// @param _address The account to return the minimal nonce for diff --git a/contracts/SystemContext.sol b/contracts/SystemContext.sol index 67f9248e..c3e6c9fc 100644 --- a/contracts/SystemContext.sol +++ b/contracts/SystemContext.sol @@ -52,7 +52,7 @@ contract SystemContext is ISystemContext, ISystemContextDeprecated, ISystemContr /// @notice The hashes of batches. /// @dev It stores batch hashes for all previous batches. - mapping(uint256 => bytes32) internal batchHash; + mapping(uint256 batchNumber => bytes32 batchHash) internal batchHashes; /// @notice The number and the timestamp of the current L2 block. BlockInfo internal currentL2BlockInfo; @@ -117,7 +117,7 @@ contract SystemContext is ISystemContext, ISystemContextDeprecated, ISystemContr } else if (_block < currentVirtualBlockUpgradeInfo.virtualBlockStartBatch) { // Note, that we will get into this branch only for a brief moment of time, right after the upgrade // for virtual blocks before 256 virtual blocks are produced. - hash = batchHash[_block]; + hash = batchHashes[_block]; } else if ( _block >= currentVirtualBlockUpgradeInfo.virtualBlockFinishL2Block && currentVirtualBlockUpgradeInfo.virtualBlockFinishL2Block > 0 @@ -135,7 +135,7 @@ contract SystemContext is ISystemContext, ISystemContextDeprecated, ISystemContr /// @param _batchNumber The number of the batch. /// @return hash The hash of the batch. function getBatchHash(uint256 _batchNumber) external view returns (bytes32 hash) { - hash = batchHash[_batchNumber]; + hash = batchHashes[_batchNumber]; } /// @notice Returns the current batch's number and timestamp. @@ -424,7 +424,7 @@ contract SystemContext is ISystemContext, ISystemContextDeprecated, ISystemContr _ensureBatchConsistentWithL2Block(_newTimestamp); - batchHash[previousBatchNumber] = _prevBatchHash; + batchHashes[previousBatchNumber] = _prevBatchHash; // Setting new block number and timestamp BlockInfo memory newBlockInfo = BlockInfo({number: previousBatchNumber + 1, timestamp: _newTimestamp}); @@ -478,6 +478,6 @@ contract SystemContext is ISystemContext, ISystemContextDeprecated, ISystemContr /// @notice Returns the hash of the given batch. /// @dev Deprecated in favor of getBatchHash. function blockHash(uint256 _blockNumber) external view returns (bytes32 hash) { - hash = batchHash[_blockNumber]; + hash = batchHashes[_blockNumber]; } }