Skip to content

Commit

Permalink
feat(pd): add --gas-price-simple flag to generate
Browse files Browse the repository at this point in the history
Adds a new CLI flag for `pd testnet generate`, to opt in to non-zero gas
prices. It's a bit of a shortcut to reuse the same numeric value across
all of them, but we can always add more CLI flags later to finetune.

Closes #4154.
  • Loading branch information
conorsch committed Apr 22, 2024
1 parent ac3217b commit d432eac
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions crates/bin/pd/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ pub enum TestnetCommand {
/// can be voted on.
#[clap(long)]
proposal_voting_blocks: Option<u64>,
/// The fixed gas price for all transactions on the network.
/// Described as "simple" because the single value will be reused
/// for all gas price types: block space, compact block space, verification, and execution.
/// The numeric value is one-thousandths of the staking token,
/// so `--gas-price-simple=1000` means all transactions will have a cost of 1penumbra.
#[clap(long)]
gas_price_simple: Option<u64>,
/// 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.
Expand Down
2 changes: 2 additions & 0 deletions crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ async fn main() -> anyhow::Result<()> {
allocations_input_file,
validators_input_file,
chain_id,
gas_price_simple,
preserve_chain_id,
external_addresses,
proposal_voting_blocks,
Expand Down Expand Up @@ -364,6 +365,7 @@ async fn main() -> anyhow::Result<()> {
epoch_duration,
unbonding_delay,
proposal_voting_blocks,
gas_price_simple,
)?;
tracing::info!(
n_validators = t.validators.len(),
Expand Down
20 changes: 20 additions & 0 deletions crates/bin/pd/src/testnet/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use crate::testnet::config::{get_testnet_dir, TestnetTendermintConfig, ValidatorKeys};
use anyhow::{Context, Result};
use penumbra_app::params::AppParameters;
use penumbra_fee::genesis::Content as FeeContent;
use penumbra_governance::genesis::Content as GovernanceContent;
use penumbra_keys::{keys::SpendKey, Address};
use penumbra_sct::genesis::Content as SctContent;
Expand Down Expand Up @@ -69,6 +70,7 @@ impl TestnetConfig {
epoch_duration: Option<u64>,
unbonding_delay: Option<u64>,
proposal_voting_blocks: Option<u64>,
gas_price_simple: Option<u64>,
) -> anyhow::Result<TestnetConfig> {
let external_addresses = external_addresses.unwrap_or_default();

Expand Down Expand Up @@ -98,6 +100,7 @@ impl TestnetConfig {
epoch_duration,
unbonding_delay,
proposal_voting_blocks,
gas_price_simple,
)?;
let genesis = Self::make_genesis(app_state)?;

Expand Down Expand Up @@ -186,6 +189,7 @@ impl TestnetConfig {
epoch_duration: Option<u64>,
unbonding_delay: Option<u64>,
proposal_voting_blocks: Option<u64>,
gas_price_simple: Option<u64>,
) -> anyhow::Result<penumbra_app::genesis::Content> {
let default_gov_params = penumbra_governance::params::GovernanceParameters::default();

Expand All @@ -198,6 +202,8 @@ impl TestnetConfig {
// Look up default app params, so we can fill in defaults.
let default_app_params = AppParameters::default();

let gas_price_simple = gas_price_simple.unwrap_or_default();

let app_state = penumbra_app::genesis::Content {
chain_id: chain_id.to_string(),
stake_content: StakeContent {
Expand All @@ -210,6 +216,16 @@ impl TestnetConfig {
..Default::default()
},
},
fee_content: FeeContent {
fee_params: penumbra_fee::params::FeeParameters {
fixed_gas_prices: penumbra_fee::GasPrices {
block_space_price: gas_price_simple,
compact_block_space_price: gas_price_simple,
verification_price: gas_price_simple,
execution_price: gas_price_simple,
},
},
},
governance_content: GovernanceContent {
governance_params: gov_params,
},
Expand Down Expand Up @@ -349,6 +365,7 @@ pub fn testnet_generate(
validators_input_file: Option<PathBuf>,
allocations_input_file: Option<PathBuf>,
proposal_voting_blocks: Option<u64>,
gas_price_simple: Option<u64>,
) -> anyhow::Result<()> {
tracing::info!(?chain_id, "Generating network config");
let t = TestnetConfig::generate(
Expand All @@ -363,6 +380,7 @@ pub fn testnet_generate(
epoch_duration,
unbonding_delay,
proposal_voting_blocks,
gas_price_simple,
)?;
tracing::info!(
n_validators = t.validators.len(),
Expand Down Expand Up @@ -668,6 +686,7 @@ mod tests {
None,
None,
None,
None,
)?;
assert_eq!(testnet_config.name, "test-chain-1234");
assert_eq!(testnet_config.genesis.validators.len(), 0);
Expand Down Expand Up @@ -697,6 +716,7 @@ mod tests {
None,
None,
None,
None,
)?;
assert_eq!(testnet_config.name, "test-chain-4567");
assert_eq!(testnet_config.genesis.validators.len(), 0);
Expand Down
2 changes: 1 addition & 1 deletion deployments/scripts/smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cargo build --quiet --release --bin pd
echo "Generating testnet config..."
EPOCH_DURATION="${EPOCH_DURATION:-50}"
UNBONDING_DELAY="${UNBONDING_DELAY:-50}"
cargo run --quiet --release --bin pd -- testnet generate --unbonding-delay "$UNBONDING_DELAY" --epoch-duration "$EPOCH_DURATION" --timeout-commit 500ms
cargo run --quiet --release --bin pd -- testnet generate --unbonding-delay "$UNBONDING_DELAY" --epoch-duration "$EPOCH_DURATION" --timeout-commit 500ms --gas-price-simple 5

echo "Starting CometBFT..."
cometbft start --log_level=error --home "${HOME}/.penumbra/testnet_data/node0/cometbft" > "${SMOKE_LOG_DIR}/comet.log" &
Expand Down

0 comments on commit d432eac

Please sign in to comment.