From e3c26c64e5f9053258397c01c5a49d9bcee438c0 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Wed, 3 Jul 2024 18:09:09 +0100 Subject: [PATCH 01/24] CI test --- core/tests/ts-integration/tests/erc20.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index 3b1d107e560..a1b9b6b44bb 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -209,6 +209,7 @@ describe('ERC20 contract checks', () => { }); test('Can perform a deposit with precalculated max value', async () => { + console.log('test'); const maxAmountBase = await alice.getBalanceL1(baseTokenDetails.l1Address); const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); // Approving the needed allowance to ensure that the user has enough funds. From b015bd7bce1de590423d21984ca574b70ddba490 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Fri, 5 Jul 2024 11:17:07 +0100 Subject: [PATCH 02/24] nonce logs --- core/tests/ts-integration/tests/erc20.test.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index a1b9b6b44bb..a11b1f823ec 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -209,24 +209,39 @@ describe('ERC20 contract checks', () => { }); test('Can perform a deposit with precalculated max value', async () => { - console.log('test'); + console.log('nonce0', await alice.getNonce()); + const maxAmountBase = await alice.getBalanceL1(baseTokenDetails.l1Address); + console.log('nonce1', await alice.getNonce()); + const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); + console.log('nonce2', await alice.getNonce()); + // Approving the needed allowance to ensure that the user has enough funds. await (await alice.approveERC20(baseTokenDetails.l1Address, maxAmountBase)).wait(); + console.log('nonce3', await alice.getNonce()); + await (await alice.approveERC20(tokenDetails.l1Address, maxAmount)).wait(); + console.log('nonce4', await alice.getNonce()); + const depositFee = await alice.getFullRequiredDepositFee({ token: tokenDetails.l1Address }); + console.log('nonce5', await alice.getNonce()); + const l1Fee = depositFee.l1GasLimit * (depositFee.maxFeePerGas! || depositFee.gasPrice!); const l2Fee = depositFee.baseCost; const aliceETHBalance = await alice.getBalanceL1(); + console.log('nonce6', await alice.getNonce()); + if (aliceETHBalance < l1Fee + l2Fee) { throw new Error('Not enough ETH to perform a deposit'); } const l2ERC20BalanceChange = await shouldChangeTokenBalances(tokenDetails.l2Address, [ { wallet: alice, change: maxAmount } ]); + console.log('nonce7', await alice.getNonce()); + const overrides: ethers.Overrides = depositFee.gasPrice ? { gasPrice: depositFee.gasPrice } : { @@ -240,6 +255,8 @@ describe('ERC20 contract checks', () => { l2GasLimit: depositFee.l2GasLimit, overrides }); + console.log('nonce8', await alice.getNonce()); + await expect(depositOp).toBeAccepted([l2ERC20BalanceChange]); }); From ac40e252df3dcca73fe53a597e75e166302fcc51 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Fri, 5 Jul 2024 12:14:47 +0100 Subject: [PATCH 03/24] unneeded allowance approval --- core/tests/ts-integration/tests/erc20.test.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index a11b1f823ec..b73582db423 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -16,7 +16,6 @@ describe('ERC20 contract checks', () => { let alice: zksync.Wallet; let bob: zksync.Wallet; let tokenDetails: Token; - let baseTokenDetails: Token; let aliceErc20: zksync.Contract; beforeAll(async () => { @@ -25,7 +24,6 @@ describe('ERC20 contract checks', () => { bob = testMaster.newEmptyAccount(); tokenDetails = testMaster.environment().erc20Token; - baseTokenDetails = testMaster.environment().baseToken; aliceErc20 = new zksync.Contract(tokenDetails.l2Address, zksync.utils.IERC20, alice); }); @@ -210,17 +208,10 @@ describe('ERC20 contract checks', () => { test('Can perform a deposit with precalculated max value', async () => { console.log('nonce0', await alice.getNonce()); - - const maxAmountBase = await alice.getBalanceL1(baseTokenDetails.l1Address); - console.log('nonce1', await alice.getNonce()); - const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); console.log('nonce2', await alice.getNonce()); // Approving the needed allowance to ensure that the user has enough funds. - await (await alice.approveERC20(baseTokenDetails.l1Address, maxAmountBase)).wait(); - console.log('nonce3', await alice.getNonce()); - await (await alice.approveERC20(tokenDetails.l1Address, maxAmount)).wait(); console.log('nonce4', await alice.getNonce()); From 12b62b4996ce056896ef5fedf2f579fe8e483383 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Fri, 5 Jul 2024 12:31:29 +0100 Subject: [PATCH 04/24] Revert "unneeded allowance approval" This reverts commit ac40e252df3dcca73fe53a597e75e166302fcc51. --- core/tests/ts-integration/tests/erc20.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index b73582db423..a11b1f823ec 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -16,6 +16,7 @@ describe('ERC20 contract checks', () => { let alice: zksync.Wallet; let bob: zksync.Wallet; let tokenDetails: Token; + let baseTokenDetails: Token; let aliceErc20: zksync.Contract; beforeAll(async () => { @@ -24,6 +25,7 @@ describe('ERC20 contract checks', () => { bob = testMaster.newEmptyAccount(); tokenDetails = testMaster.environment().erc20Token; + baseTokenDetails = testMaster.environment().baseToken; aliceErc20 = new zksync.Contract(tokenDetails.l2Address, zksync.utils.IERC20, alice); }); @@ -208,10 +210,17 @@ describe('ERC20 contract checks', () => { test('Can perform a deposit with precalculated max value', async () => { console.log('nonce0', await alice.getNonce()); + + const maxAmountBase = await alice.getBalanceL1(baseTokenDetails.l1Address); + console.log('nonce1', await alice.getNonce()); + const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); console.log('nonce2', await alice.getNonce()); // Approving the needed allowance to ensure that the user has enough funds. + await (await alice.approveERC20(baseTokenDetails.l1Address, maxAmountBase)).wait(); + console.log('nonce3', await alice.getNonce()); + await (await alice.approveERC20(tokenDetails.l1Address, maxAmount)).wait(); console.log('nonce4', await alice.getNonce()); From f8ae7f3553c5e726d4c540d91a07b5af75906bf7 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Fri, 5 Jul 2024 12:43:42 +0100 Subject: [PATCH 05/24] approval change --- core/tests/ts-integration/tests/erc20.test.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index a11b1f823ec..63d5f4e0639 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -16,7 +16,6 @@ describe('ERC20 contract checks', () => { let alice: zksync.Wallet; let bob: zksync.Wallet; let tokenDetails: Token; - let baseTokenDetails: Token; let aliceErc20: zksync.Contract; beforeAll(async () => { @@ -25,7 +24,6 @@ describe('ERC20 contract checks', () => { bob = testMaster.newEmptyAccount(); tokenDetails = testMaster.environment().erc20Token; - baseTokenDetails = testMaster.environment().baseToken; aliceErc20 = new zksync.Contract(tokenDetails.l2Address, zksync.utils.IERC20, alice); }); @@ -211,18 +209,8 @@ describe('ERC20 contract checks', () => { test('Can perform a deposit with precalculated max value', async () => { console.log('nonce0', await alice.getNonce()); - const maxAmountBase = await alice.getBalanceL1(baseTokenDetails.l1Address); - console.log('nonce1', await alice.getNonce()); - const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); - console.log('nonce2', await alice.getNonce()); - - // Approving the needed allowance to ensure that the user has enough funds. - await (await alice.approveERC20(baseTokenDetails.l1Address, maxAmountBase)).wait(); - console.log('nonce3', await alice.getNonce()); - - await (await alice.approveERC20(tokenDetails.l1Address, maxAmount)).wait(); - console.log('nonce4', await alice.getNonce()); + console.log('nonce1', await alice.getNonce()); const depositFee = await alice.getFullRequiredDepositFee({ token: tokenDetails.l1Address @@ -253,7 +241,9 @@ describe('ERC20 contract checks', () => { token: tokenDetails.l1Address, amount: maxAmount, l2GasLimit: depositFee.l2GasLimit, - overrides + overrides, + approveERC20: true, + approveBaseERC20: true }); console.log('nonce8', await alice.getNonce()); From 7c32b6e6dd3244e493e074ab5f5b1f52880ddf8c Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Fri, 5 Jul 2024 13:15:33 +0100 Subject: [PATCH 06/24] nonce override for approve --- core/tests/ts-integration/tests/erc20.test.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index 63d5f4e0639..bd5cea9edf9 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -16,6 +16,7 @@ describe('ERC20 contract checks', () => { let alice: zksync.Wallet; let bob: zksync.Wallet; let tokenDetails: Token; + let baseTokenDetails: Token; let aliceErc20: zksync.Contract; beforeAll(async () => { @@ -24,6 +25,7 @@ describe('ERC20 contract checks', () => { bob = testMaster.newEmptyAccount(); tokenDetails = testMaster.environment().erc20Token; + baseTokenDetails = testMaster.environment().baseToken; aliceErc20 = new zksync.Contract(tokenDetails.l2Address, zksync.utils.IERC20, alice); }); @@ -207,10 +209,18 @@ describe('ERC20 contract checks', () => { }); test('Can perform a deposit with precalculated max value', async () => { - console.log('nonce0', await alice.getNonce()); - + const maxAmountBase = await alice.getBalanceL1(baseTokenDetails.l1Address); const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); - console.log('nonce1', await alice.getNonce()); + const nonce = await alice.getNonce(); + + console.log('nonce1', nonce); + + // Approving the needed allowance to ensure that the user has enough funds. + await (await alice.approveERC20(baseTokenDetails.l1Address, maxAmountBase, { nonce })).wait(); + console.log('nonce2', await alice.getNonce()); + + await (await alice.approveERC20(tokenDetails.l1Address, maxAmount, { nonce: nonce + 1 })).wait(); + console.log('nonce3', await alice.getNonce()); const depositFee = await alice.getFullRequiredDepositFee({ token: tokenDetails.l1Address @@ -241,9 +251,7 @@ describe('ERC20 contract checks', () => { token: tokenDetails.l1Address, amount: maxAmount, l2GasLimit: depositFee.l2GasLimit, - overrides, - approveERC20: true, - approveBaseERC20: true + overrides }); console.log('nonce8', await alice.getNonce()); From ab387b74cd43739f1f9f349b3070e78067b959ac Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Fri, 5 Jul 2024 14:05:25 +0100 Subject: [PATCH 07/24] approval process change --- core/tests/ts-integration/tests/erc20.test.ts | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index bd5cea9edf9..8198cf493d3 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -209,36 +209,40 @@ describe('ERC20 contract checks', () => { }); test('Can perform a deposit with precalculated max value', async () => { - const maxAmountBase = await alice.getBalanceL1(baseTokenDetails.l1Address); - const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); - const nonce = await alice.getNonce(); - - console.log('nonce1', nonce); - - // Approving the needed allowance to ensure that the user has enough funds. - await (await alice.approveERC20(baseTokenDetails.l1Address, maxAmountBase, { nonce })).wait(); - console.log('nonce2', await alice.getNonce()); + const baseTokenAddress = await alice._providerL2().getBaseTokenContractAddress(); + const isETHBasedChain = baseTokenAddress == zksync.utils.ETH_ADDRESS_IN_CONTRACTS; + if (!isETHBasedChain) { + const baseTokenDetails = testMaster.environment().baseToken; + const baseTokenMaxAmount = await alice.getBalanceL1(baseTokenDetails.l1Address); + await (await alice.approveERC20(baseTokenDetails.l1Address, baseTokenMaxAmount)).wait(); + } - await (await alice.approveERC20(tokenDetails.l1Address, maxAmount, { nonce: nonce + 1 })).wait(); - console.log('nonce3', await alice.getNonce()); + console.log('LOG1'); const depositFee = await alice.getFullRequiredDepositFee({ token: tokenDetails.l1Address }); - console.log('nonce5', await alice.getNonce()); + console.log('LOG2'); const l1Fee = depositFee.l1GasLimit * (depositFee.maxFeePerGas! || depositFee.gasPrice!); const l2Fee = depositFee.baseCost; const aliceETHBalance = await alice.getBalanceL1(); - console.log('nonce6', await alice.getNonce()); + console.log('LOG3'); if (aliceETHBalance < l1Fee + l2Fee) { throw new Error('Not enough ETH to perform a deposit'); } + + // Approving the needed allowance to ensure that the user has enough funds. + const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); + await (await alice.approveERC20(tokenDetails.l1Address, maxAmount)).wait(); + + console.log('LOG4'); + const l2ERC20BalanceChange = await shouldChangeTokenBalances(tokenDetails.l2Address, [ { wallet: alice, change: maxAmount } ]); - console.log('nonce7', await alice.getNonce()); + console.log('LOG5'); const overrides: ethers.Overrides = depositFee.gasPrice ? { gasPrice: depositFee.gasPrice } @@ -253,8 +257,7 @@ describe('ERC20 contract checks', () => { l2GasLimit: depositFee.l2GasLimit, overrides }); - console.log('nonce8', await alice.getNonce()); - + console.log('LOG6'); await expect(depositOp).toBeAccepted([l2ERC20BalanceChange]); }); From 20648d8847974ad27bd01a9060ce5e28c0958986 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Fri, 5 Jul 2024 14:08:42 +0100 Subject: [PATCH 08/24] fix --- core/tests/ts-integration/tests/erc20.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index 8198cf493d3..719d33aef0d 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -219,6 +219,12 @@ describe('ERC20 contract checks', () => { console.log('LOG1'); + // Approving the needed allowance to ensure that the user has enough funds. + const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); + await (await alice.approveERC20(tokenDetails.l1Address, maxAmount)).wait(); + + console.log('LOG4'); + const depositFee = await alice.getFullRequiredDepositFee({ token: tokenDetails.l1Address }); @@ -233,12 +239,6 @@ describe('ERC20 contract checks', () => { throw new Error('Not enough ETH to perform a deposit'); } - // Approving the needed allowance to ensure that the user has enough funds. - const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); - await (await alice.approveERC20(tokenDetails.l1Address, maxAmount)).wait(); - - console.log('LOG4'); - const l2ERC20BalanceChange = await shouldChangeTokenBalances(tokenDetails.l2Address, [ { wallet: alice, change: maxAmount } ]); From df2c6c8f6ab57a8faa2ef9dfc7983922b5cd85cc Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Fri, 5 Jul 2024 14:21:40 +0100 Subject: [PATCH 09/24] lint: unused var --- core/tests/ts-integration/tests/erc20.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index 719d33aef0d..7f418e5b0cb 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -16,7 +16,6 @@ describe('ERC20 contract checks', () => { let alice: zksync.Wallet; let bob: zksync.Wallet; let tokenDetails: Token; - let baseTokenDetails: Token; let aliceErc20: zksync.Contract; beforeAll(async () => { @@ -25,7 +24,6 @@ describe('ERC20 contract checks', () => { bob = testMaster.newEmptyAccount(); tokenDetails = testMaster.environment().erc20Token; - baseTokenDetails = testMaster.environment().baseToken; aliceErc20 = new zksync.Contract(tokenDetails.l2Address, zksync.utils.IERC20, alice); }); From f2c31c4368d606abcdeaeefea4099114833614a2 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Fri, 5 Jul 2024 15:56:01 +0100 Subject: [PATCH 10/24] removing debug logs --- core/tests/ts-integration/tests/erc20.test.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index 7f418e5b0cb..0a73411b4d1 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -215,23 +215,17 @@ describe('ERC20 contract checks', () => { await (await alice.approveERC20(baseTokenDetails.l1Address, baseTokenMaxAmount)).wait(); } - console.log('LOG1'); - // Approving the needed allowance to ensure that the user has enough funds. const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); await (await alice.approveERC20(tokenDetails.l1Address, maxAmount)).wait(); - console.log('LOG4'); - const depositFee = await alice.getFullRequiredDepositFee({ token: tokenDetails.l1Address }); - console.log('LOG2'); const l1Fee = depositFee.l1GasLimit * (depositFee.maxFeePerGas! || depositFee.gasPrice!); const l2Fee = depositFee.baseCost; const aliceETHBalance = await alice.getBalanceL1(); - console.log('LOG3'); if (aliceETHBalance < l1Fee + l2Fee) { throw new Error('Not enough ETH to perform a deposit'); @@ -240,7 +234,6 @@ describe('ERC20 contract checks', () => { const l2ERC20BalanceChange = await shouldChangeTokenBalances(tokenDetails.l2Address, [ { wallet: alice, change: maxAmount } ]); - console.log('LOG5'); const overrides: ethers.Overrides = depositFee.gasPrice ? { gasPrice: depositFee.gasPrice } @@ -255,7 +248,6 @@ describe('ERC20 contract checks', () => { l2GasLimit: depositFee.l2GasLimit, overrides }); - console.log('LOG6'); await expect(depositOp).toBeAccepted([l2ERC20BalanceChange]); }); From 7691382bba274dee0a6d46587249e51b6d789059 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Mon, 8 Jul 2024 14:48:43 +0100 Subject: [PATCH 11/24] running only upgrade tests --- .github/workflows/ci-core-reusable.yml | 108 ++++++++++++------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci-core-reusable.yml b/.github/workflows/ci-core-reusable.yml index 504f7761bb8..3817b325e8a 100644 --- a/.github/workflows/ci-core-reusable.yml +++ b/.github/workflows/ci-core-reusable.yml @@ -213,45 +213,45 @@ jobs: ci_run zk contract_verifier &>contract_verifier.log & ci_run sleep 2 - - name: Server integration tests - run: ci_run zk test i server - - - name: Snapshot recovery test - # We use `yarn` directly because the test launches `zk` commands in both server and EN envs. - # An empty topmost environment helps avoid a mess when redefining env vars shared between both envs - # (e.g., DATABASE_URL). - # - # Since `base_token` doesn't meaningfully influence the test, we use it as a flag for - # enabling / disabling tree during pruning. - run: | - if [[ "${{ matrix.deployment_mode }}" == "Validium" ]]; then - ci_run zk config compile ext-node-validium - ci_run zk config compile ext-node-validium-docker - fi - ENABLE_CONSENSUS=${{ matrix.consensus }} \ - DEPLOYMENT_MODE=${{ matrix.deployment_mode }} \ - SNAPSHOTS_CREATOR_VERSION=${{ matrix.deployment_mode == 'Validium' && '0' || '1' }} \ - DISABLE_TREE_DURING_PRUNING=${{ matrix.base_token == 'Eth' }} \ - ETH_CLIENT_WEB3_URL="http://reth:8545" \ - PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE,DISABLE_TREE_DURING_PRUNING,SNAPSHOTS_CREATOR_VERSION,ETH_CLIENT_WEB3_URL" \ - ci_run yarn recovery-test snapshot-recovery-test - - - name: Genesis recovery test - run: | - ENABLE_CONSENSUS=${{ matrix.consensus }} \ - DEPLOYMENT_MODE=${{ matrix.deployment_mode }} \ - ETH_CLIENT_WEB3_URL="http://reth:8545" \ - PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE,ETH_CLIENT_WEB3_URL" \ - ci_run yarn recovery-test genesis-recovery-test - - - name: Fee projection tests - run: ci_run zk test i fees - - - name: Run revert test - run: | - ci_run pkill zksync_server || true - ci_run sleep 2 - ENABLE_CONSENSUS=${{ matrix.consensus }} DEPLOYMENT_MODE=${{ matrix.deployment_mode }} PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE" ci_run zk test i revert + # - name: Server integration tests + # run: ci_run zk test i server + + # - name: Snapshot recovery test + # # We use `yarn` directly because the test launches `zk` commands in both server and EN envs. + # # An empty topmost environment helps avoid a mess when redefining env vars shared between both envs + # # (e.g., DATABASE_URL). + # # + # # Since `base_token` doesn't meaningfully influence the test, we use it as a flag for + # # enabling / disabling tree during pruning. + # run: | + # if [[ "${{ matrix.deployment_mode }}" == "Validium" ]]; then + # ci_run zk config compile ext-node-validium + # ci_run zk config compile ext-node-validium-docker + # fi + # ENABLE_CONSENSUS=${{ matrix.consensus }} \ + # DEPLOYMENT_MODE=${{ matrix.deployment_mode }} \ + # SNAPSHOTS_CREATOR_VERSION=${{ matrix.deployment_mode == 'Validium' && '0' || '1' }} \ + # DISABLE_TREE_DURING_PRUNING=${{ matrix.base_token == 'Eth' }} \ + # ETH_CLIENT_WEB3_URL="http://reth:8545" \ + # PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE,DISABLE_TREE_DURING_PRUNING,SNAPSHOTS_CREATOR_VERSION,ETH_CLIENT_WEB3_URL" \ + # ci_run yarn recovery-test snapshot-recovery-test + + # - name: Genesis recovery test + # run: | + # ENABLE_CONSENSUS=${{ matrix.consensus }} \ + # DEPLOYMENT_MODE=${{ matrix.deployment_mode }} \ + # ETH_CLIENT_WEB3_URL="http://reth:8545" \ + # PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE,ETH_CLIENT_WEB3_URL" \ + # ci_run yarn recovery-test genesis-recovery-test + + # - name: Fee projection tests + # run: ci_run zk test i fees + + # - name: Run revert test + # run: | + # ci_run pkill zksync_server || true + # ci_run sleep 2 + # ENABLE_CONSENSUS=${{ matrix.consensus }} DEPLOYMENT_MODE=${{ matrix.deployment_mode }} PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE" ci_run zk test i revert # This test should be the last one as soon as it @@ -366,21 +366,21 @@ jobs: ci_run zk external-node $EXT_NODE_FLAGS &>>ext-node.log & ci_run sleep 30 - - name: Integration tests - run: ci_run zk test i server --testPathIgnorePatterns 'contract-verification|snapshots-creator' - - - name: Run revert test - run: | - ENABLE_CONSENSUS=${{ matrix.consensus }} DEPLOYMENT_MODE=${{ matrix.deployment_mode }} PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE" ci_run zk test i revert-en - # test terminates the nodes, so we restart them. - if [[ "${{ matrix.deployment_mode }}" == "Rollup" ]]; then - ZKSYNC_ENV=docker ci_run zk server --components=$SERVER_COMPONENTS &>>server.log & - ZKSYNC_ENV=ext-node-docker ci_run zk external-node $EXT_NODE_FLAGS &>>ext-node.log & - elif [[ "${{ matrix.deployment_mode }}" == "Validium" ]]; then - ZKSYNC_ENV=dev_validium_docker ci_run zk server --components=$SERVER_COMPONENTS &>>server.log & - ZKSYNC_ENV=ext-node-validium-docker ci_run zk external-node $EXT_NODE_FLAGS &>>ext-node.log & - fi - ci_run sleep 30 + # - name: Integration tests + # run: ci_run zk test i server --testPathIgnorePatterns 'contract-verification|snapshots-creator' + + # - name: Run revert test + # run: | + # ENABLE_CONSENSUS=${{ matrix.consensus }} DEPLOYMENT_MODE=${{ matrix.deployment_mode }} PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE" ci_run zk test i revert-en + # # test terminates the nodes, so we restart them. + # if [[ "${{ matrix.deployment_mode }}" == "Rollup" ]]; then + # ZKSYNC_ENV=docker ci_run zk server --components=$SERVER_COMPONENTS &>>server.log & + # ZKSYNC_ENV=ext-node-docker ci_run zk external-node $EXT_NODE_FLAGS &>>ext-node.log & + # elif [[ "${{ matrix.deployment_mode }}" == "Validium" ]]; then + # ZKSYNC_ENV=dev_validium_docker ci_run zk server --components=$SERVER_COMPONENTS &>>server.log & + # ZKSYNC_ENV=ext-node-validium-docker ci_run zk external-node $EXT_NODE_FLAGS &>>ext-node.log & + # fi + # ci_run sleep 30 - name: Run upgrade test run: | From fb65d9c977c66ca836fcedd553e08af6f8079949 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Mon, 8 Jul 2024 15:40:15 +0100 Subject: [PATCH 12/24] debug logs --- core/tests/upgrade-test/tests/upgrade.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/tests/upgrade-test/tests/upgrade.test.ts b/core/tests/upgrade-test/tests/upgrade.test.ts index c9c454d64bb..ae1a9a4a4c3 100644 --- a/core/tests/upgrade-test/tests/upgrade.test.ts +++ b/core/tests/upgrade-test/tests/upgrade.test.ts @@ -101,10 +101,15 @@ describe('Upgrade test', function () { const initialL1BatchNumber = await tester.web3Provider.getL1BatchNumber(); const baseToken = await tester.syncWallet.provider.getBaseTokenContractAddress(); + console.log('Base token address:', baseToken); if (!zksync.utils.isAddressEq(baseToken, zksync.utils.ETH_ADDRESS_IN_CONTRACTS)) { + console.log('Approving ERC20 token'); await (await tester.syncWallet.approveERC20(baseToken, ethers.MaxUint256)).wait(); + console.log('Minting ERC20 token'); + console.log('balance:', await tester.syncWallet.getBalance(baseToken, 'committed')); await mintToWallet(baseToken, tester.syncWallet, depositAmount * 10n); + console.log('balance:', await tester.syncWallet.getBalance(baseToken, 'committed')); } const firstDepositHandle = await tester.syncWallet.deposit({ From 31e165e330cacaf23a29ea2dbbbf1f18946138b4 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Mon, 8 Jul 2024 17:11:58 +0100 Subject: [PATCH 13/24] mintToWallet fix --- core/tests/upgrade-test/tests/upgrade.test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/tests/upgrade-test/tests/upgrade.test.ts b/core/tests/upgrade-test/tests/upgrade.test.ts index ae1a9a4a4c3..6e22b44f912 100644 --- a/core/tests/upgrade-test/tests/upgrade.test.ts +++ b/core/tests/upgrade-test/tests/upgrade.test.ts @@ -108,7 +108,7 @@ describe('Upgrade test', function () { await (await tester.syncWallet.approveERC20(baseToken, ethers.MaxUint256)).wait(); console.log('Minting ERC20 token'); console.log('balance:', await tester.syncWallet.getBalance(baseToken, 'committed')); - await mintToWallet(baseToken, tester.syncWallet, depositAmount * 10n); + await mintToAddress(baseToken, tester.ethWallet, tester.syncWallet.address, depositAmount * 10n); console.log('balance:', await tester.syncWallet.getBalance(baseToken, 'committed')); } @@ -489,10 +489,15 @@ function prepareGovernanceCalldata(to: string, data: BytesLike): UpgradeCalldata }; } -async function mintToWallet(baseTokenAddress: zksync.types.Address, ethersWallet: ethers.Wallet, amountToMint: bigint) { +async function mintToAddress( + baseTokenAddress: zksync.types.Address, + ethersWallet: ethers.Wallet, + addressToMintTo: string, + amountToMint: bigint +) { const l1Erc20ABI = ['function mint(address to, uint256 amount)']; const l1Erc20Contract = new ethers.Contract(baseTokenAddress, l1Erc20ABI, ethersWallet); - await (await l1Erc20Contract.mint(ethersWallet.address, amountToMint)).wait(); + await (await l1Erc20Contract.mint(addressToMintTo, amountToMint)).wait(); } const SEMVER_MINOR_VERSION_MULTIPLIER = 4294967296; From 36be6b27620ea4e4ea8bc87c1d0a2b890918cc33 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Mon, 8 Jul 2024 17:13:28 +0100 Subject: [PATCH 14/24] Revert "debug logs" This reverts commit fb65d9c977c66ca836fcedd553e08af6f8079949. --- core/tests/upgrade-test/tests/upgrade.test.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/core/tests/upgrade-test/tests/upgrade.test.ts b/core/tests/upgrade-test/tests/upgrade.test.ts index 6e22b44f912..63463061337 100644 --- a/core/tests/upgrade-test/tests/upgrade.test.ts +++ b/core/tests/upgrade-test/tests/upgrade.test.ts @@ -101,15 +101,10 @@ describe('Upgrade test', function () { const initialL1BatchNumber = await tester.web3Provider.getL1BatchNumber(); const baseToken = await tester.syncWallet.provider.getBaseTokenContractAddress(); - console.log('Base token address:', baseToken); if (!zksync.utils.isAddressEq(baseToken, zksync.utils.ETH_ADDRESS_IN_CONTRACTS)) { - console.log('Approving ERC20 token'); await (await tester.syncWallet.approveERC20(baseToken, ethers.MaxUint256)).wait(); - console.log('Minting ERC20 token'); - console.log('balance:', await tester.syncWallet.getBalance(baseToken, 'committed')); await mintToAddress(baseToken, tester.ethWallet, tester.syncWallet.address, depositAmount * 10n); - console.log('balance:', await tester.syncWallet.getBalance(baseToken, 'committed')); } const firstDepositHandle = await tester.syncWallet.deposit({ From 029ae93a93777190df88b0eb5823d697db83265e Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Mon, 8 Jul 2024 17:40:03 +0100 Subject: [PATCH 15/24] skipping zk_toolbox tests --- .github/workflows/ci-zk-toolbox-reusable.yml | 38 ++++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci-zk-toolbox-reusable.yml b/.github/workflows/ci-zk-toolbox-reusable.yml index 102c3d56c33..43c350dfb51 100644 --- a/.github/workflows/ci-zk-toolbox-reusable.yml +++ b/.github/workflows/ci-zk-toolbox-reusable.yml @@ -93,25 +93,25 @@ jobs: ci_run zk_inception server --ignore-prerequisites &>server.log & ci_run sleep 5 - - name: Run integration tests - run: | - ci_run zk_supervisor test integration --ignore-prerequisites --verbose - - - name: Run external node server - run: | - ci_run zk_inception external-node configs --db-url=postgres://postgres:notsecurepassword@postgres:5432 \ - --db-name=zksync_en_localhost_era --l1-rpc-url=http://reth:8545 - ci_run zk_inception external-node init --ignore-prerequisites - ci_run zk_inception external-node run --ignore-prerequisites &>external_node.log & - ci_run sleep 5 - - - name: Run integration tests en - run: | - ci_run zk_supervisor test integration --ignore-prerequisites --verbose --external-node - - - name: Run revert tests - run: | - ci_run zk_supervisor test revert --ignore-prerequisites --verbose + # - name: Run integration tests + # run: | + # ci_run zk_supervisor test integration --ignore-prerequisites --verbose + + # - name: Run external node server + # run: | + # ci_run zk_inception external-node configs --db-url=postgres://postgres:notsecurepassword@postgres:5432 \ + # --db-name=zksync_en_localhost_era --l1-rpc-url=http://reth:8545 + # ci_run zk_inception external-node init --ignore-prerequisites + # ci_run zk_inception external-node run --ignore-prerequisites &>external_node.log & + # ci_run sleep 5 + + # - name: Run integration tests en + # run: | + # ci_run zk_supervisor test integration --ignore-prerequisites --verbose --external-node + + # - name: Run revert tests + # run: | + # ci_run zk_supervisor test revert --ignore-prerequisites --verbose - name: Show server.log logs if: always() From 73ab11d720448cd595132a340c57b0c1908fa37c Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Tue, 9 Jul 2024 14:19:06 +0100 Subject: [PATCH 16/24] logs added for debugging --- core/tests/upgrade-test/tests/upgrade.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/tests/upgrade-test/tests/upgrade.test.ts b/core/tests/upgrade-test/tests/upgrade.test.ts index 63463061337..ff9c3bdb5b2 100644 --- a/core/tests/upgrade-test/tests/upgrade.test.ts +++ b/core/tests/upgrade-test/tests/upgrade.test.ts @@ -169,6 +169,7 @@ describe('Upgrade test', function () { forceDeployAddress = '0xf04ce00000000000000000000000000000000000'; forceDeployBytecode = COUNTER_BYTECODE; + console.log('Force deploy address:', forceDeployAddress); const forceDeployment: ForceDeployment = { bytecodeHash: ethers.hexlify(zksync.utils.hashBytecode(forceDeployBytecode)), newAddress: forceDeployAddress, @@ -176,10 +177,14 @@ describe('Upgrade test', function () { value: 0n, input: '0x' }; + console.log('Force deployment:', forceDeployment); const delegateTo = process.env.CONTRACTS_L2_DEFAULT_UPGRADE_ADDR!; + console.log('Delegate to:', delegateTo); const delegateCalldata = L2_FORCE_DEPLOY_UPGRADER_ABI.encodeFunctionData('forceDeploy', [[forceDeployment]]); + console.log('Delegate calldata:', delegateCalldata); const data = COMPLEX_UPGRADER_ABI.encodeFunctionData('upgrade', [delegateTo, delegateCalldata]); + console.log('Data:', data); const { stmUpgradeData, chainUpgradeData } = await prepareUpgradeCalldata( govWallet, @@ -208,15 +213,22 @@ describe('Upgrade test', function () { upgradeTimestamp: 0 } ); + console.log('STM upgrade data:', stmUpgradeData); + console.log('Chain upgrade data:', chainUpgradeData); scheduleTransparentOperation = chainUpgradeData.scheduleTransparentOperation; executeOperation = chainUpgradeData.executeOperation; await sendGovernanceOperation(stmUpgradeData.scheduleTransparentOperation); + console.log('Governance operation stmUpgradeData.scheduleTransparentOperation'); await sendGovernanceOperation(stmUpgradeData.executeOperation); + console.log('Governance operation stmUpgradeData.executeOperation'); await sendGovernanceOperation(scheduleTransparentOperation); + console.log('Governance operation scheduleTransparentOperation'); // Wait for server to process L1 event. + console.log('Waiting for server to process L1 event'); await utils.sleep(2); + console.log('Server should have processed L1 event'); }); step('Check bootloader is updated on L2', async () => { From 0af08b29c54cd64245b99d5f2c428c24e308a1b8 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Wed, 10 Jul 2024 10:01:01 +0100 Subject: [PATCH 17/24] manually setting gasLimit and gasPrice --- core/tests/upgrade-test/tests/upgrade.test.ts | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/core/tests/upgrade-test/tests/upgrade.test.ts b/core/tests/upgrade-test/tests/upgrade.test.ts index ff9c3bdb5b2..b0b5c85ee55 100644 --- a/core/tests/upgrade-test/tests/upgrade.test.ts +++ b/core/tests/upgrade-test/tests/upgrade.test.ts @@ -299,13 +299,25 @@ describe('Upgrade test', function () { }); async function sendGovernanceOperation(data: string) { - await ( - await govWallet.sendTransaction({ - to: await governanceContract.getAddress(), - data: data, - type: 0 - }) - ).wait(); + if (!govWallet.provider) { + throw new Error('Wallet should have provider'); + } + const feeData = await govWallet.provider.getFeeData(); + if (!feeData) { + throw new Error('Failed to get fee data'); + } + if (!feeData.gasPrice) { + throw new Error('Failed to get gas price'); + } + const gasPrice = (feeData.gasPrice * 140n) / 100n; + + const tx: ethers.TransactionRequest = { + to: await governanceContract.getAddress(), + data: data, + type: 0 + }; + const gasLimit = await govWallet.provider.estimateGas(tx); + await (await govWallet.sendTransaction({ ...tx, gasPrice, gasLimit })).wait(); } }); From 73fc27140b05ca8a7031b607a315356f9119eaf4 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Wed, 10 Jul 2024 10:44:23 +0100 Subject: [PATCH 18/24] fix: from address added to estimateGas --- core/tests/upgrade-test/tests/upgrade.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/tests/upgrade-test/tests/upgrade.test.ts b/core/tests/upgrade-test/tests/upgrade.test.ts index b0b5c85ee55..d633269d674 100644 --- a/core/tests/upgrade-test/tests/upgrade.test.ts +++ b/core/tests/upgrade-test/tests/upgrade.test.ts @@ -313,6 +313,7 @@ describe('Upgrade test', function () { const tx: ethers.TransactionRequest = { to: await governanceContract.getAddress(), + from: govWallet.address, data: data, type: 0 }; From ac263006e0ab268263368f6f00b89aa434e6ea7b Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Thu, 11 Jul 2024 10:28:31 +0100 Subject: [PATCH 19/24] Revert "running only upgrade tests" This reverts commit 7691382bba274dee0a6d46587249e51b6d789059. --- .github/workflows/ci-core-reusable.yml | 108 ++++++++++++------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci-core-reusable.yml b/.github/workflows/ci-core-reusable.yml index 6281cd1496d..93aa1bb1658 100644 --- a/.github/workflows/ci-core-reusable.yml +++ b/.github/workflows/ci-core-reusable.yml @@ -213,45 +213,45 @@ jobs: ci_run zk contract_verifier &>contract_verifier.log & ci_run sleep 2 - # - name: Server integration tests - # run: ci_run zk test i server - - # - name: Snapshot recovery test - # # We use `yarn` directly because the test launches `zk` commands in both server and EN envs. - # # An empty topmost environment helps avoid a mess when redefining env vars shared between both envs - # # (e.g., DATABASE_URL). - # # - # # Since `base_token` doesn't meaningfully influence the test, we use it as a flag for - # # enabling / disabling tree during pruning. - # run: | - # if [[ "${{ matrix.deployment_mode }}" == "Validium" ]]; then - # ci_run zk config compile ext-node-validium - # ci_run zk config compile ext-node-validium-docker - # fi - # ENABLE_CONSENSUS=${{ matrix.consensus }} \ - # DEPLOYMENT_MODE=${{ matrix.deployment_mode }} \ - # SNAPSHOTS_CREATOR_VERSION=${{ matrix.deployment_mode == 'Validium' && '0' || '1' }} \ - # DISABLE_TREE_DURING_PRUNING=${{ matrix.base_token == 'Eth' }} \ - # ETH_CLIENT_WEB3_URL="http://reth:8545" \ - # PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE,DISABLE_TREE_DURING_PRUNING,SNAPSHOTS_CREATOR_VERSION,ETH_CLIENT_WEB3_URL" \ - # ci_run yarn recovery-test snapshot-recovery-test - - # - name: Genesis recovery test - # run: | - # ENABLE_CONSENSUS=${{ matrix.consensus }} \ - # DEPLOYMENT_MODE=${{ matrix.deployment_mode }} \ - # ETH_CLIENT_WEB3_URL="http://reth:8545" \ - # PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE,ETH_CLIENT_WEB3_URL" \ - # ci_run yarn recovery-test genesis-recovery-test - - # - name: Fee projection tests - # run: ci_run zk test i fees - - # - name: Run revert test - # run: | - # ci_run pkill zksync_server || true - # ci_run sleep 2 - # ENABLE_CONSENSUS=${{ matrix.consensus }} DEPLOYMENT_MODE=${{ matrix.deployment_mode }} PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE" ci_run zk test i revert + - name: Server integration tests + run: ci_run zk test i server + + - name: Snapshot recovery test + # We use `yarn` directly because the test launches `zk` commands in both server and EN envs. + # An empty topmost environment helps avoid a mess when redefining env vars shared between both envs + # (e.g., DATABASE_URL). + # + # Since `base_token` doesn't meaningfully influence the test, we use it as a flag for + # enabling / disabling tree during pruning. + run: | + if [[ "${{ matrix.deployment_mode }}" == "Validium" ]]; then + ci_run zk config compile ext-node-validium + ci_run zk config compile ext-node-validium-docker + fi + ENABLE_CONSENSUS=${{ matrix.consensus }} \ + DEPLOYMENT_MODE=${{ matrix.deployment_mode }} \ + SNAPSHOTS_CREATOR_VERSION=${{ matrix.deployment_mode == 'Validium' && '0' || '1' }} \ + DISABLE_TREE_DURING_PRUNING=${{ matrix.base_token == 'Eth' }} \ + ETH_CLIENT_WEB3_URL="http://reth:8545" \ + PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE,DISABLE_TREE_DURING_PRUNING,SNAPSHOTS_CREATOR_VERSION,ETH_CLIENT_WEB3_URL" \ + ci_run yarn recovery-test snapshot-recovery-test + + - name: Genesis recovery test + run: | + ENABLE_CONSENSUS=${{ matrix.consensus }} \ + DEPLOYMENT_MODE=${{ matrix.deployment_mode }} \ + ETH_CLIENT_WEB3_URL="http://reth:8545" \ + PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE,ETH_CLIENT_WEB3_URL" \ + ci_run yarn recovery-test genesis-recovery-test + + - name: Fee projection tests + run: ci_run zk test i fees + + - name: Run revert test + run: | + ci_run pkill zksync_server || true + ci_run sleep 2 + ENABLE_CONSENSUS=${{ matrix.consensus }} DEPLOYMENT_MODE=${{ matrix.deployment_mode }} PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE" ci_run zk test i revert # This test should be the last one as soon as it @@ -366,21 +366,21 @@ jobs: ci_run zk external-node $EXT_NODE_FLAGS &>>ext-node.log & ci_run sleep 30 - # - name: Integration tests - # run: ci_run zk test i server --testPathIgnorePatterns 'contract-verification|snapshots-creator' - - # - name: Run revert test - # run: | - # ENABLE_CONSENSUS=${{ matrix.consensus }} DEPLOYMENT_MODE=${{ matrix.deployment_mode }} PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE" ci_run zk test i revert-en - # # test terminates the nodes, so we restart them. - # if [[ "${{ matrix.deployment_mode }}" == "Rollup" ]]; then - # ZKSYNC_ENV=docker ci_run zk server --components=$SERVER_COMPONENTS &>>server.log & - # ZKSYNC_ENV=ext-node-docker ci_run zk external-node $EXT_NODE_FLAGS &>>ext-node.log & - # elif [[ "${{ matrix.deployment_mode }}" == "Validium" ]]; then - # ZKSYNC_ENV=dev_validium_docker ci_run zk server --components=$SERVER_COMPONENTS &>>server.log & - # ZKSYNC_ENV=ext-node-validium-docker ci_run zk external-node $EXT_NODE_FLAGS &>>ext-node.log & - # fi - # ci_run sleep 30 + - name: Integration tests + run: ci_run zk test i server --testPathIgnorePatterns 'contract-verification|snapshots-creator' + + - name: Run revert test + run: | + ENABLE_CONSENSUS=${{ matrix.consensus }} DEPLOYMENT_MODE=${{ matrix.deployment_mode }} PASSED_ENV_VARS="ENABLE_CONSENSUS,DEPLOYMENT_MODE" ci_run zk test i revert-en + # test terminates the nodes, so we restart them. + if [[ "${{ matrix.deployment_mode }}" == "Rollup" ]]; then + ZKSYNC_ENV=docker ci_run zk server --components=$SERVER_COMPONENTS &>>server.log & + ZKSYNC_ENV=ext-node-docker ci_run zk external-node $EXT_NODE_FLAGS &>>ext-node.log & + elif [[ "${{ matrix.deployment_mode }}" == "Validium" ]]; then + ZKSYNC_ENV=dev_validium_docker ci_run zk server --components=$SERVER_COMPONENTS &>>server.log & + ZKSYNC_ENV=ext-node-validium-docker ci_run zk external-node $EXT_NODE_FLAGS &>>ext-node.log & + fi + ci_run sleep 30 - name: Run upgrade test run: | From 6bf8ec0f7f7f42e1513b740bf12453868db6dff3 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Thu, 11 Jul 2024 10:29:01 +0100 Subject: [PATCH 20/24] Revert "skipping zk_toolbox tests" This reverts commit 029ae93a93777190df88b0eb5823d697db83265e. --- .github/workflows/ci-zk-toolbox-reusable.yml | 38 ++++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci-zk-toolbox-reusable.yml b/.github/workflows/ci-zk-toolbox-reusable.yml index 43c350dfb51..102c3d56c33 100644 --- a/.github/workflows/ci-zk-toolbox-reusable.yml +++ b/.github/workflows/ci-zk-toolbox-reusable.yml @@ -93,25 +93,25 @@ jobs: ci_run zk_inception server --ignore-prerequisites &>server.log & ci_run sleep 5 - # - name: Run integration tests - # run: | - # ci_run zk_supervisor test integration --ignore-prerequisites --verbose - - # - name: Run external node server - # run: | - # ci_run zk_inception external-node configs --db-url=postgres://postgres:notsecurepassword@postgres:5432 \ - # --db-name=zksync_en_localhost_era --l1-rpc-url=http://reth:8545 - # ci_run zk_inception external-node init --ignore-prerequisites - # ci_run zk_inception external-node run --ignore-prerequisites &>external_node.log & - # ci_run sleep 5 - - # - name: Run integration tests en - # run: | - # ci_run zk_supervisor test integration --ignore-prerequisites --verbose --external-node - - # - name: Run revert tests - # run: | - # ci_run zk_supervisor test revert --ignore-prerequisites --verbose + - name: Run integration tests + run: | + ci_run zk_supervisor test integration --ignore-prerequisites --verbose + + - name: Run external node server + run: | + ci_run zk_inception external-node configs --db-url=postgres://postgres:notsecurepassword@postgres:5432 \ + --db-name=zksync_en_localhost_era --l1-rpc-url=http://reth:8545 + ci_run zk_inception external-node init --ignore-prerequisites + ci_run zk_inception external-node run --ignore-prerequisites &>external_node.log & + ci_run sleep 5 + + - name: Run integration tests en + run: | + ci_run zk_supervisor test integration --ignore-prerequisites --verbose --external-node + + - name: Run revert tests + run: | + ci_run zk_supervisor test revert --ignore-prerequisites --verbose - name: Show server.log logs if: always() From 1c184ea355f4eeda9052f6bac8815f1493fbf64c Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Thu, 11 Jul 2024 10:29:14 +0100 Subject: [PATCH 21/24] Revert "logs added for debugging" This reverts commit 73ab11d720448cd595132a340c57b0c1908fa37c. --- core/tests/upgrade-test/tests/upgrade.test.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/core/tests/upgrade-test/tests/upgrade.test.ts b/core/tests/upgrade-test/tests/upgrade.test.ts index d633269d674..2b8bfc79039 100644 --- a/core/tests/upgrade-test/tests/upgrade.test.ts +++ b/core/tests/upgrade-test/tests/upgrade.test.ts @@ -169,7 +169,6 @@ describe('Upgrade test', function () { forceDeployAddress = '0xf04ce00000000000000000000000000000000000'; forceDeployBytecode = COUNTER_BYTECODE; - console.log('Force deploy address:', forceDeployAddress); const forceDeployment: ForceDeployment = { bytecodeHash: ethers.hexlify(zksync.utils.hashBytecode(forceDeployBytecode)), newAddress: forceDeployAddress, @@ -177,14 +176,10 @@ describe('Upgrade test', function () { value: 0n, input: '0x' }; - console.log('Force deployment:', forceDeployment); const delegateTo = process.env.CONTRACTS_L2_DEFAULT_UPGRADE_ADDR!; - console.log('Delegate to:', delegateTo); const delegateCalldata = L2_FORCE_DEPLOY_UPGRADER_ABI.encodeFunctionData('forceDeploy', [[forceDeployment]]); - console.log('Delegate calldata:', delegateCalldata); const data = COMPLEX_UPGRADER_ABI.encodeFunctionData('upgrade', [delegateTo, delegateCalldata]); - console.log('Data:', data); const { stmUpgradeData, chainUpgradeData } = await prepareUpgradeCalldata( govWallet, @@ -213,22 +208,15 @@ describe('Upgrade test', function () { upgradeTimestamp: 0 } ); - console.log('STM upgrade data:', stmUpgradeData); - console.log('Chain upgrade data:', chainUpgradeData); scheduleTransparentOperation = chainUpgradeData.scheduleTransparentOperation; executeOperation = chainUpgradeData.executeOperation; await sendGovernanceOperation(stmUpgradeData.scheduleTransparentOperation); - console.log('Governance operation stmUpgradeData.scheduleTransparentOperation'); await sendGovernanceOperation(stmUpgradeData.executeOperation); - console.log('Governance operation stmUpgradeData.executeOperation'); await sendGovernanceOperation(scheduleTransparentOperation); - console.log('Governance operation scheduleTransparentOperation'); // Wait for server to process L1 event. - console.log('Waiting for server to process L1 event'); await utils.sleep(2); - console.log('Server should have processed L1 event'); }); step('Check bootloader is updated on L2', async () => { From eab33ede445239ceff860a1334e6aadab412aae7 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Tue, 23 Jul 2024 23:55:47 +0900 Subject: [PATCH 22/24] Revert "fix: from address added to estimateGas" This reverts commit 73fc27140b05ca8a7031b607a315356f9119eaf4. --- core/tests/upgrade-test/tests/upgrade.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/core/tests/upgrade-test/tests/upgrade.test.ts b/core/tests/upgrade-test/tests/upgrade.test.ts index 7ef0dac392d..d6c55f2fc20 100644 --- a/core/tests/upgrade-test/tests/upgrade.test.ts +++ b/core/tests/upgrade-test/tests/upgrade.test.ts @@ -309,7 +309,6 @@ describe('Upgrade test', function () { const tx: ethers.TransactionRequest = { to: await governanceContract.getAddress(), - from: govWallet.address, data: data, type: 0 }; From e4042ca82960557136f696c12f10c22b5747cb41 Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Tue, 23 Jul 2024 23:55:56 +0900 Subject: [PATCH 23/24] Revert "manually setting gasLimit and gasPrice" This reverts commit 0af08b29c54cd64245b99d5f2c428c24e308a1b8. --- core/tests/upgrade-test/tests/upgrade.test.ts | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/core/tests/upgrade-test/tests/upgrade.test.ts b/core/tests/upgrade-test/tests/upgrade.test.ts index d6c55f2fc20..6353456762e 100644 --- a/core/tests/upgrade-test/tests/upgrade.test.ts +++ b/core/tests/upgrade-test/tests/upgrade.test.ts @@ -295,25 +295,13 @@ describe('Upgrade test', function () { }); async function sendGovernanceOperation(data: string) { - if (!govWallet.provider) { - throw new Error('Wallet should have provider'); - } - const feeData = await govWallet.provider.getFeeData(); - if (!feeData) { - throw new Error('Failed to get fee data'); - } - if (!feeData.gasPrice) { - throw new Error('Failed to get gas price'); - } - const gasPrice = (feeData.gasPrice * 140n) / 100n; - - const tx: ethers.TransactionRequest = { - to: await governanceContract.getAddress(), - data: data, - type: 0 - }; - const gasLimit = await govWallet.provider.estimateGas(tx); - await (await govWallet.sendTransaction({ ...tx, gasPrice, gasLimit })).wait(); + await ( + await govWallet.sendTransaction({ + to: await governanceContract.getAddress(), + data: data, + type: 0 + }) + ).wait(); } async function sendChainAdminOperation(data: string) { From d1a58e3ef69341ccc56db583f0817a21c696528b Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Tue, 13 Aug 2024 19:37:48 +0100 Subject: [PATCH 24/24] test(erc20.test.ts): deposit with max balance test cleanup --- core/tests/ts-integration/tests/erc20.test.ts | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/core/tests/ts-integration/tests/erc20.test.ts b/core/tests/ts-integration/tests/erc20.test.ts index 257592c1594..9173989ea98 100644 --- a/core/tests/ts-integration/tests/erc20.test.ts +++ b/core/tests/ts-integration/tests/erc20.test.ts @@ -15,6 +15,8 @@ describe('ERC20 contract checks', () => { let testMaster: TestMaster; let alice: zksync.Wallet; let bob: zksync.Wallet; + let isETHBasedChain: boolean; + let baseTokenAddress: string; let tokenDetails: Token; let aliceErc20: zksync.Contract; @@ -23,6 +25,10 @@ describe('ERC20 contract checks', () => { alice = testMaster.mainAccount(); bob = testMaster.newEmptyAccount(); + // Get the information about base token address directly from the L2. + baseTokenAddress = await alice._providerL2().getBaseTokenContractAddress(); + isETHBasedChain = baseTokenAddress == zksync.utils.ETH_ADDRESS_IN_CONTRACTS; + tokenDetails = testMaster.environment().erc20Token; aliceErc20 = new zksync.Contract(tokenDetails.l2Address, zksync.utils.IERC20, alice); }); @@ -207,48 +213,47 @@ describe('ERC20 contract checks', () => { }); test('Can perform a deposit with precalculated max value', async () => { - const baseTokenAddress = await alice._providerL2().getBaseTokenContractAddress(); - const isETHBasedChain = baseTokenAddress == zksync.utils.ETH_ADDRESS_IN_CONTRACTS; if (!isETHBasedChain) { + // approving whole base token balance const baseTokenDetails = testMaster.environment().baseToken; const baseTokenMaxAmount = await alice.getBalanceL1(baseTokenDetails.l1Address); await (await alice.approveERC20(baseTokenDetails.l1Address, baseTokenMaxAmount)).wait(); } - // Approving the needed allowance to ensure that the user has enough funds. - const maxAmount = await alice.getBalanceL1(tokenDetails.l1Address); - await (await alice.approveERC20(tokenDetails.l1Address, maxAmount)).wait(); + // depositing the max amount: the whole balance of the token + const tokenDepositAmount = await alice.getBalanceL1(tokenDetails.l1Address); + + // approving the needed allowance for the deposit + await (await alice.approveERC20(tokenDetails.l1Address, tokenDepositAmount)).wait(); + // fee of the deposit in ether const depositFee = await alice.getFullRequiredDepositFee({ token: tokenDetails.l1Address }); + // checking if alice has enough funds to pay the fee const l1Fee = depositFee.l1GasLimit * (depositFee.maxFeePerGas! || depositFee.gasPrice!); const l2Fee = depositFee.baseCost; - const aliceETHBalance = await alice.getBalanceL1(); - - if (aliceETHBalance < l1Fee + l2Fee) { - throw new Error('Not enough ETH to perform a deposit'); + const aliceBalance = await alice.getBalanceL1(); + if (aliceBalance < l1Fee + l2Fee) { + throw new Error('Not enough balance to pay the fee'); } - const l2ERC20BalanceChange = await shouldChangeTokenBalances(tokenDetails.l2Address, [ - { wallet: alice, change: maxAmount } - ]); - - const overrides: ethers.Overrides = depositFee.gasPrice - ? { gasPrice: depositFee.gasPrice } - : { - maxFeePerGas: depositFee.maxFeePerGas, - maxPriorityFeePerGas: depositFee.maxPriorityFeePerGas - }; - overrides.gasLimit = depositFee.l1GasLimit; - const depositOp = await alice.deposit({ + // deposit handle with the precalculated max amount + const depositHandle = await alice.deposit({ token: tokenDetails.l1Address, - amount: maxAmount, + amount: tokenDepositAmount, l2GasLimit: depositFee.l2GasLimit, - overrides + approveBaseERC20: true, + approveERC20: true, + overrides: depositFee }); - await expect(depositOp).toBeAccepted([l2ERC20BalanceChange]); + + // checking the l2 balance change + const l2TokenBalanceChange = await shouldChangeTokenBalances(tokenDetails.l2Address, [ + { wallet: alice, change: tokenDepositAmount } + ]); + await expect(depositHandle).toBeAccepted([l2TokenBalanceChange]); }); afterAll(async () => {