From 0d9df71ffc5b487cb7be069311c29b9cca8c437f Mon Sep 17 00:00:00 2001 From: Yuri Tkachenko Date: Fri, 23 Aug 2024 13:25:50 +0100 Subject: [PATCH] chore: add auto-lint for test contracts --- .prettierrc | 13 +++- package.json | 4 + .../AccountingOracle__MockForLegacyOracle.sol | 5 +- .../HashConsensus__HarnessForLegacyOracle.sol | 69 +++++++--------- .../contracts/LegacyOracle__Harness.sol | 1 - .../LegacyOracle__MockForAccountingOracle.sol | 38 ++++----- .../NodeOperatorsRegistry__Harness.sol | 26 +++++-- ...Checker__MockForLidoHandleOracleReport.sol | 11 ++- .../0.4.24/contracts/SigningKeys__Harness.sol | 20 ++--- .../contracts/StakeLimitUtils__Harness.sol | 33 +++++--- ...gRouter__MockForLidoHandleOracleReport.sol | 18 ++--- .../StakingRouter__MockForLidoMisc.sol | 19 +++-- test/0.8.4/contracts/Address__Harness.sol | 6 +- test/0.8.9/BeaconChainDepositor.t.sol | 21 ++++- .../AccessControlEnumerable__Harness.sol | 1 - .../contracts/AccessControl__Harness.sol | 1 - .../contracts/AccountingOracle__Harness.sol | 12 ++- test/0.8.9/contracts/BaseOracle__Harness.sol | 39 ++-------- .../Burner__MockForOracleSanityChecker.sol | 4 +- .../contracts/ConsensusContract__Mock.sol | 60 +++----------- test/0.8.9/contracts/ERC721Receiver__Mock.sol | 5 +- .../contracts/HashConsensus__Harness.sol | 22 +++--- .../contracts/LidoLocator__MockMutable.sol | 12 +-- .../Lido__MockForAccountingOracle.sol | 24 ++---- test/0.8.9/contracts/Math__Harness.sol | 8 +- .../NFTDescriptor__MockForWithdrawalQueue.sol | 4 +- .../OracleReportSanityChecker__Mock.sol | 15 ++-- .../Receiver__MockForWithdrawalQueueBase.sol | 1 - .../StETH__HarnessForWithdrawalQueue.sol | 43 +++++----- test/0.8.9/contracts/StakingModule__Mock.sol | 35 +++++---- ...StakingRouter__MockForAccountingOracle.sol | 18 ++--- ...ngRouter__MockForDepositSecurityModule.sol | 21 +++-- .../contracts/ValidatorsExitBus__Harness.sol | 10 ++- ...rawalQueue__MockForOracleSanityChecker.sol | 4 +- .../WithdrawalsQueueBase__Harness.sol | 25 ++++-- .../contracts/WithdrawalsQueue__Harness.sol | 7 +- .../WstETH__MockForWithdrawalQueue.sol | 10 ++- test/0.8.9/positiveTokenRebaseLimiter.t.sol | 4 +- test/0.8.9/withdrawalQueue.t.sol | 2 +- test/common/math256.t.sol | 16 ++-- test/common/memUtils.t.sol | 66 ++++++++++++---- test/common/minFirstAllocationStrategy.t.sol | 78 ++++++++++--------- test/common/signatureUtils.t.sol | 12 +-- yarn.lock | 15 +++- 44 files changed, 452 insertions(+), 406 deletions(-) diff --git a/.prettierrc b/.prettierrc index 8618a9629..724d44d6f 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,5 +3,16 @@ "singleQuote": false, "printWidth": 120, "tabWidth": 2, - "quoteProps": "consistent" + "quoteProps": "consistent", + "plugins": ["prettier-plugin-solidity"], + "overrides": [ + { + "files": "*.sol", + "options": { + "parser": "solidity-parse", + "tabWidth": 4, + "useTabs": false + } + } + ] } diff --git a/package.json b/package.json index fdee3e2ac..fcdc028e0 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,9 @@ ], "./**/*.{ts,md,json}": [ "prettier --write" + ], + "./test/**/*.sol": [ + "prettier --write" ] }, "devDependencies": { @@ -80,6 +83,7 @@ "husky": "^9.1.5", "lint-staged": "^15.2.9", "prettier": "^3.3.3", + "prettier-plugin-solidity": "^1.4.1", "solhint": "^5.0.3", "solhint-plugin-lido": "^0.0.4", "solidity-coverage": "^0.8.12", diff --git a/test/0.4.24/contracts/AccountingOracle__MockForLegacyOracle.sol b/test/0.4.24/contracts/AccountingOracle__MockForLegacyOracle.sol index 18c74f736..6361bf3c2 100644 --- a/test/0.4.24/contracts/AccountingOracle__MockForLegacyOracle.sol +++ b/test/0.4.24/contracts/AccountingOracle__MockForLegacyOracle.sol @@ -30,10 +30,7 @@ contract AccountingOracle__MockForLegacyOracle { return ITimeProvider(CONSENSUS_CONTRACT).getTime(); } - function submitReportData( - AccountingOracle.ReportData calldata data, - uint256 /* contractVersion */ - ) external { + function submitReportData(AccountingOracle.ReportData calldata data, uint256 /* contractVersion */) external { uint256 slotsElapsed = data.refSlot - _lastRefSlot; _lastRefSlot = data.refSlot; diff --git a/test/0.4.24/contracts/HashConsensus__HarnessForLegacyOracle.sol b/test/0.4.24/contracts/HashConsensus__HarnessForLegacyOracle.sol index 69bf97e7d..ad4826a6b 100644 --- a/test/0.4.24/contracts/HashConsensus__HarnessForLegacyOracle.sol +++ b/test/0.4.24/contracts/HashConsensus__HarnessForLegacyOracle.sol @@ -6,7 +6,6 @@ pragma solidity 0.4.24; import {IHashConsensus} from "contracts/0.4.24/oracle/LegacyOracle.sol"; contract HashConsensus__HarnessForLegacyOracle is IHashConsensus { - uint256 internal _time = 2513040315; /// Chain specification @@ -47,16 +46,8 @@ contract HashConsensus__HarnessForLegacyOracle is IHashConsensus { _setFrameConfig(initialEpoch, epochsPerFrame, fastLaneLengthSlots); } - function _setFrameConfig( - uint256 initialEpoch, - uint256 epochsPerFrame, - uint256 fastLaneLengthSlots - ) internal { - _frameConfig = FrameConfig( - uint64(initialEpoch), - uint64(epochsPerFrame), - uint64(fastLaneLengthSlots) - ); + function _setFrameConfig(uint256 initialEpoch, uint256 epochsPerFrame, uint256 fastLaneLengthSlots) internal { + _frameConfig = FrameConfig(uint64(initialEpoch), uint64(epochsPerFrame), uint64(fastLaneLengthSlots)); } function setTime(uint256 newTime) external { @@ -71,26 +62,20 @@ contract HashConsensus__HarnessForLegacyOracle is IHashConsensus { return _time; } - function getChainConfig() external view returns ( - uint256 slotsPerEpoch, - uint256 secondsPerSlot, - uint256 genesisTime - ) { + function getChainConfig() + external + view + returns (uint256 slotsPerEpoch, uint256 secondsPerSlot, uint256 genesisTime) + { return (SLOTS_PER_EPOCH, SECONDS_PER_SLOT, GENESIS_TIME); } - function getFrameConfig() external view returns ( - uint256 initialEpoch, - uint256 epochsPerFrame - ) { + function getFrameConfig() external view returns (uint256 initialEpoch, uint256 epochsPerFrame) { FrameConfig memory config = _frameConfig; return (config.initialEpoch, config.epochsPerFrame); } - function getCurrentFrame() external view returns ( - uint256 refSlot, - uint256 reportProcessingDeadlineSlot - ) { + function getCurrentFrame() external view returns (uint256 refSlot, uint256 reportProcessingDeadlineSlot) { ConsensusFrame memory frame = _getCurrentFrame(); return (frame.refSlot, frame.reportProcessingDeadlineSlot); } @@ -99,15 +84,14 @@ contract HashConsensus__HarnessForLegacyOracle is IHashConsensus { return _getFrameAtTimestamp(_getTime(), _frameConfig); } - function _getFrameAtTimestamp(uint256 timestamp, FrameConfig memory config) - internal view returns (ConsensusFrame memory) - { + function _getFrameAtTimestamp( + uint256 timestamp, + FrameConfig memory config + ) internal view returns (ConsensusFrame memory) { return _getFrameAtIndex(_computeFrameIndex(timestamp, config), config); } - function _computeFrameIndex(uint256 timestamp, FrameConfig memory config) - internal view returns (uint256) - { + function _computeFrameIndex(uint256 timestamp, FrameConfig memory config) internal view returns (uint256) { uint256 epoch = _computeEpochAtTimestamp(timestamp); return (epoch - config.initialEpoch) / config.epochsPerFrame; } @@ -116,18 +100,20 @@ contract HashConsensus__HarnessForLegacyOracle is IHashConsensus { return _computeEpochAtSlot(_computeSlotAtTimestamp(timestamp)); } - function _getFrameAtIndex(uint256 frameIndex, FrameConfig memory config) - internal view returns (ConsensusFrame memory) - { + function _getFrameAtIndex( + uint256 frameIndex, + FrameConfig memory config + ) internal view returns (ConsensusFrame memory) { uint256 frameStartEpoch = _computeStartEpochOfFrameWithIndex(frameIndex, config); uint256 frameStartSlot = _computeStartSlotAtEpoch(frameStartEpoch); uint256 nextFrameStartSlot = frameStartSlot + config.epochsPerFrame * SLOTS_PER_EPOCH; - return ConsensusFrame({ - index: frameIndex, - refSlot: uint64(frameStartSlot - 1), - reportProcessingDeadlineSlot: uint64(nextFrameStartSlot - 1 - DEADLINE_SLOT_OFFSET) - }); + return + ConsensusFrame({ + index: frameIndex, + refSlot: uint64(frameStartSlot - 1), + reportProcessingDeadlineSlot: uint64(nextFrameStartSlot - 1 - DEADLINE_SLOT_OFFSET) + }); } // Math @@ -146,9 +132,10 @@ contract HashConsensus__HarnessForLegacyOracle is IHashConsensus { return epoch * SLOTS_PER_EPOCH; } - function _computeStartEpochOfFrameWithIndex(uint256 frameIndex, FrameConfig memory config) - internal pure returns (uint256) - { + function _computeStartEpochOfFrameWithIndex( + uint256 frameIndex, + FrameConfig memory config + ) internal pure returns (uint256) { return config.initialEpoch + frameIndex * config.epochsPerFrame; } diff --git a/test/0.4.24/contracts/LegacyOracle__Harness.sol b/test/0.4.24/contracts/LegacyOracle__Harness.sol index b4d8414b7..d0bfdf85a 100644 --- a/test/0.4.24/contracts/LegacyOracle__Harness.sol +++ b/test/0.4.24/contracts/LegacyOracle__Harness.sol @@ -10,7 +10,6 @@ interface ITimeProvider { } contract LegacyOracle__Harness is LegacyOracle { - // @dev this is a way to not use block.timestamp in the tests function _getTime() internal view returns (uint256) { address accountingOracle = ACCOUNTING_ORACLE_POSITION.getStorageAddress(); diff --git a/test/0.4.24/contracts/LegacyOracle__MockForAccountingOracle.sol b/test/0.4.24/contracts/LegacyOracle__MockForAccountingOracle.sol index e62390354..ad158c8a9 100644 --- a/test/0.4.24/contracts/LegacyOracle__MockForAccountingOracle.sol +++ b/test/0.4.24/contracts/LegacyOracle__MockForAccountingOracle.sol @@ -6,12 +6,10 @@ pragma solidity 0.4.24; import "contracts/0.4.24/oracle/LegacyOracle.sol"; interface ILegacyOracle { - function getBeaconSpec() external view returns ( - uint64 epochsPerFrame, - uint64 slotsPerEpoch, - uint64 secondsPerSlot, - uint64 genesisTime - ); + function getBeaconSpec() + external + view + returns (uint64 epochsPerFrame, uint64 slotsPerEpoch, uint64 secondsPerSlot, uint64 genesisTime); function getLastCompletedEpochId() external view returns (uint256); } @@ -20,9 +18,7 @@ interface ITimeProvider { function getTime() external view returns (uint256); } - contract LegacyOracle__MockForAccountingOracle is ILegacyOracle, LegacyOracle { - struct HandleConsensusLayerReportCallData { uint256 totalCalls; uint256 refSlot; @@ -32,14 +28,11 @@ contract LegacyOracle__MockForAccountingOracle is ILegacyOracle, LegacyOracle { HandleConsensusLayerReportCallData public lastCall__handleConsensusLayerReport; - - function getBeaconSpec() external view returns ( - uint64 epochsPerFrame, - uint64 slotsPerEpoch, - uint64 secondsPerSlot, - uint64 genesisTime - ) { - + function getBeaconSpec() + external + view + returns (uint64 epochsPerFrame, uint64 slotsPerEpoch, uint64 secondsPerSlot, uint64 genesisTime) + { ChainSpec memory spec = _getChainSpec(); epochsPerFrame = spec.epochsPerFrame; slotsPerEpoch = spec.slotsPerEpoch; @@ -47,14 +40,15 @@ contract LegacyOracle__MockForAccountingOracle is ILegacyOracle, LegacyOracle { genesisTime = spec.genesisTime; } - function setBeaconSpec(uint64 epochsPerFrame, + function setBeaconSpec( + uint64 epochsPerFrame, uint64 slotsPerEpoch, uint64 secondsPerSlot, - uint64 genesisTime) external { + uint64 genesisTime + ) external { _setChainSpec(ChainSpec(epochsPerFrame, slotsPerEpoch, secondsPerSlot, genesisTime)); } - function _getTime() internal view returns (uint256) { address accountingOracle = ACCOUNTING_ORACLE_POSITION.getStorageAddress(); return ITimeProvider(accountingOracle).getTime(); @@ -64,16 +58,13 @@ contract LegacyOracle__MockForAccountingOracle is ILegacyOracle, LegacyOracle { return _getTime(); } - function handleConsensusLayerReport(uint256 refSlot, uint256 clBalance, uint256 clValidators) - external - { + function handleConsensusLayerReport(uint256 refSlot, uint256 clBalance, uint256 clValidators) external { ++lastCall__handleConsensusLayerReport.totalCalls; lastCall__handleConsensusLayerReport.refSlot = refSlot; lastCall__handleConsensusLayerReport.clBalance = clBalance; lastCall__handleConsensusLayerReport.clValidators = clValidators; } - function setParams( uint64 epochsPerFrame, uint64 slotsPerEpoch, @@ -101,5 +92,4 @@ contract LegacyOracle__MockForAccountingOracle is ILegacyOracle, LegacyOracle { function setLido(address lido) external { LIDO_POSITION.setStorageAddress(lido); } - } diff --git a/test/0.4.24/contracts/NodeOperatorsRegistry__Harness.sol b/test/0.4.24/contracts/NodeOperatorsRegistry__Harness.sol index 84bcb3688..5ffd4a8ca 100644 --- a/test/0.4.24/contracts/NodeOperatorsRegistry__Harness.sol +++ b/test/0.4.24/contracts/NodeOperatorsRegistry__Harness.sol @@ -113,7 +113,11 @@ contract NodeOperatorsRegistry__Harness is NodeOperatorsRegistry { uint256[] _nodeOperatorIds, uint256[] _activeKeyCountsAfterAllocation ) external returns (bytes memory pubkeys, bytes memory signatures) { - (pubkeys, signatures) = _loadAllocatedSigningKeys(_keysCountToLoad, _nodeOperatorIds, _activeKeyCountsAfterAllocation); + (pubkeys, signatures) = _loadAllocatedSigningKeys( + _keysCountToLoad, + _nodeOperatorIds, + _activeKeyCountsAfterAllocation + ); obtainedPublicKeys = pubkeys; obtainedSignatures = signatures; @@ -121,11 +125,17 @@ contract NodeOperatorsRegistry__Harness is NodeOperatorsRegistry { emit ValidatorsKeysLoaded(pubkeys, signatures); } - function harness__getSigningKeysAllocationData(uint256 _keysCount) external view returns ( - uint256 allocatedKeysCount, - uint256[] memory nodeOperatorIds, - uint256[] memory activeKeyCountsAfterAllocation - ) { + function harness__getSigningKeysAllocationData( + uint256 _keysCount + ) + external + view + returns ( + uint256 allocatedKeysCount, + uint256[] memory nodeOperatorIds, + uint256[] memory activeKeyCountsAfterAllocation + ) + { return _getSigningKeysAllocationData(_keysCount); } @@ -145,8 +155,8 @@ contract NodeOperatorsRegistry__Harness is NodeOperatorsRegistry { /** * @dev Extra care is needed. - * Doesn't update the active node operators counter and node operator's summary - */ + * Doesn't update the active node operators counter and node operator's summary + */ function harness__unsafeSetNodeOperatorIsActive(uint256 _nodeOperatorId, bool _isActive) external { _nodeOperators[_nodeOperatorId].active = _isActive; } diff --git a/test/0.4.24/contracts/OracleReportSanityChecker__MockForLidoHandleOracleReport.sol b/test/0.4.24/contracts/OracleReportSanityChecker__MockForLidoHandleOracleReport.sol index d27e8d359..86425c627 100644 --- a/test/0.4.24/contracts/OracleReportSanityChecker__MockForLidoHandleOracleReport.sol +++ b/test/0.4.24/contracts/OracleReportSanityChecker__MockForLidoHandleOracleReport.sol @@ -26,7 +26,10 @@ contract OracleReportSanityChecker__MockForLidoHandleOracleReport { if (checkAccountingOracleReportReverts) revert(); } - function checkWithdrawalQueueOracleReport(uint256 _lastFinalizableRequestId, uint256 _reportTimestamp) external view { + function checkWithdrawalQueueOracleReport( + uint256 _lastFinalizableRequestId, + uint256 _reportTimestamp + ) external view { if (checkWithdrawalQueueOracleReportReverts) revert(); } @@ -41,9 +44,9 @@ contract OracleReportSanityChecker__MockForLidoHandleOracleReport { uint256 _etherToLockForWithdrawals, uint256 _newSharesToBurnForWithdrawals ) - external - view - returns (uint256 withdrawals, uint256 elRewards, uint256 simulatedSharesToBurn, uint256 sharesToBurn) + external + view + returns (uint256 withdrawals, uint256 elRewards, uint256 simulatedSharesToBurn, uint256 sharesToBurn) { withdrawals = _withdrawals; elRewards = _elRewards; diff --git a/test/0.4.24/contracts/SigningKeys__Harness.sol b/test/0.4.24/contracts/SigningKeys__Harness.sol index b448e656b..e7c164171 100644 --- a/test/0.4.24/contracts/SigningKeys__Harness.sol +++ b/test/0.4.24/contracts/SigningKeys__Harness.sol @@ -33,18 +33,20 @@ contract SigningKeys__Harness { return KEYSSIGS_POSITION.saveKeysSigs(_nodeOperatorId, _startIndex, _keysCount, _publicKeys, _signatures); } - function removeKeysSigs(uint256 _nodeOperatorId, uint256 _startIndex, uint256 _keysCount, uint256 _lastIndex) - external - returns (uint256) - { + function removeKeysSigs( + uint256 _nodeOperatorId, + uint256 _startIndex, + uint256 _keysCount, + uint256 _lastIndex + ) external returns (uint256) { return KEYSSIGS_POSITION.removeKeysSigs(_nodeOperatorId, _startIndex, _keysCount, _lastIndex); } - function loadKeysSigs(uint256 _nodeOperatorId, uint256 _startIndex, uint256 _keysCount) - external - view - returns (bytes memory pubkeys, bytes memory signatures) - { + function loadKeysSigs( + uint256 _nodeOperatorId, + uint256 _startIndex, + uint256 _keysCount + ) external view returns (bytes memory pubkeys, bytes memory signatures) { (pubkeys, signatures) = SigningKeys.initKeysSigsBuf(_keysCount); KEYSSIGS_POSITION.loadKeysSigs( diff --git a/test/0.4.24/contracts/StakeLimitUtils__Harness.sol b/test/0.4.24/contracts/StakeLimitUtils__Harness.sol index 4c64a394d..3b690d507 100644 --- a/test/0.4.24/contracts/StakeLimitUtils__Harness.sol +++ b/test/0.4.24/contracts/StakeLimitUtils__Harness.sol @@ -18,9 +18,14 @@ contract StakeLimitUnstructuredStorage__Harness { ); function getStorageStakeLimit() - external - view - returns (uint32 prevStakeBlockNumber, uint96 prevStakeLimit, uint32 maxStakeLimitGrowthBlocks, uint96 maxStakeLimit) + external + view + returns ( + uint32 prevStakeBlockNumber, + uint96 prevStakeLimit, + uint32 maxStakeLimitGrowthBlocks, + uint96 maxStakeLimit + ) { StakeLimitState.Data memory stakeLimit = position.getStorageStakeLimitStruct(); @@ -49,9 +54,14 @@ contract StakeLimitUnstructuredStorage__Harness { } function harness__getStorageStakeLimit() - external - view - returns (uint32 prevStakeBlockNumber, uint96 prevStakeLimit, uint32 maxStakeLimitGrowthBlocks, uint96 maxStakeLimit) + external + view + returns ( + uint32 prevStakeBlockNumber, + uint96 prevStakeLimit, + uint32 maxStakeLimitGrowthBlocks, + uint96 maxStakeLimit + ) { // the other way around for the tests purposes // could have done with calldata slices with a newer solidity versions @@ -123,9 +133,14 @@ contract StakeLimitUtils__Harness { } function harness_getState() - external - view - returns (uint32 prevStakeBlockNumber, uint96 prevStakeLimit, uint32 maxStakeLimitGrowthBlocks, uint96 maxStakeLimit) + external + view + returns ( + uint32 prevStakeBlockNumber, + uint96 prevStakeLimit, + uint32 maxStakeLimitGrowthBlocks, + uint96 maxStakeLimit + ) { prevStakeBlockNumber = state.prevStakeBlockNumber; prevStakeLimit = state.prevStakeLimit; diff --git a/test/0.4.24/contracts/StakingRouter__MockForLidoHandleOracleReport.sol b/test/0.4.24/contracts/StakingRouter__MockForLidoHandleOracleReport.sol index ad92c8cab..ae5581f0f 100644 --- a/test/0.4.24/contracts/StakingRouter__MockForLidoHandleOracleReport.sol +++ b/test/0.4.24/contracts/StakingRouter__MockForLidoHandleOracleReport.sol @@ -13,15 +13,15 @@ contract StakingRouter__MockForLidoHandleOracleReport { uint256 private precisionPoint__mocked; function getStakingRewardsDistribution() - public - view - returns ( - address[] memory recipients, - uint256[] memory stakingModuleIds, - uint96[] memory stakingModuleFees, - uint96 totalFee, - uint256 precisionPoints - ) + public + view + returns ( + address[] memory recipients, + uint256[] memory stakingModuleIds, + uint96[] memory stakingModuleFees, + uint96 totalFee, + uint256 precisionPoints + ) { recipients = recipients__mocked; stakingModuleIds = stakingModuleIds__mocked; diff --git a/test/0.4.24/contracts/StakingRouter__MockForLidoMisc.sol b/test/0.4.24/contracts/StakingRouter__MockForLidoMisc.sol index 9e2eb0df7..c14368284 100644 --- a/test/0.4.24/contracts/StakingRouter__MockForLidoMisc.sol +++ b/test/0.4.24/contracts/StakingRouter__MockForLidoMisc.sol @@ -20,23 +20,22 @@ contract StakingRouter__MockForLidoMisc { return 10000; // 100% } - function getStakingFeeAggregateDistributionE4Precision() external view returns ( - uint16 treasuryFee, - uint16 modulesFee - ) { + function getStakingFeeAggregateDistributionE4Precision() + external + view + returns (uint16 treasuryFee, uint16 modulesFee) + { treasuryFee = 500; modulesFee = 500; } - function getStakingModuleMaxDepositsCount(uint256 _stakingModuleId, uint256 _maxDepositsValue) - public - view - returns (uint256) - { + function getStakingModuleMaxDepositsCount( + uint256 _stakingModuleId, + uint256 _maxDepositsValue + ) public view returns (uint256) { return stakingModuleMaxDepositsCount; } - function deposit( uint256 _depositsCount, uint256 _stakingModuleId, diff --git a/test/0.8.4/contracts/Address__Harness.sol b/test/0.8.4/contracts/Address__Harness.sol index e5358d3ae..1c4bae8c9 100644 --- a/test/0.8.4/contracts/Address__Harness.sol +++ b/test/0.8.4/contracts/Address__Harness.sol @@ -18,7 +18,11 @@ contract Address__Harness { return Address.functionCall(target, data); } - function functionCall(address target, bytes memory data, string memory errorMessage) external returns (bytes memory) { + function functionCall( + address target, + bytes memory data, + string memory errorMessage + ) external returns (bytes memory) { return Address.functionCall(target, data, errorMessage); } diff --git a/test/0.8.9/BeaconChainDepositor.t.sol b/test/0.8.9/BeaconChainDepositor.t.sol index 5d435fe9f..93def7cad 100644 --- a/test/0.8.9/BeaconChainDepositor.t.sol +++ b/test/0.8.9/BeaconChainDepositor.t.sol @@ -283,17 +283,32 @@ contract DepositContractHarness is IDepositContract, IERC165 { // Emit `DepositEvent` log bytes memory amount = to_little_endian_64(uint64(deposit_amount)); - emit DepositEvent(pubkey, withdrawal_credentials, amount, signature, to_little_endian_64(uint64(deposit_count))); + emit DepositEvent( + pubkey, + withdrawal_credentials, + amount, + signature, + to_little_endian_64(uint64(deposit_count)) + ); // Dev: harness part depositEvents.push( - DepositEventData(pubkey, withdrawal_credentials, amount, signature, to_little_endian_64(uint64(deposit_count))) + DepositEventData( + pubkey, + withdrawal_credentials, + amount, + signature, + to_little_endian_64(uint64(deposit_count)) + ) ); // Compute deposit data root (`DepositData` hash tree root) bytes32 pubkey_root = sha256(abi.encodePacked(pubkey, bytes16(0))); bytes32 signature_root = sha256( - abi.encodePacked(sha256(abi.encodePacked(signature[: 64])), sha256(abi.encodePacked(signature[64 :], bytes32(0)))) + abi.encodePacked( + sha256(abi.encodePacked(signature[:64])), + sha256(abi.encodePacked(signature[64:], bytes32(0))) + ) ); bytes32 node = sha256( abi.encodePacked( diff --git a/test/0.8.9/contracts/AccessControlEnumerable__Harness.sol b/test/0.8.9/contracts/AccessControlEnumerable__Harness.sol index 132b6b8af..62c90c316 100644 --- a/test/0.8.9/contracts/AccessControlEnumerable__Harness.sol +++ b/test/0.8.9/contracts/AccessControlEnumerable__Harness.sol @@ -6,7 +6,6 @@ pragma solidity 0.8.9; import {AccessControlEnumerable} from "contracts/0.8.9/utils/access/AccessControlEnumerable.sol"; contract AccessControlEnumerable__Harness is AccessControlEnumerable { - bytes32 public constant TEST_ROLE = keccak256("TEST_ROLE"); constructor() { diff --git a/test/0.8.9/contracts/AccessControl__Harness.sol b/test/0.8.9/contracts/AccessControl__Harness.sol index ebbef1378..e706b3a68 100644 --- a/test/0.8.9/contracts/AccessControl__Harness.sol +++ b/test/0.8.9/contracts/AccessControl__Harness.sol @@ -6,7 +6,6 @@ pragma solidity 0.8.9; import {AccessControl} from "contracts/0.8.9/utils/access/AccessControl.sol"; contract AccessControl__Harness is AccessControl { - bytes32 public constant TEST_ADMIN_ROLE = keccak256("TEST_ADMIN_ROLE"); bytes32 public constant TEST_ROLE = keccak256("TEST_ROLE"); diff --git a/test/0.8.9/contracts/AccountingOracle__Harness.sol b/test/0.8.9/contracts/AccountingOracle__Harness.sol index f093b69a9..aa8f0a415 100644 --- a/test/0.8.9/contracts/AccountingOracle__Harness.sol +++ b/test/0.8.9/contracts/AccountingOracle__Harness.sol @@ -13,9 +13,13 @@ interface ITimeProvider { contract AccountingOracle__Harness is AccountingOracle, ITimeProvider { using UnstructuredStorage for bytes32; - constructor(address lidoLocator, address lido, address legacyOracle, uint256 secondsPerSlot, uint256 genesisTime) - AccountingOracle(lidoLocator, lido, legacyOracle, secondsPerSlot, genesisTime) - { + constructor( + address lidoLocator, + address lido, + address legacyOracle, + uint256 secondsPerSlot, + uint256 genesisTime + ) AccountingOracle(lidoLocator, lido, legacyOracle, secondsPerSlot, genesisTime) { // allow usage without a proxy for tests CONTRACT_VERSION_POSITION.setStorageUint256(0); } @@ -24,7 +28,7 @@ contract AccountingOracle__Harness is AccountingOracle, ITimeProvider { return _getTime(); } - function _getTime() internal override view returns (uint256) { + function _getTime() internal view override returns (uint256) { address consensus = CONSENSUS_CONTRACT_POSITION.getStorageAddress(); return ITimeProvider(consensus).getTime(); } diff --git a/test/0.8.9/contracts/BaseOracle__Harness.sol b/test/0.8.9/contracts/BaseOracle__Harness.sol index 1308f4a6a..db03d3019 100644 --- a/test/0.8.9/contracts/BaseOracle__Harness.sol +++ b/test/0.8.9/contracts/BaseOracle__Harness.sol @@ -22,24 +22,13 @@ contract BaseOracle__Harness is BaseOracle { HandleConsensusReportLastCall internal _handleConsensusReportLastCall; BaseOracle.ConsensusReport public lastDiscardedReport; - constructor( - uint256 secondsPerSlot, - uint256 genesisTime, - address admin - ) BaseOracle(secondsPerSlot, genesisTime) { + constructor(uint256 secondsPerSlot, uint256 genesisTime, address admin) BaseOracle(secondsPerSlot, genesisTime) { _setupRole(DEFAULT_ADMIN_ROLE, admin); CONTRACT_VERSION_POSITION.setStorageUint256(0); - require( - genesisTime <= _time, - "GENESIS_TIME_CANNOT_BE_MORE_THAN_MOCK_TIME" - ); + require(genesisTime <= _time, "GENESIS_TIME_CANNOT_BE_MORE_THAN_MOCK_TIME"); } - function initialize( - address consensusContract, - uint256 consensusVersion, - uint256 lastProcessingRefSlot - ) external { + function initialize(address consensusContract, uint256 consensusVersion, uint256 lastProcessingRefSlot) external { _initialize(consensusContract, consensusVersion, lastProcessingRefSlot); } @@ -69,24 +58,16 @@ contract BaseOracle__Harness is BaseOracle { uint256 prevProcessingRefSlot ) internal virtual override { _handleConsensusReportLastCall.report = report; - _handleConsensusReportLastCall - .prevSubmittedRefSlot = prevSubmittedRefSlot; - _handleConsensusReportLastCall - .prevProcessingRefSlot = prevProcessingRefSlot; + _handleConsensusReportLastCall.prevSubmittedRefSlot = prevSubmittedRefSlot; + _handleConsensusReportLastCall.prevProcessingRefSlot = prevProcessingRefSlot; ++_handleConsensusReportLastCall.callCount; } - function _handleConsensusReportDiscarded( - BaseOracle.ConsensusReport memory report - ) internal override { + function _handleConsensusReportDiscarded(BaseOracle.ConsensusReport memory report) internal override { lastDiscardedReport = report; } - function getConsensusReportLastCall() - external - view - returns (HandleConsensusReportLastCall memory) - { + function getConsensusReportLastCall() external view returns (HandleConsensusReportLastCall memory) { return _handleConsensusReportLastCall; } @@ -103,11 +84,7 @@ contract BaseOracle__Harness is BaseOracle { return _getCurrentRefSlot(); } - function checkConsensusData( - uint256 refSlot, - uint256 consensusVersion, - bytes32 hash - ) external view { + function checkConsensusData(uint256 refSlot, uint256 consensusVersion, bytes32 hash) external view { _checkConsensusData(refSlot, consensusVersion, hash); } diff --git a/test/0.8.9/contracts/Burner__MockForOracleSanityChecker.sol b/test/0.8.9/contracts/Burner__MockForOracleSanityChecker.sol index dece42b5e..ba7f4c938 100644 --- a/test/0.8.9/contracts/Burner__MockForOracleSanityChecker.sol +++ b/test/0.8.9/contracts/Burner__MockForOracleSanityChecker.sol @@ -7,9 +7,7 @@ contract Burner__MockForOracleSanityChecker { uint256 private nonCover; uint256 private cover; - function getSharesRequestedToBurn() external view returns ( - uint256 coverShares, uint256 nonCoverShares - ) { + function getSharesRequestedToBurn() external view returns (uint256 coverShares, uint256 nonCoverShares) { coverShares = cover; nonCoverShares = nonCover; } diff --git a/test/0.8.9/contracts/ConsensusContract__Mock.sol b/test/0.8.9/contracts/ConsensusContract__Mock.sol index 7ab0c99b4..ed0754369 100644 --- a/test/0.8.9/contracts/ConsensusContract__Mock.sol +++ b/test/0.8.9/contracts/ConsensusContract__Mock.sol @@ -62,26 +62,14 @@ contract ConsensusContract__Mock is IConsensusContract { return _memberIndices1b[addr] != 0; } - function getCurrentFrame() - external - view - returns (uint256 refSlot, uint256 reportProcessingDeadlineSlot) - { - return ( - _consensusFrame.refSlot, - _consensusFrame.reportProcessingDeadlineSlot - ); + function getCurrentFrame() external view returns (uint256 refSlot, uint256 reportProcessingDeadlineSlot) { + return (_consensusFrame.refSlot, _consensusFrame.reportProcessingDeadlineSlot); } - function setCurrentFrame( - uint256 index, - uint256 refSlot, - uint256 reportProcessingDeadlineSlot - ) external { + function setCurrentFrame(uint256 index, uint256 refSlot, uint256 reportProcessingDeadlineSlot) external { _consensusFrame.index = index; _consensusFrame.refSlot = refSlot; - _consensusFrame - .reportProcessingDeadlineSlot = reportProcessingDeadlineSlot; + _consensusFrame.reportProcessingDeadlineSlot = reportProcessingDeadlineSlot; } function setInitialRefSlot(uint256 initialRefSlot) external { @@ -89,22 +77,14 @@ contract ConsensusContract__Mock is IConsensusContract { } function getChainConfig() - external - view - returns ( - uint256 slotsPerEpoch, - uint256 secondsPerSlot, - uint256 genesisTime - ) + external + view + returns (uint256 slotsPerEpoch, uint256 secondsPerSlot, uint256 genesisTime) { return (SLOTS_PER_EPOCH, SECONDS_PER_SLOT, GENESIS_TIME); } - function getFrameConfig() - external - view - returns (uint256 initialEpoch, uint256 epochsPerFrame) - { + function getFrameConfig() external view returns (uint256 initialEpoch, uint256 epochsPerFrame) { return (_frameConfig.initialEpoch, _frameConfig.epochsPerFrame); } @@ -112,16 +92,8 @@ contract ConsensusContract__Mock is IConsensusContract { return _initialRefSlot; } - function _setFrameConfig( - uint256 initialEpoch, - uint256 epochsPerFrame, - uint256 fastLaneLengthSlots - ) internal { - _frameConfig = FrameConfig( - initialEpoch.toUint64(), - epochsPerFrame.toUint64(), - fastLaneLengthSlots.toUint64() - ); + function _setFrameConfig(uint256 initialEpoch, uint256 epochsPerFrame, uint256 fastLaneLengthSlots) internal { + _frameConfig = FrameConfig(initialEpoch.toUint64(), epochsPerFrame.toUint64(), fastLaneLengthSlots.toUint64()); } // @@ -132,16 +104,8 @@ contract ConsensusContract__Mock is IConsensusContract { _reportProcessor = reportProcessor; } - function submitReportAsConsensus( - bytes32 reportHash, - uint256 refSlot, - uint256 deadline - ) external { - IReportAsyncProcessor(_reportProcessor).submitConsensusReport( - reportHash, - refSlot, - deadline - ); + function submitReportAsConsensus(bytes32 reportHash, uint256 refSlot, uint256 deadline) external { + IReportAsyncProcessor(_reportProcessor).submitConsensusReport(reportHash, refSlot, deadline); } function discardReportAsConsensus(uint256 refSlot) external { diff --git a/test/0.8.9/contracts/ERC721Receiver__Mock.sol b/test/0.8.9/contracts/ERC721Receiver__Mock.sol index 1d925a854..4ad9e045e 100644 --- a/test/0.8.9/contracts/ERC721Receiver__Mock.sol +++ b/test/0.8.9/contracts/ERC721Receiver__Mock.sol @@ -30,10 +30,7 @@ contract ERC721Receiver__Mock is IERC721Receiver { if (!isReturnValid) { return bytes4(keccak256("neverGonnaGiveYouUp()")); } - return - bytes4( - keccak256("onERC721Received(address,address,uint256,bytes)") - ); + return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); } receive() external payable { diff --git a/test/0.8.9/contracts/HashConsensus__Harness.sol b/test/0.8.9/contracts/HashConsensus__Harness.sol index 25fa75881..aa06b8318 100644 --- a/test/0.8.9/contracts/HashConsensus__Harness.sol +++ b/test/0.8.9/contracts/HashConsensus__Harness.sol @@ -16,19 +16,21 @@ contract HashConsensus__Harness is HashConsensus { uint256 fastLaneLengthSlots, address admin, address reportProcessor - ) HashConsensus( - slotsPerEpoch, - secondsPerSlot, - genesisTime, - epochsPerFrame, - fastLaneLengthSlots, - admin, - reportProcessor - ) { + ) + HashConsensus( + slotsPerEpoch, + secondsPerSlot, + genesisTime, + epochsPerFrame, + fastLaneLengthSlots, + admin, + reportProcessor + ) + { require(genesisTime <= _time, "GENESIS_TIME_CANNOT_BE_MORE_THAN_MOCK_TIME"); } - function _getTime() internal override view returns (uint256) { + function _getTime() internal view override returns (uint256) { return _time; } diff --git a/test/0.8.9/contracts/LidoLocator__MockMutable.sol b/test/0.8.9/contracts/LidoLocator__MockMutable.sol index d9ef43434..ead0d44e1 100644 --- a/test/0.8.9/contracts/LidoLocator__MockMutable.sol +++ b/test/0.8.9/contracts/LidoLocator__MockMutable.sol @@ -40,9 +40,9 @@ contract LidoLocator__MockMutable { /** * @notice declare service locations - * @dev accepts a struct to avoid the "stack-too-deep" error - * @param _config struct of addresses - */ + * @dev accepts a struct to avoid the "stack-too-deep" error + * @param _config struct of addresses + */ constructor(Config memory _config) { accountingOracle = _assertNonZero(_config.accountingOracle); depositSecurityModule = _assertNonZero(_config.depositSecurityModule); @@ -65,9 +65,9 @@ contract LidoLocator__MockMutable { } function oracleReportComponentsForLido() - external - view - returns (address, address, address, address, address, address, address) + external + view + returns (address, address, address, address, address, address, address) { return ( accountingOracle, diff --git a/test/0.8.9/contracts/Lido__MockForAccountingOracle.sol b/test/0.8.9/contracts/Lido__MockForAccountingOracle.sol index b3d736de4..38b3f8915 100644 --- a/test/0.8.9/contracts/Lido__MockForAccountingOracle.sol +++ b/test/0.8.9/contracts/Lido__MockForAccountingOracle.sol @@ -35,11 +35,7 @@ contract Lido__MockForAccountingOracle is ILido { HandleOracleReportLastCall internal _handleOracleReportLastCall; - function getLastCall_handleOracleReport() - external - view - returns (HandleOracleReportLastCall memory) - { + function getLastCall_handleOracleReport() external view returns (HandleOracleReportLastCall memory) { return _handleOracleReportLastCall; } @@ -62,20 +58,14 @@ contract Lido__MockForAccountingOracle is ILido { uint256[] calldata withdrawalFinalizationBatches, uint256 simulatedShareRate ) external { - _handleOracleReportLastCall - .currentReportTimestamp = currentReportTimestamp; - _handleOracleReportLastCall - .secondsElapsedSinceLastReport = secondsElapsedSinceLastReport; + _handleOracleReportLastCall.currentReportTimestamp = currentReportTimestamp; + _handleOracleReportLastCall.secondsElapsedSinceLastReport = secondsElapsedSinceLastReport; _handleOracleReportLastCall.numValidators = numValidators; _handleOracleReportLastCall.clBalance = clBalance; - _handleOracleReportLastCall - .withdrawalVaultBalance = withdrawalVaultBalance; - _handleOracleReportLastCall - .elRewardsVaultBalance = elRewardsVaultBalance; - _handleOracleReportLastCall - .sharesRequestedToBurn = sharesRequestedToBurn; - _handleOracleReportLastCall - .withdrawalFinalizationBatches = withdrawalFinalizationBatches; + _handleOracleReportLastCall.withdrawalVaultBalance = withdrawalVaultBalance; + _handleOracleReportLastCall.elRewardsVaultBalance = elRewardsVaultBalance; + _handleOracleReportLastCall.sharesRequestedToBurn = sharesRequestedToBurn; + _handleOracleReportLastCall.withdrawalFinalizationBatches = withdrawalFinalizationBatches; _handleOracleReportLastCall.simulatedShareRate = simulatedShareRate; ++_handleOracleReportLastCall.callCount; diff --git a/test/0.8.9/contracts/Math__Harness.sol b/test/0.8.9/contracts/Math__Harness.sol index e46c56b4b..c07b5e6bc 100644 --- a/test/0.8.9/contracts/Math__Harness.sol +++ b/test/0.8.9/contracts/Math__Harness.sol @@ -14,15 +14,11 @@ contract Math__Harness { return Math.min(a, b); } - function pointInHalfOpenIntervalModN(uint256 x, uint256 a, uint256 b, uint256 n) - public pure returns (bool) - { + function pointInHalfOpenIntervalModN(uint256 x, uint256 a, uint256 b, uint256 n) public pure returns (bool) { return Math.pointInHalfOpenIntervalModN(x, a, b, n); } - function pointInClosedIntervalModN(uint256 x, uint256 a, uint256 b, uint256 n) - public pure returns (bool) - { + function pointInClosedIntervalModN(uint256 x, uint256 a, uint256 b, uint256 n) public pure returns (bool) { return Math.pointInClosedIntervalModN(x, a, b, n); } } diff --git a/test/0.8.9/contracts/NFTDescriptor__MockForWithdrawalQueue.sol b/test/0.8.9/contracts/NFTDescriptor__MockForWithdrawalQueue.sol index 44dcd4d6c..76d7af268 100644 --- a/test/0.8.9/contracts/NFTDescriptor__MockForWithdrawalQueue.sol +++ b/test/0.8.9/contracts/NFTDescriptor__MockForWithdrawalQueue.sol @@ -15,9 +15,7 @@ contract NFTDescriptor__MockForWithdrawalQueue is INFTDescriptor { BASE_TOKEN_URI = _toBytes32(_baseURI); } - function constructTokenURI( - uint256 _requestId - ) external view returns (string memory) { + function constructTokenURI(uint256 _requestId) external view returns (string memory) { string memory baseURI = _toString(BASE_TOKEN_URI); return string(abi.encodePacked(baseURI, _requestId.toString())); } diff --git a/test/0.8.9/contracts/OracleReportSanityChecker__Mock.sol b/test/0.8.9/contracts/OracleReportSanityChecker__Mock.sol index 23a5fda6c..a3ff27f95 100644 --- a/test/0.8.9/contracts/OracleReportSanityChecker__Mock.sol +++ b/test/0.8.9/contracts/OracleReportSanityChecker__Mock.sol @@ -6,7 +6,9 @@ pragma solidity 0.8.9; contract OracleReportSanityChecker__Mock { error SelectorNotFound(bytes4 sig, uint256 value, bytes data); - fallback() external payable {revert SelectorNotFound(msg.sig, msg.value, msg.data);} + fallback() external payable { + revert SelectorNotFound(msg.sig, msg.value, msg.data); + } function checkAccountingOracleReport( uint256 _timeElapsed, @@ -42,12 +44,11 @@ contract OracleReportSanityChecker__Mock { uint256, uint256 _etherToLockForWithdrawals, uint256 - ) external view returns ( - uint256 withdrawals, - uint256 elRewards, - uint256 simulatedSharesToBurn, - uint256 sharesToBurn - ) { + ) + external + view + returns (uint256 withdrawals, uint256 elRewards, uint256 simulatedSharesToBurn, uint256 sharesToBurn) + { withdrawals = _withdrawalVaultBalance; elRewards = _elRewardsVaultBalance; diff --git a/test/0.8.9/contracts/Receiver__MockForWithdrawalQueueBase.sol b/test/0.8.9/contracts/Receiver__MockForWithdrawalQueueBase.sol index dbfaa8ea7..f316d0c60 100644 --- a/test/0.8.9/contracts/Receiver__MockForWithdrawalQueueBase.sol +++ b/test/0.8.9/contracts/Receiver__MockForWithdrawalQueueBase.sol @@ -4,7 +4,6 @@ pragma solidity 0.8.9; contract Receiver__MockForWithdrawalQueueBase { - bool public canReceive; function mock__setCanReceive(bool _value) external { diff --git a/test/0.8.9/contracts/StETH__HarnessForWithdrawalQueue.sol b/test/0.8.9/contracts/StETH__HarnessForWithdrawalQueue.sol index 4028c05eb..0d263f1e3 100644 --- a/test/0.8.9/contracts/StETH__HarnessForWithdrawalQueue.sol +++ b/test/0.8.9/contracts/StETH__HarnessForWithdrawalQueue.sol @@ -17,19 +17,26 @@ interface IStETH { function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256); function permit( - address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s + address _owner, + address _spender, + uint256 _value, + uint256 _deadline, + uint8 _v, + bytes32 _r, + bytes32 _s ) external; } contract StETH__HarnessForWithdrawalQueue is IStETH { using UnstructuredStorage for bytes32; - uint256 constant internal INFINITE_ALLOWANCE = ~uint256(0); + uint256 internal constant INFINITE_ALLOWANCE = ~uint256(0); uint256 public totalPooledEther; uint256 public totalShares; - bytes32 internal constant TOTAL_SHARES_POSITION = 0xe3b4b636e601189b5f4c6742edf2538ac12bb61ed03e6da26949d69838fa447e; + bytes32 internal constant TOTAL_SHARES_POSITION = + 0xe3b4b636e601189b5f4c6742edf2538ac12bb61ed03e6da26949d69838fa447e; mapping(address => uint256) private shares; @@ -38,25 +45,13 @@ contract StETH__HarnessForWithdrawalQueue is IStETH { bool internal isSignatureValid = true; // StETH::TransferShares - event TransferShares( - address indexed from, - address indexed to, - uint256 sharesValue - ); + event TransferShares(address indexed from, address indexed to, uint256 sharesValue); // openzeppelin-solidity/contracts/token/ERC20/IERC20.sol (0.4.24) - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); + event Approval(address indexed owner, address indexed spender, uint256 value); // openzeppelin-solidity/contracts/token/ERC20/IERC20.sol (0.4.24) - event Transfer( - address indexed from, - address indexed to, - uint256 value - ); + event Transfer(address indexed from, address indexed to, uint256 value); constructor() {} @@ -64,12 +59,12 @@ contract StETH__HarnessForWithdrawalQueue is IStETH { // StETH::getSharesByPooledEth function getSharesByPooledEth(uint256 _ethAmount) public view returns (uint256) { - return _ethAmount * _getTotalShares() / totalPooledEther; + return (_ethAmount * _getTotalShares()) / totalPooledEther; } // StETH::getPooledEthByShares function getPooledEthByShares(uint256 _sharesAmount) public view returns (uint256) { - return _sharesAmount * totalPooledEther / _getTotalShares(); + return (_sharesAmount * totalPooledEther) / _getTotalShares(); } // StETH::transfer @@ -96,7 +91,13 @@ contract StETH__HarnessForWithdrawalQueue is IStETH { // @dev Overrides the actual permit function to allow testing without signatures based on `isSignatureValid` flag. // StETHPermit::permit function permit( - address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s + address _owner, + address _spender, + uint256 _value, + uint256 _deadline, + uint8 _v, + bytes32 _r, + bytes32 _s ) external { require(block.timestamp <= _deadline, "DEADLINE_EXPIRED"); require(isSignatureValid, "INVALID_SIGNATURE"); diff --git a/test/0.8.9/contracts/StakingModule__Mock.sol b/test/0.8.9/contracts/StakingModule__Mock.sol index 7526d992a..07589c5f5 100644 --- a/test/0.8.9/contracts/StakingModule__Mock.sol +++ b/test/0.8.9/contracts/StakingModule__Mock.sol @@ -20,9 +20,9 @@ contract StakingModule__Mock is IStakingModule { uint256 private depositableValidatorsCount__mocked; function getStakingModuleSummary() - external - view - returns (uint256 totalExitedValidators, uint256 totalDepositedValidators, uint256 depositableValidatorsCount) + external + view + returns (uint256 totalExitedValidators, uint256 totalDepositedValidators, uint256 depositableValidatorsCount) { totalExitedValidators = totalExitedValidators__mocked; totalDepositedValidators = totalDepositedValidators__mocked; @@ -51,18 +51,18 @@ contract StakingModule__Mock is IStakingModule { function getNodeOperatorSummary( uint256 _nodeOperatorId ) - external - view - returns ( - bool isTargetLimitActive, - uint256 targetValidatorsCount, - uint256 stuckValidatorsCount, - uint256 refundedValidatorsCount, - uint256 stuckPenaltyEndTimestamp, - uint256 totalExitedValidators, - uint256 totalDepositedValidators, - uint256 depositableValidatorsCount - ) + external + view + returns ( + bool isTargetLimitActive, + uint256 targetValidatorsCount, + uint256 stuckValidatorsCount, + uint256 refundedValidatorsCount, + uint256 stuckPenaltyEndTimestamp, + uint256 totalExitedValidators, + uint256 totalDepositedValidators, + uint256 depositableValidatorsCount + ) { isTargetLimitActive = nodeOperatorIsTargetLimitActive__mocked; targetValidatorsCount = nodeOperatorTargetValidatorsCount__mocked; @@ -157,7 +157,10 @@ contract StakingModule__Mock is IStakingModule { event Mock__StuckValidatorsCountUpdated(bytes _nodeOperatorIds, bytes _stuckValidatorsCounts); - function updateStuckValidatorsCount(bytes calldata _nodeOperatorIds, bytes calldata _stuckValidatorsCounts) external { + function updateStuckValidatorsCount( + bytes calldata _nodeOperatorIds, + bytes calldata _stuckValidatorsCounts + ) external { emit Mock__StuckValidatorsCountUpdated(_nodeOperatorIds, _stuckValidatorsCounts); } diff --git a/test/0.8.9/contracts/StakingRouter__MockForAccountingOracle.sol b/test/0.8.9/contracts/StakingRouter__MockForAccountingOracle.sol index e92a98cf1..b2233b6f5 100644 --- a/test/0.8.9/contracts/StakingRouter__MockForAccountingOracle.sol +++ b/test/0.8.9/contracts/StakingRouter__MockForAccountingOracle.sol @@ -6,7 +6,6 @@ pragma solidity 0.8.9; import {IStakingRouter} from "contracts/0.8.9/oracle/AccountingOracle.sol"; contract StakingRouter__MockForAccountingOracle is IStakingRouter { - struct UpdateExitedKeysByModuleCallData { uint256[] moduleIds; uint256[] exitedKeysCounts; @@ -28,10 +27,7 @@ contract StakingRouter__MockForAccountingOracle is IStakingRouter { uint256 public totalCalls_onValidatorsCountsByNodeOperatorReportingFinished; - - function lastCall_updateExitedKeysByModule() - external view returns (UpdateExitedKeysByModuleCallData memory) - { + function lastCall_updateExitedKeysByModule() external view returns (UpdateExitedKeysByModuleCallData memory) { return _lastCall_updateExitedKeysByModule; } @@ -71,9 +67,9 @@ contract StakingRouter__MockForAccountingOracle is IStakingRouter { bytes calldata nodeOperatorIds, bytes calldata exitedKeysCounts ) external { - calls_reportExitedKeysByNodeOperator.push(ReportKeysByNodeOperatorCallData( - stakingModuleId, nodeOperatorIds, exitedKeysCounts - )); + calls_reportExitedKeysByNodeOperator.push( + ReportKeysByNodeOperatorCallData(stakingModuleId, nodeOperatorIds, exitedKeysCounts) + ); } function reportStakingModuleStuckValidatorsCountByNodeOperator( @@ -81,9 +77,9 @@ contract StakingRouter__MockForAccountingOracle is IStakingRouter { bytes calldata nodeOperatorIds, bytes calldata stuckKeysCounts ) external { - calls_reportStuckKeysByNodeOperator.push(ReportKeysByNodeOperatorCallData( - stakingModuleId, nodeOperatorIds, stuckKeysCounts - )); + calls_reportStuckKeysByNodeOperator.push( + ReportKeysByNodeOperatorCallData(stakingModuleId, nodeOperatorIds, stuckKeysCounts) + ); } function onValidatorsCountsByNodeOperatorReportingFinished() external { diff --git a/test/0.8.9/contracts/StakingRouter__MockForDepositSecurityModule.sol b/test/0.8.9/contracts/StakingRouter__MockForDepositSecurityModule.sol index cee39d1a4..5501f79ec 100644 --- a/test/0.8.9/contracts/StakingRouter__MockForDepositSecurityModule.sol +++ b/test/0.8.9/contracts/StakingRouter__MockForDepositSecurityModule.sol @@ -10,7 +10,11 @@ contract StakingRouter__MockForDepositSecurityModule is IStakingRouter { error StakingModuleUnregistered(); event StakingModuleDeposited(uint256 maxDepositsCount, uint24 stakingModuleId, bytes depositCalldata); - event StakingModuleStatusSet(uint24 indexed stakingModuleId, StakingRouter.StakingModuleStatus status, address setBy); + event StakingModuleStatusSet( + uint24 indexed stakingModuleId, + StakingRouter.StakingModuleStatus status, + address setBy + ); StakingRouter.StakingModuleStatus private status; uint256 private stakingModuleNonce; @@ -25,7 +29,7 @@ contract StakingRouter__MockForDepositSecurityModule is IStakingRouter { uint256 maxDepositsCount, uint256 stakingModuleId, bytes calldata depositCalldata - ) external whenModuleIsRegistered(stakingModuleId) payable returns (uint256 keysCount) { + ) external payable whenModuleIsRegistered(stakingModuleId) returns (uint256 keysCount) { emit StakingModuleDeposited(maxDepositsCount, uint24(stakingModuleId), depositCalldata); return maxDepositsCount; } @@ -34,19 +38,26 @@ contract StakingRouter__MockForDepositSecurityModule is IStakingRouter { return _stakingModuleId == registeredStakingModuleId; } - function getStakingModuleStatus(uint256 stakingModuleId) external view whenModuleIsRegistered(stakingModuleId) returns (StakingRouter.StakingModuleStatus) { + function getStakingModuleStatus( + uint256 stakingModuleId + ) external view whenModuleIsRegistered(stakingModuleId) returns (StakingRouter.StakingModuleStatus) { return status; } function setStakingModuleStatus( - uint256 _stakingModuleId, StakingRouter.StakingModuleStatus _status + uint256 _stakingModuleId, + StakingRouter.StakingModuleStatus _status ) external whenModuleIsRegistered(_stakingModuleId) { emit StakingModuleStatusSet(uint24(_stakingModuleId), _status, msg.sender); status = _status; } function pauseStakingModule(uint256 stakingModuleId) external whenModuleIsRegistered(stakingModuleId) { - emit StakingModuleStatusSet(uint24(stakingModuleId), StakingRouter.StakingModuleStatus.DepositsPaused, msg.sender); + emit StakingModuleStatusSet( + uint24(stakingModuleId), + StakingRouter.StakingModuleStatus.DepositsPaused, + msg.sender + ); status = StakingRouter.StakingModuleStatus.DepositsPaused; } diff --git a/test/0.8.9/contracts/ValidatorsExitBus__Harness.sol b/test/0.8.9/contracts/ValidatorsExitBus__Harness.sol index 5dd67837e..87e6cd541 100644 --- a/test/0.8.9/contracts/ValidatorsExitBus__Harness.sol +++ b/test/0.8.9/contracts/ValidatorsExitBus__Harness.sol @@ -13,9 +13,11 @@ interface ITimeProvider { contract ValidatorsExitBus__Harness is ValidatorsExitBusOracle, ITimeProvider { using UnstructuredStorage for bytes32; - constructor(uint256 secondsPerSlot, uint256 genesisTime, address lidoLocator) - ValidatorsExitBusOracle(secondsPerSlot, genesisTime, lidoLocator) - { + constructor( + uint256 secondsPerSlot, + uint256 genesisTime, + address lidoLocator + ) ValidatorsExitBusOracle(secondsPerSlot, genesisTime, lidoLocator) { // allow usage without a proxy for tests CONTRACT_VERSION_POSITION.setStorageUint256(0); } @@ -24,7 +26,7 @@ contract ValidatorsExitBus__Harness is ValidatorsExitBusOracle, ITimeProvider { return _getTime(); } - function _getTime() internal override view returns (uint256) { + function _getTime() internal view override returns (uint256) { address consensus = CONSENSUS_CONTRACT_POSITION.getStorageAddress(); return ITimeProvider(consensus).getTime(); } diff --git a/test/0.8.9/contracts/WithdrawalQueue__MockForOracleSanityChecker.sol b/test/0.8.9/contracts/WithdrawalQueue__MockForOracleSanityChecker.sol index 94e0dd191..92f3585d0 100644 --- a/test/0.8.9/contracts/WithdrawalQueue__MockForOracleSanityChecker.sol +++ b/test/0.8.9/contracts/WithdrawalQueue__MockForOracleSanityChecker.sol @@ -14,9 +14,7 @@ contract WithdrawalQueue__MockForOracleSanityChecker is IWithdrawalQueue { function getWithdrawalStatus( uint256[] calldata _requestIds - ) external view returns ( - WithdrawalRequestStatus[] memory statuses - ) { + ) external view returns (WithdrawalRequestStatus[] memory statuses) { statuses = new WithdrawalRequestStatus[](_requestIds.length); for (uint256 i; i < _requestIds.length; ++i) { statuses[i].timestamp = _timestamps[_requestIds[i]]; diff --git a/test/0.8.9/contracts/WithdrawalsQueueBase__Harness.sol b/test/0.8.9/contracts/WithdrawalsQueueBase__Harness.sol index d68dc4357..fa17a1e11 100644 --- a/test/0.8.9/contracts/WithdrawalsQueueBase__Harness.sol +++ b/test/0.8.9/contracts/WithdrawalsQueueBase__Harness.sol @@ -6,16 +6,23 @@ pragma solidity 0.8.9; import {WithdrawalQueueBase} from "contracts/0.8.9/WithdrawalQueueBase.sol"; contract WithdrawalsQueueBase__Harness is WithdrawalQueueBase { - constructor() { _initializeQueue(); } - function harness__enqueue(uint128 _amountOfStETH, uint128 _amountOfShares, address _owner) external returns (uint256 requestId) { + function harness__enqueue( + uint128 _amountOfStETH, + uint128 _amountOfShares, + address _owner + ) external returns (uint256 requestId) { return _enqueue(_amountOfStETH, _amountOfShares, _owner); } - function harness__finalize(uint256 _lastRequestIdToBeFinalized, uint256 _amountOfETH, uint256 _maxShareRate) external { + function harness__finalize( + uint256 _lastRequestIdToBeFinalized, + uint256 _amountOfETH, + uint256 _maxShareRate + ) external { _finalize(_lastRequestIdToBeFinalized, _amountOfETH, _maxShareRate); } @@ -23,7 +30,11 @@ contract WithdrawalsQueueBase__Harness is WithdrawalQueueBase { return _getStatus(_requestId); } - function harness__findCheckpointHint(uint256 _requestId, uint256 _start, uint256 _end) external view returns (uint256) { + function harness__findCheckpointHint( + uint256 _requestId, + uint256 _start, + uint256 _end + ) external view returns (uint256) { return _findCheckpointHint(_requestId, _start, _end); } @@ -31,8 +42,10 @@ contract WithdrawalsQueueBase__Harness is WithdrawalQueueBase { return _sendValue(_recipient, _amount); } - function harness__calcBatch(WithdrawalRequest memory _preStartRequest, WithdrawalRequest memory _endRequest) external pure returns (uint256 shareRate, uint256 stETH, uint256 shares) - { + function harness__calcBatch( + WithdrawalRequest memory _preStartRequest, + WithdrawalRequest memory _endRequest + ) external pure returns (uint256 shareRate, uint256 stETH, uint256 shares) { return _calcBatch(_preStartRequest, _endRequest); } diff --git a/test/0.8.9/contracts/WithdrawalsQueue__Harness.sol b/test/0.8.9/contracts/WithdrawalsQueue__Harness.sol index b85ce6145..fbe24dd79 100644 --- a/test/0.8.9/contracts/WithdrawalsQueue__Harness.sol +++ b/test/0.8.9/contracts/WithdrawalsQueue__Harness.sol @@ -6,12 +6,15 @@ pragma solidity 0.8.9; import {WithdrawalQueue, IWstETH} from "contracts/0.8.9/WithdrawalQueue.sol"; contract WithdrawalsQueue__Harness is WithdrawalQueue { - event Mock__Transfer(address indexed from, address indexed to, uint256 requestId); constructor(address _wstETH) WithdrawalQueue(IWstETH(_wstETH)) {} - function harness__enqueue(uint128 _amountOfStETH, uint128 _amountOfShares, address _owner) external returns (uint256 requestId) { + function harness__enqueue( + uint128 _amountOfStETH, + uint128 _amountOfShares, + address _owner + ) external returns (uint256 requestId) { return _enqueue(_amountOfStETH, _amountOfShares, _owner); } diff --git a/test/0.8.9/contracts/WstETH__MockForWithdrawalQueue.sol b/test/0.8.9/contracts/WstETH__MockForWithdrawalQueue.sol index ec4b5903d..7f7823ffa 100644 --- a/test/0.8.9/contracts/WstETH__MockForWithdrawalQueue.sol +++ b/test/0.8.9/contracts/WstETH__MockForWithdrawalQueue.sol @@ -63,7 +63,15 @@ contract WstETH__MockForWithdrawalQueue { // @dev Overrides the actual permit function to allow for testing without signatures based on `isSignatureValid` flag. // openzeppelin/contracts/drafts/ERC20Permit.sol - function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external { + function permit( + address owner, + address spender, + uint256 value, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); require(isSignatureValid, "ERC20Permit: invalid signature"); diff --git a/test/0.8.9/positiveTokenRebaseLimiter.t.sol b/test/0.8.9/positiveTokenRebaseLimiter.t.sol index 9da7ac226..c30089b69 100644 --- a/test/0.8.9/positiveTokenRebaseLimiter.t.sol +++ b/test/0.8.9/positiveTokenRebaseLimiter.t.sol @@ -77,7 +77,9 @@ contract PositiveTokenRebaseLimiterTest is Test { assertEq(data.positiveRebaseLimit, rebaseLimit); assertEq( data.maxTotalPooledEther, - preTotalPooledEther + (preTotalPooledEther * rebaseLimit) / PositiveTokenRebaseLimiter.LIMITER_PRECISION_BASE + preTotalPooledEther + + (preTotalPooledEther * rebaseLimit) / + PositiveTokenRebaseLimiter.LIMITER_PRECISION_BASE ); } else { assertEq(data.positiveRebaseLimit, PositiveTokenRebaseLimiter.UNLIMITED_REBASE); diff --git a/test/0.8.9/withdrawalQueue.t.sol b/test/0.8.9/withdrawalQueue.t.sol index 79c08e0d0..8605709ac 100644 --- a/test/0.8.9/withdrawalQueue.t.sol +++ b/test/0.8.9/withdrawalQueue.t.sol @@ -152,7 +152,7 @@ contract WQHandler is CommonBase, StdAssertions, StdUtils { uint256[] memory batches = calculateBatches(ethBudget, maxShareRate); if (batches.length > 0) { - (uint256 eth,) = wq.prefinalize(batches, maxShareRate); + (uint256 eth, ) = wq.prefinalize(batches, maxShareRate); vm.deal(address(this), eth); wq.finalize{value: eth}(batches[batches.length - 1], maxShareRate); diff --git a/test/common/math256.t.sol b/test/common/math256.t.sol index 6ea8055b5..bc5c0431e 100644 --- a/test/common/math256.t.sol +++ b/test/common/math256.t.sol @@ -117,36 +117,36 @@ contract Math256Test is Test { } function test_max_WorksWithBothNegativeABInt256() public pure { - int256 a = - 1; - int256 b = - 2; + int256 a = -1; + int256 b = -2; assertEq(Math256.max(a, b), a); } function test_max_WorksWithBothNegativeBAInt256() public pure { - int256 a = - 1; - int256 b = - 2; + int256 a = -1; + int256 b = -2; assertEq(Math256.max(b, a), a); } function test_max_WorksWithPositiveAndNegativeInt256() public pure { int256 a = 1; - int256 b = - 2; + int256 b = -2; assertEq(Math256.max(a, b), a); } function test_max_WorksWithNegativeAndPositiveInt256() public pure { int256 a = 1; - int256 b = - 2; + int256 b = -2; assertEq(Math256.max(b, a), a); } function test_max_WorksWithEqualNegativeBAInt256() public pure { - int256 a = - 1; - int256 b = - 1; + int256 a = -1; + int256 b = -1; assertEq(Math256.max(b, a), b); } diff --git a/test/common/memUtils.t.sol b/test/common/memUtils.t.sol index edd405d22..1e10db057 100644 --- a/test/common/memUtils.t.sol +++ b/test/common/memUtils.t.sol @@ -80,7 +80,7 @@ contract MemUtilsTest is Test, MemUtilsTestHelper { initialFreeMemPtr, freeMemPtr, abi.encodePacked( - // array 1: length + // array 1: length uint256(32), // array 1: data bytes32(0x1111111111111111111111111111111111111111111111111111111111111111), @@ -386,9 +386,13 @@ contract MemUtilsTest is Test, MemUtilsTestHelper { } function test_memcpy_CopiesMemChunksShorterThan32Bytes() external pure { - bytes memory src = abi.encodePacked(bytes32(0x1111111111111111111111111111111111111111111111111111111111111111)); + bytes memory src = abi.encodePacked( + bytes32(0x1111111111111111111111111111111111111111111111111111111111111111) + ); - bytes memory dst = abi.encodePacked(bytes32(0x2222222222222222222222222222222222222222222222222222222222222222)); + bytes memory dst = abi.encodePacked( + bytes32(0x2222222222222222222222222222222222222222222222222222222222222222) + ); MemUtils.memcpy(getDataPtr(src), getDataPtr(dst), 5); @@ -396,9 +400,13 @@ contract MemUtilsTest is Test, MemUtilsTestHelper { } function test_memcpy_CopiesMemChunksShorterThan32BytesFromANon32BytesOffset() external pure { - bytes memory src = abi.encodePacked(bytes32(0xcccccccccccccccccccccccccccccccccc8badf00d1234eeeeeeeeeeeeeeeeee)); + bytes memory src = abi.encodePacked( + bytes32(0xcccccccccccccccccccccccccccccccccc8badf00d1234eeeeeeeeeeeeeeeeee) + ); - bytes memory dst = abi.encodePacked(bytes32(0x2222222222222222222222222222222222222222222222222222222222222222)); + bytes memory dst = abi.encodePacked( + bytes32(0x2222222222222222222222222222222222222222222222222222222222222222) + ); MemUtils.memcpy(getDataPtr(src) + 17, getDataPtr(dst), 4); @@ -406,9 +414,13 @@ contract MemUtilsTest is Test, MemUtilsTestHelper { } function test_memcpy_CopiesMemChunksShorterThan32BytesToANon32BytesOffset() external pure { - bytes memory src = abi.encodePacked(bytes32(0x1111111111111111111111111111111111111111111111111111111111111111)); + bytes memory src = abi.encodePacked( + bytes32(0x1111111111111111111111111111111111111111111111111111111111111111) + ); - bytes memory dst = abi.encodePacked(bytes32(0x2222222222222222222222222222222222222222222222222222222222222222)); + bytes memory dst = abi.encodePacked( + bytes32(0x2222222222222222222222222222222222222222222222222222222222222222) + ); MemUtils.memcpy(getDataPtr(src), getDataPtr(dst) + 5, 5); @@ -416,9 +428,13 @@ contract MemUtilsTest is Test, MemUtilsTestHelper { } function test_memcpy_CopiesMemChunksShorterThan32BytesFromAndToANon32BytesOffset() external pure { - bytes memory src = abi.encodePacked(bytes32(0xcccccccccccccccccccccccccccccccccc8badf00d1234eeeeeeeeeeeeeeeeee)); + bytes memory src = abi.encodePacked( + bytes32(0xcccccccccccccccccccccccccccccccccc8badf00d1234eeeeeeeeeeeeeeeeee) + ); - bytes memory dst = abi.encodePacked(bytes32(0x2222222222222222222222222222222222222222222222222222222222222222)); + bytes memory dst = abi.encodePacked( + bytes32(0x2222222222222222222222222222222222222222222222222222222222222222) + ); MemUtils.memcpy(getDataPtr(src) + 17, getDataPtr(dst) + 3, 4); @@ -426,9 +442,13 @@ contract MemUtilsTest is Test, MemUtilsTestHelper { } function test_memcpy_HandlesZeroLength() external pure { - bytes memory src = abi.encodePacked(bytes32(0x1111111111111111111111111111111111111111111111111111111111111111)); + bytes memory src = abi.encodePacked( + bytes32(0x1111111111111111111111111111111111111111111111111111111111111111) + ); - bytes memory dst = abi.encodePacked(bytes32(0x2222222222222222222222222222222222222222222222222222222222222222)); + bytes memory dst = abi.encodePacked( + bytes32(0x2222222222222222222222222222222222222222222222222222222222222222) + ); MemUtils.memcpy(getDataPtr(src) + 11, getDataPtr(dst) + 13, 0); @@ -436,9 +456,13 @@ contract MemUtilsTest is Test, MemUtilsTestHelper { } function test_copyBytes_CopiesMemChunksThatAreMultiplesOf32Bytes() external pure { - bytes memory src = abi.encodePacked(bytes32(0x1111111111111111111111111111111111111111111111111111111111111111)); + bytes memory src = abi.encodePacked( + bytes32(0x1111111111111111111111111111111111111111111111111111111111111111) + ); - bytes memory dst = abi.encodePacked(bytes32(0x2222222222222222222222222222222222222222222222222222222222222222)); + bytes memory dst = abi.encodePacked( + bytes32(0x2222222222222222222222222222222222222222222222222222222222222222) + ); MemUtils.copyBytes(src, dst, 0); @@ -446,9 +470,13 @@ contract MemUtilsTest is Test, MemUtilsTestHelper { } function test_copyBytes_CopiesMemChunksThatAreMultiplesOf32BytesFromANon32BytesOffset() external pure { - bytes memory src = abi.encodePacked(bytes32(0x1111111111111111111111111111111111111111111111111111111111111111)); + bytes memory src = abi.encodePacked( + bytes32(0x1111111111111111111111111111111111111111111111111111111111111111) + ); - bytes memory dst = abi.encodePacked(bytes32(0x2222222222222222222222222222222222222222222222222222222222222222)); + bytes memory dst = abi.encodePacked( + bytes32(0x2222222222222222222222222222222222222222222222222222222222222222) + ); MemUtils.copyBytes(src, dst, 1, 1, 31); @@ -456,9 +484,13 @@ contract MemUtilsTest is Test, MemUtilsTestHelper { } function test_copyBytes_RevertsWhenSrcArrayIsOutOfBounds() external { - bytes memory src = abi.encodePacked(bytes32(0x1111111111111111111111111111111111111111111111111111111111111111)); + bytes memory src = abi.encodePacked( + bytes32(0x1111111111111111111111111111111111111111111111111111111111111111) + ); - bytes memory dst = abi.encodePacked(bytes32(0x2222222222222222222222222222222222222222222222222222222222222222)); + bytes memory dst = abi.encodePacked( + bytes32(0x2222222222222222222222222222222222222222222222222222222222222222) + ); vm.expectRevert(bytes("BYTES_ARRAY_OUT_OF_BOUNDS")); MemUtils.copyBytes(src, dst, 1, 1, 32); diff --git a/test/common/minFirstAllocationStrategy.t.sol b/test/common/minFirstAllocationStrategy.t.sol index 5c0bf0f37..fe283f56b 100644 --- a/test/common/minFirstAllocationStrategy.t.sol +++ b/test/common/minFirstAllocationStrategy.t.sol @@ -28,7 +28,7 @@ contract MinFirstAllocationStrategyInvariants is Test { uint256[] memory capacities = new uint256[](1); uint256 allocationSize = 0; - (uint256 allocated,,) = harness.allocateToBestCandidate(buckets, capacities, allocationSize); + (uint256 allocated, , ) = harness.allocateToBestCandidate(buckets, capacities, allocationSize); assertEq(allocated, 0, "INVALID_ALLOCATED_VALUE"); } @@ -45,7 +45,7 @@ contract MinFirstAllocationStrategyInvariants is Test { capacities[1] = 101; capacities[2] = 100; - (uint256 allocated, uint256[] memory newBuckets,) = harness.allocate(buckets, capacities, allocationSize); + (uint256 allocated, uint256[] memory newBuckets, ) = harness.allocate(buckets, capacities, allocationSize); assertEq(allocated, 101, "INVALID_ALLOCATED_VALUE"); @@ -63,8 +63,8 @@ contract MinFirstAllocationStrategyInvariants is Test { * forge-config: default.invariant.fail-on-revert = true */ function invariant_AllocatedOutput() public view { - (,, uint256 allocatedActual) = handler.getActualOutput(); - (,, uint256 allocatedExpected) = handler.getExpectedOutput(); + (, , uint256 allocatedActual) = handler.getActualOutput(); + (, , uint256 allocatedExpected) = handler.getExpectedOutput(); assertEq(allocatedExpected, allocatedActual, "INVALID_ALLOCATED_VALUE"); } @@ -78,8 +78,8 @@ contract MinFirstAllocationStrategyInvariants is Test { * forge-config: default.invariant.fail-on-revert = true */ function invariant_BucketsOutput() public view { - (uint256[] memory bucketsActual,,) = handler.getActualOutput(); - (uint256[] memory bucketsExpected,,) = handler.getExpectedOutput(); + (uint256[] memory bucketsActual, , ) = handler.getActualOutput(); + (uint256[] memory bucketsExpected, , ) = handler.getExpectedOutput(); for (uint256 i = 0; i < bucketsExpected.length; ++i) { assertEq(bucketsExpected[i], bucketsActual[i], "INVALID_ALLOCATED_VALUE"); @@ -95,8 +95,8 @@ contract MinFirstAllocationStrategyInvariants is Test { * forge-config: default.invariant.fail-on-revert = true */ function invariant_AllocatedBucketValuesNotExceedCapacities() public view { - (uint256[] memory inputBuckets, uint256[] memory inputCapacities,) = handler.getInput(); - (uint256[] memory buckets, uint256[] memory capacities,) = handler.getActualOutput(); + (uint256[] memory inputBuckets, uint256[] memory inputCapacities, ) = handler.getInput(); + (uint256[] memory buckets, uint256[] memory capacities, ) = handler.getActualOutput(); for (uint256 i = 0; i < buckets.length; ++i) { // when bucket initially overloaded skip it from the check @@ -114,8 +114,8 @@ contract MinFirstAllocationStrategyInvariants is Test { * forge-config: default.invariant.fail-on-revert = true */ function invariant_AllocatedMatchesBucketChanges() public view { - (uint256[] memory inputBuckets,,) = handler.getInput(); - (uint256[] memory buckets,, uint256 allocated) = handler.getActualOutput(); + (uint256[] memory inputBuckets, , ) = handler.getInput(); + (uint256[] memory buckets, , uint256 allocated) = handler.getActualOutput(); uint256 inputSum = 0; uint256 outputSum = 0; @@ -137,7 +137,7 @@ contract MinFirstAllocationStrategyInvariants is Test { * forge-config: default.invariant.fail-on-revert = true */ function invariant_AllocatedLessThenAllocationSizeOnlyWhenAllBucketsFilled() public view { - (,, uint256 allocationSize) = handler.getInput(); + (, , uint256 allocationSize) = handler.getInput(); (uint256[] memory buckets, uint256[] memory capacities, uint256 allocated) = handler.getActualOutput(); if (allocationSize == allocated) return; @@ -171,9 +171,9 @@ contract MinFirstAllocationStrategyBase { TestOutput internal _expected; function getInput() - external - view - returns (uint256[] memory buckets, uint256[] memory capacities, uint256 allocationSize) + external + view + returns (uint256[] memory buckets, uint256[] memory capacities, uint256 allocationSize) { buckets = _input.buckets; capacities = _input.capacities; @@ -181,9 +181,9 @@ contract MinFirstAllocationStrategyBase { } function getExpectedOutput() - external - view - returns (uint256[] memory buckets, uint256[] memory capacities, uint256 allocated) + external + view + returns (uint256[] memory buckets, uint256[] memory capacities, uint256 allocated) { buckets = _expected.buckets; capacities = _expected.capacities; @@ -191,9 +191,9 @@ contract MinFirstAllocationStrategyBase { } function getActualOutput() - external - view - returns (uint256[] memory buckets, uint256[] memory capacities, uint256 allocated) + external + view + returns (uint256[] memory buckets, uint256[] memory capacities, uint256 allocated) { buckets = _actual.buckets; capacities = _actual.capacities; @@ -217,9 +217,11 @@ contract MinFirstAllocationStrategyBase { } contract MinFirstAllocationStrategyAllocateHandler is MinFirstAllocationStrategyBase { - function allocate(uint256[] memory _fuzzBuckets, uint256[] memory _fuzzCapacities, uint256 _fuzzAllocationSize) - public - { + function allocate( + uint256[] memory _fuzzBuckets, + uint256[] memory _fuzzCapacities, + uint256 _fuzzAllocationSize + ) public { _fillTestInput(_fuzzBuckets, _fuzzCapacities, _fuzzAllocationSize); _fillActualAllocateOutput(); @@ -252,21 +254,21 @@ contract MinFirstAllocationStrategyAllocateHandler is MinFirstAllocationStrategy } contract MinFirstAllocationStrategy__Harness { - function allocate(uint256[] memory _buckets, uint256[] memory _capacities, uint256 _allocationSize) - public - pure - returns (uint256 allocated, uint256[] memory newBuckets, uint256[] memory newCapacities) - { + function allocate( + uint256[] memory _buckets, + uint256[] memory _capacities, + uint256 _allocationSize + ) public pure returns (uint256 allocated, uint256[] memory newBuckets, uint256[] memory newCapacities) { allocated = MinFirstAllocationStrategy.allocate(_buckets, _capacities, _allocationSize); newBuckets = _buckets; newCapacities = _capacities; } - function allocateToBestCandidate(uint256[] memory _buckets, uint256[] memory _capacities, uint256 _allocationSize) - public - pure - returns (uint256 allocated, uint256[] memory newBuckets, uint256[] memory newCapacities) - { + function allocateToBestCandidate( + uint256[] memory _buckets, + uint256[] memory _capacities, + uint256 _allocationSize + ) public pure returns (uint256 allocated, uint256[] memory newBuckets, uint256[] memory newCapacities) { allocated = MinFirstAllocationStrategy.allocateToBestCandidate(_buckets, _capacities, _allocationSize); newBuckets = _buckets; newCapacities = _capacities; @@ -276,11 +278,11 @@ contract MinFirstAllocationStrategy__Harness { library NaiveMinFirstAllocationStrategy { uint256 private constant MAX_UINT256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; - function allocate(uint256[] memory buckets, uint256[] memory capacities, uint256 allocationSize) - internal - pure - returns (uint256 allocated) - { + function allocate( + uint256[] memory buckets, + uint256[] memory capacities, + uint256 allocationSize + ) internal pure returns (uint256 allocated) { while (allocated < allocationSize) { uint256 bestCandidateIndex = MAX_UINT256; uint256 bestCandidateAllocation = MAX_UINT256; diff --git a/test/common/signatureUtils.t.sol b/test/common/signatureUtils.t.sol index 5e36365e2..893e149b6 100644 --- a/test/common/signatureUtils.t.sol +++ b/test/common/signatureUtils.t.sol @@ -172,11 +172,13 @@ contract SignatureUtilsTest is Test { } contract SignatureUtils__Harness { - function isValidSignature(address signer, bytes32 msgHash, uint8 v, bytes32 r, bytes32 s) - public - view - returns (bool) - { + function isValidSignature( + address signer, + bytes32 msgHash, + uint8 v, + bytes32 r, + bytes32 s + ) public view returns (bool) { return SignatureUtils.isValidSignature(signer, msgHash, v, r, s); } diff --git a/yarn.lock b/yarn.lock index 7ea4d6dc5..493e5e6a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7991,6 +7991,7 @@ __metadata: lint-staged: "npm:^15.2.9" openzeppelin-solidity: "npm:2.0.0" prettier: "npm:^3.3.3" + prettier-plugin-solidity: "npm:^1.4.1" solhint: "npm:^5.0.3" solhint-plugin-lido: "npm:^0.0.4" solidity-coverage: "npm:^0.8.12" @@ -9444,6 +9445,18 @@ __metadata: languageName: node linkType: hard +"prettier-plugin-solidity@npm:^1.4.1": + version: 1.4.1 + resolution: "prettier-plugin-solidity@npm:1.4.1" + dependencies: + "@solidity-parser/parser": "npm:^0.18.0" + semver: "npm:^7.5.4" + peerDependencies: + prettier: ">=2.3.0" + checksum: 10c0/5ea7631fe01002319b87bf493e96b7b1cdc442fe4faebf227a4d5accb953140af6b3f63a330de53b1139b56e0ff8de6f055b84c902b75ba331824302d604418d + languageName: node + linkType: hard + "prettier@npm:^2.3.1, prettier@npm:^2.8.3": version: 2.8.8 resolution: "prettier@npm:2.8.8" @@ -10212,7 +10225,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.2, semver@npm:^7.6.0, semver@npm:^7.6.2": +"semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.2, semver@npm:^7.5.4, semver@npm:^7.6.0, semver@npm:^7.6.2": version: 7.6.3 resolution: "semver@npm:7.6.3" bin: