Skip to content

Commit

Permalink
Add params to amend-genesis command line for overriding gas limit and…
Browse files Browse the repository at this point in the history
… max inflation rate in output genesis file (#11374)

This will likely be used in the forknet setup to set specific non-zero
values for max-inflation-rate and gas-limit, so adding them to the
command proactively. The mocknet/mirror toolset uses the `amend-genesis`
command to initialize the genesis for the network to start with. There
will be follow-up changes to add these extra params to the
`amend-genesis` invocation from the mocknet setup code.

Related issue: #11371
  • Loading branch information
tayfunelmas committed May 22, 2024
1 parent 8fd58cb commit 4ec9561
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/amend-genesis/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ pub struct AmendGenesisCommand {
/// protocol_reward_rate to set in the output genesis file. Give a ratio here (e.g. "1/10")
#[clap(long)]
protocol_reward_rate: Option<Rational32>,
/// maximum inflation to se in the output genesis file. Give a ratio here (e.g. "1/10")
#[clap(long)]
max_inflation_rate: Option<Rational32>,
/// optional file that should contain a JSON-serialized shard layout
#[clap(long)]
shard_layout_file: Option<PathBuf>,
Expand All @@ -68,6 +71,9 @@ pub struct AmendGenesisCommand {
/// on accounts in the output state
#[clap(long)]
num_extra_bytes_record: Option<u64>,
/// initial gas limit to set in the output genesis file
#[clap(long)]
gas_limit: Option<u64>,
/// min_gas_price to set in the output genesis file
#[clap(long)]
min_gas_price: Option<u128>,
Expand All @@ -85,8 +91,10 @@ impl AmendGenesisCommand {
epoch_length: self.epoch_length,
transaction_validity_period: self.transaction_validity_period,
protocol_reward_rate: self.protocol_reward_rate,
max_inflation_rate: self.max_inflation_rate,
block_producer_kickout_threshold: self.block_producer_kickout_threshold,
chunk_producer_kickout_threshold: self.chunk_producer_kickout_threshold,
gas_limit: self.gas_limit,
min_gas_price: self.min_gas_price,
max_gas_price: self.max_gas_price,
};
Expand Down
8 changes: 8 additions & 0 deletions tools/amend-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ pub struct GenesisChanges {
pub epoch_length: Option<BlockHeightDelta>,
pub transaction_validity_period: Option<NumBlocks>,
pub protocol_reward_rate: Option<Rational32>,
pub max_inflation_rate: Option<Rational32>,
pub block_producer_kickout_threshold: Option<u8>,
pub chunk_producer_kickout_threshold: Option<u8>,
pub gas_limit: Option<u64>,
pub min_gas_price: Option<Balance>,
pub max_gas_price: Option<Balance>,
}
Expand Down Expand Up @@ -398,12 +400,18 @@ pub fn amend_genesis(
if let Some(r) = genesis_changes.protocol_reward_rate {
genesis.config.protocol_reward_rate = r;
}
if let Some(r) = genesis_changes.max_inflation_rate {
genesis.config.max_inflation_rate = r;
}
if let Some(t) = genesis_changes.block_producer_kickout_threshold {
genesis.config.block_producer_kickout_threshold = t;
}
if let Some(t) = genesis_changes.chunk_producer_kickout_threshold {
genesis.config.chunk_producer_kickout_threshold = t;
}
if let Some(l) = genesis_changes.gas_limit {
genesis.config.gas_limit = l;
}
if let Some(p) = genesis_changes.min_gas_price {
genesis.config.min_gas_price = p;
}
Expand Down

0 comments on commit 4ec9561

Please sign in to comment.