Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove admin and use governance owner as admin instead #85

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethereum/contracts/zksync/facets/Admin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract AdminFacet is Base, IAdmin {
/// @notice Starts the transfer of admin rights. Only the current governor or admin can propose a new pending one.
/// @notice New admin can accept admin rights by calling `acceptAdmin` function.
/// @param _newPendingAdmin Address of the new admin
function setPendingAdmin(address _newPendingAdmin) external onlyGovernorOrAdmin {
function setPendingAdmin(address _newPendingAdmin) external onlyGovernor {
// Save previous value into the stack to put it into the event later
address oldPendingAdmin = s.pendingAdmin;
// Change pending admin
Expand Down
21 changes: 21 additions & 0 deletions ethereum/test/foundry/unit/concrete/Admin/Authorization.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;

import {AdminTest} from "./_Admin_Shared.t.sol";

contract AuthorizationTest is AdminTest {
function test_SetPendingAdmin_RevertWhen() public {
address newAdmin = address(0x1337);
vm.prank(owner);
vm.expectRevert(bytes.concat("1g"));
proxyAsAdmin.setPendingAdmin(newAdmin);
}

function test_SetPendingAdmin_RevertWhen_AdminNotGovernanceOwner() public {
koloz193 marked this conversation as resolved.
Show resolved Hide resolved
address newAdmin = address(0x1337);
vm.prank(owner);
vm.expectRevert(bytes.concat("1g"));
proxyAsAdmin.setPendingAdmin(newAdmin);
}
}
84 changes: 84 additions & 0 deletions ethereum/test/foundry/unit/concrete/Admin/_Admin_Shared.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import {Test} from "forge-std/Test.sol";
import {DiamondProxy} from "solpp/zksync/DiamondProxy.sol";
import {DiamondInit} from "solpp/zksync/DiamondInit.sol";
import {VerifierParams} from "solpp/zksync/Storage.sol";
import {Diamond} from "solpp/zksync/libraries/Diamond.sol";
import {AdminFacet} from "solpp/zksync/facets/Admin.sol";
import {Governance} from "solpp/governance/Governance.sol";

contract AdminTest is Test {
DiamondProxy internal diamondProxy;
address internal owner;
address internal securityCouncil;
Governance internal governor;
AdminFacet internal adminFacet;
AdminFacet internal proxyAsAdmin;

function getAdminSelectors() private view returns (bytes4[] memory) {
bytes4[] memory dcSelectors = new bytes4[](10);
dcSelectors[0] = adminFacet.setPendingGovernor.selector;
dcSelectors[1] = adminFacet.acceptGovernor.selector;
dcSelectors[2] = adminFacet.setPendingAdmin.selector;
dcSelectors[3] = adminFacet.acceptAdmin.selector;
dcSelectors[4] = adminFacet.setValidator.selector;
dcSelectors[5] = adminFacet.setPorterAvailability.selector;
dcSelectors[6] = adminFacet.setPriorityTxMaxGasLimit.selector;
dcSelectors[7] = adminFacet.executeUpgrade.selector;
dcSelectors[8] = adminFacet.freezeDiamond.selector;
dcSelectors[9] = adminFacet.unfreezeDiamond.selector;
return dcSelectors;
}

function setUp() public {
owner = makeAddr("owner");
securityCouncil = makeAddr("securityCouncil");
governor = new Governance(owner, securityCouncil, 10_000);
DiamondInit diamondInit = new DiamondInit();

VerifierParams memory dummyVerifierParams = VerifierParams({
recursionNodeLevelVkHash: 0,
recursionLeafLevelVkHash: 0,
recursionCircuitsSetVksHash: 0
});

adminFacet = new AdminFacet();

bytes memory diamondInitCalldata = abi.encodeWithSelector(
diamondInit.initialize.selector,
0x03752D8252d67f99888E741E3fB642803B29B155,
governor,
owner,
0x02c775f0a90abf7a0e8043f2fdc38f0580ca9f9996a895d05a501bfeaa3b2e21,
0,
0x0000000000000000000000000000000000000000000000000000000000000000,
0x70a0F165d6f8054d0d0CF8dFd4DD2005f0AF6B55,
dummyVerifierParams,
false,
0x0100000000000000000000000000000000000000000000000000000000000000,
0x0100000000000000000000000000000000000000000000000000000000000000,
500000 // priority tx max L2 gas limit
);

Diamond.FacetCut[] memory facetCuts = new Diamond.FacetCut[](1);
facetCuts[0] = Diamond.FacetCut({
facet: address(adminFacet),
action: Diamond.Action.Add,
isFreezable: false,
selectors: getAdminSelectors()
});

emit log_uint(facetCuts[0].selectors.length);

Diamond.DiamondCutData memory diamondCutData = Diamond.DiamondCutData({
facetCuts: facetCuts,
initAddress: address(diamondInit),
initCalldata: diamondInitCalldata
});

diamondProxy = new DiamondProxy(block.chainid, diamondCutData);
proxyAsAdmin = AdminFacet(address(diamondProxy));
}
}
Loading