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

chore(drive): additional logging and minor refactoring #1947

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,19 @@ pub(super) fn verify_recent_instant_lock_signature_locally_v0(
)))
})?;

let mut selected_quorums_for_logging = Vec::new();
if tracing::enabled!(tracing::Level::TRACE) {
selected_quorums_for_logging = Vec::from_iter(selected_quorums.clone());
}

for (i, quorums) in selected_quorums.enumerate() {
let Some((quorum_hash, quorum)) = quorums.choose_quorum(request_id.as_ref()) else {
if tracing::enabled!(tracing::Level::TRACE) {
tracing::trace!(
quorums_iteration = i + 1,
selected_quorums = ?selected_quorums_for_logging,
instant_lock = ?InstantLockDebug(instant_lock),
?quorum_set,
request_id = request_id.to_string(),
quorums = ?quorums.quorums,
request_id = request_id.to_string(),
Expand Down Expand Up @@ -99,9 +106,10 @@ pub(super) fn verify_recent_instant_lock_signature_locally_v0(
if tracing::enabled!(tracing::Level::TRACE) {
tracing::trace!(
quorums_iteration = i + 1,
selected_quorums = ?selected_quorums_for_logging,
instant_lock = ?InstantLockDebug(instant_lock),
?quorum_set,
quorum_hash = quorum_hash.to_string(),
quorum_config = ?quorum_set.config(),
quorum = ?quorum,
request_id = request_id.to_string(),
message_digest = message_digest.to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<C> Platform<C> {
total_hpmns,
required_upgraded_hpmns,
all_votes = ?protocol_versions_counter.global_cache,
versions_passing_threshold = versions_passing_threshold.len(),
?versions_passing_threshold,
"Protocol version voting is finished. {} versions passing the threshold: {:?}",
versions_passing_threshold.len(),
versions_passing_threshold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ impl<C> Platform<C> {
"Next protocol version set to {}",
protocol_version
);

block_platform_state.set_next_epoch_protocol_version(protocol_version);
} else {
tracing::trace!(
current_epoch_index = epoch_info.current_epoch_index(),
"Non of the votes reached threshold. Next protocol version remains the same {}",
block_platform_state.next_epoch_protocol_version()
);
}

// Since we are starting a new epoch we need to drop previously
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ where
}
// Errors that can happen if we created invalid tx or Core isn't responding
Err(e) => {
tracing::error!(
tracing::warn!(
tx_id = transaction.txid().to_string(),
index,
"Failed to broadcast asset unlock transaction {}: {}",
Expand Down Expand Up @@ -114,6 +114,12 @@ fn store_transaction_failures(
return Ok(());
}

tracing::trace!(
"Store {} Asset Unlock transaction submission failures in {}",
failures.len(),
dir_path.display()
);

// Ensure the directory exists
fs::create_dir_all(dir_path).map_err(|e| {
std::io::Error::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl From<QuorumConfigForSavingV0> for QuorumConfig {
#[derive(Debug, Clone, Encode, Decode)]
pub struct PreviousPastQuorumsForSavingV0 {
quorums: Vec<QuorumForSavingV0>,
active_core_height: u32,
last_active_core_height: u32,
updated_at_core_height: u32,
previous_change_height: Option<u32>,
}
Expand All @@ -99,14 +99,14 @@ impl From<PreviousPastQuorumsV0> for PreviousPastQuorumsForSavingV0 {
fn from(value: PreviousPastQuorumsV0) -> Self {
let PreviousPastQuorumsV0 {
quorums,
active_core_height,
last_active_core_height,
updated_at_core_height,
previous_change_height,
} = value;

Self {
quorums: quorums.into(),
active_core_height,
last_active_core_height,
updated_at_core_height,
previous_change_height,
}
Expand All @@ -117,14 +117,14 @@ impl From<PreviousPastQuorumsForSavingV0> for PreviousPastQuorumsV0 {
fn from(value: PreviousPastQuorumsForSavingV0) -> Self {
let PreviousPastQuorumsForSavingV0 {
quorums,
active_core_height,
last_active_core_height: active_core_height,
updated_at_core_height,
previous_change_height,
} = value;

Self {
quorums: quorums.into(),
active_core_height,
last_active_core_height: active_core_height,
updated_at_core_height,
previous_change_height,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(super) struct PreviousPastQuorumsV0 {
pub(super) quorums: Quorums<VerificationQuorum>,

/// The core height at which these quorums were last active
pub(super) active_core_height: u32,
pub(super) last_active_core_height: u32,

/// The core height when the quorums were changed
pub(super) updated_at_core_height: u32,
Expand Down Expand Up @@ -80,6 +80,7 @@ pub trait SignatureVerificationQuorumSetV0Methods {
}

/// Iterator over selected quorum sets and specific quorums based on request_id and quorum configuration
#[derive(Clone)]
pub struct SelectedQuorumSetIterator<'q> {
/// Quorum configuration
config: &'q QuorumConfig,
Expand All @@ -101,6 +102,7 @@ impl<'q> Iterator for SelectedQuorumSetIterator<'q> {
}

/// Quorums with configuration
#[derive(Debug)]
pub struct QuorumsWithConfig<'q> {
/// Quorums
pub quorums: &'q Quorums<VerificationQuorum>,
Expand Down Expand Up @@ -191,14 +193,16 @@ impl SignatureVerificationQuorumSetV0Methods for SignatureVerificationQuorumSetV
last_active_core_height: u32,
updated_at_core_height: u32,
) {
let previous_change_height = self
.previous
.as_ref()
.map(|previous| previous.updated_at_core_height);

self.previous = Some(PreviousPastQuorumsV0 {
quorums: previous_quorums,
active_core_height: last_active_core_height,
last_active_core_height,
updated_at_core_height,
previous_change_height: self
.previous
.as_ref()
.map(|previous| previous.updated_at_core_height),
previous_change_height,
});
}

Expand All @@ -211,7 +215,7 @@ impl SignatureVerificationQuorumSetV0Methods for SignatureVerificationQuorumSetV
let mut should_be_verifiable = false;

if let Some(previous) = &self.previous {
let previous_quorum_height = previous.active_core_height;
let previous_quorum_height = previous.last_active_core_height;
let change_quorum_height = previous.updated_at_core_height;
let previous_quorums_change_height = previous.previous_change_height;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bincode::{Decode, Encode};

pub mod v1;

#[derive(Clone, Debug, Encode, Decode, Default, PartialEq, Eq)]
#[derive(Clone, Debug, Default, Encode, Decode, PartialEq, Eq)]
pub struct FeeDataContractValidationVersion {
pub document_type_base_fee: u64,
pub document_type_size_fee: u64,
Expand Down
Loading