From 7ce1e00bdf1c5aed385cc95f2a5b4a930e684c82 Mon Sep 17 00:00:00 2001 From: vladbochok Date: Mon, 14 Oct 2024 19:07:11 +0400 Subject: [PATCH 1/2] Fix N-06 --- .../contracts/governance/PermanentRestriction.sol | 8 ++++---- .../unit/concrete/Governance/PermanentRestriction.t.sol | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/l1-contracts/contracts/governance/PermanentRestriction.sol b/l1-contracts/contracts/governance/PermanentRestriction.sol index 153ce369e..f5b184df1 100644 --- a/l1-contracts/contracts/governance/PermanentRestriction.sol +++ b/l1-contracts/contracts/governance/PermanentRestriction.sol @@ -48,7 +48,7 @@ contract PermanentRestriction is IRestriction, IPermanentRestriction, Ownable2St mapping(bytes allowedCalldata => bool isAllowed) public allowedCalls; /// @notice The mapping of the validated selectors. - mapping(bytes4 selector => bool isValidated) public validatedSelectors; + mapping(bytes4 selector => bool isValidated) public selectorsToValidate; /// @notice The mapping of whitelisted L2 admins. mapping(address adminAddress => bool isWhitelisted) public allowedL2Admins; @@ -87,8 +87,8 @@ contract PermanentRestriction is IRestriction, IPermanentRestriction, Ownable2St /// @notice Allows a certain selector to be validated. /// @param _selector The selector of the function. /// @param _isValidated The flag that indicates if the selector is validated. - function setSelectorIsValidated(bytes4 _selector, bool _isValidated) external onlyOwner { - validatedSelectors[_selector] = _isValidated; + function setSelectorShouldBeValidated(bytes4 _selector, bool _isValidated) external onlyOwner { + selectorsToValidate[_selector] = _isValidated; emit SelectorValidationChanged(_selector, _isValidated); } @@ -161,7 +161,7 @@ contract PermanentRestriction is IRestriction, IPermanentRestriction, Ownable2St return; } - if (!validatedSelectors[selector]) { + if (!selectorsToValidate[selector]) { // The selector is not validated, any data is allowed. return; } diff --git a/l1-contracts/test/foundry/l1/unit/concrete/Governance/PermanentRestriction.t.sol b/l1-contracts/test/foundry/l1/unit/concrete/Governance/PermanentRestriction.t.sol index bcfe6ae2c..92e58c888 100644 --- a/l1-contracts/test/foundry/l1/unit/concrete/Governance/PermanentRestriction.t.sol +++ b/l1-contracts/test/foundry/l1/unit/concrete/Governance/PermanentRestriction.t.sol @@ -92,12 +92,12 @@ contract PermanentRestrictionTest is ChainTypeManagerTest { permRestriction.setAllowedData(data, true); } - function test_setSelectorIsValidated(bytes4 selector) public { + function test_setSelectorShouldBeValidated(bytes4 selector) public { vm.expectEmit(true, false, false, true); emit IPermanentRestriction.SelectorValidationChanged(selector, true); vm.prank(owner); - permRestriction.setSelectorIsValidated(selector, true); + permRestriction.setSelectorShouldBeValidated(selector, true); } function test_tryCompareAdminOfAChainIsAddressZero() public { @@ -190,7 +190,7 @@ contract PermanentRestrictionTest is ChainTypeManagerTest { function test_validateCallCallNotAllowed() public { vm.prank(owner); - permRestriction.setSelectorIsValidated(IAdmin.acceptAdmin.selector, true); + permRestriction.setSelectorShouldBeValidated(IAdmin.acceptAdmin.selector, true); Call memory call = Call({ target: hyperchain, value: 0, @@ -206,7 +206,7 @@ contract PermanentRestrictionTest is ChainTypeManagerTest { function test_validateCall() public { vm.prank(owner); - permRestriction.setSelectorIsValidated(IAdmin.acceptAdmin.selector, true); + permRestriction.setSelectorShouldBeValidated(IAdmin.acceptAdmin.selector, true); Call memory call = Call({ target: hyperchain, value: 0, From af8a60eeffd9185c8332c4bcdc92b24e40ffe092 Mon Sep 17 00:00:00 2001 From: vladbochok Date: Tue, 15 Oct 2024 12:14:59 +0400 Subject: [PATCH 2/2] Apply suggestion --- .../contracts/governance/PermanentRestriction.sol | 2 +- .../unit/concrete/Governance/PermanentRestriction.t.sol | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/l1-contracts/contracts/governance/PermanentRestriction.sol b/l1-contracts/contracts/governance/PermanentRestriction.sol index f5b184df1..6796df354 100644 --- a/l1-contracts/contracts/governance/PermanentRestriction.sol +++ b/l1-contracts/contracts/governance/PermanentRestriction.sol @@ -69,7 +69,7 @@ contract PermanentRestriction is IRestriction, IPermanentRestriction, Ownable2St /// @notice Allows a certain `ChainAdmin` implementation to be used as an admin. /// @param _implementationHash The hash of the implementation code. /// @param _isAllowed The flag that indicates if the implementation is allowed. - function allowAdminImplementation(bytes32 _implementationHash, bool _isAllowed) external onlyOwner { + function setAllowedAdminImplementation(bytes32 _implementationHash, bool _isAllowed) external onlyOwner { allowedAdminImplementations[_implementationHash] = _isAllowed; emit AdminImplementationAllowed(_implementationHash, _isAllowed); diff --git a/l1-contracts/test/foundry/l1/unit/concrete/Governance/PermanentRestriction.t.sol b/l1-contracts/test/foundry/l1/unit/concrete/Governance/PermanentRestriction.t.sol index 92e58c888..103311925 100644 --- a/l1-contracts/test/foundry/l1/unit/concrete/Governance/PermanentRestriction.t.sol +++ b/l1-contracts/test/foundry/l1/unit/concrete/Governance/PermanentRestriction.t.sol @@ -76,12 +76,12 @@ contract PermanentRestrictionTest is ChainTypeManagerTest { ); } - function test_allowAdminImplementation(bytes32 implementationHash) public { + function test_setAllowedAdminImplementation(bytes32 implementationHash) public { vm.expectEmit(true, false, false, true); emit IPermanentRestriction.AdminImplementationAllowed(implementationHash, true); vm.prank(owner); - permRestriction.allowAdminImplementation(implementationHash, true); + permRestriction.setAllowedAdminImplementation(implementationHash, true); } function test_setAllowedData(bytes memory data) public { @@ -143,7 +143,7 @@ contract PermanentRestrictionTest is ChainTypeManagerTest { function test_validateCallSetPendingAdminRemovingPermanentRestriction() public { vm.prank(owner); - permRestriction.allowAdminImplementation(address(chainAdmin).codehash, true); + permRestriction.setAllowedAdminImplementation(address(chainAdmin).codehash, true); Call memory call = Call({ target: hyperchain, @@ -160,7 +160,7 @@ contract PermanentRestrictionTest is ChainTypeManagerTest { function test_validateCallSetPendingAdmin() public { vm.prank(owner); - permRestriction.allowAdminImplementation(address(chainAdmin).codehash, true); + permRestriction.setAllowedAdminImplementation(address(chainAdmin).codehash, true); vm.prank(address(chainAdmin)); chainAdmin.addRestriction(address(permRestriction));