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: adapt eth_sender tests for running both in Validium mode and Rollup mode #120

Merged
merged 18 commits into from
Feb 15, 2024

Conversation

toni-calvin
Copy link

@toni-calvin toni-calvin commented Feb 9, 2024

Description

Closes #118

This Pull Request addresses the need to support and test a new type of SenderTester, specifically the "validium" tester, in addition to the default "rollup" tester. In a previous PR, we introduced different testers, but the default was set to "rollup" without adequate testing for the "validium" tester.

The main objective of this PR is to enhance testing coverage for the "validium" tester. The existing test structure has been adjusted to accept a SenderTest as a parameter, allowing for greater flexibility in testing various tester types. Additionally, new methods have been added to validate the tests specifically for each tester type, ensuring thorough and targeted testing for both "rollup" and "validium" testers.

Changes Made

  • Adjustment of the l1_batch_commit_generator to accommodate the unique requirements of the "validium" tester, as it is the only differing aspect between tester types.
  • Adaptation of the existing test structure to accept a SenderTest as a parameter.
  • Addition of methods that instantiate one of each type of SenderTester (including "rollup" and "validium") and call the existing tests, now with the Tester as a parameter.

How to Test

  • For testing, inside the root folder of the project run:

zk test rust --package zksync_core --lib -j 1 -- eth_sender::tests

@toni-calvin toni-calvin changed the base branch from main to fix-integration-test February 9, 2024 13:14
@toni-calvin toni-calvin marked this pull request as draft February 9, 2024 13:14
@toni-calvin toni-calvin self-assigned this Feb 9, 2024
@toni-calvin toni-calvin changed the base branch from fix-integration-test to validium_mode_new_fee_model_final February 9, 2024 13:17
@toni-calvin toni-calvin changed the base branch from validium_mode_new_fee_model_final to fix-integration-test February 9, 2024 13:17
Comment on lines 727 to 728
let l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator> =
tester.aggregator.get_l1_batch_commit_data_generator();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we just do this? (We'd get rid of the getter method)

Suggested change
let l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator> =
tester.aggregator.get_l1_batch_commit_data_generator();
let l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator> =
tester.aggregator.l1_batch_commit_data_generator.clone();

Copy link
Author

Choose a reason for hiding this comment

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

In order to do that, we should expose public the aggregator field inside the EthTxAggregator and the field l1_batch_commit_data_generator.

@ilitteri
Copy link
Collaborator

ilitteri commented Feb 9, 2024

The base branch should be feat_validium_pubdata_abstraction.

@ilitteri ilitteri added this to the Validium Mode: Make it work milestone Feb 9, 2024
@ilitteri ilitteri changed the title Abstract eth sender test Adapt eth_sender tests for running both in Validium mode and Rollup mode Feb 9, 2024
@ilitteri ilitteri changed the title Adapt eth_sender tests for running both in Validium mode and Rollup mode feat: adapt eth_sender tests for running both in Validium mode and Rollup mode Feb 9, 2024
@toni-calvin toni-calvin changed the base branch from fix-integration-test to feat_validium_pubdata_abstraction February 12, 2024 12:53
@toni-calvin toni-calvin marked this pull request as ready for review February 13, 2024 11:27
Copy link
Collaborator

@ilitteri ilitteri left a comment

Choose a reason for hiding this comment

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

The PR is looking good, great work! Here I leave some comments:

  • Let's add a description to the PR, given that there's an issue associated we can mention Resolves #X or Closes #X. Then if some additional information is needed by the reviewer it'd be good to add it in subsequent sections (like how to run the tests you're changing).
  • Let's move the auxiliary functions (the abstractions) to a test_helpers module. If I'm not wrong, by doing so we an get rid of the prefix _ and call the methods like test_helpers::xxx after importing the module test_helpers.
  • Regarding the get_l1_batch_commit_data_generator method: I see why you added it, but I think we can avoid needing it (in terms of design it'd be ok to have it as a method for Aggregator by maybe not for EthTxAggregator, we'll still remove it from both though). As it is only meant for testing purposes we can make the method public for the crate or super if necessary, even better, we can make the struct fields public for the crate or super; this won't be the case either because it'd be more difficult to be accepted in the main PR.
    I saw in the tests that it is only consumed by commit_l1_batch to instantiate an AggregatedOperation::Commit which instantiates a CommitBatches struct that will be the final consumer of l1_batch_commit_data_generator. This is great news because this means that the EthTxAggregator's Aggregator that is in the tester is not the one in charge of creating an AggregatedOperation::Commit for later committing, therefore we can pass l1_batch_commit_data_generator as a parameter to the functions along with the tester and get rid of using the method and roll it back.

Copy link
Collaborator

@ilitteri ilitteri left a comment

Choose a reason for hiding this comment

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

LGTM! Great work!

@ilitteri ilitteri merged commit fc03061 into feat_validium_pubdata_abstraction Feb 15, 2024
6 of 10 checks passed
@ilitteri ilitteri deleted the abstract-eth_sender-test branch February 15, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adapt tests for testing both with Rollup and Validium mode in eth_sender module
2 participants