Rent tangential stuff (#5910)

* rename rent.rs to rent_calculator.rs

* add rent sysvar

* integrate rent_calculator with bank

* rent_calculator integration with genesis

* add test for rent sysvar
This commit is contained in:
Parth
2019-09-17 17:12:55 +05:30
committed by GitHub
parent b31d334ef4
commit d63518a835
11 changed files with 157 additions and 30 deletions

View File

@@ -11,7 +11,7 @@ use solana_sdk::genesis_block::Builder;
use solana_sdk::hash::{hash, Hash};
use solana_sdk::poh_config::PohConfig;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::rent::Rent;
use solana_sdk::rent_calculator::RentCalculator;
use solana_sdk::signature::{read_keypair, Keypair, KeypairUtil};
use solana_sdk::system_program;
use solana_sdk::timing;
@@ -70,7 +70,11 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let default_target_lamports_per_signature = &FeeCalculator::default()
.target_lamports_per_signature
.to_string();
let default_lamports_per_byte_year = &Rent::default().lamports_per_byte_year.to_string();
let default_lamports_per_byte_year =
&RentCalculator::default().lamports_per_byte_year.to_string();
let default_rent_exemption_threshold =
&RentCalculator::default().exemption_threshold.to_string();
let default_rent_burn_percentage = &RentCalculator::default().burn_percent.to_string();
let default_target_signatures_per_slot = &FeeCalculator::default()
.target_signatures_per_slot
.to_string();
@@ -184,6 +188,25 @@ fn main() -> Result<(), Box<dyn error::Error>> {
for accounts with data.",
),
)
.arg(
Arg::with_name("rent_exemption_threshold")
.long("rent-exemption-threshold")
.value_name("NUMBER")
.takes_value(true)
.default_value(default_rent_exemption_threshold)
.help(
"amount of time (in years) the balance has to include rent for \
to qualify as rent exempted account.",
),
)
.arg(
Arg::with_name("rent_burn_percentage")
.long("rent-burn-percentage")
.value_name("NUMBER")
.takes_value(true)
.default_value(default_rent_burn_percentage)
.help("amount of rent to burn, as a fraction of std::u8::MAX."),
)
.arg(
Arg::with_name("target_signatures_per_slot")
.long("target-signatures-per-slot")
@@ -315,6 +338,13 @@ fn main() -> Result<(), Box<dyn error::Error>> {
value_t_or_exit!(matches, "target_signatures_per_slot", usize);
builder = builder.fee_calculator(FeeCalculator::new_derived(&fee_calculator, 0));
let rent_calculator = RentCalculator {
lamports_per_byte_year: value_t_or_exit!(matches, "lamports_per_byte_year", u64),
exemption_threshold: value_t_or_exit!(matches, "rent_exemption_threshold", f64),
burn_percent: value_t_or_exit!(matches, "rent_burn_percentage", u8),
};
builder = builder.rent_calculator(rent_calculator);
let mut poh_config = PohConfig::default();
poh_config.target_tick_duration =
Duration::from_millis(value_t_or_exit!(matches, "target_tick_duration", u64));