gas counter scale up fix
@@ -209,22 +209,26 @@ impl GasCounter {
}
pub fn commit_gas_limit_aggregated(blocks: &[Block]) -> U256 {
- U256::from(Self::BASE_COMMIT_BLOCKS_TX_COST)
+ let approx_limit = U256::from(Self::BASE_COMMIT_BLOCKS_TX_COST)
+ blocks
.iter()
- .fold(U256::zero(), |acc, block| acc + block.commit_gas_limit)
+ .fold(U256::zero(), |acc, block| acc + block.commit_gas_limit);
+
+ Self::scale_up(approx_limit)
}
pub fn execute_gas_limit_aggregated(blocks: &[Block]) -> U256 {
- U256::from(Self::BASE_EXECUTE_BLOCKS_TX_COST)
+ let approx_limit = U256::from(Self::BASE_EXECUTE_BLOCKS_TX_COST)
+ blocks
.iter()
- .fold(U256::zero(), |acc, block| acc + block.verify_gas_limit)
+ .fold(U256::zero(), |acc, block| acc + block.verify_gas_limit);
+
+ Self::scale_up(approx_limit)
}
- /// Increases the value by 30%.
+ /// Increases the value by 35%.
fn scale_up(value: U256) -> U256 {
- value * U256::from(130) / U256::from(100)
+ value * U256::from(135) / U256::from(100)
}
}
