-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: feat: adding main module #311
Conversation
Codecov ReportAttention: Patch coverage is
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. |
3141333
to
e349a16
Compare
778c186
to
4bd2b80
Compare
c125404
to
28e75b8
Compare
8525b93
to
ba88c86
Compare
28e75b8
to
72c8507
Compare
There was a problem hiding this 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),
}
There was a problem hiding this 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<()>
There was a problem hiding this 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
There was a problem hiding this 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);
There was a problem hiding this 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?
72c8507
to
97c0957
Compare
fdfe74c
to
ddc76ad
Compare
97c0957
to
36c6040
Compare
36c6040
to
fd692f7
Compare
354900e
to
533cacb
Compare
fd692f7
to
91ed2a2
Compare
91ed2a2
to
41d8bd2
Compare
There was a problem hiding this 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.
There was a problem hiding this 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, 4 of 4 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @lev-starkware)
There was a problem hiding this 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @lev-starkware)
41d8bd2
to
0c0e3af
Compare
0c0e3af
to
68e753e
Compare
There was a problem hiding this 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: complete! all files reviewed, all discussions resolved (waiting on @lev-starkware)
b943062
to
49daaf3
Compare
68e753e
to
21bf365
Compare
commit-id:8df0f3c6
21bf365
to
e89ace6
Compare
✓ Commit merged in pull request #339 |
Stack:
This change is