From bb2fd67b78c8a231edf0c2ddd28b19f58c9a9e59 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Fri, 17 May 2024 15:52:36 -0400 Subject: [PATCH] Deprecate random.sol (#10997) * setup * deprecated random contract calls * bump version * fixed version * remove version restriction --- .github/workflows/protocol_tests.yml | 2 - .../contracts-0.8/common/IsL2Check.sol | 9 ++- .../protocol/contracts/identity/Random.sol | 33 ++++++++--- packages/protocol/test-sol/Readme.md | 57 ++++++++++++++++--- .../protocol/test-sol/common/Accounts.t.sol | 2 +- .../protocol/test-sol/common/IsL2Check.t.sol | 14 +++-- .../governance/validators/Validators.t.sol | 48 ++++++++-------- .../protocol/test-sol/identity/Random.t.sol | 27 ++++++++- .../protocol/test-sol/utils/ECDSAHelper.sol | 2 +- .../protocol/test-sol/voting/Election.t.sol | 20 +++---- yarn.lock | 53 +++++------------ 11 files changed, 164 insertions(+), 103 deletions(-) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 7f1d4b20e48..780bec9e5d5 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -39,8 +39,6 @@ jobs: - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 - with: - version: "nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9" - name: Install forge dependencies run: forge install diff --git a/packages/protocol/contracts-0.8/common/IsL2Check.sol b/packages/protocol/contracts-0.8/common/IsL2Check.sol index d07e5a7c3ed..d222ecdb5c6 100644 --- a/packages/protocol/contracts-0.8/common/IsL2Check.sol +++ b/packages/protocol/contracts-0.8/common/IsL2Check.sol @@ -11,6 +11,13 @@ contract IsL2Check { _; } + modifier onlyL2() { + if (!isL2()) { + revert("This method is not supported in L1."); + } + _; + } + function isL2() public view returns (bool) { uint32 size; address _addr = proxyAdminAddress; @@ -22,7 +29,7 @@ contract IsL2Check { function allowOnlyL1() internal view { if (isL2()) { - revert("This method is not supported in L2 anymore."); + revert("This method is no longer supported in L2."); } } } diff --git a/packages/protocol/contracts/identity/Random.sol b/packages/protocol/contracts/identity/Random.sol index b709522eb24..81249f17540 100644 --- a/packages/protocol/contracts/identity/Random.sol +++ b/packages/protocol/contracts/identity/Random.sol @@ -8,6 +8,7 @@ import "../common/CalledByVm.sol"; import "../common/Initializable.sol"; import "../common/UsingPrecompiles.sol"; import "../common/interfaces/ICeloVersionedContract.sol"; +import "../../contracts-0.8/common/IsL2Check.sol"; /** * @title Provides randomness for verifier selection @@ -18,7 +19,8 @@ contract Random is Ownable, Initializable, UsingPrecompiles, - CalledByVm + CalledByVm, + IsL2Check { using SafeMath for uint256; @@ -64,15 +66,16 @@ contract Random is bytes32 randomness, bytes32 newCommitment, address proposer - ) external onlyVm { + ) external onlyL1 onlyVm { _revealAndCommit(randomness, newCommitment, proposer); } /** * @notice Querying the current randomness value. * @return Returns the current randomness value. + * @dev Only available on L1. */ - function random() external view returns (bytes32) { + function random() external view onlyL1 returns (bytes32) { return _getBlockRandomness(block.number, block.number); } @@ -80,8 +83,9 @@ contract Random is * @notice Get randomness values of previous blocks. * @param blockNumber The number of block whose randomness value we want to know. * @return The associated randomness value. + * @dev Only available on L1. */ - function getBlockRandomness(uint256 blockNumber) external view returns (bytes32) { + function getBlockRandomness(uint256 blockNumber) external view onlyL1 returns (bytes32) { return _getBlockRandomness(blockNumber, block.number); } @@ -93,14 +97,15 @@ contract Random is * @return Patch version of the contract. */ function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) { - return (1, 1, 1, 1); + return (1, 1, 2, 0); } /** * @notice Sets the number of old random blocks whose randomness values can be queried. * @param value Number of old random blocks whose randomness values can be queried. + * @dev Only available on L1. */ - function setRandomnessBlockRetentionWindow(uint256 value) public onlyOwner { + function setRandomnessBlockRetentionWindow(uint256 value) public onlyL1 onlyOwner { require(value > 0, "randomnessBlockRetetionWindow cannot be zero"); randomnessBlockRetentionWindow = value; emit RandomnessBlockRetentionWindowSet(value); @@ -120,8 +125,13 @@ contract Random is * @param randomness Bytes that will be added to the entropy pool. * @param newCommitment The hash of randomness that will be revealed in the future. * @param proposer Address of the block proposer. + * @dev Only available on L1. */ - function _revealAndCommit(bytes32 randomness, bytes32 newCommitment, address proposer) internal { + function _revealAndCommit( + bytes32 randomness, + bytes32 newCommitment, + address proposer + ) internal onlyL1 { require(newCommitment != computeCommitment(0), "cannot commit zero randomness"); // ensure revealed randomness matches previous commitment @@ -149,8 +159,9 @@ contract Random is * @param randomness The new randomness added to history. * @dev The calls to this function should be made so that on the next call, blockNumber will * be the previous one, incremented by one. + * @dev Only available on L1. */ - function addRandomness(uint256 blockNumber, bytes32 randomness) internal { + function addRandomness(uint256 blockNumber, bytes32 randomness) internal onlyL1 { history[blockNumber] = randomness; if (blockNumber % getEpochSize() == 0) { if (lastEpochBlock < historyFirst) { @@ -187,8 +198,12 @@ contract Random is * @param blockNumber The number of block whose randomness value we want to know. * @param cur Number of the current block. * @return The associated randomness value. + * @dev Only available on L1. */ - function _getBlockRandomness(uint256 blockNumber, uint256 cur) internal view returns (bytes32) { + function _getBlockRandomness( + uint256 blockNumber, + uint256 cur + ) internal view onlyL1 returns (bytes32) { require(blockNumber <= cur, "Cannot query randomness of future blocks"); require( blockNumber == lastEpochBlock || diff --git a/packages/protocol/test-sol/Readme.md b/packages/protocol/test-sol/Readme.md index bff73a3380d..772c23d40f8 100644 --- a/packages/protocol/test-sol/Readme.md +++ b/packages/protocol/test-sol/Readme.md @@ -1,13 +1,56 @@ +### Building -## Naming Convention +You can build this project by simply running -Our tests generally follow the Foundry Book best [practices](https://book.getfoundry.sh/tutorials/best-practices#general-test-guidance), however, a few notable exepctions are enforced: +```bash +forge build +``` -1. Naming of contracts. Contract names for test are called `ContractTest_functionToTest_[When|After]`. In case necesary, a contract with setUp `ContractTest` and basic general test are created. Most other contracts are expected to inherit from this. -2. Function naming. - 1. In case of a emit expected `test_Emits_EventName_[When|After]` - 2. In case of a revert expected `test_Reverts_EventName_[When|After]` +### Testing + +We are in the process of migrating our tests to use [Foundry](https://book.getfoundry.sh/). The tests in this folder have already been migrated from [Truffle](../test). + +To run tests with Foundry there's no need to `yarn` or manage any Javascript dependencies. Instead, run + +```bash +forge test +``` + +This will run all tests in this folder. To run only a specific file you can use + +```bash +forge test --match-path ./path/to/file.t.sol +``` + +To run only a specific contract in a test file, you can use + +```bash +forge test --match-contract CONTRACT_NAME +``` + +To run only a specific test, you can use + +```bash +forge test --match-test test_ToMatch +``` + +You can specify a verbosity level with the `-v`, `-vv`, `-vvv`, and `-vvvv` flags. The more `v`s you put the more verbose the output will be. + +Putting it all together, you might run something like + +```bash +forge test --match-path ./path/to/file.t.sol --match-test test_ToMatch -vvv +``` + +You can read more about the `forge test` command [here](https://book.getfoundry.sh/reference/forge/forge-test). + +To skip a specific test, you can add `vm.skip(true);` as the first line of the test. + +If a test name begins with `testFail` rather than `test`, foundry will expect the test to fail / revert. + +Please follow the naming convention `test_NameOfTest` / `testFail_NameOfTest`. + +If you're new to Forge / Foundry, we recommend looking through the [Cheatcode Reference](https://book.getfoundry.sh/cheatcodes/) for a list of useful commands that make writing tests easier. -Generally, words as "should" are expected to be omitted. The world `If` is generally not used in favor of `When`. diff --git a/packages/protocol/test-sol/common/Accounts.t.sol b/packages/protocol/test-sol/common/Accounts.t.sol index e984757e62d..717bf9d9bc8 100644 --- a/packages/protocol/test-sol/common/Accounts.t.sol +++ b/packages/protocol/test-sol/common/Accounts.t.sol @@ -613,7 +613,7 @@ contract AccountsTest_setPaymentDelegation is AccountsTest { function test_Revert_SetPaymentDelegation_WhenL2() public { _whenL2(); accounts.createAccount(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); accounts.setPaymentDelegation(beneficiary, fraction); } diff --git a/packages/protocol/test-sol/common/IsL2Check.t.sol b/packages/protocol/test-sol/common/IsL2Check.t.sol index 73d9971c3d1..fece179a17d 100644 --- a/packages/protocol/test-sol/common/IsL2Check.t.sol +++ b/packages/protocol/test-sol/common/IsL2Check.t.sol @@ -35,16 +35,20 @@ contract IsL2Check_IsL2Test is IsL2CheckBase { helper_WhenProxyAdminAddressIsSet(); assertTrue(isL2Check.isL2()); } -} -contract IsL2Check_OnlyL1 is IsL2CheckBase { - function test_WhenIsL1() public view { - isL2Check.onlyL1Function(); + function test_IsL1_WhenProxyAdminSet() public { + helper_WhenProxyAdminAddressIsSet(); + assertFalse(!isL2Check.isL2()); } +} +contract IsL2Check_OnlyL1 is IsL2CheckBase { function test_WhenIsL2_WhenProxyAdminSet() public { helper_WhenProxyAdminAddressIsSet(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); + isL2Check.onlyL1Function(); + } + function test_WhenIsL1() public view { isL2Check.onlyL1Function(); } } diff --git a/packages/protocol/test-sol/governance/validators/Validators.t.sol b/packages/protocol/test-sol/governance/validators/Validators.t.sol index 3da5b9e4eaf..5c971b21f26 100644 --- a/packages/protocol/test-sol/governance/validators/Validators.t.sol +++ b/packages/protocol/test-sol/governance/validators/Validators.t.sol @@ -437,7 +437,7 @@ contract ValidatorsTest_Initialize is ValidatorsTest { function test_Reverts_setCommissionUpdateDelay_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.setCommissionUpdateDelay(commissionUpdateDelay); } @@ -448,7 +448,7 @@ contract ValidatorsTest_Initialize is ValidatorsTest { function test_Reverts_SetDowntimeGracePeriod_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.setDowntimeGracePeriod(downtimeGracePeriod); } } @@ -468,7 +468,7 @@ contract ValidatorsTest_SetMembershipHistoryLength is ValidatorsTest { function test_Reverts_SetTheMembershipHistoryLength_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.setMembershipHistoryLength(newLength); } @@ -492,7 +492,7 @@ contract ValidatorsTest_SetMaxGroupSize is ValidatorsTest { function test_Reverts_SetMaxGroupSize_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.setMaxGroupSize(newSize); } @@ -602,7 +602,7 @@ contract ValidatorsTest_SetValidatorScoreParameters is ValidatorsTest { function test_Reverts_SetExponentAndAdjustmentSpeed_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.setValidatorScoreParameters(newParams.exponent, newParams.adjustmentSpeed.unwrap()); } @@ -682,7 +682,7 @@ contract ValidatorsTest_RegisterValidator is ValidatorsTest { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); vm.prank(validator); validators.registerValidator(_ecdsaPubKey, blsPublicKey, blsPop); validatorRegistrationEpochNumber = validators.getEpochNumber(); @@ -997,7 +997,7 @@ contract ValidatorsTest_Affiliate_WhenGroupAndValidatorMeetLockedGoldRequirement function test_Reverts_WhenL2_WhenAffiliatingWithRegisteredValidatorGroup() public { _whenL2(); vm.prank(validator); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.affiliate(group); } @@ -1076,7 +1076,7 @@ contract ValidatorsTest_Affiliate_WhenValidatorIsAlreadyAffiliatedWithValidatorG function test_ShouldRevert_WhenL2_WhenValidatorNotMemberOfThatValidatorGroup() public { _whenL2(); vm.prank(validator); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.affiliate(otherGroup); } @@ -1327,7 +1327,7 @@ contract ValidatorsTest_UpdateEcdsaPublicKey is ValidatorsTest { signerPk ); vm.prank(address(accounts)); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.updateEcdsaPublicKey(validator, signer, _newEcdsaPubKey); } @@ -1431,7 +1431,7 @@ contract ValidatorsTest_UpdatePublicKeys is ValidatorsTest { ); vm.prank(address(accounts)); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.updatePublicKeys(validator, signer, _newEcdsaPubKey, newBlsPublicKey, newBlsPop); } @@ -1546,7 +1546,7 @@ contract ValidatorsTest_UpdateBlsPublicKey is ValidatorsTest { ); vm.prank(validator); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.updateBlsPublicKey(newBlsPublicKey, newBlsPop); } @@ -1861,7 +1861,7 @@ contract ValidatorsTest_AddMember is ValidatorsTest { expectedMembersList[0] = validator; vm.prank(group); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.addFirstMember(validator, address(0), address(0)); } @@ -1871,7 +1871,7 @@ contract ValidatorsTest_AddMember is ValidatorsTest { expectedMembersList[0] = validator; vm.prank(group); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.addMember(validator); } @@ -2155,7 +2155,7 @@ contract ValidatorsTest_ReorderMember is ValidatorsTest { expectedMembersList[1] = validator; vm.prank(group); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.reorderMember(vm.addr(1), validator, address(0)); } @@ -2209,7 +2209,7 @@ contract ValidatorsTest_SetNextCommissionUpdate is ValidatorsTest { function test_Reverts_SetValidatorGroupCommission_WhenL2() public { _whenL2(); vm.prank(group); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.setNextCommissionUpdate(newCommission); } @@ -2273,7 +2273,7 @@ contract ValidatorsTest_UpdateCommission is ValidatorsTest { function test_Reverts_SetValidatorGroupCommission_WhenL2() public { _whenL2(); vm.prank(group); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.setNextCommissionUpdate(newCommission); } @@ -2782,7 +2782,7 @@ contract ValidatorsTest_GetMembershipInLastEpoch is ValidatorsTest { validators.addFirstMember(validator, address(0), address(0)); _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.getMembershipInLastEpoch(validator); } } @@ -2954,7 +2954,7 @@ contract ValidatorsTest_DistributeEpochPaymentsFromSigner is ValidatorsTest { function test_Reverts_WhenL2_WhenValidatorAndGroupMeetBalanceRequirements() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.distributeEpochPaymentsFromSigner(validator, maxPayment); } @@ -3162,7 +3162,7 @@ contract ValidatorsTest_ForceDeaffiliateIfValidator is ValidatorsTest { function test_Reverts_WhenSenderIsWhitelistedSlashingAddress_WhenL2() public { _whenL2(); vm.prank(paymentDelegatee); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.forceDeaffiliateIfValidator(validator); } @@ -3252,14 +3252,14 @@ contract ValidatorsTest_GroupMembershipInEpoch is ValidatorsTest { address _group = epochInfoList[i].groupy; if (epochInfoList.length.sub(i) <= membershipHistoryLength) { - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.groupMembershipInEpoch( validator, epochInfoList[i].epochNumber, uint256(1).add(i) ); } else { - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.groupMembershipInEpoch( validator, epochInfoList[i].epochNumber, @@ -3334,7 +3334,7 @@ contract ValidatorsTest_HalveSlashingMultiplier is ValidatorsTest { _whenL2(); FixidityLib.Fraction memory expectedMultiplier = FixidityLib.fixed1(); vm.prank(paymentDelegatee); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.halveSlashingMultiplier(group); } @@ -3390,7 +3390,7 @@ contract ValidatorsTest_ResetSlashingMultiplier is ValidatorsTest { timeTravel(slashingMultiplierResetPeriod); vm.prank(group); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.resetSlashingMultiplier(); } @@ -3413,7 +3413,7 @@ contract ValidatorsTest_ResetSlashingMultiplier is ValidatorsTest { function test_Reverts_SetSlashingMultiplierResetPeriod_WhenL2() public { _whenL2(); uint256 newResetPeriod = 10 * DAY; - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); validators.setSlashingMultiplierResetPeriod(newResetPeriod); } } diff --git a/packages/protocol/test-sol/identity/Random.t.sol b/packages/protocol/test-sol/identity/Random.t.sol index 847654c8a2b..23a7216c2dc 100644 --- a/packages/protocol/test-sol/identity/Random.t.sol +++ b/packages/protocol/test-sol/identity/Random.t.sol @@ -7,7 +7,7 @@ import { Utils } from "@test-sol/utils.sol"; import "@celo-contracts/identity/Random.sol"; import "@celo-contracts/identity/test/RandomTest.sol"; -contract SetRandomnessRetentionWindow is Test { +contract RandomnessTest_SetRandomnessRetentionWindow is Test, IsL2Check { event RandomnessBlockRetentionWindowSet(uint256 value); RandomTest random; @@ -33,9 +33,15 @@ contract SetRandomnessRetentionWindow is Test { vm.prank(address(0x45)); random.setRandomnessBlockRetentionWindow(1000); } + + function test_Reverts_WhenCalledOnL2() public { + deployCodeTo("Registry.sol", abi.encode(false), proxyAdminAddress); + vm.expectRevert("This method is no longer supported in L2."); + random.setRandomnessBlockRetentionWindow(1000); + } } -contract AddTestRandomness is Test, Utils { +contract RandomnessTest_AddTestRandomness is Test, Utils, IsL2Check { uint256 constant RETENTION_WINDOW = 5; uint256 constant EPOCH_SIZE = 10; @@ -208,9 +214,17 @@ contract AddTestRandomness is Test, Utils { vm.expectRevert("Cannot query randomness older than the stored history"); random.getTestRandomness(lastBlockOfEpoch - EPOCH_SIZE, block.number); } + + function test_Reverts_WhenCalledOnL2() public { + deployCodeTo("Registry.sol", abi.encode(false), proxyAdminAddress); + vm.expectRevert("This method is no longer supported in L2."); + random.addTestRandomness(1, 0x0000000000000000000000000000000000000000000000000000000000000001); + vm.expectRevert("This method is no longer supported in L2."); + random.getTestRandomness(1, 4); + } } -contract RevealAndCommit is Test, Utils { +contract RandomnessTest_RevealAndCommit is Test, Utils, IsL2Check { address constant ACCOUNT = address(0x01); bytes32 constant RANDONMESS = bytes32(uint256(0x00)); @@ -246,4 +260,11 @@ contract RevealAndCommit is Test, Utils { assertEq(random.getBlockRandomness(block.number), expected); } + + function test_Reverts_WhenCalledOnL2() public { + deployCodeTo("Registry.sol", abi.encode(false), proxyAdminAddress); + vm.expectRevert("This method is no longer supported in L2."); + blockTravel(2); + random.testRevealAndCommit(RANDONMESS, commitmentFor(0x01), ACCOUNT); + } } diff --git a/packages/protocol/test-sol/utils/ECDSAHelper.sol b/packages/protocol/test-sol/utils/ECDSAHelper.sol index cd85d52cccd..aaa7c1119ae 100644 --- a/packages/protocol/test-sol/utils/ECDSAHelper.sol +++ b/packages/protocol/test-sol/utils/ECDSAHelper.sol @@ -13,7 +13,7 @@ contract ECDSAHelper is Test { bytes32 _s ) public returns (bytes memory) { address SECP256K1Address = actor("SECP256K1Address"); - deployCodeTo("out/SECP256K1.sol/SECP256K1.0.5.17.json", SECP256K1Address); + deployCodeTo("SECP256K1.sol:SECP256K1", SECP256K1Address); sECP256K1 = ISECP256K1(SECP256K1Address); string memory header = "\x19Ethereum Signed Message:\n32"; diff --git a/packages/protocol/test-sol/voting/Election.t.sol b/packages/protocol/test-sol/voting/Election.t.sol index a1ab398cea4..a52f03a897e 100644 --- a/packages/protocol/test-sol/voting/Election.t.sol +++ b/packages/protocol/test-sol/voting/Election.t.sol @@ -199,7 +199,7 @@ contract Election_SetElectabilityThreshold is ElectionTest { function test_Revert_setElectabilityThreshold_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); election.setElectabilityThreshold(FixidityLib.fixed1().unwrap() + 1); } } @@ -218,7 +218,7 @@ contract Election_SetElectableValidators is ElectionTest { _whenL2(); uint256 newElectableValidatorsMin = 2; uint256 newElectableValidatorsMax = 4; - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); election.setElectableValidators(newElectableValidatorsMin, newElectableValidatorsMax); } @@ -262,7 +262,7 @@ contract Election_SetMaxNumGroupsVotedFor is ElectionTest { function test_Revert_SetMaxNumGroupsVotedFor_WhenL2() public { _whenL2(); uint256 newMaxNumGroupsVotedFor = 4; - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); election.setMaxNumGroupsVotedFor(newMaxNumGroupsVotedFor); } @@ -293,7 +293,7 @@ contract Election_SetAllowedToVoteOverMaxNumberOfGroups is ElectionTest { function test_Revert_SetAllowedToVoteOverMaxNumberOfGroups_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); election.setAllowedToVoteOverMaxNumberOfGroups(true); } @@ -348,7 +348,7 @@ contract Election_MarkGroupEligible is ElectionTest { function test_Revert_MarkGroupEligible_WhenL2() public { _whenL2(); address group = address(this); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); election.markGroupEligible(group, address(0), address(0)); } @@ -468,7 +468,7 @@ contract Election_Vote_WhenGroupEligible is ElectionTest { function test_Revert_Vote_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); election.vote(group, value - maxNumGroupsVotedFor, address(0), address(0)); } @@ -861,7 +861,7 @@ contract Election_Activate is ElectionTest { function test_Revert_Activate_WhenL2() public { WhenVoterHasPendingVotes(); _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); election.activate(group); } @@ -941,7 +941,7 @@ contract Election_Activate is ElectionTest { function test_Revert_ActivateForAccount_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); election.activateForAccount(group, voter); } @@ -1949,7 +1949,7 @@ contract Election_DistributeEpochRewards is ElectionTest { function test_Revert_DistributeEpochRewards_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); vm.prank(address(0)); election.distributeEpochRewards(group, rewardValue, address(0), address(0)); } @@ -2712,7 +2712,7 @@ contract Election_ConsistencyChecks is ElectionTest { contract Election_HasActivatablePendingVotes is ElectionTest { function test_Revert_hasActivatablePendingVotes_WhenL2() public { _whenL2(); - vm.expectRevert("This method is not supported in L2 anymore."); + vm.expectRevert("This method is no longer supported in L2."); vm.prank(address(0)); election.hasActivatablePendingVotes(address(0), address(0)); } diff --git a/yarn.lock b/yarn.lock index 6fa4548ef83..8969a1a693e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3786,12 +3786,10 @@ dependencies: antlr4ts "^0.5.0-alpha.4" -"@solidity-parser/parser@^0.16.0": - version "0.16.0" - resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.16.0.tgz#1fb418c816ca1fc3a1e94b08bcfe623ec4e1add4" - integrity sha512-ESipEcHyRHg4Np4SqBCfcXwyxxna1DgFVz69bgpLV8vzl/NP1DtcKsJ4dJZXWQhY/Z4J2LeKBiOkOVZn9ct33Q== - dependencies: - antlr4ts "^0.5.0-alpha.4" +"@solidity-parser/parser@^0.17.0": + version "0.17.0" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.17.0.tgz#52a2fcc97ff609f72011014e4c5b485ec52243ef" + integrity sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw== "@solidity-parser/parser@^0.18.0": version "0.18.0" @@ -5531,7 +5529,7 @@ abi-to-sol@^0.6.6: source-map-support "^0.5.19" optionalDependencies: prettier "^2.7.1" - prettier-plugin-solidity "^1.3.1" + prettier-plugin-solidity "^1.0.0-dev.23" abi-to-sol@^0.7.0: version "0.7.1" @@ -5547,7 +5545,7 @@ abi-to-sol@^0.7.0: source-map-support "^0.5.19" optionalDependencies: prettier "^2.7.1" - prettier-plugin-solidity "^1.3.1" + prettier-plugin-solidity "^1.0.0-dev.23" abitype@0.8.7: version "0.8.7" @@ -8745,11 +8743,6 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" -dir-to-object@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/dir-to-object/-/dir-to-object-2.0.0.tgz#29723e9bd1c3e58e4f307bd04ff634c0370c8f8a" - integrity sha512-sXs0JKIhymON7T1UZuO2Ud6VTNAx/VTBXIl4+3mjb2RgfOpt+hectX0x04YqPOPdkeOAKoJuKqwqnXXURNPNEA== - dirty-chai@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/dirty-chai/-/dirty-chai-2.0.1.tgz#6b2162ef17f7943589da840abc96e75bda01aff3" @@ -9538,13 +9531,6 @@ espree@^9.6.0, espree@^9.6.1: acorn-jsx "^5.3.2" eslint-visitor-keys "^3.4.1" -esprima-extract-comments@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/esprima-extract-comments/-/esprima-extract-comments-1.1.0.tgz#0dacab567a5900240de6d344cf18c33617becbc9" - integrity sha512-sBQUnvJwpeE9QnPrxh7dpI/dp67erYG4WXEAreAMoelPRpMR7NWb4YtwRPn9b+H1uLQKl/qS8WYmyaljTpjIsw== - dependencies: - esprima "^4.0.0" - esprima@2.7.x, esprima@^2.7.1: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" @@ -10325,14 +10311,6 @@ extglob@^0.3.0, extglob@^0.3.1: dependencies: is-extglob "^1.0.0" -extract-comments@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/extract-comments/-/extract-comments-1.1.0.tgz#b90bca033a056bd69b8ba1c6b6b120fc2ee95c18" - integrity sha512-dzbZV2AdSSVW/4E7Ti5hZdHWbA+Z80RJsJhr5uiL10oyjl/gy7/o+HI1HwK4/WSZhlq4SNKU3oUzXlM13Qx02Q== - dependencies: - esprima-extract-comments "^1.1.0" - parse-code-context "^1.0.0" - extsprintf@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" @@ -16584,11 +16562,6 @@ parse-cache-control@^1.0.1: resolved "https://registry.yarnpkg.com/parse-cache-control/-/parse-cache-control-1.0.1.tgz#8eeab3e54fa56920fe16ba38f77fa21aacc2d74e" integrity sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg== -parse-code-context@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/parse-code-context/-/parse-code-context-1.0.0.tgz#718c295c593d0d19a37f898473268cc75e98de1e" - integrity sha512-OZQaqKaQnR21iqhlnPfVisFjBWjhnMl5J9MgbP8xC+EwoVqbXrq78lp+9Zb3ahmLzrIX5Us/qbvBnaS3hkH6OA== - parse-conflict-json@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/parse-conflict-json/-/parse-conflict-json-2.0.2.tgz#3d05bc8ffe07d39600dc6436c6aefe382033d323" @@ -17248,7 +17221,7 @@ prettier-plugin-solidity@^1.3.1: semver "^7.5.4" solidity-comments-extractor "^0.0.8" -prettier@^1.14.2, prettier@^1.15.3: +prettier@^1.14.2: version "1.19.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== @@ -18508,7 +18481,7 @@ semver@7.5.2: dependencies: lru-cache "^6.0.0" -semver@7.x, semver@^7.0.0, semver@^7.1.1, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8: +semver@7.x, semver@^7.0.0, semver@^7.1.1, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7: version "7.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.0.tgz#ed8c5dc8efb6c629c88b23d41dc9bf40c1d96cd0" integrity sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA== @@ -18966,12 +18939,12 @@ solidity-bytes-utils@0.0.7: dependencies: truffle-hdwallet-provider "0.0.3" -solidity-comments-extractor@^0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19" - integrity sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw== +solidity-comments-extractor@^0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.8.tgz#f6e148ab0c49f30c1abcbecb8b8df01ed8e879f8" + integrity sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g== -solidity-parser-antlr@^0.4.11, solidity-parser-antlr@^0.4.2: +solidity-parser-antlr@^0.4.2: version "0.4.11" resolved "https://registry.yarnpkg.com/solidity-parser-antlr/-/solidity-parser-antlr-0.4.11.tgz#af43e1f13b3b88309a875455f5d6e565b05ee5f1" integrity sha512-4jtxasNGmyC0midtjH/lTFPZYvTTUMy6agYcF+HoMnzW8+cqo3piFrINb4ZCzpPW+7tTVFCGa5ubP34zOzeuMg==