From 5fb82c15f3a3de8e0673c57be045f563366932d8 Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Wed, 29 Nov 2023 09:30:03 -0800 Subject: [PATCH] feat(pd): custom voting periods testnet generate During testing of upgrades, it's been handy to reduce the default, static value of "24h" for voting on a given proposal, so that a proposal can be made, voted on, and passed, all within e.g. 1h. This setting greatly accelerates testing on devnets. Also includes customization var in deploy scripts for `epoch_duration`, which we're not currently overriding, but now we can if we want to. Ideally we'd set these customizations by just overriding the `pd testnet generate` command, but given that the cmd requires a storage dir arg that's non-standard, it's more straightforward to stick with the clunky vars-based approach for now. --- crates/bin/pd/src/main.rs | 6 +++++ crates/bin/pd/src/testnet/generate.rs | 26 ++++++++++++++++--- .../templates/job-generate.yaml | 6 +++++ .../charts/penumbra-network/values.yaml | 3 +++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/crates/bin/pd/src/main.rs b/crates/bin/pd/src/main.rs index 9d83371bbe..cd47c3ca81 100644 --- a/crates/bin/pd/src/main.rs +++ b/crates/bin/pd/src/main.rs @@ -183,6 +183,10 @@ enum TestnetCommand { /// Testnet name [default: latest testnet]. #[clap(long)] chain_id: Option, + /// The duration, in number of blocks, that a governance proposal + /// can be voted on. + #[clap(long)] + proposal_voting_blocks: Option, /// Base hostname for a validator's p2p service. If multiple validators /// exist in the genesis, e.g. via `--validators-input-file`, then /// numeric suffixes are automatically added, e.g. "-0", "-1", etc. @@ -600,6 +604,7 @@ async fn main() -> anyhow::Result<()> { chain_id, preserve_chain_id, external_addresses, + proposal_voting_blocks, }, testnet_dir, } => { @@ -655,6 +660,7 @@ async fn main() -> anyhow::Result<()> { active_validator_limit, epoch_duration, unbonding_epochs, + proposal_voting_blocks, )?; tracing::info!( n_validators = t.validators.len(), diff --git a/crates/bin/pd/src/testnet/generate.rs b/crates/bin/pd/src/testnet/generate.rs index a2164010f4..9521610006 100644 --- a/crates/bin/pd/src/testnet/generate.rs +++ b/crates/bin/pd/src/testnet/generate.rs @@ -5,6 +5,7 @@ use crate::testnet::config::{get_testnet_dir, TestnetTendermintConfig, Validator use anyhow::{Context, Result}; use penumbra_app::{genesis, params::AppParameters}; use penumbra_chain::{genesis::Content as ChainContent, params::ChainParameters}; +use penumbra_governance::genesis::Content as GovernanceContent; use penumbra_keys::{keys::SpendKey, Address}; use penumbra_shielded_pool::genesis::{ self as shielded_pool_genesis, Allocation, Content as ShieldedPoolContent, @@ -65,6 +66,7 @@ impl TestnetConfig { active_validator_limit: Option, epoch_duration: Option, unbonding_epochs: Option, + proposal_voting_blocks: Option, ) -> anyhow::Result { let external_addresses = external_addresses.unwrap_or_default(); @@ -93,6 +95,7 @@ impl TestnetConfig { active_validator_limit, epoch_duration, unbonding_epochs, + proposal_voting_blocks, )?; let genesis = Self::make_genesis(app_state)?; @@ -180,20 +183,33 @@ impl TestnetConfig { active_validator_limit: Option, epoch_duration: Option, unbonding_epochs: Option, + proposal_voting_blocks: Option, ) -> anyhow::Result { + let default_gov_params = penumbra_governance::params::GovernanceParameters::default(); + + let gov_params = penumbra_governance::params::GovernanceParameters { + proposal_voting_blocks: proposal_voting_blocks + .unwrap_or(default_gov_params.proposal_voting_blocks), + ..default_gov_params + }; + // Look up default app params, so we can fill in defaults. - let default_params = AppParameters::default(); + let default_app_params = AppParameters::default(); + let app_state = genesis::Content { stake_content: StakeContent { validators: validators.into_iter().map(Into::into).collect(), stake_params: StakeParameters { active_validator_limit: active_validator_limit - .unwrap_or(default_params.stake_params.active_validator_limit), + .unwrap_or(default_app_params.stake_params.active_validator_limit), unbonding_epochs: unbonding_epochs - .unwrap_or(default_params.stake_params.unbonding_epochs), + .unwrap_or(default_app_params.stake_params.unbonding_epochs), ..Default::default() }, }, + governance_content: GovernanceContent { + governance_params: gov_params, + }, shielded_pool_content: ShieldedPoolContent { allocations: allocations.clone(), }, @@ -202,7 +218,7 @@ impl TestnetConfig { chain_id: chain_id.to_string(), // Fall back to chain param defaults epoch_duration: epoch_duration - .unwrap_or(default_params.chain_params.epoch_duration), + .unwrap_or(default_app_params.chain_params.epoch_duration), }, }, ..Default::default() @@ -332,6 +348,7 @@ pub fn testnet_generate( external_addresses: Vec, validators_input_file: Option, allocations_input_file: Option, + proposal_voting_blocks: Option, ) -> anyhow::Result<()> { tracing::info!(?chain_id, "Generating network config"); let t = TestnetConfig::generate( @@ -345,6 +362,7 @@ pub fn testnet_generate( active_validator_limit, epoch_duration, unbonding_epochs, + proposal_voting_blocks, )?; tracing::info!( n_validators = t.validators.len(), diff --git a/deployments/charts/penumbra-network/templates/job-generate.yaml b/deployments/charts/penumbra-network/templates/job-generate.yaml index bd43204408..c572b308ac 100644 --- a/deployments/charts/penumbra-network/templates/job-generate.yaml +++ b/deployments/charts/penumbra-network/templates/job-generate.yaml @@ -74,6 +74,12 @@ spec: {{- if .Values.network.preserve_chain_id }} --preserve-chain-id \ {{- end }} + {{- if .Values.network.epoch_duration }} + --epoch-duration {{ .Values.network.epoch_duration }} \ + {{- end }} + {{- if .Values.network.proposal_voting_blocks }} + --proposal-voting-blocks {{ .Values.network.proposal_voting_blocks }} \ + {{- end }} --validators-input-file /penumbra/validators.json \ --external-addresses {{ .Values.network.external_addresses }} diff --git a/deployments/charts/penumbra-network/values.yaml b/deployments/charts/penumbra-network/values.yaml index 9f39c787a4..a66d470505 100644 --- a/deployments/charts/penumbra-network/values.yaml +++ b/deployments/charts/penumbra-network/values.yaml @@ -25,6 +25,9 @@ network: # It'd be grand to have a DNS hostname in here, e.g. `veil.petrichor.guru:31888`. # external_addresses: veil.petrichor.guru:31888 external_addresses: "" + # Customization of the voting period for governance proposals. + # Dial this down if you want faster voting for testing. + proposal_voting_blocks: # How many validators are present at genesis. This number must # match the count in the JSON file used to define the validators.