Skip to content

Commit

Permalink
safe math and more noice decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Jan 31, 2025
1 parent 81e4437 commit 5def551
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app-libs/stf/src/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,12 @@ impl ExecuteGetter for PublicGetter {
// This avoids leaking the exact number and cost of recent TrustedCalls
let noise =
MinimalChainSpec::one_unit(shielding_target_genesis_hash().unwrap_or_default())
/ STF_TX_FEE_UNIT_DIVIDER
* Balance::from(SgxRandomness::random_u32(0, 10));
.checked_div(STF_TX_FEE_UNIT_DIVIDER)
.unwrap_or(1)
.saturating_mul(SgxRandomness::random_u32(0, 10_000).into())
.checked_div(1000)
.unwrap_or_default();
// better to strictly subtract from real value to avoid overpayment errors during distribution
let noisy_fees = fees.saturating_sub(noise);
std::println!(
"⣿STF⣿ 🔍 PublicGetter query: undistributed fees at least {}",
Expand Down

0 comments on commit 5def551

Please sign in to comment.