Fix bad rent in Bank::deposit as if since epoch 0 (#10468) (#11539)

* Fix bad rent in Bank::deposit as if since epoch 0

* Remove redundant predicate

* Rename

* Start to add tests with some cleanup

* Forgot to add refactor code...

* Enchance test

* Really fix rent timing in deposit with robust test

* Simplify new behavior by disabling rent altogether

(cherry picked from commit 6c242f3fec)

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
This commit is contained in:
mergify[bot]
2020-08-11 16:20:06 +00:00
committed by GitHub
parent 4d49c99ac9
commit 53e917b54f
5 changed files with 120 additions and 22 deletions

View File

@@ -14,6 +14,7 @@ use crate::{
shred_version::compute_shred_version,
signature::{Keypair, Signer},
system_program,
timing::years_as_slots,
};
use bincode::{deserialize, serialize};
use chrono::{TimeZone, Utc};
@@ -183,6 +184,26 @@ impl GenesisConfig {
pub fn add_rewards_pool(&mut self, pubkey: Pubkey, account: Account) {
self.rewards_pools.insert(pubkey, account);
}
pub fn hashes_per_tick(&self) -> Option<u64> {
self.poh_config.hashes_per_tick
}
pub fn ticks_per_slot(&self) -> u64 {
self.ticks_per_slot
}
pub fn ns_per_slot(&self) -> u128 {
self.poh_config.target_tick_duration.as_nanos() * self.ticks_per_slot() as u128
}
pub fn slots_per_year(&self) -> f64 {
years_as_slots(
1.0,
&self.poh_config.target_tick_duration,
self.ticks_per_slot(),
)
}
}
impl fmt::Display for GenesisConfig {