diff --git a/Cargo.lock b/Cargo.lock index fabdeea3ee..99622f5da1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5813,6 +5813,7 @@ dependencies = [ "num-bigint", "penumbra-app", "penumbra-asset", + "penumbra-dex", "penumbra-governance", "penumbra-num", "penumbra-proto", diff --git a/crates/bin/pindexer/Cargo.toml b/crates/bin/pindexer/Cargo.toml index ad096336c8..86805da998 100644 --- a/crates/bin/pindexer/Cargo.toml +++ b/crates/bin/pindexer/Cargo.toml @@ -11,16 +11,19 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow = {workspace = true} +clap = {workspace = true} +cometindex = {workspace = true} +num-bigint = { version = "0.4" } penumbra-shielded-pool = {workspace = true, default-features = false} penumbra-stake = {workspace = true, default-features = false} -penumbra-governance = {workspace = true, default-features = false} penumbra-app = {workspace = true, default-features = false} +penumbra-dex = {workspace = true, default-features = false} +penumbra-governance = {workspace = true, default-features = false} penumbra-num = {workspace = true, default-features = false} penumbra-asset = {workspace = true, default-features = false} penumbra-proto = {workspace = true, default-features = false} -sqlx = { workspace = true, features = ["chrono"] } -cometindex = { workspace = true } +tracing = {workspace = true} tokio = {workspace = true, features = ["full"]} -anyhow = {workspace = true} serde_json = {workspace = true} -tracing = {workspace = true} +sqlx = { workspace = true, features = ["chrono", "postgres"] } diff --git a/crates/bin/pindexer/src/governance.rs b/crates/bin/pindexer/src/governance.rs index 9b089be4ca..4d2a1a91fc 100644 --- a/crates/bin/pindexer/src/governance.rs +++ b/crates/bin/pindexer/src/governance.rs @@ -13,6 +13,7 @@ use penumbra_proto::{ event::ProtoEvent, }; use penumbra_stake::IdentityKey; +use sqlx::PgPool; #[derive(Debug)] pub struct GovernanceProposals {} @@ -225,6 +226,7 @@ impl AppView for GovernanceProposals { &self, dbtx: &mut PgTransaction, event: &ContextualizedEvent, + _src_db: &PgPool, ) -> Result<(), anyhow::Error> { match event.event.kind.as_str() { EVENT_PROPOSAL_SUBMIT => { diff --git a/crates/bin/pindexer/src/indexer_ext.rs b/crates/bin/pindexer/src/indexer_ext.rs index e134169078..80d034950d 100644 --- a/crates/bin/pindexer/src/indexer_ext.rs +++ b/crates/bin/pindexer/src/indexer_ext.rs @@ -10,5 +10,6 @@ impl IndexerExt for cometindex::Indexer { .with_index(crate::stake::DelegationTxs {}) .with_index(crate::stake::UndelegationTxs {}) .with_index(crate::governance::GovernanceProposals {}) + .with_index(crate::dex::Component::new()) } } diff --git a/crates/core/component/governance/src/proposal.rs b/crates/core/component/governance/src/proposal.rs index f89268158f..050bc21fa6 100644 --- a/crates/core/component/governance/src/proposal.rs +++ b/crates/core/component/governance/src/proposal.rs @@ -242,9 +242,12 @@ impl From for pb::ProposalKind { } } -impl From for ProposalKind { - fn from(kind: pb::ProposalKind) -> ProposalKind { - match kind { +impl TryFrom for ProposalKind { + type Error = anyhow::Error; + + fn try_from(kind: pb::ProposalKind) -> anyhow::Result { + let kind = match kind { + pb::ProposalKind::Unspecified => anyhow::bail!("unspecified proposal kind"), pb::ProposalKind::Signaling => ProposalKind::Signaling, pb::ProposalKind::Emergency => ProposalKind::Emergency, pb::ProposalKind::ParameterChange => ProposalKind::ParameterChange, @@ -252,7 +255,8 @@ impl From for ProposalKind { pb::ProposalKind::UpgradePlan => ProposalKind::UpgradePlan, pb::ProposalKind::FreezeIbcClient => ProposalKind::FreezeIbcClient, pb::ProposalKind::UnfreezeIbcClient => ProposalKind::UnfreezeIbcClient, - } + }; + Ok(kind) } } diff --git a/crates/proto/src/gen/penumbra.core.component.governance.v1.rs b/crates/proto/src/gen/penumbra.core.component.governance.v1.rs index a34feebc90..4c188cf312 100644 --- a/crates/proto/src/gen/penumbra.core.component.governance.v1.rs +++ b/crates/proto/src/gen/penumbra.core.component.governance.v1.rs @@ -1344,16 +1344,19 @@ impl ::prost::Name for EventProposalSlashed { ::prost::alloc::format!("penumbra.core.component.governance.v1.{}", Self::NAME) } } +/// All the different kinds of proposals. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum ProposalKind { - Signaling = 0, - Emergency = 1, - ParameterChange = 2, - CommunityPoolSpend = 3, - UpgradePlan = 4, - FreezeIbcClient = 5, - UnfreezeIbcClient = 6, + /// To make the linter happy + Unspecified = 0, + Signaling = 1, + Emergency = 2, + ParameterChange = 3, + CommunityPoolSpend = 4, + UpgradePlan = 5, + FreezeIbcClient = 6, + UnfreezeIbcClient = 7, } impl ProposalKind { /// String value of the enum field names used in the ProtoBuf definition. @@ -1362,25 +1365,27 @@ impl ProposalKind { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - ProposalKind::Signaling => "SIGNALING", - ProposalKind::Emergency => "EMERGENCY", - ProposalKind::ParameterChange => "PARAMETER_CHANGE", - ProposalKind::CommunityPoolSpend => "COMMUNITY_POOL_SPEND", - ProposalKind::UpgradePlan => "UPGRADE_PLAN", - ProposalKind::FreezeIbcClient => "FREEZE_IBC_CLIENT", - ProposalKind::UnfreezeIbcClient => "UNFREEZE_IBC_CLIENT", + ProposalKind::Unspecified => "PROPOSAL_KIND_UNSPECIFIED", + ProposalKind::Signaling => "PROPOSAL_KIND_SIGNALING", + ProposalKind::Emergency => "PROPOSAL_KIND_EMERGENCY", + ProposalKind::ParameterChange => "PROPOSAL_KIND_PARAMETER_CHANGE", + ProposalKind::CommunityPoolSpend => "PROPOSAL_KIND_COMMUNITY_POOL_SPEND", + ProposalKind::UpgradePlan => "PROPOSAL_KIND_UPGRADE_PLAN", + ProposalKind::FreezeIbcClient => "PROPOSAL_KIND_FREEZE_IBC_CLIENT", + ProposalKind::UnfreezeIbcClient => "PROPOSAL_KIND_UNFREEZE_IBC_CLIENT", } } /// Creates an enum from field names used in the ProtoBuf definition. pub fn from_str_name(value: &str) -> ::core::option::Option { match value { - "SIGNALING" => Some(Self::Signaling), - "EMERGENCY" => Some(Self::Emergency), - "PARAMETER_CHANGE" => Some(Self::ParameterChange), - "COMMUNITY_POOL_SPEND" => Some(Self::CommunityPoolSpend), - "UPGRADE_PLAN" => Some(Self::UpgradePlan), - "FREEZE_IBC_CLIENT" => Some(Self::FreezeIbcClient), - "UNFREEZE_IBC_CLIENT" => Some(Self::UnfreezeIbcClient), + "PROPOSAL_KIND_UNSPECIFIED" => Some(Self::Unspecified), + "PROPOSAL_KIND_SIGNALING" => Some(Self::Signaling), + "PROPOSAL_KIND_EMERGENCY" => Some(Self::Emergency), + "PROPOSAL_KIND_PARAMETER_CHANGE" => Some(Self::ParameterChange), + "PROPOSAL_KIND_COMMUNITY_POOL_SPEND" => Some(Self::CommunityPoolSpend), + "PROPOSAL_KIND_UPGRADE_PLAN" => Some(Self::UpgradePlan), + "PROPOSAL_KIND_FREEZE_IBC_CLIENT" => Some(Self::FreezeIbcClient), + "PROPOSAL_KIND_UNFREEZE_IBC_CLIENT" => Some(Self::UnfreezeIbcClient), _ => None, } } diff --git a/crates/proto/src/gen/penumbra.core.component.governance.v1.serde.rs b/crates/proto/src/gen/penumbra.core.component.governance.v1.serde.rs index 8e80312ab0..e5a2731256 100644 --- a/crates/proto/src/gen/penumbra.core.component.governance.v1.serde.rs +++ b/crates/proto/src/gen/penumbra.core.component.governance.v1.serde.rs @@ -4834,13 +4834,14 @@ impl serde::Serialize for ProposalKind { S: serde::Serializer, { let variant = match self { - Self::Signaling => "SIGNALING", - Self::Emergency => "EMERGENCY", - Self::ParameterChange => "PARAMETER_CHANGE", - Self::CommunityPoolSpend => "COMMUNITY_POOL_SPEND", - Self::UpgradePlan => "UPGRADE_PLAN", - Self::FreezeIbcClient => "FREEZE_IBC_CLIENT", - Self::UnfreezeIbcClient => "UNFREEZE_IBC_CLIENT", + Self::Unspecified => "PROPOSAL_KIND_UNSPECIFIED", + Self::Signaling => "PROPOSAL_KIND_SIGNALING", + Self::Emergency => "PROPOSAL_KIND_EMERGENCY", + Self::ParameterChange => "PROPOSAL_KIND_PARAMETER_CHANGE", + Self::CommunityPoolSpend => "PROPOSAL_KIND_COMMUNITY_POOL_SPEND", + Self::UpgradePlan => "PROPOSAL_KIND_UPGRADE_PLAN", + Self::FreezeIbcClient => "PROPOSAL_KIND_FREEZE_IBC_CLIENT", + Self::UnfreezeIbcClient => "PROPOSAL_KIND_UNFREEZE_IBC_CLIENT", }; serializer.serialize_str(variant) } @@ -4852,13 +4853,14 @@ impl<'de> serde::Deserialize<'de> for ProposalKind { D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ - "SIGNALING", - "EMERGENCY", - "PARAMETER_CHANGE", - "COMMUNITY_POOL_SPEND", - "UPGRADE_PLAN", - "FREEZE_IBC_CLIENT", - "UNFREEZE_IBC_CLIENT", + "PROPOSAL_KIND_UNSPECIFIED", + "PROPOSAL_KIND_SIGNALING", + "PROPOSAL_KIND_EMERGENCY", + "PROPOSAL_KIND_PARAMETER_CHANGE", + "PROPOSAL_KIND_COMMUNITY_POOL_SPEND", + "PROPOSAL_KIND_UPGRADE_PLAN", + "PROPOSAL_KIND_FREEZE_IBC_CLIENT", + "PROPOSAL_KIND_UNFREEZE_IBC_CLIENT", ]; struct GeneratedVisitor; @@ -4899,13 +4901,14 @@ impl<'de> serde::Deserialize<'de> for ProposalKind { E: serde::de::Error, { match value { - "SIGNALING" => Ok(ProposalKind::Signaling), - "EMERGENCY" => Ok(ProposalKind::Emergency), - "PARAMETER_CHANGE" => Ok(ProposalKind::ParameterChange), - "COMMUNITY_POOL_SPEND" => Ok(ProposalKind::CommunityPoolSpend), - "UPGRADE_PLAN" => Ok(ProposalKind::UpgradePlan), - "FREEZE_IBC_CLIENT" => Ok(ProposalKind::FreezeIbcClient), - "UNFREEZE_IBC_CLIENT" => Ok(ProposalKind::UnfreezeIbcClient), + "PROPOSAL_KIND_UNSPECIFIED" => Ok(ProposalKind::Unspecified), + "PROPOSAL_KIND_SIGNALING" => Ok(ProposalKind::Signaling), + "PROPOSAL_KIND_EMERGENCY" => Ok(ProposalKind::Emergency), + "PROPOSAL_KIND_PARAMETER_CHANGE" => Ok(ProposalKind::ParameterChange), + "PROPOSAL_KIND_COMMUNITY_POOL_SPEND" => Ok(ProposalKind::CommunityPoolSpend), + "PROPOSAL_KIND_UPGRADE_PLAN" => Ok(ProposalKind::UpgradePlan), + "PROPOSAL_KIND_FREEZE_IBC_CLIENT" => Ok(ProposalKind::FreezeIbcClient), + "PROPOSAL_KIND_UNFREEZE_IBC_CLIENT" => Ok(ProposalKind::UnfreezeIbcClient), _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), } } diff --git a/crates/proto/src/gen/proto_descriptor.bin.no_lfs b/crates/proto/src/gen/proto_descriptor.bin.no_lfs index 844e2da6c5..049d277678 100644 Binary files a/crates/proto/src/gen/proto_descriptor.bin.no_lfs and b/crates/proto/src/gen/proto_descriptor.bin.no_lfs differ diff --git a/proto/penumbra/penumbra/core/component/governance/v1/governance.proto b/proto/penumbra/penumbra/core/component/governance/v1/governance.proto index 542145e0d1..25d7ae69fc 100644 --- a/proto/penumbra/penumbra/core/component/governance/v1/governance.proto +++ b/proto/penumbra/penumbra/core/component/governance/v1/governance.proto @@ -323,14 +323,17 @@ message Proposal { } } +// All the different kinds of proposals. enum ProposalKind { - SIGNALING = 0; - EMERGENCY = 1; - PARAMETER_CHANGE = 2; - COMMUNITY_POOL_SPEND = 3; - UPGRADE_PLAN = 4; - FREEZE_IBC_CLIENT = 5; - UNFREEZE_IBC_CLIENT = 6; + // To make the linter happy + PROPOSAL_KIND_UNSPECIFIED = 0; + PROPOSAL_KIND_SIGNALING = 1; + PROPOSAL_KIND_EMERGENCY = 2; + PROPOSAL_KIND_PARAMETER_CHANGE = 3; + PROPOSAL_KIND_COMMUNITY_POOL_SPEND = 4; + PROPOSAL_KIND_UPGRADE_PLAN = 5; + PROPOSAL_KIND_FREEZE_IBC_CLIENT = 6; + PROPOSAL_KIND_UNFREEZE_IBC_CLIENT = 7; } // Query operations for the governance component.