diff --git a/crates/core/app/src/action_handler/transaction.rs b/crates/core/app/src/action_handler/transaction.rs index 0a4b6a6cb1..80e8a97568 100644 --- a/crates/core/app/src/action_handler/transaction.rs +++ b/crates/core/app/src/action_handler/transaction.rs @@ -4,7 +4,7 @@ use anyhow::Result; use async_trait::async_trait; use cnidarium::{StateRead, StateWrite}; use penumbra_sdk_fee::component::FeePay as _; -use penumbra_sdk_sct::{component::source::SourceContext, CommitmentSource}; +use penumbra_sdk_sct::component::source::SourceContext; use penumbra_sdk_shielded_pool::component::ClueManager; use penumbra_sdk_transaction::{gas::GasCost as _, Transaction}; use tokio::task::JoinSet; @@ -107,10 +107,7 @@ impl AppActionHandler for Transaction { async fn check_and_execute(&self, mut state: S) -> Result<()> { // While we have access to the full Transaction, hash it to // obtain a NoteSource we can cache for various actions. - let source = CommitmentSource::Transaction { - id: Some(self.id().0), - }; - state.put_current_source(Some(source)); + state.put_current_source(Some(self.id())); // Check and record the transaction's fee payment, // before doing the rest of execution. diff --git a/crates/core/component/dex/src/component/action_handler/swap.rs b/crates/core/component/dex/src/component/action_handler/swap.rs index 1ca8de7fda..64187d1fc8 100644 --- a/crates/core/component/dex/src/component/action_handler/swap.rs +++ b/crates/core/component/dex/src/component/action_handler/swap.rs @@ -55,7 +55,7 @@ impl ActionHandler for Swap { // Record the swap commitment in the state. let source = state.get_current_source().expect("source is set"); state - .add_swap_payload(self.body.payload.clone(), source) + .add_swap_payload(self.body.payload.clone(), source.into()) .await; // Mark the assets for the swap's trading pair as accessed during this block. diff --git a/crates/core/component/dex/src/component/action_handler/swap_claim.rs b/crates/core/component/dex/src/component/action_handler/swap_claim.rs index 4b83ee9e7e..5a40f037b2 100644 --- a/crates/core/component/dex/src/component/action_handler/swap_claim.rs +++ b/crates/core/component/dex/src/component/action_handler/swap_claim.rs @@ -87,13 +87,13 @@ impl ActionHandler for SwapClaim { .expect("source is set during tx execution"); state - .add_rolled_up_payload(self.body.output_1_commitment, source.clone()) + .add_rolled_up_payload(self.body.output_1_commitment, source.into()) .await; state - .add_rolled_up_payload(self.body.output_2_commitment, source.clone()) + .add_rolled_up_payload(self.body.output_2_commitment, source.into()) .await; - state.nullify(self.body.nullifier, source).await; + state.nullify(self.body.nullifier, source.into()).await; state.record_proto(event::EventSwapClaim::from(self).to_proto()); diff --git a/crates/core/component/sct/src/component/source.rs b/crates/core/component/sct/src/component/source.rs index 0a94977d50..e5d5485757 100644 --- a/crates/core/component/sct/src/component/source.rs +++ b/crates/core/component/sct/src/component/source.rs @@ -1,12 +1,13 @@ use async_trait::async_trait; use cnidarium::StateWrite; +use penumbra_sdk_txhash::TransactionId; -use crate::{state_key, CommitmentSource}; +use crate::state_key; -/// A helper trait for placing a `CommitmentSource` as ambient context during execution. +/// A helper trait for placing a transaction id as an ambient source during execution. #[async_trait] pub trait SourceContext: StateWrite { - fn put_current_source(&mut self, source: Option) { + fn put_current_source(&mut self, source: Option) { if let Some(source) = source { self.object_put(state_key::ambient::current_source(), source) } else { @@ -14,7 +15,7 @@ pub trait SourceContext: StateWrite { } } - fn get_current_source(&self) -> Option { + fn get_current_source(&self) -> Option { self.object_get(state_key::ambient::current_source()) } @@ -22,9 +23,7 @@ pub trait SourceContext: StateWrite { /// /// The `counter` field allows distinguishing hashes at different stages of the test. fn put_mock_source(&mut self, counter: u8) { - self.put_current_source(Some(CommitmentSource::Transaction { - id: Some([counter; 32]), - })) + self.put_current_source(Some(TransactionId([counter; 32]))) } } impl SourceContext for T {} diff --git a/crates/core/component/sct/src/source.rs b/crates/core/component/sct/src/source.rs index fa49916bdb..e4cdc69230 100644 --- a/crates/core/component/sct/src/source.rs +++ b/crates/core/component/sct/src/source.rs @@ -141,3 +141,9 @@ impl TryFrom for CommitmentSource { }) } } + +impl From for CommitmentSource { + fn from(id: TransactionId) -> Self { + Self::Transaction { id: Some(id.0) } + } +} diff --git a/crates/core/component/shielded-pool/src/component/action_handler/output.rs b/crates/core/component/shielded-pool/src/component/action_handler/output.rs index d9b6049989..c8e7b1e2ca 100644 --- a/crates/core/component/shielded-pool/src/component/action_handler/output.rs +++ b/crates/core/component/shielded-pool/src/component/action_handler/output.rs @@ -31,7 +31,7 @@ impl ActionHandler for Output { .expect("source should be set during execution"); state - .add_note_payload(self.body.note_payload.clone(), source) + .add_note_payload(self.body.note_payload.clone(), source.into()) .await; state.record_proto( diff --git a/crates/core/component/shielded-pool/src/component/action_handler/spend.rs b/crates/core/component/shielded-pool/src/component/action_handler/spend.rs index 13263c4671..6d683373fc 100644 --- a/crates/core/component/shielded-pool/src/component/action_handler/spend.rs +++ b/crates/core/component/shielded-pool/src/component/action_handler/spend.rs @@ -46,7 +46,7 @@ impl ActionHandler for Spend { let source = state.get_current_source().expect("source should be set"); - state.nullify(self.body.nullifier, source).await; + state.nullify(self.body.nullifier, source.into()).await; // Also record an ABCI event for transaction indexing. state.record_proto(