From 410a6af02dd8fc9c76b18a1bc1a248e69b98fe17 Mon Sep 17 00:00:00 2001 From: LHerskind Date: Thu, 28 Nov 2024 14:23:10 +0000 Subject: [PATCH] chore: fixing sol warnings --- l1-contracts/test/Outbox.t.sol | 2 +- l1-contracts/test/decoders/Decoders.t.sol | 14 +++++++------- .../registry/getCurrentSnapshotTest.t.sol | 2 +- .../test/governance/registry/getRollup.t.sol | 2 +- .../test/governance/registry/getSnapshot.t.sol | 8 ++++++-- .../test/governance/registry/getVersionFor.t.sol | 2 +- .../governance/registry/isRollupRegistered.t.sol | 4 ++-- l1-contracts/test/merkle/TestUtil.sol | 2 +- l1-contracts/test/merkle/UnbalancedMerkle.t.sol | 12 ++++++------ l1-contracts/test/sparta/Sampling.t.sol | 2 +- 10 files changed, 27 insertions(+), 23 deletions(-) diff --git a/l1-contracts/test/Outbox.t.sol b/l1-contracts/test/Outbox.t.sol index 007e8ec01e8..ca9db33eb85 100644 --- a/l1-contracts/test/Outbox.t.sol +++ b/l1-contracts/test/Outbox.t.sol @@ -288,7 +288,7 @@ contract OutboxTest is Test { } } - function testCheckOutOfBoundsStatus(uint256 _blockNumber, uint256 _leafIndex) public { + function testCheckOutOfBoundsStatus(uint256 _blockNumber, uint256 _leafIndex) public view { bool outOfBounds = outbox.hasMessageBeenConsumedAtBlockAndIndex(_blockNumber, _leafIndex); assertFalse(outOfBounds); } diff --git a/l1-contracts/test/decoders/Decoders.t.sol b/l1-contracts/test/decoders/Decoders.t.sol index 9087a5734ed..22e091c028d 100644 --- a/l1-contracts/test/decoders/Decoders.t.sol +++ b/l1-contracts/test/decoders/Decoders.t.sol @@ -168,7 +168,7 @@ contract DecodersTest is DecoderBase { // The public inputs are computed based of these values, but not directly part of the decoding per say. } - function testComputeKernelLogsIterationWithoutLogs() public { + function testComputeKernelLogsIterationWithoutLogs() public view { bytes memory kernelLogsLength = hex"00000004"; // 4 bytes containing value 4 bytes memory iterationLogsLength = hex"00000000"; // 4 empty bytes indicating that length of this iteration's logs is 0 bytes memory encodedLogs = abi.encodePacked(kernelLogsLength, iterationLogsLength); @@ -181,7 +181,7 @@ contract DecodersTest is DecoderBase { assertEq(logsHash, bytes32(0), "Incorrect logs hash"); } - function testComputeKernelLogs1Iteration() public { + function testComputeKernelLogs1Iteration() public view { // || K_LOGS_LEN | I1_LOGS_LEN | I1_LOGS || // K_LOGS_LEN = 4 + 8 = 12 (hex"0000000c") // I1_LOGS_LEN = 8 (hex"00000008") @@ -214,7 +214,7 @@ contract DecodersTest is DecoderBase { assertEq(logsHash, referenceLogsHash, "Incorrect logs hash"); } - function testComputeKernelLogs2Iterations() public { + function testComputeKernelLogs2Iterations() public view { // || K_LOGS_LEN | I1_LOGS_LEN | I1_LOGS | I2_LOGS_LEN | I2_LOGS || // K_LOGS_LEN = 4 + 8 + 4 + 20 = 36 (hex"00000024") // I1_LOGS_LEN = 8 (hex"00000008") @@ -263,7 +263,7 @@ contract DecodersTest is DecoderBase { assertEq(logsHash, referenceLogsHashFromIteration2, "Incorrect logs hash"); } - function testComputeKernelLogsMiddleIterationWithoutLogs() public { + function testComputeKernelLogsMiddleIterationWithoutLogs() public view { // || K_LOGS_LEN | I1_LOGS_LEN | I1_LOGS | I2_LOGS_LEN | I2_LOGS | I3_LOGS_LEN | I3_LOGS || // K_LOGS_LEN = 4 + 8 + 4 + 0 + 4 + 20 = 40 (hex"00000028") // I1_LOGS_LEN = 8 (hex"00000008") @@ -319,7 +319,7 @@ contract DecodersTest is DecoderBase { assertEq(logsHash, referenceLogsHashFromIteration3, "Incorrect logs hash"); } - function testComputeTxOutHash() public { + function testComputeTxOutHash() public view { // A tx with no msgs should give an out hash of 0 bytes memory encodedMsgs = abi.encodePacked(hex"00"); bytes32 outHash = txsHelper.computeTxOutHash(encodedMsgs); @@ -334,7 +334,7 @@ contract DecodersTest is DecoderBase { assertEq(outHash, expectedOutHash, "Incorrect tx out hash"); } - function testTxsDecoderCorrectlyComputesNumTxEffectsToPad() public { + function testTxsDecoderCorrectlyComputesNumTxEffectsToPad() public view { // Minimum num txs is 2 so when there are no real txs we need to pad to 2 uint32 numTxEffects = 0; uint32 paddedNumTxEffects = txsHelper.computeNumTxEffectsToPad(numTxEffects); @@ -353,7 +353,7 @@ contract DecodersTest is DecoderBase { assertEq(paddedNumTxEffects, 0, "Incorrect number of tx effects to pad"); } - function testTxsDecoderCorrectlyComputesNumMsgsToPad() public { + function testTxsDecoderCorrectlyComputesNumMsgsToPad() public view { uint32 numMsgs = 0; uint32 numMsgsToPad = txsHelper.computeNumMsgsToPad(numMsgs); assertEq(numMsgsToPad, 1, "Incorrect number of msgs to pad"); diff --git a/l1-contracts/test/governance/registry/getCurrentSnapshotTest.t.sol b/l1-contracts/test/governance/registry/getCurrentSnapshotTest.t.sol index 4e9e1d652db..bd7d752338a 100644 --- a/l1-contracts/test/governance/registry/getCurrentSnapshotTest.t.sol +++ b/l1-contracts/test/governance/registry/getCurrentSnapshotTest.t.sol @@ -6,7 +6,7 @@ import {RegistryBase} from "./Base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; contract GetCurrentSnapshotTest is RegistryBase { - function test_GivenOneListedRollup() external { + function test_GivenOneListedRollup() external view { // it should return the newest DataStructures.RegistrySnapshot memory snapshot = registry.getCurrentSnapshot(); assertEq(snapshot.blockNumber, block.number); diff --git a/l1-contracts/test/governance/registry/getRollup.t.sol b/l1-contracts/test/governance/registry/getRollup.t.sol index 28d336f32e1..bc95b03465e 100644 --- a/l1-contracts/test/governance/registry/getRollup.t.sol +++ b/l1-contracts/test/governance/registry/getRollup.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {RegistryBase} from "./Base.t.sol"; contract GetRollupTest is RegistryBase { - function test_GivenOneListedRollup() external { + function test_GivenOneListedRollup() external view { // it should return the newest assertEq(registry.getRollup(), address(0xdead)); } diff --git a/l1-contracts/test/governance/registry/getSnapshot.t.sol b/l1-contracts/test/governance/registry/getSnapshot.t.sol index 2c3ee39e8b7..0cf111ec530 100644 --- a/l1-contracts/test/governance/registry/getSnapshot.t.sol +++ b/l1-contracts/test/governance/registry/getSnapshot.t.sol @@ -10,7 +10,7 @@ contract GetSnapshotTest is RegistryBase { _; } - function test_When_versionExists() external givenMultipleListedRollups { + function test_When_versionExists() external view givenMultipleListedRollups { // it should return the snapshot DataStructures.RegistrySnapshot memory snapshot = registry.getSnapshot(0); @@ -19,7 +19,11 @@ contract GetSnapshotTest is RegistryBase { assertEq(registry.numberOfVersions(), 1); } - function test_When_versionDoesNotExists(uint256 _version) external givenMultipleListedRollups { + function test_When_versionDoesNotExists(uint256 _version) + external + view + givenMultipleListedRollups + { // it should return empty snapshot uint256 version = bound(_version, 1, type(uint256).max); diff --git a/l1-contracts/test/governance/registry/getVersionFor.t.sol b/l1-contracts/test/governance/registry/getVersionFor.t.sol index e9a6a05b0c5..51a05a2f781 100644 --- a/l1-contracts/test/governance/registry/getVersionFor.t.sol +++ b/l1-contracts/test/governance/registry/getVersionFor.t.sol @@ -11,7 +11,7 @@ contract GetVersionForTest is RegistryBase { _; } - function test_When_rollupIs0xdead() external givenNoAdditionalListedRollups { + function test_When_rollupIs0xdead() external view givenNoAdditionalListedRollups { // it should return 0 assertEq(registry.getVersionFor(address(0xdead)), 0); } diff --git a/l1-contracts/test/governance/registry/isRollupRegistered.t.sol b/l1-contracts/test/governance/registry/isRollupRegistered.t.sol index b426dedf039..3f6d76f575d 100644 --- a/l1-contracts/test/governance/registry/isRollupRegistered.t.sol +++ b/l1-contracts/test/governance/registry/isRollupRegistered.t.sol @@ -10,12 +10,12 @@ contract IsRollupRegisteredTest is RegistryBase { _; } - function test_When_rollupIs0xdead() external givenNoAdditionalListedRollups { + function test_When_rollupIs0xdead() external view givenNoAdditionalListedRollups { // it should return true assertTrue(registry.isRollupRegistered(address(0xdead))); } - function test_When_rollupNot0xdead(address _rollup) external givenNoAdditionalListedRollups { + function test_When_rollupNot0xdead(address _rollup) external view givenNoAdditionalListedRollups { // it should return false vm.assume(_rollup != address(0xdead)); assertFalse(registry.isRollupRegistered(_rollup)); diff --git a/l1-contracts/test/merkle/TestUtil.sol b/l1-contracts/test/merkle/TestUtil.sol index 2024b461150..397162b03e4 100644 --- a/l1-contracts/test/merkle/TestUtil.sol +++ b/l1-contracts/test/merkle/TestUtil.sol @@ -34,7 +34,7 @@ contract MerkleTestUtil is Test { return (2 ** height) != originalNumber ? ++height : height; } - function testCalculateTreeHeightFromSize() external { + function testCalculateTreeHeightFromSize() external pure { assertEq(calculateTreeHeightFromSize(0), 1); assertEq(calculateTreeHeightFromSize(1), 1); assertEq(calculateTreeHeightFromSize(2), 1); diff --git a/l1-contracts/test/merkle/UnbalancedMerkle.t.sol b/l1-contracts/test/merkle/UnbalancedMerkle.t.sol index e248f878b5a..44727f03c92 100644 --- a/l1-contracts/test/merkle/UnbalancedMerkle.t.sol +++ b/l1-contracts/test/merkle/UnbalancedMerkle.t.sol @@ -24,7 +24,7 @@ contract UnbalancedMerkleTest is Test { txsHelper = new TxsDecoderHelper(); } - function testDecomp() public { + function testDecomp() public view { // Worst case - max num txs uint32 numTxs = 65535; (uint256 min, uint256 max) = txsHelper.computeMinMaxPathLength(numTxs); @@ -62,7 +62,7 @@ contract UnbalancedMerkleTest is Test { // root // / \ // base base - function testComputeTxsEffectsHash2() public { + function testComputeTxsEffectsHash2() public view { // Generate some base leaves bytes32[] memory baseLeaves = new bytes32[](2); for (uint256 i = 0; i < 2; i++) { @@ -84,7 +84,7 @@ contract UnbalancedMerkleTest is Test { // / \ // base base - function testComputeTxsEffectsHash3() public { + function testComputeTxsEffectsHash3() public view { // Generate some base leaves bytes32[] memory baseLeaves = new bytes32[](3); for (uint256 i = 0; i < 3; i++) { @@ -109,7 +109,7 @@ contract UnbalancedMerkleTest is Test { // merge merge // / \ / \ // base base base base - function testComputeTxsEffectsHash5() public { + function testComputeTxsEffectsHash5() public view { // Generate some base leaves bytes32[] memory baseLeaves = new bytes32[](5); for (uint256 i = 0; i < 5; i++) { @@ -139,7 +139,7 @@ contract UnbalancedMerkleTest is Test { // merge1 merge2 base base // / \ / \ // base base base base - function testComputeTxsEffectsHash6() public { + function testComputeTxsEffectsHash6() public view { // Generate some base leaves bytes32[] memory baseLeaves = new bytes32[](6); for (uint256 i = 0; i < 6; i++) { @@ -171,7 +171,7 @@ contract UnbalancedMerkleTest is Test { // merge1 merge2 merge4 base // / \ / \ / \ // base base base base base base - function testComputeTxsEffectsHash7() public { + function testComputeTxsEffectsHash7() public view { // Generate some base leaves bytes32[] memory baseLeaves = new bytes32[](7); for (uint256 i = 0; i < 6; i++) { diff --git a/l1-contracts/test/sparta/Sampling.t.sol b/l1-contracts/test/sparta/Sampling.t.sol index 013512c877b..f537c96b399 100644 --- a/l1-contracts/test/sparta/Sampling.t.sol +++ b/l1-contracts/test/sparta/Sampling.t.sol @@ -44,7 +44,7 @@ contract Sampler { contract SamplingTest is Test { Sampler sampler = new Sampler(); - function testShuffle() public { + function testShuffle() public view { // Sizes pulled out of thin air uint256 setSize = 1024; uint256 commiteeSize = 32;