From 6ad35918de644fc0543e407cd2ffd26715ca71b0 Mon Sep 17 00:00:00 2001 From: pauldelucia Date: Tue, 18 Feb 2025 15:51:42 +0700 Subject: [PATCH 1/3] fix: used the wrong identity to set amount of frozen funds to destroy --- .../v0/transformer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs index 0b0ee7adbec..07ad9e32ecf 100644 --- a/packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs @@ -82,7 +82,7 @@ impl TokenDestroyFrozenFundsTransitionActionV0 { let maybe_token_amount = drive.fetch_identity_token_balance_operations( base.token_id().to_buffer(), - owner_id.to_buffer(), + frozen_identity_id.to_buffer(), !approximate_without_state_for_costs, transaction, &mut drive_operations, @@ -228,7 +228,7 @@ impl TokenDestroyFrozenFundsTransitionActionV0 { let maybe_token_amount = drive.fetch_identity_token_balance_operations( base.token_id().to_buffer(), - owner_id.to_buffer(), + frozen_identity_id.to_buffer(), !approximate_without_state_for_costs, transaction, &mut drive_operations, From 0c9d66db5e9a725b7a0ee9c741b02d3fcf573f3b Mon Sep 17 00:00:00 2001 From: pauldelucia Date: Tue, 18 Feb 2025 17:43:38 +0700 Subject: [PATCH 2/3] fix: proof was checking for None but we get Some with zero balance --- .../v0/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs b/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs index d579d94dc15..571eaff6a35 100644 --- a/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs +++ b/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs @@ -461,7 +461,7 @@ impl Drive { TokenTransition::DestroyFrozenFunds( destroy_frozen_funds_transition, ) => { - let (root_hash, None) = + let (root_hash, maybe_token_amount) = Drive::verify_token_balance_for_identity_id( proof, token_id.into_buffer(), @@ -470,10 +470,12 @@ impl Drive { .into_buffer(), false, platform_version, - )? - else { + )?; + if !(maybe_token_amount == Some(0) + || maybe_token_amount == None) + { return Err(Error::Proof(ProofError::IncorrectProof( - format!("proof contained token balance for identity {} expected to not exist because of state transition (token destroy frozen funds)", owner_id)))); + format!("proof contained non-zero token balance for identity {} expected to be zero or not exist because of state transition (token destroy frozen funds)", destroy_frozen_funds_transition.frozen_identity_id())))); }; Ok(( root_hash, From 0f588296e5ae71ffcf4629ebb8d76408a760d438 Mon Sep 17 00:00:00 2001 From: pauldelucia Date: Wed, 19 Feb 2025 09:58:03 +0700 Subject: [PATCH 3/3] fix: only accept zero balance for proof --- .../v0/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs b/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs index 571eaff6a35..c52ae174cee 100644 --- a/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs +++ b/packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs @@ -471,11 +471,9 @@ impl Drive { false, platform_version, )?; - if !(maybe_token_amount == Some(0) - || maybe_token_amount == None) - { + if maybe_token_amount != Some(0) { return Err(Error::Proof(ProofError::IncorrectProof( - format!("proof contained non-zero token balance for identity {} expected to be zero or not exist because of state transition (token destroy frozen funds)", destroy_frozen_funds_transition.frozen_identity_id())))); + format!("proof contained non-zero token balance for identity {} expected to be zero because of state transition (token destroy frozen funds)", destroy_frozen_funds_transition.frozen_identity_id())))); }; Ok(( root_hash,