-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shielded-pool: delegate supply tracking to components #4020
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b7709f5
shielded-pool: don't track supply in `mint_note`
erwanor 5c3321b
shielded-pool(ics20): don't decrease supply in withdrawals
erwanor dc67a47
staking: implement and use `ValidatorPoolTracker`
erwanor 39d65a4
staking: add `set_validator_pool_size`
erwanor 59fd619
pd: remove unused `generate` method
erwanor 4ee642b
shielded-pool: chop down `SupplyWrite/Read`
erwanor 1c85370
stake(identity_key): add warning about change display impl
erwanor b483e30
staking: propagate api changes throughout
erwanor b42fd2e
shielded-pool: remove unused state keys
erwanor c87595b
shielded-pool: s/SupplyWrite/AssetRegistry
erwanor 6a65a88
shielded-pool: simplify `register_denom`
erwanor 3defa63
staking: clean-up validator definition upload
erwanor 5a8f1aa
staking: simplify end-epoch delegation pool adjustment
erwanor 539ea2b
staking: fix docstring s/increase/decrease
erwanor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
//! The Penumbra shielded pool [`Component`] and [`ActionHandler`] implementations. | ||
|
||
mod action_handler; | ||
mod assets; | ||
mod metrics; | ||
mod note_manager; | ||
mod shielded_pool; | ||
mod supply; | ||
mod transfer; | ||
|
||
pub use self::metrics::register_metrics; | ||
pub use assets::{AssetRegistry, AssetRegistryRead}; | ||
pub use note_manager::NoteManager; | ||
pub use shielded_pool::{ShieldedPool, StateReadExt, StateWriteExt}; | ||
pub use supply::{SupplyRead, SupplyWrite}; | ||
pub use transfer::Ics20Transfer; | ||
|
||
pub mod rpc; |
36 changes: 36 additions & 0 deletions
36
crates/core/component/shielded-pool/src/component/assets.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use async_trait::async_trait; | ||
use cnidarium::{StateRead, StateWrite}; | ||
use penumbra_asset::asset::{self, Metadata}; | ||
use penumbra_proto::{StateReadProto, StateWriteProto}; | ||
|
||
use tracing::instrument; | ||
|
||
use crate::state_key; | ||
|
||
#[async_trait] | ||
pub trait AssetRegistryRead: StateRead { | ||
async fn denom_by_asset(&self, asset_id: &asset::Id) -> Option<Metadata> { | ||
self.get(&state_key::denom_by_asset(asset_id)) | ||
.await | ||
.expect("no deserialization error") | ||
} | ||
} | ||
|
||
impl<T: StateRead + ?Sized> AssetRegistryRead for T {} | ||
|
||
#[async_trait] | ||
pub trait AssetRegistry: StateWrite { | ||
/// Register a new asset present in the shielded pool. | ||
/// If the asset is already registered, this is a no-op. | ||
#[instrument(skip(self))] | ||
async fn register_denom(&mut self, denom: &Metadata) { | ||
let asset_id = denom.id(); | ||
tracing::debug!(?asset_id, "registering asset metadata in shielded pool"); | ||
|
||
if self.denom_by_asset(&asset_id).await.is_none() { | ||
self.put(state_key::denom_by_asset(&asset_id), denom.clone()); | ||
} | ||
} | ||
} | ||
|
||
impl<T: StateWrite + ?Sized> AssetRegistry for T {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 0 additions & 97 deletions
97
crates/core/component/shielded-pool/src/component/supply.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Will this potentially fail for benign resigns we nevertheless want to throw upstream, e.g. wrong storage path? IDK what the convention here is though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, the failure mode for this is if we have a cache miss that hits storage and fails. The most likely reason this happens is some disk failure that cause storage degradation. Either way, it's irrecoverable for callers and the node should halt.