Skip to content

Commit

Permalink
chore(drive): improve withdrawal logging (#2203)
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov authored Oct 3, 2024
1 parent 3404f59 commit 6230b53
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ where
}

tracing::debug!(
"Broadcasting {} withdrawal transactions",
"Broadcasting {} asset unlock transactions",
withdrawal_transactions_with_vote_extensions.len(),
);

Expand All @@ -55,19 +55,20 @@ where
let signature = BLSSignature::from(signature_bytes);

// Modify the transaction's payload
if let Some(AssetUnlockPayloadType(mut payload)) =
transaction.special_transaction_payload
{
// Assign the quorum signature
payload.quorum_sig = signature;

// Assign the modified payload back to the transaction
transaction.special_transaction_payload = Some(AssetUnlockPayloadType(payload));
} else {
let Some(AssetUnlockPayloadType(mut payload)) = transaction.special_transaction_payload
else {
return Err(Error::Execution(ExecutionError::CorruptedCachedState(
"withdrawal transaction payload must be AssetUnlockPayloadType".to_string(),
)));
}
};

// Assign the quorum signature
payload.quorum_sig = signature;

let tx_index = payload.base.index;

// Assign the modified payload back to the transaction
transaction.special_transaction_payload = Some(AssetUnlockPayloadType(payload));

// Serialize the transaction
let tx_bytes = consensus::serialize(&transaction);
Expand All @@ -77,7 +78,8 @@ where
Ok(_) => {
tracing::debug!(
tx_id = transaction.txid().to_hex(),
"Successfully broadcasted withdrawal transaction"
tx_index,
"Successfully broadcasted asset unlock transaction with index {tx_index}",
);
}
// Handle specific errors
Expand All @@ -92,7 +94,9 @@ where
{
tracing::debug!(
tx_id = transaction.txid().to_string(),
"Asset unlock is expired or has no active quorum: {}",
tx_index,
error = ?e,
"Asset unlock transaction with index {tx_index} is expired or has no active quorum: {}",
e.message
);
transaction_submission_failures.push((transaction.txid(), tx_bytes));
Expand All @@ -101,7 +105,8 @@ where
Err(e) => {
tracing::warn!(
tx_id = transaction.txid().to_string(),
"Failed to broadcast asset unlock transaction: {}",
tx_index,
"Failed to broadcast asset unlock transaction with index {tx_index}: {}",
e
);
// Collect failed transactions for potential future retries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ where
let Some(position_of_current_quorum) =
last_committed_platform_state.current_validator_set_position_in_list_by_most_recent()
else {
tracing::warn!("Current quorum not in current validator set, not making withdrawals");
tracing::warn!("Current quorum not in current validator set, do not re-broadcast expired withdrawals");
return Ok(());
};
if position_of_current_quorum != 0 {
tracing::debug!(
"Current quorum is not most recent, it is in position {}, not making withdrawals",
"Current quorum is not most recent, it is in position {}, do not re-broadcast expired withdrawals",
position_of_current_quorum
);
return Ok(());
Expand Down

0 comments on commit 6230b53

Please sign in to comment.