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

feat(zksync acceptance test): extend test, add example .env for mainnet #18

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
55 changes: 55 additions & 0 deletions zksync/.env.mainnet.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
CHAIN_ETH_NETWORK=mainnet
ZKSYNC_PROVIDER_URL=https://mainnet.era.zksync.io

# default test account, don't warry
# Replace with your secret if needed (not required for for deployment.acceptance.test.ts)
PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

ETH_CLIENT_WEB3_URL="PUT YOUR SECRET"
ETHER_SCAN_API_KEY="PUT YOUR SECRET"

ZKSYNC_VERIFY_URL=

CONTRACTS_PRIORITY_TX_MAX_GAS_LIMIT=72000000
CONTRACTS_DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT=10000000

CONTRACTS_CREATE2_FACTORY_ADDR=

# === L1 ===

L1_EMERGENCY_BRAKE_MULTISIG=0x73b047fe6337183A454c5217241D780a932777bD
CONTRACTS_L1_LIDO_TOKEN_ADDR=0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0
CONTRACTS_L1_GOVERNANCE_AGENT_ADDR=0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c
CONTRACTS_DIAMOND_PROXY_ADDR=0x32400084C286CF3E17e7B677ea9583e60a000324

L1_EXECUTOR_ADDR=0xFf7F4d05e3247374e86A3f7231A2Ed1CA63647F2
L1_EXECUTOR_IMPL_ADDR=0x06185d60eD72a91D1367Eb0733B9d20AE7336D3B

CONTRACTS_L1_LIDO_BRIDGE_PROXY_ADDR=0x41527B2d03844dB6b0945f25702cB958b6d55989
CONTRACTS_L1_LIDO_BRIDGE_IMPL_ADDR=0x9a810469F4a451Ebb7ef53672142053b4971587c

# === L2 ===

L2_EMERGENCY_BRAKE_MULTISIG=0x0D7F0A811978B3B62CbfF4EF6149B5909EAcfE94

# ProxyAdmin
TRANSPARENT_PROXY_ADMIN=0xBD80E505ECC49BAE2cc86094a78fA0e2dB28b52A

# TransparentUpgradeableProxy
L2_BRIDGE_EXECUTOR_ADDR=0x139EE25DCad405d2a038E7A67f9ffdbf0f573f3c
L2_BRIDGE_EXECUTOR_IMPL_ADDR=0x13f46B59067f064C634Fb17e207ed203916dcCC8

# TransparentUpgradeableProxy
CONTRACTS_L2_LIDO_TOKEN_ADDR=0x703b52F2b28fEbcB60E1372858AF5b18849FE867
CONTRACTS_L2_LIDO_TOKEN_IMPL_ADDR=0xC7A0DAA1B8FeA68532B6425D0e156088B0D2ab2c

# OssifiableProxy
CONTRACTS_L2_LIDO_BRIDGE_PROXY_ADDR=0xE1D6A50E7101c8f8db77352897Ee3f1AC53f782B
CONTRACTS_L2_LIDO_BRIDGE_IMPL_ADDR=0x64Ee90B086c99fD3439354f382Fef25229A01F02

GUARDIAN_ADDRESS=0x0000000000000000000000000000000000000000

EXECUTION_DELAY=0
EXECUTION_GRACE_PERIOD=86400
EXECUTION_MIN_DELAY=0
EXECUTION_MAX_DELAY=1
105 changes: 92 additions & 13 deletions zksync/l1/test/deployment.acceptance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import { defaultAbiCoder } from "ethers/lib/utils";

const ETH_CLIENT_WEB3_URL = process.env.ETH_CLIENT_WEB3_URL as string;
const ZKSYNC_PROVIDER_URL = process.env.ZKSYNC_PROVIDER_URL as string;
const CONTRACTS_DIAMOND_PROXY_ADDR = process.env
.CONTRACTS_DIAMOND_PROXY_ADDR as string;

const TRANSPARENT_PROXY_ADMIN_STORAGE_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103"

scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)
.step("L1 Bridge :: proxy admin", async (ctx) => {
Expand All @@ -40,6 +40,16 @@ scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)
);
})

.step("L1 Bridge :: proxy implementation", async (ctx) => {
const {
l1: { proxy },
} = ctx;
assert.equal(
await proxy.l1Bridge.proxy__getImplementation(),
ZKSYNC_ADDRESSES.l1.l1BridgeImpl
);
})

