Skip to content

Commit

Permalink
addressing feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
TalDerei committed Jan 31, 2025
1 parent e2bbc91 commit d38fa3c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions crates/core/app/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ pub trait StateReadExt: StateRead {
let distributions_params = self.get_distributions_params().await?;
let ibc_params = self.get_ibc_params().await?;
let fee_params = self.get_fee_params().await?;
let funding_params = self.get_staking_funding_params().await?;
let funding_params = self.get_funding_params().await?;
let governance_params = self.get_governance_params().await?;
let sct_params = self.get_sct_params().await?;
let shielded_pool_params = self.get_shielded_pool_params().await?;
Expand Down Expand Up @@ -812,7 +812,7 @@ pub trait StateWriteExt: StateWrite {
self.put_community_pool_params(community_pool_params);
self.put_distributions_params(distributions_params);
self.put_fee_params(fee_params);
self.put_staking_funding_params(funding_params);
self.put_funding_params(funding_params);
self.put_governance_params(governance_params);
self.put_ibc_params(ibc_params);
self.put_sct_params(sct_params);
Expand Down
2 changes: 1 addition & 1 deletion crates/core/component/funding/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Component for Funding {
match app_state {
None => { /* no-op */ }
Some(genesis) => {
state.put_staking_funding_params(genesis.funding_params.clone());
state.put_funding_params(genesis.funding_params.clone());
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ use penumbra_sdk_sct::{component::clock::EpochRead, Nullifier};
#[allow(dead_code)]
#[async_trait]
pub trait NullifierRead: StateRead {
/// Gets the transaction id associated with the given nullifier from the JMT.
async fn get_txid_from_nullifier(&self, nullifier: Nullifier) -> Option<TransactionId> {
/// Returns the `TransactionId` if the nullifier has been spent; otherwise, returns None.
async fn get_lqt_spent_nullifier(&self, nullifier: Nullifier) -> Option<TransactionId> {
// Grab the ambient epoch index.
let epoch_index = self
.get_current_epoch()
.await
.expect("epoch is always set")
.index;

let nullifier_key =
&state_key::lqt::v1::nullifier::lqt_nullifier_lookup_for_txid(epoch_index, &nullifier);
let nullifier_key = &state_key::lqt::v1::nullifier::key(epoch_index, &nullifier);

let tx_id: Option<TransactionId> = self
.nonverifiable_get(&nullifier_key.as_bytes())
Expand All @@ -35,12 +34,16 @@ impl<T: StateRead + ?Sized> NullifierRead for T {}
#[allow(dead_code)]
#[async_trait]
pub trait NullifierWrite: StateWrite {
/// Sets the LQT nullifier in the JMT.
fn put_lqt_nullifier(&mut self, epoch_index: u64, nullifier: Nullifier, tx_id: TransactionId) {
let nullifier_key =
state_key::lqt::v1::nullifier::lqt_nullifier_lookup_for_txid(epoch_index, &nullifier);

self.put(nullifier_key, tx_id);
/// Sets the LQT nullifier in the NV storage.
fn put_lqt_spent_nullifier(
&mut self,
epoch_index: u64,
nullifier: Nullifier,
tx_id: TransactionId,
) {
let nullifier_key = state_key::lqt::v1::nullifier::key(epoch_index, &nullifier);

self.nonverifiable_put(nullifier_key.into(), tx_id);
}
}

Expand Down
6 changes: 2 additions & 4 deletions crates/core/component/funding/src/component/state_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ pub mod lqt {
pub mod nullifier {
use penumbra_sdk_sct::Nullifier;

pub(crate) fn lqt_nullifier_lookup_for_txid(
epoch_index: u64,
nullifier: &Nullifier,
) -> String {
/// A nullifier set indexed by epoch, mapping each epoch to its corresponding `TransactionId`.
pub(crate) fn key(epoch_index: u64, nullifier: &Nullifier) -> String {
format!("funding/lqt/v1/nullifier/{epoch_index:020}/lookup/{nullifier}")
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/core/component/funding/src/component/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use penumbra_sdk_proto::{StateReadProto, StateWriteProto};
#[async_trait]
pub trait StateReadExt: StateRead {
/// Gets the funding module chain parameters from the JMT.
async fn get_staking_funding_params(&self) -> Result<FundingParameters> {
async fn get_funding_params(&self) -> Result<FundingParameters> {
self.get(state_key::staking_funding_parameters())
.await?
.ok_or_else(|| anyhow::anyhow!("Missing FundingParameters"))
Expand All @@ -19,7 +19,7 @@ impl<T: StateRead + ?Sized> StateReadExt for T {}
#[async_trait]
pub trait StateWriteExt: StateWrite + StateReadExt {
/// Set the Funding parameters in the JMT.
fn put_staking_funding_params(&mut self, params: FundingParameters) {
fn put_funding_params(&mut self, params: FundingParameters) {
self.put(state_key::staking_funding_parameters().into(), params)
}
}
Expand Down

0 comments on commit d38fa3c

Please sign in to comment.