From f8cadcbdf3231058d314fcf41efb1986865d5072 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 3 Oct 2024 12:08:42 +0300 Subject: [PATCH 1/4] chore(drive): improve withdrawal logging --- .../v0/mod.rs | 30 +++++++++++-------- .../v0/mod.rs | 4 +-- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs index d84db00848..4f85ae38a3 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs @@ -31,7 +31,7 @@ where } tracing::debug!( - "Broadcasting {} withdrawal transactions", + "Broadcasting {} asset unlock transactions", withdrawal_transactions_with_vote_extensions.len(), ); @@ -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); @@ -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" ); } // Handle specific errors @@ -92,7 +94,8 @@ where { tracing::debug!( tx_id = transaction.txid().to_string(), - "Asset unlock is expired or has no active quorum: {}", + tx_index, + "Asset unlock transaction is expired or has no active quorum: {}", e.message ); transaction_submission_failures.push((transaction.txid(), tx_bytes)); @@ -101,6 +104,7 @@ where Err(e) => { tracing::warn!( tx_id = transaction.txid().to_string(), + tx_index, "Failed to broadcast asset unlock transaction: {}", e ); diff --git a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/v0/mod.rs index 011867a872..d8949a06a0 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/v0/mod.rs @@ -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(()); From e8262af5e448227ee7b49603b0ca87419f0d1dc2 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 3 Oct 2024 14:56:34 +0300 Subject: [PATCH 2/4] chore: add error to log code and data as well --- .../v0/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs index 4f85ae38a3..ca5ba818aa 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs @@ -95,6 +95,7 @@ where tracing::debug!( tx_id = transaction.txid().to_string(), tx_index, + error = ?e, "Asset unlock transaction is expired or has no active quorum: {}", e.message ); From 0d23614975dcd5724718eda4f94bbffc8de38514 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 3 Oct 2024 14:57:11 +0300 Subject: [PATCH 3/4] chore: tx_index to broadcast message --- .../v0/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs index ca5ba818aa..c5e1763003 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs @@ -79,7 +79,7 @@ where tracing::debug!( tx_id = transaction.txid().to_hex(), tx_index, - "Successfully broadcasted asset unlock transaction" + "Successfully broadcasted asset unlock transaction with index {tx_index}", ); } // Handle specific errors From 34cc64e0ed6c176b4c7f195cadd1ef9f1fe160bd Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 3 Oct 2024 14:57:55 +0300 Subject: [PATCH 4/4] chore: add indexes to other messages --- .../v0/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs index c5e1763003..1f6cacbc2b 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/append_signatures_and_broadcast_withdrawal_transactions/v0/mod.rs @@ -96,7 +96,7 @@ where tx_id = transaction.txid().to_string(), tx_index, error = ?e, - "Asset unlock transaction is expired or has no active quorum: {}", + "Asset unlock transaction with index {tx_index} is expired or has no active quorum: {}", e.message ); transaction_submission_failures.push((transaction.txid(), tx_bytes)); @@ -106,7 +106,7 @@ where tracing::warn!( tx_id = transaction.txid().to_string(), tx_index, - "Failed to broadcast asset unlock transaction: {}", + "Failed to broadcast asset unlock transaction with index {tx_index}: {}", e ); // Collect failed transactions for potential future retries