Add --fee-burn-percentage

This commit is contained in:
Michael Vines 2020-02-18 16:21:15 -07:00
parent ac1d075d73
commit 3975c7f8c9
1 changed files with 30 additions and 9 deletions

View File

@ -104,12 +104,18 @@ pub fn load_genesis_accounts(file: &str, genesis_config: &mut GenesisConfig) ->
#[allow(clippy::cognitive_complexity)] #[allow(clippy::cognitive_complexity)]
fn main() -> Result<(), Box<dyn error::Error>> { fn main() -> Result<(), Box<dyn error::Error>> {
let default_target_lamports_per_signature = &FeeCalculator::default() let fee_calculator = FeeCalculator::default();
.target_lamports_per_signature let (
.to_string(); default_target_lamports_per_signature,
let default_target_signatures_per_slot = &FeeCalculator::default() default_target_signatures_per_slot,
.target_signatures_per_slot default_fee_burn_percentage,
.to_string(); ) = {
(
&fee_calculator.target_lamports_per_signature.to_string(),
&fee_calculator.target_signatures_per_slot.to_string(),
&fee_calculator.burn_percent.to_string(),
)
};
let rent = Rent::default(); let rent = Rent::default();
let ( let (
@ -123,6 +129,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
&rent.burn_percent.to_string(), &rent.burn_percent.to_string(),
) )
}; };
// vote account // vote account
let default_bootstrap_validator_lamports = &sol_to_lamports(500.0) let default_bootstrap_validator_lamports = &sol_to_lamports(500.0)
.max(VoteState::get_rent_exempt_reserve(&rent)) .max(VoteState::get_rent_exempt_reserve(&rent))
@ -274,6 +281,15 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.help("percentage of collected rent to burn") .help("percentage of collected rent to burn")
.validator(is_valid_percentage), .validator(is_valid_percentage),
) )
.arg(
Arg::with_name("fee_burn_percentage")
.long("fee-burn-percentage")
.value_name("NUMBER")
.takes_value(true)
.default_value(default_fee_burn_percentage)
.help("percentage of collected fee to burn")
.validator(is_valid_percentage),
)
.arg( .arg(
Arg::with_name("target_signatures_per_slot") Arg::with_name("target_signatures_per_slot")
.long("target-signatures-per-slot") .long("target-signatures-per-slot")
@ -427,10 +443,11 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let ticks_per_slot = value_t_or_exit!(matches, "ticks_per_slot", u64); let ticks_per_slot = value_t_or_exit!(matches, "ticks_per_slot", u64);
let fee_calculator = FeeCalculator::new( let mut fee_calculator = FeeCalculator::new(
value_t_or_exit!(matches, "target_lamports_per_signature", u64), value_t_or_exit!(matches, "target_lamports_per_signature", u64),
value_t_or_exit!(matches, "target_signatures_per_slot", usize), value_t_or_exit!(matches, "target_signatures_per_slot", usize),
); );
fee_calculator.burn_percent = value_t_or_exit!(matches, "fee_burn_percentage", u8);
let mut poh_config = PohConfig::default(); let mut poh_config = PohConfig::default();
poh_config.target_tick_duration = if matches.is_present("target_tick_duration") { poh_config.target_tick_duration = if matches.is_present("target_tick_duration") {
@ -532,7 +549,9 @@ fn main() -> Result<(), Box<dyn error::Error>> {
Shred version: {}\n\ Shred version: {}\n\
Hashes per tick: {:?}\n\ Hashes per tick: {:?}\n\
Slots per epoch: {}\n\ Slots per epoch: {}\n\
Capitalization: {} SOL in {} accounts\ {:?}\n\
{:?}\n\
Capitalization: {} SOL in {} accounts\n\
", ",
Utc.timestamp(genesis_config.creation_time, 0).to_rfc3339(), Utc.timestamp(genesis_config.creation_time, 0).to_rfc3339(),
operating_mode, operating_mode,
@ -540,6 +559,8 @@ fn main() -> Result<(), Box<dyn error::Error>> {
compute_shred_version(&genesis_config.hash(), None), compute_shred_version(&genesis_config.hash(), None),
genesis_config.poh_config.hashes_per_tick, genesis_config.poh_config.hashes_per_tick,
slots_per_epoch, slots_per_epoch,
genesis_config.rent,
genesis_config.fee_calculator,
lamports_to_sol( lamports_to_sol(
genesis_config genesis_config
.accounts .accounts
@ -552,7 +573,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
}) })
.sum::<u64>() .sum::<u64>()
), ),
genesis_config.accounts.len() genesis_config.accounts.len(),
); );
Ok(()) Ok(())