Skip to content

Commit

Permalink
update bank to init fee_structure from FeeRateGovernor for both new_f…
Browse files Browse the repository at this point in the history
…rom_path and new_from_fields
  • Loading branch information
tao-stones committed Jan 18, 2024
1 parent 3fe6ae2 commit 1d3a8bb
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,16 +1077,6 @@ impl Bank {
debug_do_not_add_builtins,
);

// There is a bug in accounts_db's open_genesis_config() that sets lamports_per_signature
// to zero right after loading it from ledger, after the first block with a transaction
// in it is completed, the correct value will be set to it. This is a hack to restore it
let derived_fee_rate_governor =
FeeRateGovernor::new_derived(&genesis_config.fee_rate_governor, 0);
// new bank's fee_structure.lamports_per_signature be inline with
// what's configured in GenesisConfig
bank.fee_structure.lamports_per_signature =
derived_fee_rate_governor.lamports_per_signature;

// genesis needs stakes for all epochs up to the epoch implied by
// slot = 0 and genesis configuration
{
Expand Down Expand Up @@ -1857,6 +1847,7 @@ impl Bank {
additional_builtins,
debug_do_not_add_builtins,
);

bank.fill_missing_sysvar_cache_entries();
bank.rebuild_skipped_rewrites();

Expand Down Expand Up @@ -6671,6 +6662,17 @@ impl Bank {
&self.runtime_config.compute_budget.unwrap_or_default(),
false, /* debugging_features */
));

// genesis_config loaded by accounts_db::open_genesis_config() from ledger
// has it's lamports_per_signature set to zero; bank sets its value correctly
// after the first block with a transaction in it. This is a hack to mimic
// the process.
let derived_fee_rate_governor =
FeeRateGovernor::new_derived(&genesis_config.fee_rate_governor, 0);
// new bank's fee_structure.lamports_per_signature should be inline with
// what's configured in GenesisConfig
self.fee_structure.lamports_per_signature =
derived_fee_rate_governor.lamports_per_signature;
}

pub fn set_inflation(&self, inflation: Inflation) {
Expand Down

0 comments on commit 1d3a8bb

Please sign in to comment.