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: feat: adding main module #311

Conversation

lev-starkware
Copy link
Contributor

@lev-starkware lev-starkware commented Jun 27, 2024

Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.


This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 0% with 52 lines in your changes missing coverage. Please review.

Project coverage is 78.47%. Comparing base (37d7bc8) to head (e89ace6).

Files Patch % Lines
crates/mempool_node/src/servers.rs 0.00% 31 Missing ⚠️
crates/mempool_node/src/main.rs 0.00% 21 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                          @@
##           pr/lev-starkware/lev_dev/f9f21462     #311      +/-   ##
=====================================================================
- Coverage                              80.85%   78.47%   -2.38%     
=====================================================================
  Files                                     35       35              
  Lines                                   1619     1668      +49     
  Branches                                1619     1668      +49     
=====================================================================
  Hits                                    1309     1309              
- Misses                                   244      293      +49     
  Partials                                  66       66              

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

@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch 3 times, most recently from 3141333 to e349a16 Compare June 30, 2024 12:05
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/0f64f96b branch from 778c186 to 4bd2b80 Compare July 1, 2024 10:31
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch 2 times, most recently from c125404 to 28e75b8 Compare July 1, 2024 10:42
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/0f64f96b branch 2 times, most recently from 8525b93 to ba88c86 Compare July 1, 2024 11:10
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch from 28e75b8 to 72c8507 Compare July 1, 2024 11:10
Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware 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: 0 of 6 files reviewed, 2 unresolved discussions (waiting on @lev-starkware)


crates/gateway/src/gateway.rs line 85 at r1 (raw file):

            .with_state(self.app_state.clone())
    }
}

Please create a different pr solely for these changes.

Code quote:

    pub async fn run(&mut self) -> Result<(), GatewayRunError> {
        // Parses the bind address from GatewayConfig, returning an error for invalid addresses.
        let GatewayNetworkConfig { ip, port } = self.config.network_config;
        let addr = SocketAddr::new(ip, port);
        let app = self.app();

        // Create a server that runs forever.
        Ok(axum::Server::bind(&addr).serve(app.into_make_service()).await?)
    }

    pub fn app(&self) -> Router {
        Router::new()
            .route("/is_alive", get(is_alive))
            .route("/add_tx", post(add_tx))
            .with_state(self.app_state.clone())
    }
}

crates/gateway/src/gateway.rs line 208 at r1 (raw file):

            Ok(_) => Ok(()),
            Err(_) => Err(ComponentStartError::InternalComponentError),
        }

Please check out the map_err syntax, should be useful here.

Code quote:

        match self.run().await {
            Ok(_) => Ok(()),
            Err(_) => Err(ComponentStartError::InternalComponentError),
        }

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware 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: 0 of 6 files reviewed, 3 unresolved discussions (waiting on @lev-starkware)


crates/mempool_node/src/main.rs line 12 at r1 (raw file):

#[tokio::main]
async fn main() -> anyhow::Result<()> {

Why is anyhow required here?

ChatGPT suggested the following, does this remove the need for the anyhow dependency?

use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    // Your async code here

    Ok(())
}

Code quote:

anyhow::Result<()>

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware 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: 0 of 6 files reviewed, 4 unresolved discussions (waiting on @lev-starkware)


crates/mempool_node/src/main.rs line 14 at r1 (raw file):

