Skip to content

Commit

Permalink
test: Fix "missing revert data" error; fix / debug integration tests (#…
Browse files Browse the repository at this point in the history
…2804)

## What ❔

- Fixes the "missing revert data" error by updating the used reth Docker
image. The error is probably caused by [this
issue](paradigmxyz/reth#7381) fixed in the new
reth versions.
- Removes "web3 API compatibility tests › Should check API returns error
when there are too many logs in eth_getLogs" test as fundamentally flaky
and able to poison other tests.
- Adds logging for upgrade test to investigate L1 "nonce too low"
errors.

## Why ❔

Flaky CI bad.

## Checklist

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
  • Loading branch information
slowli authored Sep 10, 2024
1 parent 4cff529 commit fe08677
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 66 deletions.
1 change: 1 addition & 0 deletions core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ impl MainNodeBuilder {
subscriptions_limit: Some(rpc_config.subscriptions_limit()),
batch_request_size_limit: Some(rpc_config.max_batch_request_size()),
response_body_size_limit: Some(rpc_config.max_response_body_size()),
with_extended_tracing: rpc_config.extended_api_tracing,
..Default::default()
};
self.node.add_layer(Web3ServerLayer::http(
Expand Down
58 changes: 11 additions & 47 deletions core/tests/ts-integration/tests/api/web3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('web3 API compatibility tests', () => {

test('Should test web3 response extensions', async () => {
if (testMaster.isFastMode()) {
// This test requires a new L1 batch to be created, which may be very time consuming on stage.
// This test requires a new L1 batch to be created, which may be very time-consuming on stage.
return;
}

Expand Down Expand Up @@ -333,7 +333,7 @@ describe('web3 API compatibility tests', () => {

// Pubsub notifier is not reactive + tests are being run in parallel, so we can't expect that the next block
// would be expected one. Instead, we just want to receive an event with the particular block number.
wsProvider.on('block', (block) => {
await wsProvider.on('block', (block) => {
if (block >= currentBlock) {
newBlock = block;
}
Expand All @@ -355,7 +355,6 @@ describe('web3 API compatibility tests', () => {
// ...though the gap should not be *too* big.
expect(newBlock).toBeLessThan(currentBlock + 100);
await tx.wait(); // To not leave a hanging promise.
wsProvider.removeAllListeners();
await wsProvider.destroy();
});

Expand All @@ -368,7 +367,7 @@ describe('web3 API compatibility tests', () => {

let newTxHash: string | null = null;
// We can't use `once` as there may be other pending txs sent together with our one.
wsProvider.on('pending', async (txHash) => {
await wsProvider.on('pending', async (txHash) => {
const tx = await alice.provider.getTransaction(txHash);
// We're waiting for the exact transaction to appear.
if (!tx || tx.to != uniqueRecipient) {
Expand All @@ -392,7 +391,6 @@ describe('web3 API compatibility tests', () => {

expect(newTxHash as string).toEqual(tx.hash);
await tx.wait(); // To not leave a hanging promise.
wsProvider.removeAllListeners();
await wsProvider.destroy();
});

Expand All @@ -404,7 +402,7 @@ describe('web3 API compatibility tests', () => {
// We're sending a few transfers from the wallet, so we'll use a new account to make event unique.
let uniqueRecipient = testMaster.newEmptyAccount().address;

// Setup a filter for an ERC20 transfer.
// Set up a filter for an ERC20 transfer.
const erc20TransferTopic = ethers.id('Transfer(address,address,uint256)');
let filter = {
address: l2Token,
Expand All @@ -414,15 +412,15 @@ describe('web3 API compatibility tests', () => {
ethers.zeroPadValue(uniqueRecipient, 32) // Recipient
]
};
wsProvider.once(filter, (event) => {
await wsProvider.once(filter, (event) => {
newEvent = event;
});

// Setup a filter that should not match anything.
// Set up a filter that should not match anything.
let incorrectFilter = {
address: alice.address
};
wsProvider.once(incorrectFilter, (_) => {
await wsProvider.once(incorrectFilter, (_) => {
expect(null).fail('Found log for incorrect filter');
});

Expand All @@ -439,7 +437,6 @@ describe('web3 API compatibility tests', () => {

expect((newEvent as any).transactionHash).toEqual(tx.hash);
await tx.wait(); // To not leave a hanging promise.
wsProvider.removeAllListeners();
await wsProvider.destroy();
});

Expand Down Expand Up @@ -608,7 +605,7 @@ describe('web3 API compatibility tests', () => {

// Pubsub notify is not reactive and may be laggy, so we want to increase the chances
// for test to pass. So we try to sleep a few iterations until we receive expected amount
// of events. If we won't receive them, we continue and the test will fail anyway.
// of events. If we don't receive them, we continue and the test will fail anyway.
const expectedTrivialEventsCount = 2;
const expectedSimpleEventsCount = 2;
const expectedIndexedEventsCount = 1;
Expand Down Expand Up @@ -681,42 +678,9 @@ describe('web3 API compatibility tests', () => {
).resolves.toHaveProperty('result', expect.stringMatching(HEX_VALUE_REGEX));
});

test('Should check API returns error when there are too many logs in eth_getLogs', async () => {
const contract = await deployContract(alice, contracts.events, []);
const maxLogsLimit = testMaster.environment().maxLogsLimit;

// Send 3 transactions that emit `maxLogsLimit / 2` events.
const tx1 = await contract.emitManyEvents(maxLogsLimit / 2);
const tx1Receipt = await tx1.wait();

const tx2 = await contract.emitManyEvents(maxLogsLimit / 2);
await tx2.wait();

const tx3 = await contract.emitManyEvents(maxLogsLimit / 2);
const tx3Receipt = await tx3.wait();

// There are around `0.5 * maxLogsLimit` logs in [tx1Receipt.blockNumber, tx1Receipt.blockNumber] range,
// so query with such filter should succeed.
await expect(
alice.provider.getLogs({
fromBlock: tx1Receipt.blockNumber,
toBlock: tx1Receipt.blockNumber
})
).resolves;

// There are at least `1.5 * maxLogsLimit` logs in [tx1Receipt.blockNumber, tx3Receipt.blockNumber] range,
// so query with such filter should fail.
await expect(
alice.provider.getLogs({
fromBlock: tx1Receipt.blockNumber,
toBlock: tx3Receipt.blockNumber
})
).rejects.toThrow(`Query returned more than ${maxLogsLimit} results.`);
});

test('Should throw error for estimate gas for account with balance < tx.value', async () => {
let poorBob = testMaster.newEmptyAccount();
expect(
await expect(
poorBob.estimateGas({ value: 1, to: alice.address })
).toBeRejected(/*'insufficient balance for transfer'*/);
});
Expand Down Expand Up @@ -860,7 +824,7 @@ describe('web3 API compatibility tests', () => {
const getLogsByHash = (await alice.provider.getLogs({ blockHash: latestBlock.hash || undefined })).map((x) => {
return new zksync.types.Log({ ...x, l1BatchNumber: 0 }, alice.provider); // Set bogus value.
});
await expect(getLogsByNumber).toEqual(getLogsByHash);
expect(getLogsByNumber).toEqual(getLogsByHash);

// Check that incorrect queries are rejected.
await expect(
Expand Down Expand Up @@ -1030,7 +994,7 @@ describe('web3 API compatibility tests', () => {
const incrementFunctionData = contract2.interface.encodeFunctionData('increment', [1]);

// Assert that the estimation fails because the increment function is not present in contract1
expect(
await expect(
alice.provider.estimateGas({
to: contract1Address.toString(),
data: incrementFunctionData
Expand Down
34 changes: 19 additions & 15 deletions core/tests/upgrade-test/tests/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,11 @@ describe('Upgrade test', function () {
);
executeOperation = chainUpgradeCalldata;

console.log('Sending scheduleTransparentOperation');
await sendGovernanceOperation(stmUpgradeData.scheduleTransparentOperation);
console.log('Sending executeOperation');
await sendGovernanceOperation(stmUpgradeData.executeOperation);

console.log('Sending chain admin operation');
await sendChainAdminOperation(setTimestampCalldata);

// Wait for server to process L1 event.
Expand Down Expand Up @@ -371,23 +373,25 @@ describe('Upgrade test', function () {
});

async function sendGovernanceOperation(data: string) {
await (
await ecosystemGovWallet.sendTransaction({
to: await governanceContract.getAddress(),
data: data,
type: 0
})
).wait();
const transaction = await ecosystemGovWallet.sendTransaction({
to: await governanceContract.getAddress(),
data: data,
type: 0
});
console.log(`Sent governance operation, tx_hash=${transaction.hash}, nonce=${transaction.nonce}`);
await transaction.wait();
console.log(`Governance operation succeeded, tx_hash=${transaction.hash}`);
}

async function sendChainAdminOperation(data: string) {
await (
await adminGovWallet.sendTransaction({
to: await chainAdminContract.getAddress(),
data: data,
type: 0
})
).wait();
const transaction = await adminGovWallet.sendTransaction({
to: await chainAdminContract.getAddress(),
data: data,
type: 0
});
console.log(`Sent chain admin operation, tx_hash=${transaction.hash}, nonce=${transaction.nonce}`);
await transaction.wait();
console.log(`Chain admin operation succeeded, tx_hash=${transaction.hash}`);
}
});

Expand Down
2 changes: 1 addition & 1 deletion docker-compose-cpu-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.2'
services:
reth:
restart: always
image: "ghcr.io/paradigmxyz/reth:v0.2.0-beta.2"
image: "ghcr.io/paradigmxyz/reth:v1.0.6"
volumes:
- type: bind
source: ./volumes/reth/data
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-gpu-runner-cuda-12-0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.2'
services:
reth:
restart: always
image: "ghcr.io/paradigmxyz/reth:v0.2.0-beta.2"
image: "ghcr.io/paradigmxyz/reth:v1.0.6"
volumes:
- type: bind
source: ./volumes/reth/data
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-gpu-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.2'
services:
reth:
restart: always
image: "ghcr.io/paradigmxyz/reth:v0.2.0-beta.2"
image: "ghcr.io/paradigmxyz/reth:v1.0.6"
volumes:
- type: bind
source: ./volumes/reth/data
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.2'
services:
reth:
restart: always
image: "ghcr.io/paradigmxyz/reth:v0.2.0-beta.2"
image: "ghcr.io/paradigmxyz/reth:v1.0.6"
ports:
- 127.0.0.1:8545:8545
volumes:
Expand Down

0 comments on commit fe08677

Please sign in to comment.