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

Logs, log levels #797

Merged
merged 17 commits into from
Aug 8, 2024
11 changes: 6 additions & 5 deletions chain-signatures/node/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ async fn handle_block(
mut block: near_lake_primitives::block::Block,
ctx: &Context,
) -> anyhow::Result<()> {
tracing::debug!(block_height = block.block_height(), "handle_block");
let mut pending_requests = Vec::new();
for action in block.actions().cloned().collect::<Vec<_>>() {
if action.receiver_id() == ctx.mpc_contract_id {
Expand Down Expand Up @@ -205,10 +206,13 @@ async fn handle_block(
continue;
};

let Ok(entropy) = serde_json::from_str::<'_, [u8; 32]>(&receipt.logs()[1]) else {
let entropy_log_index = 1;
let Ok(entropy) =
serde_json::from_str::<'_, [u8; 32]>(&receipt.logs()[entropy_log_index])
else {
tracing::warn!(
"`sign` did not produce entropy correctly: {:?}",
receipt.logs()[0]
receipt.logs()[entropy_log_index]
);
continue;
};
Expand Down Expand Up @@ -260,9 +264,6 @@ async fn handle_block(
}
drop(queue);

if block.block_height() % 1000 == 0 {
tracing::info!(block_height = block.block_height(), "indexed block");
}
volovyks marked this conversation as resolved.
Show resolved Hide resolved
Ok(())
}

Expand Down
15 changes: 15 additions & 0 deletions chain-signatures/node/src/mesh/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl Pool {
}
}

tracing::debug!("pinging participants");
volovyks marked this conversation as resolved.
Show resolved Hide resolved
let connections = self.connections.read().await;

let mut status = self.status.write().await;
Expand Down Expand Up @@ -74,6 +75,10 @@ impl Pool {

let mut active = self.current_active.write().await;
*active = Some((participants.clone(), Instant::now()));
tracing::debug!(
"active participant account id's {:?}",
participants.account_ids()
);
participants
}

Expand All @@ -84,6 +89,8 @@ impl Pool {
}
}

tracing::debug!("pinging potential participants");
volovyks marked this conversation as resolved.
Show resolved Hide resolved

let connections = self.potential_connections.read().await;

let mut status = self.status.write().await;
Expand All @@ -108,6 +115,10 @@ impl Pool {

let mut potential_active = self.potential_active.write().await;
*potential_active = Some((participants.clone(), Instant::now()));
tracing::debug!(
"potential participant account id's {:?}",
participants.account_ids()
);
volovyks marked this conversation as resolved.
Show resolved Hide resolved
participants
}

Expand Down Expand Up @@ -143,6 +154,10 @@ impl Pool {

async fn set_potential_participants(&self, participants: &Participants) {
*self.potential_connections.write().await = participants.clone();
tracing::debug!(
"Pool set potential participants to {:?}",
self.potential_connections.read().await.keys_vec()
);
}
volovyks marked this conversation as resolved.
Show resolved Hide resolved

pub async fn potential_participants(&self) -> Participants {
Expand Down
4 changes: 0 additions & 4 deletions chain-signatures/node/src/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ impl Mesh {
/// Ping the active participants such that we can see who is alive.
pub async fn ping(&mut self) {
self.active_participants = self.connections.ping().await;
tracing::debug!(
"Mesh.ping set active participants to {:?}",
self.active_participants.keys_vec()
);
self.active_potential_participants = self.connections.ping_potential().await;
}
}
5 changes: 4 additions & 1 deletion chain-signatures/node/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub async fn fetch_mpc_contract_state(
) -> anyhow::Result<ProtocolState> {
let protocol_state: mpc_contract::ProtocolContractState =
rpc_client.view(mpc_contract_id, "state").await?.json()?;
tracing::debug!(?protocol_state, "fetched protocol state");
volovyks marked this conversation as resolved.
Show resolved Hide resolved
protocol_state
.try_into()
.map_err(|_| anyhow::anyhow!("protocol state has not been initialized yet"))
Expand All @@ -24,6 +25,7 @@ pub async fn fetch_mpc_config(
) -> anyhow::Result<Config> {
let contract_config: ContractConfig =
rpc_client.view(mpc_contract_id, "config").await?.json()?;
tracing::debug!(?contract_config, "fetched contract config");
Config::try_from_contract(contract_config, original)
.ok_or_else(|| anyhow::anyhow!("failed to parse contract config"))
}
Expand All @@ -34,7 +36,7 @@ pub async fn vote_for_public_key(
mpc_contract_id: &AccountId,
public_key: &near_crypto::PublicKey,
) -> anyhow::Result<bool> {
tracing::info!(%public_key, "voting for public key");
tracing::info!(%public_key, %signer.account_id, "voting for public key");
let result = rpc_client
.call(signer, mpc_contract_id, "vote_pk")
.args_json(json!({
Expand All @@ -55,6 +57,7 @@ pub async fn vote_reshared(
mpc_contract_id: &AccountId,
epoch: u64,
) -> anyhow::Result<bool> {
tracing::info!(%epoch, %signer.account_id, "voting for reshared");
let result = rpc_client
.call(signer, mpc_contract_id, "vote_reshared")
.args_json(json!({
Expand Down
Loading