.step("L1 Bridge :: bridge admin", async (ctx) => {
const {
l1: { l1Bridge },
Expand Down Expand Up @@ -68,6 +78,15 @@ scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)
assert.equal(await l1Bridge.l2Token(), ZKSYNC_ADDRESSES.l2.l2Token);
})


.step("L1 Bridge :: L2 Token address", async (ctx) => {
const {
l1: { l1Bridge },
} = ctx;

assert.equal(await l1Bridge.l2TokenAddress(ZKSYNC_ADDRESSES.l1.l1Token), ZKSYNC_ADDRESSES.l2.l2Token);
})

.step("L1 Bridge :: L2 Bridge", async (ctx) => {
const {
l1: { l1Bridge },
Expand All @@ -76,6 +95,14 @@ scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)
assert.equal(await l1Bridge.l2Bridge(), ZKSYNC_ADDRESSES.l2.l2Bridge);
})

.step("L1 Bridge :: zkSync", async (ctx) => {
const {
l1: { l1Bridge },
} = ctx;

assert.equal(await l1Bridge.zkSync(), ZKSYNC_ADDRESSES.l2.diamondProxy);
})

.step("L1 Bridge :: is deposits disabled", async (ctx) => {
const {
l1: { l1Bridge },
Expand Down Expand Up @@ -158,6 +185,16 @@ scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)
}
})

.step("L1 Executor :: proxy implementation", async (ctx) => {
const {
l1: {
proxy: { l1Executor },
},
} = ctx;

assert.equal(await l1Executor.proxy__getImplementation(), ZKSYNC_ADDRESSES.l1.l1ExecutorImpl);
})

