* - make cost_tracker a member of bank, remove shared instance from TPU; (#20627)
- decouple cost_model from cost_tracker; allowing one cost_model
instance being shared within a validator;
- update cost_model api to calculate_cost(&self...)->transaction_cost
(cherry picked from commit 7496b5784b
)
# Conflicts:
# core/src/banking_stage.rs
# ledger-tool/src/main.rs
# runtime/src/bank.rs
# runtime/src/cost_model.rs
# runtime/src/cost_tracker.rs
* manual fix merge conflicts
Co-authored-by: Tao Zhu <82401714+taozhu-chicago@users.noreply.github.com>
Co-authored-by: Tao Zhu <tao@solana.com>
This commit is contained in:
@@ -745,18 +745,16 @@ fn compute_slot_cost(blockstore: &Blockstore, slot: Slot) -> Result<(), String>
|
||||
let mut program_ids = HashMap::new();
|
||||
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());
|
||||
let mut cost_tracker = CostTracker::default();
|
||||
let mut cost_tracker_stats = CostTrackerStats::default();
|
||||
|
||||
for entry in &entries {
|
||||
transactions += entry.transactions.len();
|
||||
let mut cost_model = cost_model.write().unwrap();
|
||||
for transaction in &entry.transactions {
|
||||
programs += transaction.message().instructions.len();
|
||||
let tx_cost = cost_model.calculate_cost(transaction, true);
|
||||
if cost_tracker
|
||||
.try_add(tx_cost, &mut cost_tracker_stats)
|
||||
.try_add(transaction, &tx_cost, &mut cost_tracker_stats)
|
||||
.is_err()
|
||||
{
|
||||
println!(
|
||||
|
Reference in New Issue
Block a user