Skip to content

Commit

Permalink
Tweaks after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
cronokirby committed Aug 14, 2024
1 parent 5d68ecd commit 21fcba6
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 58 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions crates/bin/pindexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
2 changes: 2 additions & 0 deletions crates/bin/pindexer/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use penumbra_proto::{
event::ProtoEvent,
};
use penumbra_stake::IdentityKey;
use sqlx::PgPool;

#[derive(Debug)]
pub struct GovernanceProposals {}
Expand Down Expand Up @@ -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 => {
Expand Down
1 change: 1 addition & 0 deletions crates/bin/pindexer/src/indexer_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
12 changes: 8 additions & 4 deletions crates/core/component/governance/src/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,21 @@ impl From<ProposalKind> for pb::ProposalKind {
}
}

impl From<pb::ProposalKind> for ProposalKind {
fn from(kind: pb::ProposalKind) -> ProposalKind {
match kind {
impl TryFrom<pb::ProposalKind> for ProposalKind {
type Error = anyhow::Error;

fn try_from(kind: pb::ProposalKind) -> anyhow::Result<ProposalKind> {
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,
pb::ProposalKind::CommunityPoolSpend => ProposalKind::CommunityPoolSpend,
pb::ProposalKind::UpgradePlan => ProposalKind::UpgradePlan,
pb::ProposalKind::FreezeIbcClient => ProposalKind::FreezeIbcClient,
pb::ProposalKind::UnfreezeIbcClient => ProposalKind::UnfreezeIbcClient,
}
};
Ok(kind)
}
}

Expand Down
47 changes: 26 additions & 21 deletions crates/proto/src/gen/penumbra.core.component.governance.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<Self> {
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,
}
}
Expand Down
45 changes: 24 additions & 21 deletions crates/proto/src/gen/penumbra.core.component.governance.v1.serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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;
Expand Down Expand Up @@ -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)),
}
}
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 @@ -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.
Expand Down

0 comments on commit 21fcba6

Please sign in to comment.