Skip to content

Commit

Permalink
renaming chain governor to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
kelemeno committed Feb 16, 2024
1 parent 46fa6af commit 468ea9c
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 50 deletions.
5 changes: 2 additions & 3 deletions docs/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ even an upgrade system is a separate facet that can be replaced.

One of the differences from the reference implementation is access freezability. Each of the facets has an associated
parameter that indicates if it is possible to freeze access to the facet. Privileged actors can freeze the **diamond**
(not a specific facet!) and all facets with the marker `isFreezable` should be inaccessible until the governor or its
owner unfreezes the diamond. Note that it is a very dangerous thing since the diamond proxy can freeze the upgrade
(not a specific facet!) and all facets with the marker `isFreezable` should be inaccessible until the admin or the state transition manager unfreezes the diamond. Note that it is a very dangerous thing since the diamond proxy can freeze the upgrade
system and then the diamond will be frozen forever.

#### DiamondInit
Expand All @@ -66,7 +65,7 @@ must never be frozen.

#### AdminFacet

Controls changing the privileged addresses such as governor and validators or one of the system parameters (L2
Controls changing the privileged addresses such as admin and validators or one of the system parameters (L2
bootloader bytecode hash, verifier address, verifier parameters, etc), and it also manages the freezing/unfreezing and
execution of upgrades in the diamond proxy.

Expand Down
16 changes: 8 additions & 8 deletions l1-contracts/scripts/display-governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ async function main() {

const zkSync = deployer.stateTransitionContract(deployWallet);

console.log("zkSync governor: ", await zkSync.getGovernor());
console.log("zkSync pendingGovernor: ", await zkSync.getPendingGovernor());
console.log("zkSync admin: ", await zkSync.getAdmin());
console.log("zkSync pendingGovernor: ", await zkSync.getPendingAdmin());

const validatorTimelock = deployer.validatorTimelock(deployWallet);
console.log("validatorTimelock governor: ", await validatorTimelock.owner());
console.log("validatorTimelock pendingGovernor: ", await validatorTimelock.pendingOwner());
console.log("validatorTimelock owner: ", await validatorTimelock.owner());
console.log("validatorTimelock pendingOwner: ", await validatorTimelock.pendingOwner());

const l1Erc20Bridge = deployer.transparentUpgradableProxyContract(
deployer.addresses.Bridges.ERC20BridgeProxy,
deployWallet
);

console.log("l1Erc20Bridge governor: ", await proxyGov(l1Erc20Bridge.address, deployWallet.provider));
console.log("l1Erc20Bridge proxy admin: ", await proxyGov(l1Erc20Bridge.address, deployWallet.provider));

// Now, starting to deploy the info about the L2 contracts

Expand All @@ -80,19 +80,19 @@ async function main() {
process.env.CONTRACTS_L2_ERC20_BRIDGE_ADDR!,
deployWallet2
);
console.log("L2SharedBridge governor: ", await proxyGov(l2SharedBridge.address, deployWallet2.provider));
console.log("L2SharedBridge proxy admin: ", await proxyGov(l2SharedBridge.address, deployWallet2.provider));

const l2wethToken = deployer.transparentUpgradableProxyContract(
process.env.CONTRACTS_L2_WETH_TOKEN_PROXY_ADDR!,
deployWallet2
);
console.log("l2wethToken governor: ", await proxyGov(l2wethToken.address, deployWallet2.provider));
console.log("l2wethToken proxy admin: ", await proxyGov(l2wethToken.address, deployWallet2.provider));

// L2 Tokens are BeaconProxies
const l2Erc20BeaconAddress: string = await getERC20BeaconAddress(l2SharedBridge.address);
const l2Erc20TokenBeacon = UpgradeableBeaconFactory.connect(l2Erc20BeaconAddress, deployWallet2);

console.log("l2Erc20TokenBeacon governor: ", await l2Erc20TokenBeacon.owner());
console.log("l2Erc20TokenBeacon owner: ", await l2Erc20TokenBeacon.owner());
});

