update ledger tool to restore cost table from blockstore (#18489)
* update ledger tool to restore cost model from blockstore when compute-slot-cost * Move initialize_cost_table into cost_model, so the function can be tested and shared between validator and ledger-tool * refactor and simplify a test
This commit is contained in:
@ -14,7 +14,7 @@ use solana_clap_utils::{
|
||||
is_parsable, is_pubkey, is_pubkey_or_keypair, is_slot, is_valid_percentage,
|
||||
},
|
||||
};
|
||||
use solana_core::cost_model::{CostModel, ACCOUNT_MAX_COST, BLOCK_MAX_COST};
|
||||
use solana_core::cost_model::CostModel;
|
||||
use solana_core::cost_tracker::CostTracker;
|
||||
use solana_ledger::entry::Entry;
|
||||
use solana_ledger::{
|
||||
@ -737,10 +737,9 @@ fn compute_slot_cost(blockstore: &Blockstore, slot: Slot) -> Result<(), String>
|
||||
let mut transactions = 0;
|
||||
let mut programs = 0;
|
||||
let mut program_ids = HashMap::new();
|
||||
let cost_model = Arc::new(RwLock::new(CostModel::new(
|
||||
ACCOUNT_MAX_COST,
|
||||
BLOCK_MAX_COST,
|
||||
)));
|
||||
let mut cost_model = CostModel::default();
|
||||
cost_model.initialize_cost_table(&blockstore.read_program_costs().unwrap());
|
||||
let cost_model = Arc::new(RwLock::new(cost_model));
|
||||
let mut cost_tracker = CostTracker::new(cost_model.clone());
|
||||
|
||||
for entry in &entries {
|
||||
|
Reference in New Issue
Block a user