Skip to content

Commit

Permalink
penumbra: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanor committed Dec 25, 2024
1 parent 2070ae0 commit fdafd9a
Show file tree
Hide file tree
Showing 27 changed files with 122 additions and 57 deletions.
4 changes: 3 additions & 1 deletion crates/bench/benches/spend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use penumbra_sdk_asset::Value;
use penumbra_sdk_keys::keys::{Bip44Path, SeedPhrase, SpendKey};
use penumbra_sdk_proof_params::{DummyWitness, SPEND_PROOF_PROVING_KEY};
use penumbra_sdk_sct::Nullifier;
use penumbra_sdk_shielded_pool::{Note, SpendCircuit, SpendProof, SpendProofPrivate, SpendProofPublic};
use penumbra_sdk_shielded_pool::{
Note, SpendCircuit, SpendProof, SpendProofPrivate, SpendProofPublic,
};
use penumbra_sdk_tct as tct;

use criterion::{criterion_group, criterion_main, Criterion};
Expand Down
7 changes: 3 additions & 4 deletions crates/bin/pcli/src/command/query/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,9 @@ impl GovernanceCmd {
.tally
.expect("tally must be set for vote response")
.try_into()?;
Ok::<(IdentityKey, penumbra_sdk_governance::Tally), anyhow::Error>((
identity_key,
tally,
))
Ok::<(IdentityKey, penumbra_sdk_governance::Tally), anyhow::Error>(
(identity_key, tally),
)
})
// TODO: double iterator here is suboptimal but trying to collect
// `Result<Vec<_>>` was annoying
Expand Down
8 changes: 6 additions & 2 deletions crates/bin/pcli/src/command/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ use liquidity_position::PositionCmd;
use penumbra_sdk_asset::{asset, asset::Metadata, Value, STAKING_TOKEN_ASSET_ID};
use penumbra_sdk_dex::{lp::position, swap_claim::SwapClaimPlan};
use penumbra_sdk_fee::FeeTier;
use penumbra_sdk_governance::{proposal::ProposalToml, proposal_state::State as ProposalState, Vote};
use penumbra_sdk_governance::{
proposal::ProposalToml, proposal_state::State as ProposalState, Vote,
};
use penumbra_sdk_keys::{keys::AddressIndex, Address};
use penumbra_sdk_num::Amount;
use penumbra_sdk_proto::{
Expand Down Expand Up @@ -64,7 +66,9 @@ use penumbra_sdk_proto::{
};
use penumbra_sdk_shielded_pool::Ics20Withdrawal;
use penumbra_sdk_stake::rate::RateData;
use penumbra_sdk_stake::{DelegationToken, IdentityKey, Penalty, UnbondingToken, UndelegateClaimPlan};
use penumbra_sdk_stake::{
DelegationToken, IdentityKey, Penalty, UnbondingToken, UndelegateClaimPlan,
};
use penumbra_sdk_transaction::{gas::swap_claim_gas_cost, Transaction};
use penumbra_sdk_view::{SpendableNoteRecord, ViewClient};
use penumbra_sdk_wallet::plan::{self, Planner};
Expand Down
4 changes: 3 additions & 1 deletion crates/bin/pcli/src/command/tx/auction/dutch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use clap::Subcommand;
use comfy_table::presets;
use dialoguer::Confirm;
use penumbra_sdk_asset::{asset::Cache, Value};
use penumbra_sdk_auction::auction::{dutch::DutchAuction, dutch::DutchAuctionDescription, AuctionId};
use penumbra_sdk_auction::auction::{
dutch::DutchAuction, dutch::DutchAuctionDescription, AuctionId,
};
use penumbra_sdk_keys::keys::AddressIndex;
use penumbra_sdk_num::Amount;
use penumbra_sdk_proto::{view::v1::GasPricesRequest, DomainType};
Expand Down
4 changes: 3 additions & 1 deletion crates/bin/pcli/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ fn pretty_print_transaction_plan(
output::Output {
body: output::Body {
note_payload: penumbra_sdk_shielded_pool::NotePayload {
note_commitment: penumbra_sdk_shielded_pool::note::StateCommitment(Fq::default()),
note_commitment: penumbra_sdk_shielded_pool::note::StateCommitment(
Fq::default(),
),
ephemeral_key: [0u8; 32]
.as_slice()
.try_into()
Expand Down
8 changes: 6 additions & 2 deletions crates/bin/pcli/src/transaction_view_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ impl TransactionViewExt for TransactionView {
penumbra_sdk_transaction::ActionView::PositionWithdraw(_) => {
["Withdraw Liquitity Position", ""]
}
penumbra_sdk_transaction::ActionView::ProposalDepositClaim(proposal_deposit_claim) => {
penumbra_sdk_transaction::ActionView::ProposalDepositClaim(
proposal_deposit_claim,
) => {
action = format!(
"Claim Deposit for Governance Proposal #{}",
proposal_deposit_claim.proposal
Expand Down Expand Up @@ -415,7 +417,9 @@ impl TransactionViewExt for TransactionView {
}
penumbra_sdk_transaction::ActionView::Delegate(_) => ["Delegation", ""],
penumbra_sdk_transaction::ActionView::Undelegate(_) => ["Undelegation", ""],
penumbra_sdk_transaction::ActionView::UndelegateClaim(_) => ["Undelegation Claim", ""],
penumbra_sdk_transaction::ActionView::UndelegateClaim(_) => {
["Undelegation Claim", ""]
}
penumbra_sdk_transaction::ActionView::ActionDutchAuctionSchedule(x) => {
let description = &x.action.description;

Expand Down
4 changes: 3 additions & 1 deletion crates/bin/pcli/tests/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ use penumbra_sdk_shielded_pool::{
NullifierDerivationProof, NullifierDerivationProofPrivate, NullifierDerivationProofPublic,
OutputProof, SpendProof, SpendProofPrivate, SpendProofPublic,
};
use penumbra_sdk_stake::undelegate_claim::{UndelegateClaimProofPrivate, UndelegateClaimProofPublic};
use penumbra_sdk_stake::undelegate_claim::{
UndelegateClaimProofPrivate, UndelegateClaimProofPublic,
};
use penumbra_sdk_stake::{IdentityKey, Penalty, UnbondingToken, UndelegateClaimProof};
use penumbra_sdk_tct as tct;
use rand_core::OsRng;
Expand Down
13 changes: 7 additions & 6 deletions crates/bin/pclientd/tests/network_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,13 @@ async fn swap_claim_flow() -> anyhow::Result<()> {
.ok_or_else(|| anyhow::anyhow!("TransactionPlannerResponse missing plan"))?;

// Hold on to the swap plaintext to be able to claim.
let swap_plaintext = TryInto::<penumbra_sdk_transaction::TransactionPlan>::try_into(plan.clone())?
.swap_plans()
.next()
.expect("swap plan must be present")
.swap_plaintext
.clone();
let swap_plaintext =
TryInto::<penumbra_sdk_transaction::TransactionPlan>::try_into(plan.clone())?
.swap_plans()
.next()
.expect("swap plan must be present")
.swap_plaintext
.clone();

// 5.2. Get authorization data for the transaction from pclientd (signing).
let auth_data = custody_client
Expand Down
12 changes: 10 additions & 2 deletions crates/bin/pd/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,18 @@ pub enum NetworkCommand {
#[clap(long, env = "penumbra_sdk_PD_TM_EXTERNAL_ADDR")]
external_address: Option<SocketAddr>,
/// When generating Tendermint config, use this socket to bind the Tendermint RPC service.
#[clap(long, env = "penumbra_sdk_PD_TM_RPC_BIND", default_value = "0.0.0.0:26657")]
#[clap(
long,
env = "penumbra_sdk_PD_TM_RPC_BIND",
default_value = "0.0.0.0:26657"
)]
tendermint_rpc_bind: SocketAddr,
/// When generating Tendermint config, use this socket to bind the Tendermint P2P service.
#[clap(long, env = "penumbra_sdk_PD_TM_P2P_BIND", default_value = "0.0.0.0:26656")]
#[clap(
long,
env = "penumbra_sdk_PD_TM_P2P_BIND",
default_value = "0.0.0.0:26656"
)]
tendermint_p2p_bind: SocketAddr,
/// Leave the downloaded archive file on disk after extraction.
#[clap(long, env = "penumbra_sdk_PD_LEAVE_ARCHIVE", action)]
Expand Down
25 changes: 13 additions & 12 deletions crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,19 @@ async fn main() -> anyhow::Result<()> {

let tm_proxy = penumbra_sdk_tendermint_proxy::TendermintProxy::new(cometbft_addr);

let grpc_routes = penumbra_sdk_app::rpc::routes(&storage, tm_proxy, enable_expensive_rpc)?
.into_axum_router()
.layer(
ServiceBuilder::new().layer(TraceLayer::new_for_grpc().make_span_with(
|req: &http::Request<_>| match remote_addr(req) {
Some(remote_addr) => {
tracing::error_span!("grpc", ?remote_addr)
}
None => tracing::error_span!("grpc"),
},
)),
);
let grpc_routes =
penumbra_sdk_app::rpc::routes(&storage, tm_proxy, enable_expensive_rpc)?
.into_axum_router()
.layer(
ServiceBuilder::new().layer(TraceLayer::new_for_grpc().make_span_with(
|req: &http::Request<_>| match remote_addr(req) {
Some(remote_addr) => {
tracing::error_span!("grpc", ?remote_addr)
}
None => tracing::error_span!("grpc"),
},
)),
);

// Create Axum routes for the frontend app.
let frontend = pd::zipserve::router("/app/", pd::MINIFRONT_ARCHIVE_BYTES);
Expand Down
6 changes: 4 additions & 2 deletions crates/bin/pd/src/network/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,8 @@ mod tests {
assert_eq!(testnet_config.name, "test-chain-1234");
assert_eq!(testnet_config.genesis.validators.len(), 0);
// No external address template was given, so only 1 validator will be present.
let penumbra_sdk_app::genesis::AppState::Content(app_state) = testnet_config.genesis.app_state
let penumbra_sdk_app::genesis::AppState::Content(app_state) =
testnet_config.genesis.app_state
else {
unimplemented!("TODO: support checkpointed app state")
};
Expand Down Expand Up @@ -803,7 +804,8 @@ mod tests {
)?;
assert_eq!(testnet_config.name, "test-chain-4567");
assert_eq!(testnet_config.genesis.validators.len(), 0);
let penumbra_sdk_app::genesis::AppState::Content(app_state) = testnet_config.genesis.app_state
let penumbra_sdk_app::genesis::AppState::Content(app_state) =
testnet_config.genesis.app_state
else {
unimplemented!("TODO: support checkpointed app state")
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ async fn app_can_define_and_delegate_to_a_validator() -> anyhow::Result<()> {

// Show that the existing validator is and was active.
{
use penumbra_sdk_stake::{component::validator_handler::ValidatorDataRead, validator::State};
use penumbra_sdk_stake::{
component::validator_handler::ValidatorDataRead, validator::State,
};
let start = snapshot_start
.get_validator_state(&existing_validator_id)
.await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ async fn app_can_disable_community_pool_spends() -> anyhow::Result<()> {
},
},
community_pool_content: penumbra_sdk_community_pool::genesis::Content {
community_pool_params: penumbra_sdk_community_pool::params::CommunityPoolParameters {
// Disable community spend proposals.
community_pool_spend_proposals_enabled: false,
},
community_pool_params:
penumbra_sdk_community_pool::params::CommunityPoolParameters {
// Disable community spend proposals.
community_pool_spend_proposals_enabled: false,
},
..Default::default()
},
..Default::default()
Expand Down
4 changes: 3 additions & 1 deletion crates/core/app/tests/app_can_undelegate_from_a_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ use {
penumbra_sdk_num::fixpoint::U128x128,
penumbra_sdk_proto::DomainType,
penumbra_sdk_sct::component::clock::EpochRead as _,
penumbra_sdk_stake::{component::validator_handler::ValidatorDataRead as _, UndelegateClaimPlan},
penumbra_sdk_stake::{
component::validator_handler::ValidatorDataRead as _, UndelegateClaimPlan,
},
penumbra_sdk_transaction::{
memo::MemoPlaintext, plan::MemoPlan, TransactionParameters, TransactionPlan,
},
Expand Down
5 changes: 4 additions & 1 deletion crates/core/app/tests/common/ibc_tests/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ impl TestNodeWithIBC {
pub fn create_tendermint_header(
&self,
trusted_height: Option<Height>,
penumbra_sdk_proto::util::tendermint_proxy::v1::GetBlockByHeightResponse{block_id: _, block}: penumbra_sdk_proto::util::tendermint_proxy::v1::GetBlockByHeightResponse,
penumbra_sdk_proto::util::tendermint_proxy::v1::GetBlockByHeightResponse {
block_id: _,
block,
}: penumbra_sdk_proto::util::tendermint_proxy::v1::GetBlockByHeightResponse,
) -> Result<TendermintHeader> {
let pk = self
.node
Expand Down
4 changes: 3 additions & 1 deletion crates/core/app/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ pub use {
temp_storage_ext::TempStorageExt, test_node_builder_ext::BuilderExt,
test_node_ext::TestNodeExt, validator_read_ext::ValidatorDataReadExt,
},
penumbra_sdk_test_subscriber::{set_tracing_subscriber, set_tracing_subscriber_with_env_filter},
penumbra_sdk_test_subscriber::{
set_tracing_subscriber, set_tracing_subscriber_with_env_filter,
},
};

/// Penumbra-specific extensions to the mock consensus builder.
Expand Down
5 changes: 4 additions & 1 deletion crates/core/app/tests/common/test_node_builder_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ pub trait BuilderExt: Sized {

impl BuilderExt for Builder {
type Error = anyhow::Error;
fn with_penumbra_sdk_auto_app_state(mut self, app_state: AppState) -> Result<Self, Self::Error> {
fn with_penumbra_sdk_auto_app_state(
mut self,
app_state: AppState,
) -> Result<Self, Self::Error> {
let Self { keyring, .. } = &self;
let mut content = match app_state {
AppState::Content(c) => c,
Expand Down
9 changes: 7 additions & 2 deletions crates/core/asset/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ mod tests {
penumbra_sdk_display_denom.format_value(6700001u64.into()),
"6.700001"
);
assert_eq!(penumbra_sdk_display_denom.format_value(1u64.into()), "0.000001");
assert_eq!(
penumbra_sdk_display_denom.format_value(1u64.into()),
"0.000001"
);

// with exponent 3, 1782000 formats to 1782
let mpenumbra_sdk_display_denom = REGISTRY.parse_unit("mpenumbra");
Expand Down Expand Up @@ -183,7 +186,9 @@ mod tests {
mpenumbra_sdk_display_denom.parse_value("1782").unwrap(),
1782000u64.into()
);
assert!(mpenumbra_sdk_display_denom.parse_value("1782.0001").is_err());
assert!(mpenumbra_sdk_display_denom
.parse_value("1782.0001")
.is_err());

let upenumbra_sdk_display_denom = REGISTRY.parse_unit("upenumbra");
assert_eq!(
Expand Down
8 changes: 5 additions & 3 deletions crates/core/component/dex/src/component/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,11 @@ impl QueryService for Server {
}
};
Ok(tonic::Response::new(
s.map_ok(|p: penumbra_sdk_proto::core::component::dex::v1::Position| {
LiquidityPositionsByIdResponse { data: Some(p) }
})
s.map_ok(
|p: penumbra_sdk_proto::core::component::dex::v1::Position| {
LiquidityPositionsByIdResponse { data: Some(p) }
},
)
.map_err(|e: anyhow::Error| {
tonic::Status::unavailable(format!(
"error getting position value from storage: {e}"
Expand Down
4 changes: 3 additions & 1 deletion crates/core/component/fee/src/component/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use async_trait::async_trait;
use cnidarium::Storage;
use penumbra_sdk_proto::core::component::fee::v1::{self as pb, query_service_server::QueryService};
use penumbra_sdk_proto::core::component::fee::v1::{
self as pb, query_service_server::QueryService,
};

use super::StateReadExt;

Expand Down
3 changes: 2 additions & 1 deletion crates/core/component/funding/src/component/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ pub fn register_metrics() {
);
}

pub const TOTAL_VALIDATOR_REWARDS: &str = "penumbra_sdk_funding_total_validator_rewards_staking_token";
pub const TOTAL_VALIDATOR_REWARDS: &str =
"penumbra_sdk_funding_total_validator_rewards_staking_token";
pub const VALIDATOR_FUNDING_VS_BUDGET_DIFFERENCE: &str =
"penumbra_sdk_funding_validator_vs_budget_difference_staking_token";
pub const FETCH_FUNDING_QUEUE_LATENCY: &str =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use async_trait::async_trait;
use cnidarium::{StateRead, StateWrite};
use futures::{Future, FutureExt};
use penumbra_sdk_num::Amount;
use penumbra_sdk_proto::{state::future::DomainFuture, DomainType, StateReadProto, StateWriteProto};
use penumbra_sdk_proto::{
state::future::DomainFuture, DomainType, StateReadProto, StateWriteProto,
};
use std::pin::Pin;
use tendermint::PublicKey;
use tracing::instrument;
Expand Down
4 changes: 3 additions & 1 deletion crates/core/transaction/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ mod test {
output::Output {
body: output::Body {
note_payload: penumbra_sdk_shielded_pool::NotePayload {
note_commitment: penumbra_sdk_shielded_pool::note::StateCommitment(Fq::default()),
note_commitment: penumbra_sdk_shielded_pool::note::StateCommitment(
Fq::default(),
),
ephemeral_key: [0u8; 32]
.as_slice()
.try_into()
Expand Down
4 changes: 3 additions & 1 deletion crates/core/transaction/src/view/action_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use penumbra_sdk_dex::{
swap::SwapView,
swap_claim::SwapClaimView,
};
use penumbra_sdk_governance::{ProposalDepositClaim, ProposalSubmit, ProposalWithdraw, ValidatorVote};
use penumbra_sdk_governance::{
ProposalDepositClaim, ProposalSubmit, ProposalWithdraw, ValidatorVote,
};
use penumbra_sdk_ibc::IbcRelay;
use penumbra_sdk_proto::{core::transaction::v1 as pbt, DomainType};
use penumbra_sdk_shielded_pool::Ics20Withdrawal;
Expand Down
8 changes: 6 additions & 2 deletions crates/proto/src/protobuf/tendermint_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ pub struct HeightOverflowError {
source: <i64 as TryFrom<u64>>::Error,
}

impl TryFrom<tendermint_rpc::endpoint::abci_query::AbciQuery> for penumbra_sdk_pb::AbciQueryResponse {
impl TryFrom<tendermint_rpc::endpoint::abci_query::AbciQuery>
for penumbra_sdk_pb::AbciQueryResponse
{
type Error = HeightOverflowError;
fn try_from(
tendermint_rpc::endpoint::abci_query::AbciQuery {
Expand Down Expand Up @@ -338,7 +340,9 @@ impl From<tendermint::merkle::proof::ProofOp> for crate::tendermint::crypto::Pro

// === get_block_by_height ===

impl TryFrom<tendermint_rpc::endpoint::block::Response> for penumbra_sdk_pb::GetBlockByHeightResponse {
impl TryFrom<tendermint_rpc::endpoint::block::Response>
for penumbra_sdk_pb::GetBlockByHeightResponse
{
type Error = anyhow::Error;
fn try_from(
tendermint_rpc::endpoint::block::Response {
Expand Down
5 changes: 4 additions & 1 deletion crates/test/mock-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ impl MockClient {
self.swaps.get(commitment).cloned()
}

pub fn position(&self, commitment: note::StateCommitment) -> Option<penumbra_sdk_tct::Position> {
pub fn position(
&self,
commitment: note::StateCommitment,
) -> Option<penumbra_sdk_tct::Position> {
self.sct.witness(commitment).map(|proof| proof.position())
}

Expand Down
Loading

0 comments on commit fdafd9a

Please sign in to comment.