Skip to content

Commit

Permalink
fix up rest of imports
Browse files Browse the repository at this point in the history
  • Loading branch information
redshiftzero committed Sep 21, 2023
1 parent 298ee45 commit e3c35b1
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 59 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/bin/pcli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ penumbra-asset = { path = "../../core/asset", default-features=false }
penumbra-keys = { path = "../../core/keys", default-features=false }
penumbra-chain = { path = "../../core/component/chain", default-features = false }
penumbra-shielded-pool = { path = "../../core/component/shielded-pool", default-features = false }
penumbra-governance = { path = "../../core/component/governance", default-features = false }
penumbra-stake = { path = "../../core/component/stake", default-features = false }
penumbra-sct = { path = "../../core/component/sct", default-features = false }
penumbra-fee = { path = "../../core/component/fee", default-features = false }
Expand Down
53 changes: 26 additions & 27 deletions crates/bin/pcli/src/command/query/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ use std::{

use anyhow::{Context, Result};
use futures::{StreamExt, TryStreamExt};
use penumbra_app::governance::{self, state_key::*};
use penumbra_governance::state_key::*;
use penumbra_governance::{proposal_state::State as ProposalState, Proposal, Vote};
use penumbra_proto::client::v1alpha1::{PrefixValueRequest, PrefixValueResponse};
use penumbra_stake::IdentityKey;
use penumbra_transaction::{
proposal::{self, Proposal},
vote::Vote,
};
use serde::Serialize;
use serde_json::json;

Expand Down Expand Up @@ -91,7 +88,7 @@ impl GovernanceCmd {

let proposal_title = proposal.title;

let proposal_state: proposal::State = client
let proposal_state: ProposalState = client
.key_domain(proposal_state(proposal_id))
.await?
.context(format!("proposal state for {} not found", proposal_id))?;
Expand All @@ -114,7 +111,7 @@ impl GovernanceCmd {
toml(&proposal)?;
}
State => {
let state: proposal::State = client
let state: ProposalState = client
.key_domain(proposal_state(*proposal_id))
.await?
.context(format!(
Expand Down Expand Up @@ -169,24 +166,25 @@ impl GovernanceCmd {
validator_votes_and_power.insert(*identity_key, (*vote, power));
}

let mut delegator_tallies: BTreeMap<IdentityKey, governance::Tally> = client
.prefix_domain::<governance::Tally>(
all_tallied_delegator_votes_for_proposal(*proposal_id),
)
.await?
.and_then(|r| async move {
Ok((
IdentityKey::from_str(
r.0.rsplit('/').next().context("invalid key")?,
)?,
r.1,
))
})
.try_collect()
.await?;
let mut delegator_tallies: BTreeMap<IdentityKey, penumbra_governance::Tally> =
client
.prefix_domain::<penumbra_governance::Tally>(
all_tallied_delegator_votes_for_proposal(*proposal_id),
)
.await?
.and_then(|r| async move {
Ok((
IdentityKey::from_str(
r.0.rsplit('/').next().context("invalid key")?,
)?,
r.1,
))
})
.try_collect()
.await?;

// Combine the two mappings
let mut total = governance::Tally::default();
let mut total = penumbra_governance::Tally::default();
let mut all_votes_and_power: BTreeMap<String, serde_json::Value> =
BTreeMap::new();
for (identity_key, (vote, power)) in validator_votes_and_power.into_iter() {
Expand All @@ -207,9 +205,10 @@ impl GovernanceCmd {
};
// Subtract delegator total from validator power, then add delegator
// tally in to get the total tally for this validator:
let sub_total =
governance::Tally::from((vote, power - delegator_tally.total()))
+ delegator_tally;
let sub_total = penumbra_governance::Tally::from((
vote,
power - delegator_tally.total(),
)) + delegator_tally;
map.insert("sub_total".to_string(), json_tally(&sub_total));
total += sub_total;
map.into()
Expand Down Expand Up @@ -245,7 +244,7 @@ fn json<T: Serialize>(value: &T) -> Result<()> {
Ok(())
}

fn json_tally(tally: &governance::Tally) -> serde_json::Value {
fn json_tally(tally: &penumbra_governance::Tally) -> serde_json::Value {
let mut map = serde_json::Map::new();
if tally.yes() > 0 {
map.insert("yes".to_string(), tally.yes().into());
Expand Down
18 changes: 9 additions & 9 deletions crates/bin/pcli/src/command/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use ibc_types::core::channel::ChannelId;
use penumbra_asset::{asset, asset::DenomMetadata, Value, STAKING_TOKEN_ASSET_ID};
use penumbra_dex::{lp::position, swap_claim::SwapClaimPlan};
use penumbra_fee::Fee;
use penumbra_governance::{proposal::ProposalToml, proposal_state::State as ProposalState, Vote};
use penumbra_ibc::Ics20Withdrawal;
use penumbra_keys::keys::AddressIndex;
use penumbra_num::Amount;
Expand All @@ -25,7 +26,7 @@ use penumbra_proto::{
};
use penumbra_stake::rate::RateData;
use penumbra_stake::{DelegationToken, IdentityKey, Penalty, UnbondingToken, UndelegateClaimPlan};
use penumbra_transaction::{memo::MemoPlaintext, proposal::ProposalToml, vote::Vote};
use penumbra_transaction::memo::MemoPlaintext;
use penumbra_view::ViewClient;
use penumbra_wallet::plan::{self, Planner};
use rand_core::OsRng;
Expand Down Expand Up @@ -654,7 +655,7 @@ impl TxCmd {
// Find out what the latest proposal ID is so we can include the next ID in the template:
let mut client = app.specific_client().await?;
let next_proposal_id: u64 = client
.key_proto(penumbra_app::governance::state_key::next_proposal_id())
.key_proto(penumbra_governance::state_key::next_proposal_id())
.await?
.context(format!("there are no proposals yet"))?;

Expand All @@ -676,13 +677,12 @@ impl TxCmd {
proposal_id,
source,
}) => {
use penumbra_app::governance::state_key;
use penumbra_transaction::proposal;
use penumbra_governance::state_key;

let fee = Fee::from_staking_token_amount((*fee).into());

let mut client = app.specific_client().await?;
let state: proposal::State = client
let state: ProposalState = client
.key_domain(state_key::proposal_state(*proposal_id))
.await?
.context(format!(
Expand All @@ -691,15 +691,15 @@ impl TxCmd {
))?;

let outcome = match state {
proposal::State::Voting => anyhow::bail!(
ProposalState::Voting => anyhow::bail!(
"proposal {} is still voting, so the deposit cannot yet be claimed",
proposal_id
),
proposal::State::Withdrawn { reason: _ } => {
ProposalState::Withdrawn { reason: _ } => {
anyhow::bail!("proposal {} has been withdrawn but voting has not yet concluded, so the deposit cannot yet be claimed", proposal_id);
}
proposal::State::Finished { outcome } => outcome.map(|_| ()),
proposal::State::Claimed { outcome: _ } => {
ProposalState::Finished { outcome } => outcome.map(|_| ()),
ProposalState::Claimed { outcome: _ } => {
anyhow::bail!("proposal {} has already been claimed", proposal_id)
}
};
Expand Down
9 changes: 4 additions & 5 deletions crates/bin/pcli/src/command/tx/proposal.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use anyhow::{Context, Result};

use penumbra_chain::params::ChainParameters;
use penumbra_transaction::{
plan::TransactionPlan,
proposal::{Proposal, ProposalPayload},
};
use penumbra_governance::{Proposal, ProposalPayload};
use penumbra_proto::DomainType;
use penumbra_transaction::plan::TransactionPlan;

#[derive(Debug, clap::Subcommand)]
pub enum ProposalCmd {
Expand Down Expand Up @@ -108,7 +107,7 @@ impl ProposalKindCmd {
}
} else {
ProposalPayload::DaoSpend {
transaction_plan: TransactionPlan::default(),
transaction_plan: TransactionPlan::default().encode_to_vec(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/pcli/src/command/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use std::{

use anyhow::{Context, Result};
use penumbra_fee::Fee;
use penumbra_governance::{ValidatorVote, ValidatorVoteBody, Vote};
use penumbra_keys::keys::AddressIndex;
use penumbra_proto::{core::stake::v1alpha1::Validator as ProtoValidator, DomainType, Message};
use penumbra_stake::{
validator,
validator::{Validator, ValidatorToml},
FundingStream, FundingStreams, GovernanceKey, IdentityKey,
};
use penumbra_transaction::action::{ValidatorVote, ValidatorVoteBody, Vote};
use penumbra_wallet::plan;
use rand_core::OsRng;
use serde_json::Value;
Expand Down
4 changes: 2 additions & 2 deletions crates/bin/pd/src/info/specific.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::sync::Arc;
use async_stream::try_stream;
use futures::StreamExt;
use futures::TryStreamExt;
use penumbra_app::governance::StateReadExt as _;
use penumbra_asset::{asset, Value};
use penumbra_chain::component::AppHashRead;
use penumbra_chain::component::StateReadExt as _;
Expand All @@ -15,6 +14,7 @@ use penumbra_dex::{
lp::{position, position::Position},
DirectedTradingPair, SwapExecution, TradingPair,
};
use penumbra_governance::StateReadExt as _;
use penumbra_proto::{
self as proto,
client::v1alpha1::{
Expand Down Expand Up @@ -747,7 +747,7 @@ impl SpecificQueryService for Info {
.map_err(|e| tonic::Status::unknown(format!("chain_id not OK: {e}")))?;
let proposal_id = request.into_inner().proposal_id;

use penumbra_app::governance::state_key;
use penumbra_governance::state_key;

let s = state.prefix(&state_key::all_rate_data_at_proposal_start(proposal_id));
Ok(tonic::Response::new(
Expand Down
1 change: 1 addition & 0 deletions crates/core/component/governance/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
pub use metrics::*;

#[allow(dead_code)]
/// Registers all metrics used by this crate.
pub fn register_metrics() {
/*
Expand Down
1 change: 1 addition & 0 deletions crates/view/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ penumbra-chain = { path = "../core/component/chain" }
penumbra-shielded-pool = { path = "../core/component/shielded-pool", default-features = false, features = [
"proving-keys",
] }
penumbra-governance = { path = "../core/component/governance", default-features = false }
penumbra-stake = { path = "../core/component/stake", default-features = false }
penumbra-ibc = { path = "../core/component/ibc", default-features = false }
penumbra-dao = { path = "../core/component/dao", default-features = false }
Expand Down
12 changes: 6 additions & 6 deletions crates/view/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ use penumbra_dex::{
TradingPair,
};
use penumbra_fee::Fee;
use penumbra_governance::{
proposal_state, DelegatorVotePlan, Proposal, ProposalDepositClaim, ProposalSubmit,
ProposalWithdraw, ValidatorVote, Vote,
};
use penumbra_ibc::{IbcAction, Ics20Withdrawal};
use penumbra_keys::{
keys::{AccountGroupId, AddressIndex},
Expand All @@ -32,12 +36,8 @@ use penumbra_stake::{rate::RateData, validator};
use penumbra_stake::{IdentityKey, UndelegateClaimPlan};
use penumbra_tct as tct;
use penumbra_transaction::{
action::{
Proposal, ProposalDepositClaim, ProposalSubmit, ProposalWithdraw, ValidatorVote, Vote,
},
memo::MemoPlaintext,
plan::{ActionPlan, DelegatorVotePlan, MemoPlan, TransactionPlan},
proposal,
plan::{ActionPlan, MemoPlan, TransactionPlan},
};
use rand::{CryptoRng, RngCore};
use tracing::instrument;
Expand Down Expand Up @@ -320,7 +320,7 @@ impl<R: RngCore + CryptoRng> Planner<R> {
&mut self,
proposal: u64,
deposit_amount: Amount,
outcome: proposal::Outcome<()>,
outcome: proposal_state::Outcome<()>,
) -> &mut Self {
self.action(ActionPlan::ProposalDepositClaim(ProposalDepositClaim {
proposal,
Expand Down
1 change: 1 addition & 0 deletions crates/wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ penumbra-dex = { path = "../core/component/dex" }
penumbra-transaction = { path = "../core/transaction" }
penumbra-app = { path = "../core/app" }
penumbra-stake = { path = "../core/component/stake" }
penumbra-governance = { path = "../core/component/governance" }
penumbra-fee = { path = "../core/component/fee" }
penumbra-view = { path = "../view" }
penumbra-custody = { path = "../custody" }
Expand Down
10 changes: 3 additions & 7 deletions crates/wallet/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@ use ark_std::UniformRand;
use decaf377::Fq;
use penumbra_asset::Value;
use penumbra_fee::Fee;
use penumbra_governance::{proposal_state, Proposal, ValidatorVote};
use penumbra_keys::{
keys::{AccountGroupId, AddressIndex},
Address,
};
use penumbra_num::Amount;
use penumbra_stake::rate::RateData;
use penumbra_stake::validator;
use penumbra_transaction::{
action::{Proposal, ValidatorVote},
memo::MemoPlaintext,
plan::TransactionPlan,
proposal,
};
use penumbra_transaction::{memo::MemoPlaintext, plan::TransactionPlan};
use penumbra_view::{SpendableNoteRecord, ViewClient};
use rand_core::{CryptoRng, RngCore};
use tracing::instrument;
Expand Down Expand Up @@ -328,7 +324,7 @@ pub async fn proposal_deposit_claim<V, R>(
rng: R,
proposal_id: u64,
deposit_amount: Amount,
outcome: proposal::Outcome<()>,
outcome: proposal_state::Outcome<()>,
fee: Fee,
source_address: AddressIndex,
) -> Result<TransactionPlan>
Expand Down
1 change: 1 addition & 0 deletions crates/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ penumbra-proto = { path = "../proto", default-features = false }
penumbra-sct = { path = "../core/component/sct", default-features = false }
penumbra-shielded-pool = { path = "../core/component/shielded-pool", default-features = false, features = ["proving-keys"] }
penumbra-stake = { path = "../core/component/stake", default-features = false }
penumbra-governance = { path = "../core/component/governance", default-features = false, features = ["proving-keys"] }
penumbra-tct = { path = "../crypto/tct" }
penumbra-transaction = { path = "../core/transaction", default-features = false }

Expand Down
6 changes: 4 additions & 2 deletions crates/wasm/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ use penumbra_asset::{asset::DenomMetadata, Balance, Value};
use penumbra_chain::params::{ChainParameters, FmdParameters};
use penumbra_dex::{swap::SwapPlaintext, swap::SwapPlan, swap_claim::SwapClaimPlan, TradingPair};
use penumbra_fee::Fee;
use penumbra_governance::{
DelegatorVotePlan, Proposal, ProposalSubmit, ProposalWithdraw, ValidatorVote, Vote,
};
use penumbra_keys::{keys::AddressIndex, Address, FullViewingKey};
use penumbra_num::Amount;
use penumbra_shielded_pool::{Note, OutputPlan, SpendPlan};
use penumbra_stake::{IdentityKey, UndelegateClaimPlan};
use penumbra_tct as tct;
use penumbra_transaction::{
action::{Proposal, ProposalSubmit, ProposalWithdraw, ValidatorVote, Vote},
memo::MemoPlaintext,
plan::{ActionPlan, DelegatorVotePlan, MemoPlan, TransactionPlan},
plan::{ActionPlan, MemoPlan, TransactionPlan},
};

// use penumbra_view::{SpendableNoteRecord, ViewClient};
Expand Down

0 comments on commit e3c35b1

Please sign in to comment.