async fn main() -> anyhow::Result<()> {
    let config = MempoolNodeConfig::load_and_process(args().collect());
    if let Err(ConfigError::CommandInput(clap_err)) = config {

What does this stand for?

Code quote:

clap_err

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware 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: 0 of 6 files reviewed, 5 unresolved discussions (waiting on @lev-starkware)


crates/mempool_node/src/main.rs line 21 at r1 (raw file):

    if let Err(error) = config_validate(&config) {
        println!("Error: {}", error);
        exit(1);

Where does this error code originates from? Or was it an arbitrary choice?

Code quote:

exit(1);

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware 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: 0 of 6 files reviewed, 6 unresolved discussions (waiting on @lev-starkware)


crates/mempool_node/src/main.rs line 32 at r1 (raw file):

    run_server_components(&config, servers).await?;

    Ok(())

This should never return, right?

@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch from 72c8507 to 97c0957 Compare July 1, 2024 16:59
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/0f64f96b branch 2 times, most recently from fdfe74c to ddc76ad Compare July 1, 2024 18:12
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch from 97c0957 to 36c6040 Compare July 1, 2024 18:12
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch from 36c6040 to fd692f7 Compare July 2, 2024 11:20
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/0f64f96b branch 2 times, most recently from 354900e to 533cacb Compare July 2, 2024 11:30
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch from fd692f7 to 91ed2a2 Compare July 2, 2024 11:30
@lev-starkware lev-starkware changed the base branch from pr/lev-starkware/lev_dev/0f64f96b to main July 3, 2024 13:44
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch from 91ed2a2 to 41d8bd2 Compare July 3, 2024 13:44
@lev-starkware lev-starkware changed the title feat: adding main module feat: feat: adding main module Jul 3, 2024
@lev-starkware lev-starkware changed the base branch from main to pr/lev-starkware/lev_dev/f9f21462 July 3, 2024 13:44
Copy link
Contributor Author

@lev-starkware lev-starkware 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: 0 of 6 files reviewed, 6 unresolved discussions (waiting on @Itay-Tsabary-Starkware)


crates/mempool_node/src/main.rs line 12 at r1 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Why is anyhow required here?

ChatGPT suggested the following, does this remove the need for the anyhow dependency?

use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    // Your async code here

    Ok(())
}

This is how its done in the papyrus main.


crates/mempool_node/src/main.rs line 14 at r1 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

What does this stand for?

I command line argument parsing error.


crates/mempool_node/src/main.rs line 21 at r1 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Where does this error code originates from? Or was it an arbitrary choice?

In case config validation returns error we cannot continue.


crates/mempool_node/src/main.rs line 32 at r1 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

This should never return, right?

Right, but once more, went after papyrus main.


crates/gateway/src/gateway.rs line 85 at r1 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Please create a different pr solely for these changes.

Done.


crates/gateway/src/gateway.rs line 208 at r1 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Please check out the map_err syntax, should be useful here.

Done.

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware 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 2 of 6 files at r1, 4 of 4 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lev-starkware)

Copy link
Contributor

@uriel-starkware uriel-starkware 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, 1 unresolved discussion (waiting on @lev-starkware)


crates/mempool_node/src/main.rs line 32 at r1 (raw file):

Previously, lev-starkware wrote…

Right, but once more, went after papyrus main.

if run\_server\_components(&config, servers).await returns the same result as main then no need for ?; and then Ok(()). Change to:

Code snippet:

run_server_components(&config, servers).await

Copy link
Contributor

@uriel-starkware uriel-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lev-starkware)

@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch from 41d8bd2 to 0c0e3af Compare July 4, 2024 14:08
@lev-starkware lev-starkware changed the base branch from pr/lev-starkware/lev_dev/f9f21462 to main July 4, 2024 14:20
@lev-starkware lev-starkware changed the base branch from main to pr/lev-starkware/lev_dev/f9f21462 July 4, 2024 14:21
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch from 0c0e3af to 68e753e Compare July 4, 2024 14:21
Copy link
Contributor Author

@lev-starkware lev-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 6 files at r1, 2 of 4 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lev-starkware)

@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/f9f21462 branch from b943062 to 49daaf3 Compare July 4, 2024 17:15
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch from 68e753e to 21bf365 Compare July 4, 2024 17:15
@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/8df0f3c6 branch from 21bf365 to e89ace6 Compare July 7, 2024 10:11
@lev-starkware
Copy link
Contributor Author

✓ Commit merged in pull request #339

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