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: add mock batcher and implement as a wrapper in integration test #332

Merged

Conversation

ayeletstarkware
Copy link
Contributor

@ayeletstarkware ayeletstarkware commented Jul 1, 2024

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Jul 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.46%. Comparing base (26060ef) to head (9e57a3e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #332      +/-   ##
==========================================
+ Coverage   82.38%   82.46%   +0.08%     
==========================================
  Files          33       34       +1     
  Lines        1612     1620       +8     
  Branches     1612     1620       +8     
==========================================
+ Hits         1328     1336       +8     
  Misses        219      219              
  Partials       65       65              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@MohammadNassar1 MohammadNassar1 left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware and @giladchase)


crates/tests-integration/src/mock_batcher.rs line 10 at r1 (raw file):

#[derive(Clone)]
pub struct MockBatcher {
    mempool_client: MempoolClientImpl,

Why does it implement add_tx?
Maybe we should have a trait for Mempool <-> Batcher communication?

Code quote:

mempool_client: MempoolClientImpl,

Copy link
Contributor Author

@ayeletstarkware ayeletstarkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @giladchase)


crates/tests-integration/src/mock_batcher.rs line 15 at r1 (raw file):

impl MockBatcher {
    pub fn new(
        mempool: Sender<ComponentRequestAndResponseSender<MempoolRequest, MempoolResponse>>,

Should it be renamed to sender?

Code quote:

mempool

Copy link
Collaborator

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware and @MohammadNassar1)


crates/tests-integration/src/integration_test_setup.rs line 24 at r1 (raw file):

    pub task_executor: TokioExecutor,
    pub gateway_client: GatewayClient,
    pub mock_batcher: MockBatcher,

Mock is an implementation constraint, the field should describe the role.
There is also consistency with other fields, which also describes roles (note that Tokio isn't mentioned in the executor field).

Suggestion:

    pub batcher: MockBatcher,

crates/tests-integration/src/mock_batcher.rs line 10 at r1 (raw file):

Why does it implement add_tx?

This was the requirement.

The requirement was to have a trait that represents the mempool fully, so that it can either be represented by the infra communication layer, or by the mempool itself.

Maybe we should have a trait for Mempool <-> Batcher communication?

I see why you're referring this, but it'd contradict the above requirement.


crates/tests-integration/src/mock_batcher.rs line 15 at r1 (raw file):

Previously, ayeletstarkware (Ayelet Zilber) wrote…

Should it be renamed to sender?

See how the gateway communicates with the mempool, name it similarly.

As a second step after merging this, before the step of creating the channel for communicating between the batcher and the integrationtestsetup, see how much work it would be to make the batcher use the same client that the gateway used in order to communicate with the mempool (unless that's already the case?).

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mock-batcher-wrapper-integration-test branch from ebb3d3f to 4786460 Compare July 2, 2024 07:43
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @giladchase)


crates/tests-integration/src/mock_batcher.rs line 10 at r1 (raw file):

Previously, giladchase wrote…

Why does it implement add_tx?

This was the requirement.

The requirement was to have a trait that represents the mempool fully, so that it can either be represented by the infra communication layer, or by the mempool itself.

Maybe we should have a trait for Mempool <-> Batcher communication?

I see why you're referring this, but it'd contradict the above requirement.

The requirement is a bit weird, as we now have a Batcher that can send a transaction!

@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mock-batcher-wrapper-integration-test branch 2 times, most recently from 67e6cbb to 22dbc48 Compare July 3, 2024 13:41
@ayeletstarkware ayeletstarkware force-pushed the ayelet/mempool/mock-batcher-wrapper-integration-test branch from 22dbc48 to 9e57a3e Compare July 3, 2024 14:03
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware and @giladchase)


crates/tests-integration/Cargo.toml line 25 at r3 (raw file):

starknet_gateway = { path = "../gateway", version = "0.0", features = ["testing"] }
starknet_mempool = { path = "../mempool", version = "0.0" }
starknet_mempool_infra = { path = "../mempool_infra", version = "0.0" }

Out of curiosity, what's the difference between them?

Code quote:

starknet_mempool_infra = { path = "../mempool_infra", version = "0.0" }

Copy link
Contributor Author

@ayeletstarkware ayeletstarkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @giladchase and @MohammadNassar1)


crates/tests-integration/Cargo.toml line 25 at r3 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Out of curiosity, what's the difference between them?

i have no idea

Copy link
Collaborator

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @MohammadNassar1)


crates/tests-integration/src/mock_batcher.rs line 10 at r1 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

The requirement is a bit weird, as we now have a Batcher that can send a transaction!

That you're describing, i think, is an authentication scheme, with users and roles.

This needs to be added separately at some point, perhaps even into the mempool itself, but it could also be added at the infra level.

In any case, this is a separate abstraction.
One which is independent from the infra itself, and the mempol's API.

The alternative, of warding things off at the API level, would probably make our type system more convoluted than it needs to be.
It can be done, and it'd work, but since we're gonna have to do some kind of user roles at some point, we might as well put that behavior there, which is a more natural location for it.

Copy link
Collaborator

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 4 files at r1, 3 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware and @MohammadNassar1)


crates/tests-integration/Cargo.toml line 25 at r3 (raw file):

Previously, ayeletstarkware (Ayelet Zilber) wrote…

i have no idea

The version thing isn't really necessary for us yet, it is basically to appease crates.io, which doesn't support path dependencies.

So when we do publish, which we haven't thus far, we'll need to assign the current version in addition to the path, for every path dependency we have.

@ayeletstarkware ayeletstarkware merged commit 20f6e18 into main Jul 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants