Skip to content
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

feat: add indexing of denoms #4777

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195,725 changes: 195,725 additions & 0 deletions crates/bin/pcli/spend_proof.txt

Large diffs are not rendered by default.

Binary file modified crates/cnidarium/src/gen/proto_descriptor.bin.no_lfs
Binary file not shown.
7 changes: 7 additions & 0 deletions crates/core/component/shielded-pool/src/component/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use cnidarium::{StateRead, StateWrite};
use penumbra_asset::asset::{self, Metadata};
use penumbra_proto::{StateReadProto, StateWriteProto};

use penumbra_proto::core::asset::v1::AssetId;
use penumbra_proto::core::component::shielded_pool::v1::EventDenomRegistered;
use tracing::instrument;

use crate::state_key;
Expand Down Expand Up @@ -32,6 +34,11 @@ pub trait AssetRegistry: StateWrite {
state_key::denom_metadata_by_asset::by_asset_id(&asset_id),
denom.clone(),
);

self.record_proto(EventDenomRegistered {
asset_id: Some(AssetId::from(asset_id)),
denom_metadata: Some(denom.clone().into()),
});
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions crates/proto/src/gen/penumbra.core.component.shielded_pool.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,23 @@ impl ::prost::Name for AssetMetadataByIdsResponse {
)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EventDenomRegistered {
#[prost(message, optional, tag = "1")]
pub asset_id: ::core::option::Option<super::super::super::asset::v1::AssetId>,
#[prost(message, optional, tag = "2")]
pub denom_metadata: ::core::option::Option<super::super::super::asset::v1::Metadata>,
}
impl ::prost::Name for EventDenomRegistered {
const NAME: &'static str = "EventDenomRegistered";
const PACKAGE: &'static str = "penumbra.core.component.shielded_pool.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!(
"penumbra.core.component.shielded_pool.v1.{}", Self::NAME
)
}
}
/// Generated client implementations.
#[cfg(feature = "rpc")]
pub mod query_service_client {
Expand Down
114 changes: 114 additions & 0 deletions crates/proto/src/gen/penumbra.core.component.shielded_pool.v1.serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,120 @@ impl<'de> serde::Deserialize<'de> for EventBroadcastClue {
deserializer.deserialize_struct("penumbra.core.component.shielded_pool.v1.EventBroadcastClue", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for EventDenomRegistered {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.asset_id.is_some() {
len += 1;
}
if self.denom_metadata.is_some() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.component.shielded_pool.v1.EventDenomRegistered", len)?;
if let Some(v) = self.asset_id.as_ref() {
struct_ser.serialize_field("assetId", v)?;
}
if let Some(v) = self.denom_metadata.as_ref() {
struct_ser.serialize_field("denomMetadata", v)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for EventDenomRegistered {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"asset_id",
"assetId",
"denom_metadata",
"denomMetadata",
];

#[allow(clippy::enum_variant_names)]
enum GeneratedField {
AssetId,
DenomMetadata,
__SkipField__,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;

impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;

fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}

#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"assetId" | "asset_id" => Ok(GeneratedField::AssetId),
"denomMetadata" | "denom_metadata" => Ok(GeneratedField::DenomMetadata),
_ => Ok(GeneratedField::__SkipField__),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = EventDenomRegistered;

fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct penumbra.core.component.shielded_pool.v1.EventDenomRegistered")
}

fn visit_map<V>(self, mut map_: V) -> std::result::Result<EventDenomRegistered, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut asset_id__ = None;
let mut denom_metadata__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::AssetId => {
if asset_id__.is_some() {
return Err(serde::de::Error::duplicate_field("assetId"));
}
asset_id__ = map_.next_value()?;
}
GeneratedField::DenomMetadata => {
if denom_metadata__.is_some() {
return Err(serde::de::Error::duplicate_field("denomMetadata"));
}
denom_metadata__ = map_.next_value()?;
}
GeneratedField::__SkipField__ => {
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
}
}
}
Ok(EventDenomRegistered {
asset_id: asset_id__,
denom_metadata: denom_metadata__,
})
}
}
deserializer.deserialize_struct("penumbra.core.component.shielded_pool.v1.EventDenomRegistered", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for EventOutput {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
Expand Down
Binary file modified crates/proto/src/gen/proto_descriptor.bin.no_lfs
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,8 @@ message AssetMetadataByIdsResponse {
// A single asset metadata streamed from the node.
core.asset.v1.Metadata denom_metadata = 1;
}

message EventDenomRegistered {
core.asset.v1.AssetId asset_id = 1;
core.asset.v1.Metadata denom_metadata = 2;
}
Loading