Skip to content

Commit

Permalink
fix nit, update test
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Sep 25, 2023
1 parent 634228f commit 53a8deb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions cost-model/src/cost_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,9 @@ impl CostTracker {
if self.vote_cost.saturating_add(cost) > self.vote_cost_limit {
return Err(CostTrackerError::WouldExceedVoteMaxLimit);
}
} else {
} else if self.block_cost.saturating_add(cost) > self.block_cost_limit {
// check against the total package cost
if self.block_cost.saturating_add(cost) > self.block_cost_limit {
return Err(CostTrackerError::WouldExceedBlockMaxLimit);
}
return Err(CostTrackerError::WouldExceedBlockMaxLimit);
}

// check if the transaction itself is more costly than the account_cost_limit
Expand Down
5 changes: 3 additions & 2 deletions cost-model/src/transaction_cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ impl UsageCostDetails {
#[cfg(test)]
mod tests {
use {
super::*,
crate::cost_model::CostModel,
solana_sdk::{
feature_set::FeatureSet,
Expand Down Expand Up @@ -211,8 +212,8 @@ mod tests {
)
.unwrap();

// expected vote tx cost: 2 write locks, 2 sig, 1 vote ix,
let expected_vote_cost = 4140;
// expected vote tx cost: 2 write locks, 1 sig, 1 vote ix, 8cu of loaded accounts size,
let expected_vote_cost = SIMPLE_VOTE_USAGE_COST;
// expected non-vote tx cost would include default loaded accounts size cost (16384) additionally
let expected_none_vote_cost = 20535;

Expand Down

0 comments on commit 53a8deb

Please sign in to comment.