await program.parseAsync(process.argv);
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/scripts/upgrades/upgrade-6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function getCalldata(
) {
// Generate wallet with random private key to load main contract governor.
const randomWallet = new Wallet(ethers.utils.randomBytes(32), zksProvider, provider);
let governor = await (await randomWallet.getMainContract()).getGovernor();
let governor = await (await randomWallet.getMainContract()).getAdmin();
// Apply L1 to L2 mask if needed.
if (ethers.utils.hexDataLength(await provider.getCode(governor)) != 0) {
governor = applyL1ToL2Alias(governor);
Expand Down
6 changes: 3 additions & 3 deletions l1-contracts/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class Deployer {
bridgehub: "0x0000000000000000000000000000000000001234",
stateTransitionManager: "0x0000000000000000000000000000000000002234",
protocolVersion: "0x0000000000000000000000000000000000002234",
governor: "0x0000000000000000000000000000000000003234",
admin: "0x0000000000000000000000000000000000003234",
validatorTimelock: "0x0000000000000000000000000000000000004234",
baseToken: "0x0000000000000000000000000000000000004234",
baseTokenBridge: "0x0000000000000000000000000000000000004234",
Expand Down Expand Up @@ -617,7 +617,7 @@ export class Deployer {
const stateTransitionManager = this.stateTransitionManagerContract(this.deployWallet);

const inputChainId = getNumberFromEnv("CHAIN_ETH_ZKSYNC_NETWORK_ID");
const governor = this.ownerAddress;
const admin = this.ownerAddress;
const diamondCutData = await this.initialZkSyncStateTransitionDiamondCut(extraFacets);
const initialDiamondCut = new ethers.utils.AbiCoder().encode(
[
Expand All @@ -631,7 +631,7 @@ export class Deployer {
this.addresses.StateTransition.StateTransitionProxy,
baseTokenAddress,
Date.now(),
governor,
admin,
initialDiamondCut,
{
gasPrice,
Expand Down
3 changes: 1 addition & 2 deletions l1-contracts/src.ts/diamondCut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export interface DiamondCut {
export interface InitializeData {
bridgehub: BigNumberish;
verifier: BigNumberish;
governor: BigNumberish;
admin: BigNumberish;
genesisBatchHash: string;
genesisIndexRepeatedStorageChanges: BigNumberish;
Expand Down Expand Up @@ -75,7 +74,7 @@ export async function getCurrentFacetCutsForAdd(
) {
const facetsCuts = {};
// Some facets should always be available regardless of freezing: upgradability system, getters, etc.
// And for some facets there are should be possibility to freeze them by the governor if we found a bug inside.
// And for some facets there are should be possibility to freeze them by the admin if we found a bug inside.
if (adminAddress) {
// Should be unfreezable. The function to unfreeze contract is located on the admin facet.
// That means if the admin facet will be freezable, the proxy can NEVER be unfrozen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract AuthorizationTest is AdminTest {
priorityTxMaxPubdata: 99,
minimalL2GasPrice: 500_000_000
});
vm.prank(governor);
vm.prank(admin);
proxyAsAdmin.changeFeeParams(newParams);

bytes32 correctNewFeeParamsHash = keccak256(abi.encode(newParams));
Expand All @@ -40,7 +40,7 @@ contract AuthorizationTest is AdminTest {
priorityTxMaxPubdata: 1_001,
minimalL2GasPrice: 500_000_000
});
vm.prank(governor);
vm.prank(admin);
vm.expectRevert(bytes.concat("n6"));
proxyAsAdmin.changeFeeParams(newParams);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract AdminTest is Test {
DiamondProxy internal diamondProxy;
address internal owner;
address internal securityCouncil;
address internal governor;
address internal admin;
AdminFacet internal adminFacet;
AdminFacet internal proxyAsAdmin;
GettersMock internal proxyAsGettersMock;
Expand Down Expand Up @@ -51,7 +51,7 @@ contract AdminTest is Test {
function setUp() public {
owner = makeAddr("owner");
securityCouncil = makeAddr("securityCouncil");
governor = makeAddr("governor");
admin = makeAddr("admin");
DiamondInit diamondInit = new DiamondInit();

VerifierParams memory dummyVerifierParams = VerifierParams({
Expand All @@ -62,7 +62,7 @@ contract AdminTest is Test {

DiamondInit.InitializeData memory params = DiamondInit.InitializeData({
verifier: IVerifier(0x03752D8252d67f99888E741E3fB642803B29B155), // verifier
governor: governor,
admin: admin,
admin: owner,
genesisBatchHash: 0x02c775f0a90abf7a0e8043f2fdc38f0580ca9f9996a895d05a501bfeaa3b2e21,
genesisIndexRepeatedStorageChanges: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ contract ExecutorTest is Test {
function getGettersSelectors() public view returns (bytes4[] memory) {
bytes4[] memory selectors = new bytes4[](28);
selectors[0] = getters.getVerifier.selector;
selectors[1] = getters.getGovernor.selector;
selectors[2] = getters.getPendingGovernor.selector;
selectors[1] = getters.getAdmin.selector;
selectors[2] = getters.getPendingAdmin.selector;
selectors[3] = getters.getTotalBlocksCommitted.selector;
selectors[4] = getters.getTotalBlocksVerified.selector;
selectors[5] = getters.getTotalBlocksExecuted.selector;
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/test/foundry/unit/concrete/Utils/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ library Utils {
function getGettersSelectors() public pure returns (bytes4[] memory) {
bytes4[] memory selectors = new bytes4[](29);
selectors[0] = GettersFacet.getVerifier.selector;
selectors[1] = GettersFacet.getGovernor.selector;
selectors[2] = GettersFacet.getPendingGovernor.selector;
selectors[1] = GettersFacet.getAdmin.selector;
selectors[2] = GettersFacet.getPendingAdmin.selector;
selectors[3] = GettersFacet.getTotalBlocksCommitted.selector;
selectors[4] = GettersFacet.getTotalBlocksVerified.selector;
selectors[5] = GettersFacet.getTotalBlocksExecuted.selector;
Expand Down
34 changes: 17 additions & 17 deletions l1-contracts/test/test_config/constant/hardhat.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,96 +3,96 @@
"name": "DAI",
"symbol": "DAI",
"decimals": 18,
"address": "0x18d8b7878Ee8D1cf3c32b177e0B0EC2379084B11"
"address": "0x9F5d1DA449A6c22CCCCE139acD98adD82797fEec"
},
{
"name": "wBTC",
"symbol": "wBTC",
"decimals": 8,
"address": "0xe4B41b2c8e3831cbEdC8b3D82047fA30B6B22946"
"address": "0x275E5aa56a705c8726eE35B3DC6530DE0a0e5f6c"
},
{
"name": "BAT",
"symbol": "BAT",
"decimals": 18,
"address": "0xe8c976ce9F855825e52015bd1E88Fc84Da1946d2"
"address": "0x18d8b7878Ee8D1cf3c32b177e0B0EC2379084B11"
},
{
"name": "GNT",
"symbol": "GNT",
"decimals": 18,
"address": "0xd012f213dDD34858A1357e30B4c491dbFCba8Ee3"
"address": "0xe4B41b2c8e3831cbEdC8b3D82047fA30B6B22946"
},
{
"name": "MLTT",
"symbol": "MLTT",
"decimals": 18,
"address": "0x8fbdf8cEAf04E3cc9ac53C90b344c0c2489a0645"
"address": "0xe8c976ce9F855825e52015bd1E88Fc84Da1946d2"
},
{
"name": "DAIK",
"symbol": "DAIK",
"decimals": 18,
"address": "0x91D6cBBb7006A3fC6686d65375A067624b8D405A"
"address": "0xd012f213dDD34858A1357e30B4c491dbFCba8Ee3"
},
{
"name": "wBTCK",
"symbol": "wBTCK",
"decimals": 8,
"address": "0xEbD3994f1a9d85458bD2a40Fc6927C4048291067"
"address": "0x8fbdf8cEAf04E3cc9ac53C90b344c0c2489a0645"
},
{
"name": "BATK",
"symbol": "BATS",
"decimals": 18,
"address": "0x194475D0de71858B134e2084fa627B5A7d04334c"
"address": "0x91D6cBBb7006A3fC6686d65375A067624b8D405A"
},
{
"name": "GNTK",
"symbol": "GNTS",
"decimals": 18,
"address": "0xfB6306147E50e7042E74eA6Cc3db38a8489F8D78"
"address": "0xEbD3994f1a9d85458bD2a40Fc6927C4048291067"
},
{
"name": "MLTTK",
"symbol": "MLTTS",
"decimals": 18,
"address": "0xA50C21DE8a2d575F915E5f8D6D5ec8eF2935D58e"
"address": "0x194475D0de71858B134e2084fa627B5A7d04334c"
},
{
"name": "DAIL",
"symbol": "DAIL",
"decimals": 18,
"address": "0xCBaDEF24FA67dB5a56fD84c72b22797A125C3132"
"address": "0xfB6306147E50e7042E74eA6Cc3db38a8489F8D78"
},
{
"name": "wBTCL",
"symbol": "wBTCP",
"decimals": 8,
"address": "0x80C92D6E8d4015660506Cf4F4503eBF3bc073190"
"address": "0xA50C21DE8a2d575F915E5f8D6D5ec8eF2935D58e"
},
{
"name": "BATL",
"symbol": "BATW",
"decimals": 18,
"address": "0x44bD975d5735ab2E1b61787228f538e13bF263DC"
"address": "0xCBaDEF24FA67dB5a56fD84c72b22797A125C3132"
},
{
"name": "GNTL",
"symbol": "GNTW",
"decimals": 18,
"address": "0xDbEBD56A3068c71f6F71973171c6880a238Ff742"
"address": "0x80C92D6E8d4015660506Cf4F4503eBF3bc073190"
},
{
"name": "MLTTL",
"symbol": "MLTTW",
"decimals": 18,
"address": "0x3Ca0576c73B1A6e1788eD9De747eD63ecEce5eB0"
"address": "0x44bD975d5735ab2E1b61787228f538e13bF263DC"
},
{
"name": "Wrapped Ether",
"symbol": "WETH",
"decimals": 18,
"address": "0x16d1b025Ab084f9fA9ba6569f6EB98329dc10dc4"
"address": "0xDbEBD56A3068c71f6F71973171c6880a238Ff742"
}
]
]
6 changes: 3 additions & 3 deletions l1-contracts/test/unit_tests/governance_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ describe("Admin facet tests", function () {
const proposedGovernor = await randomSigner.getAddress();
await adminFacetTest.setPendingGovernor(proposedGovernor);

const pendingGovernor = await adminFacetTest.getPendingGovernor();
const pendingGovernor = await adminFacetTest.getPendingAdmin();
expect(pendingGovernor).equal(proposedGovernor);
});

it("reset pending governor", async () => {
const proposedGovernor = await newGovernor.getAddress();
await adminFacetTest.setPendingGovernor(proposedGovernor);

const pendingGovernor = await adminFacetTest.getPendingGovernor();
const pendingGovernor = await adminFacetTest.getPendingAdmin();
expect(pendingGovernor).equal(proposedGovernor);
});

Expand All @@ -98,7 +98,7 @@ describe("Admin facet tests", function () {
it("accept governor from proposed account", async () => {
await adminFacetTest.connect(newGovernor).acceptGovernor();

const governor = await adminFacetTest.getGovernor();
const governor = await adminFacetTest.getAdmin();
expect(governor).equal(await newGovernor.getAddress());
});
});
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/test/unit_tests/validator_timelock_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ describe("ValidatorTimelock tests", function () {
expect(await validatorTimelock.validator(chainId)).equal(ethers.constants.AddressZero);
expect(await validatorTimelock.stateTransitionManager()).equal(dummyStateTransitionManager.address);
expect(await dummyStateTransitionManager.stateTransition(chainId)).equal(dummyExecutor.address);
expect(await dummyStateTransitionManager.getChainGovernor(chainId)).equal(await owner.getAddress());
expect(await dummyExecutor.getGovernor()).equal(await owner.getAddress());
expect(await dummyStateTransitionManager.getChainAdmin(chainId)).equal(await owner.getAddress());
expect(await dummyExecutor.getAdmin()).equal(await owner.getAddress());
});

it("Should revert if non-validator commits batches", async () => {
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/test/unit_tests/zksync-upgrade.fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("Diamond proxy upgrade fork test", function () {
before(async () => {
const signers = await hardhat.ethers.getSigners();
diamondProxy = IBridgehubFactory.connect(DIAMOND_PROXY_ADDRESS, signers[0]);
const governorAddress = await diamondProxy.getGovernor();
const governorAddress = await diamondProxy.getAdmin();

await hardhat.network.provider.request({ method: "hardhat_impersonateAccount", params: [governorAddress] });
governor = await hardhat.ethers.provider.getSigner(governorAddress);
Expand Down Expand Up @@ -149,7 +149,7 @@ describe("Diamond proxy upgrade fork test", function () {
});

it("check getters functions", async () => {
const governorAddr = await diamondProxy.getGovernor();
const governorAddr = await diamondProxy.getAdmin();
expect(governorAddr).to.be.eq(await governor.getAddress());

const isFrozen = await diamondProxy.isDiamondStorageFrozen();
Expand Down

0 comments on commit 468ea9c

Please sign in to comment.