diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/fetch_documents.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/fetch_documents.rs index 75f5abfe02..1b55ac6a67 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/fetch_documents.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/fetch_documents.rs @@ -95,8 +95,6 @@ pub(crate) fn fetch_documents_for_transitions_knowing_contract_id_and_document_t )); }; - let contract_fetch_info = contract_fetch_info; - let Some(document_type) = contract_fetch_info .contract .document_type_optional_for_name(document_type_name) diff --git a/packages/rs-drive/Cargo.toml b/packages/rs-drive/Cargo.toml index c923db94d8..fbc4013db5 100644 --- a/packages/rs-drive/Cargo.toml +++ b/packages/rs-drive/Cargo.toml @@ -91,4 +91,5 @@ full = [ "rust_decimal_macros", "lazy_static", ] +grovedb_operations_logging = [] verify = ["grovedb/verify", "grovedb-costs"] diff --git a/packages/rs-drive/src/drive/grove_operations/grove_apply_batch_with_add_costs/v0/mod.rs b/packages/rs-drive/src/drive/grove_operations/grove_apply_batch_with_add_costs/v0/mod.rs index 0763f56fe8..d1c696c920 100644 --- a/packages/rs-drive/src/drive/grove_operations/grove_apply_batch_with_add_costs/v0/mod.rs +++ b/packages/rs-drive/src/drive/grove_operations/grove_apply_batch_with_add_costs/v0/mod.rs @@ -11,6 +11,7 @@ use grovedb::batch::{BatchApplyOptions, GroveDbOp}; use grovedb::TransactionArg; use grovedb_costs::storage_cost::removal::StorageRemovedBytes::BasicStorageRemoval; use grovedb_costs::storage_cost::transition::OperationStorageTransitionType; +use tracing::Level; impl Drive { /// Applies the given groveDB operations batch and gets and passes the costs to `push_drive_operation_result`. @@ -42,6 +43,15 @@ impl Drive { } } + // Clone ops only if we log them + #[cfg(feature = "grovedb_operations_logging")] + let maybe_ops_for_logs = if tracing::event_enabled!(target: "grovedb_operations", Level::TRACE) + { + Some(ops.clone()) + } else { + None + }; + let cost_context = self.grove.apply_batch_with_element_flags_update( ops.operations, Some(BatchApplyOptions { @@ -140,6 +150,26 @@ impl Drive { }, transaction, ); + + #[cfg(feature = "grovedb_operations_logging")] + if tracing::event_enabled!(target: "grovedb_operations", Level::TRACE) + && cost_context.value.is_ok() + { + let root_hash = self + .grove + .root_hash(transaction) + .unwrap() + .map_err(Error::GroveDB)?; + + tracing::trace!( + target = "grovedb_operations", + ops = ?maybe_ops_for_logs.unwrap(), + root_hash = ?root_hash, + is_transactional = transaction.is_some(), + "grovedb batch applied", + ); + } + push_drive_operation_result(cost_context, drive_operations) } } diff --git a/packages/rs-drive/src/drive/grove_operations/grove_clear/v0/mod.rs b/packages/rs-drive/src/drive/grove_operations/grove_clear/v0/mod.rs index 9777b56744..1b41f82bf6 100644 --- a/packages/rs-drive/src/drive/grove_operations/grove_clear/v0/mod.rs +++ b/packages/rs-drive/src/drive/grove_operations/grove_clear/v0/mod.rs @@ -3,6 +3,7 @@ use crate::error::Error; use grovedb::operations::delete::ClearOptions; use grovedb::TransactionArg; use grovedb_path::SubtreePath; +use tracing::Level; impl Drive { /// Pushes the `OperationCost` of deleting an element in groveDB to `drive_operations`. @@ -16,10 +17,39 @@ impl Drive { allow_deleting_subtrees: false, trying_to_clear_with_subtrees_returns_error: false, }; + + #[cfg(feature = "grovedb_operations_logging")] + let maybe_path_for_logs = if tracing::event_enabled!(target: "grovedb_operations", Level::TRACE) + { + Some(path.clone()) + } else { + None + }; + // we will always return true if there is no error when we don't check for subtrees - self.grove + let result = self + .grove .clear_subtree(path, Some(options), transaction) .map_err(Error::GroveDB) - .map(|_| ()) + .map(|_| ()); + + #[cfg(feature = "grovedb_operations_logging")] + if tracing::event_enabled!(target: "grovedb_operations", Level::TRACE) && result.is_ok() { + let root_hash = self + .grove + .root_hash(transaction) + .unwrap() + .map_err(Error::GroveDB)?; + + tracing::trace!( + target = "grovedb_operations", + path = ?maybe_path_for_logs.unwrap().to_vec(), + root_hash = ?root_hash, + is_transactional = transaction.is_some(), + "grovedb clear", + ); + } + + result } }