Skip to content

multi: refactor mailbox item handling, more logs #40

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/app.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, sync::Arc};
use std::{collections::HashMap, sync::Arc, time::Duration};

use futures::{StreamExt, TryFutureExt};
use parking_lot::RwLock;
Expand Down Expand Up @@ -206,6 +206,7 @@ impl App {
format!("{}", config.mainchain_grpc_url),
)
.unwrap()
.timeout(Duration::from_secs(10))
.concurrency_limit(256)
.connect_lazy();
let (cusf_mainchain, cusf_mainchain_wallet) = if runtime
Expand Down
1 change: 1 addition & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ tokio-util = { workspace = true, features = ["rt"] }
tonic = { workspace = true }
tracing = { workspace = true }
utoipa = { workspace = true, features = ["macros", "non_strict_integers"] }
uuid = { workspace = true }

[lints]
workspace = true
Expand Down
6 changes: 4 additions & 2 deletions lib/net/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl std::fmt::Display for PeerStateId {
}
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, strum::Display)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if a Display impl is a good idea here, debug should be enough.
If you just want to show the discriminant, use https://docs.rs/strum/latest/strum/derive.EnumDiscriminants.html and https://docs.rs/strum/latest/strum/trait.IntoDiscriminant.html

pub enum Response {
Block {
header: Header,
Expand All @@ -157,7 +157,9 @@ pub enum Response {
TransactionRejected(Txid),
}

#[derive(BorshSerialize, Clone, Debug, Deserialize, Serialize)]
#[derive(
BorshSerialize, Clone, Debug, Deserialize, Serialize, strum::Display,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if a Display impl is a good idea here, debug should be enough.
If you just want to show the discriminant, use https://docs.rs/strum/latest/strum/derive.EnumDiscriminants.html and https://docs.rs/strum/latest/strum/trait.IntoDiscriminant.html

)]
pub enum Request {
Heartbeat(PeerState),
GetBlock {
Expand Down
16 changes: 9 additions & 7 deletions lib/node/mainchain_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use tokio::{
spawn,
task::{self, JoinHandle},
};
use tracing::instrument;

use crate::{
archive::{self, Archive},
Expand Down Expand Up @@ -166,6 +167,7 @@ where
/// up to and including the specified block.
/// Mainchain headers for the specified block and all ancestors MUST exist
/// in the archive.
#[instrument(skip_all, fields(main_hash), err)]
async fn request_bmm_commitments(
env: &sneed::Env,
archive: &Archive,
Expand Down Expand Up @@ -196,10 +198,10 @@ where
.collect()?
};
missing_commitments.reverse();
tracing::debug!(%main_hash, "requesting ancestor bmm commitments");
tracing::debug!("requesting ancestor BMM commitments");
for missing_commitment in missing_commitments {
tracing::trace!(%main_hash,
"requesting ancestor bmm commitment: {missing_commitment}"
tracing::trace!(
"requesting ancestor BMM commitment: {missing_commitment}"
);
let commitment = match mainchain
.get_bmm_hstar_commitments(missing_commitment)
Expand All @@ -208,8 +210,8 @@ where
Ok(commitment) => commitment,
Err(block_not_found) => return Ok(Err(block_not_found)),
};
tracing::trace!(%main_hash,
"storing ancestor bmm commitment: {missing_commitment}"
tracing::trace!(
"storing ancestor BMM commitment: {missing_commitment}"
);
{
let mut rwtxn = env.write_txn().map_err(EnvError::from)?;
Expand All @@ -220,8 +222,8 @@ where
)?;
rwtxn.commit().map_err(RwTxnError::from)?;
}
tracing::trace!(%main_hash,
"stored ancestor bmm commitment: {missing_commitment}"
tracing::trace!(
"stored ancestor BMM commitment: {missing_commitment}"
);
}
Ok(Ok(()))
Expand Down
Loading