.step("L1 Executor :: proxy admin", async (ctx) => {
const {
l1: {
Expand All @@ -176,6 +213,14 @@ scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)
assert.equal(await l1Executor.owner(), ZKSYNC_ADDRESSES.l1.agent);
})

.step("L1 Executor :: zksync", async (ctx) => {
const {
l1: { l1Executor },
} = ctx;

assert.equal(await l1Executor.zksync(), ZKSYNC_ADDRESSES.l2.diamondProxy);
})

/**
*
* L2
Expand All @@ -192,6 +237,16 @@ scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)
);
})

.step("L2 Bridge :: proxy implementation", async (ctx) => {
const {
l2: { proxy },
} = ctx;
assert.equal(
await proxy.l2Bridge.proxy__getImplementation(),
ZKSYNC_ADDRESSES.l2.l2BridgeImpl
);
})

.step("L2 Bridge :: bridge admin", async (ctx) => {
const {
l2: { l2Bridge },
Expand Down Expand Up @@ -307,7 +362,7 @@ scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)
}
})

.step("L2 Token :: proxy admin", async (ctx) => {
.step("L2 Token :: proxy admin checks", async (ctx) => {
const {
l2: {
accounts: { deployer },
Expand All @@ -317,19 +372,31 @@ scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)

const proxyAdminAddressBytes32 = await zkProvider.getStorageAt(
ZKSYNC_ADDRESSES.l2.l2Token,
"0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103" // storage where admin address is stored
TRANSPARENT_PROXY_ADMIN_STORAGE_SLOT
); // returns bytes32

const proxyAdminAddress = defaultAbiCoder.decode(
const proxyAdminAddress = String(defaultAbiCoder.decode(
["address"],
proxyAdminAddressBytes32
); // returns Result => []
)[0]); // returns Result => [], 0 index is the location of address

assert.equal(proxyAdminAddress, ZKSYNC_ADDRESSES.l2.proxyAdmin);

const proxyAdminContract = ProxyAdmin__factory.connect(
proxyAdminAddress[0], // proxyAdminAddress 0 index is the location of address
proxyAdminAddress,
deployer
);

assert.equal(
await proxyAdminContract.getProxyAdmin(ZKSYNC_ADDRESSES.l2.l2Token),
ZKSYNC_ADDRESSES.l2.proxyAdmin
);

assert.equal(
await proxyAdminContract.getProxyImplementation(ZKSYNC_ADDRESSES.l2.l2Token),
ZKSYNC_ADDRESSES.l2.l2TokenImpl
);

const L2TokenProxyAdminOwner = await proxyAdminContract.owner();

assert.equal(
Expand Down Expand Up @@ -363,7 +430,7 @@ scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)
assert.equal(await ctx.l2.l2Token.bridge(), ZKSYNC_ADDRESSES.l2.l2Bridge);
})

.step("L2 Governance Executor :: proxy admin", async (ctx) => {
.step("L2 Governance Executor :: proxy admin checks", async (ctx) => {
const {
l2: {
accounts: { deployer },
Expand All @@ -373,19 +440,31 @@ scenario("Lido on zkSync Era :: deployment acceptance test", ctxFactory)

const proxyAdminAddressBytes32 = await zkProvider.getStorageAt(
ZKSYNC_ADDRESSES.l2.govExecutor,
"0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103"
TRANSPARENT_PROXY_ADMIN_STORAGE_SLOT
); // returns bytes32

const proxyAdminAddress = defaultAbiCoder.decode(
const proxyAdminAddress = String(defaultAbiCoder.decode(
["address"],
proxyAdminAddressBytes32
); // returns Result => []
)[0]); // returns Result => [], 0 index is the location of address

assert.equal(proxyAdminAddress, ZKSYNC_ADDRESSES.l2.proxyAdmin);

const proxyAdminContract = ProxyAdmin__factory.connect(
proxyAdminAddress[0], // proxyAdminAddress 0 index is the location of address
proxyAdminAddress,
deployer
);

assert.equal(
await proxyAdminContract.getProxyAdmin(ZKSYNC_ADDRESSES.l2.govExecutor),
ZKSYNC_ADDRESSES.l2.proxyAdmin
);

assert.equal(
await proxyAdminContract.getProxyImplementation(ZKSYNC_ADDRESSES.l2.govExecutor),
ZKSYNC_ADDRESSES.l2.govExecutorImpl
);

const L2TokenProxyAdminOwner = await proxyAdminContract.owner();

assert.equal(
Expand Down Expand Up @@ -482,7 +561,7 @@ async function ctxFactory() {
},
l1Bridge: new L1ERC20Bridge__factory(ethDeployer).attach(l1.l1Bridge),
l1Executor: new L1Executor__factory(ethDeployer).attach(l1.l1Executor),
zkSync: IZkSyncFactory.connect(CONTRACTS_DIAMOND_PROXY_ADDR, ethDeployer),
zkSync: IZkSyncFactory.connect(ZKSYNC_ADDRESSES.l2.diamondProxy, ethDeployer),
accounts: {
deployer: ethDeployer,
},
Expand Down
7 changes: 7 additions & 0 deletions zksync/l1/test/e2e/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ export const ZKSYNC_ADDRESSES = {
l1: {
l1Token: process.env.CONTRACTS_L1_LIDO_TOKEN_ADDR as string,
l1Bridge: process.env.CONTRACTS_L1_LIDO_BRIDGE_PROXY_ADDR as string,
l1BridgeImpl: process.env.CONTRACTS_L1_LIDO_BRIDGE_IMPL_ADDR as string,
l1Executor: process.env.L1_EXECUTOR_ADDR as string,
l1ExecutorImpl: process.env.L1_EXECUTOR_IMPL_ADDR as string,
agent: process.env.CONTRACTS_L1_GOVERNANCE_AGENT_ADDR as string,
emergencyBrakeMultisig: process.env.L1_EMERGENCY_BRAKE_MULTISIG as string,
},
l2: {
l2Token: process.env.CONTRACTS_L2_LIDO_TOKEN_ADDR as string,
l2TokenImpl: process.env.CONTRACTS_L2_LIDO_TOKEN_IMPL_ADDR as string,
l2Bridge: process.env.CONTRACTS_L2_LIDO_BRIDGE_PROXY_ADDR as string,
l2BridgeImpl: process.env.CONTRACTS_L2_LIDO_BRIDGE_IMPL_ADDR as string,
govExecutor: process.env.L2_BRIDGE_EXECUTOR_ADDR as string,
govExecutorImpl: process.env.L2_BRIDGE_EXECUTOR_IMPL_ADDR as string,
emergencyBrakeMultisig: process.env.L2_EMERGENCY_BRAKE_MULTISIG as string,
guardian: process.env.GUARDIAN_ADDRESS as string,
proxyAdmin: process.env.TRANSPARENT_PROXY_ADMIN as string,
diamondProxy: process.env.CONTRACTS_DIAMOND_PROXY_ADDR as string,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, Diamond Proxy contract is the zkSync contract that is deployed to L1, so better to move this constant under l1 contants.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you moved it in the env file, but I was referring to this e2e.ts

},
};