Skip to content

Commit

Permalink
[move] patch arithmetic issue on net_val_reward 6.9.2 (#142)
Browse files Browse the repository at this point in the history
Co-authored-by: 0o-de-lally <[email protected]>
Co-authored-by: Nonast <[email protected]>
Co-authored-by: sh1hsh1nk <[email protected]>
  • Loading branch information
3 people committed Jan 15, 2024
1 parent bc94e27 commit 61f594d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
1 change: 0 additions & 1 deletion .github/actions/build_env/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ description: initialize ubuntu environment
runs:
using: composite
steps:

- name: free disk space
uses: jlumbroso/free-disk-space@main
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ In general, we have a light touch approach with our upstream dependencies, and o

Smart Contract Devs should [start here](./docs/publishing_smart_contracts.md).

Core Devs should [start here](./docs/core_devs/dev_quick_start.md).
Core Devs should [start here](./docs/core_devs/dev_quick_start.md).
28 changes: 15 additions & 13 deletions framework/libra-framework/sources/ol_sources/epoch_boundary.move
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,21 @@ module diem_framework::epoch_boundary {

// since we reserved some fees to go to the oracle miners
// we take the NET REWARD of the validators, since it is the equivalent of what the validator would earn net of entry fee.
let net_val_reward = nominal_reward_to_vals - entry_fee;

if (coin::value(&all_fees) > net_val_reward) {
let oracle_budget = coin::extract(&mut all_fees, net_val_reward);
status.oracle_budget = coin::value(&oracle_budget);

let (count, amount) = oracle::epoch_boundary(root, &mut oracle_budget);
status.oracle_pay_count = count;
status.oracle_pay_amount = amount;
status.oracle_pay_success = (amount > 0);
// in case there is any dust left
ol_account::merge_coins(&mut all_fees, oracle_budget);
};
if (nominal_reward_to_vals > entry_fee) {
let net_val_reward = nominal_reward_to_vals - entry_fee;

if (coin::value(&all_fees) > net_val_reward) {
let oracle_budget = coin::extract(&mut all_fees, net_val_reward);
status.oracle_budget = coin::value(&oracle_budget);

let (count, amount) = oracle::epoch_boundary(root, &mut oracle_budget);
status.oracle_pay_count = count;
status.oracle_pay_amount = amount;
status.oracle_pay_success = (amount > 0);
// in case there is any dust left
ol_account::merge_coins(&mut all_fees, oracle_budget);
};
};

// remainder gets burnt according to fee maker preferences
let (b_success, b_fees) = burn::epoch_burn_fees(root, &mut all_fees);
Expand Down
5 changes: 3 additions & 2 deletions framework/libra-framework/sources/ol_sources/grade.move
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module ol_framework::grade {
/// one validator before jailing?
const FAILED_PROPS_THRESHOLD_PCT: u64 =20;

/// how far behind the leading validator by net proposals
/// percent of net proposals vs. leading val
/// i.e. how far behind the leading validator by net proposals
/// should the trailing validator be allowed
const TRAILING_VALIDATOR_THRESHOLD: u64 = 5;

Expand Down Expand Up @@ -90,7 +91,7 @@ module ol_framework::grade {
let net = proposed - failed;
let net_props_vs_leader= fixed_point32::create_from_rational(net,
highest_net_props);
fixed_point32::multiply_u64(100, net_props_vs_leader) > FAILED_PROPS_THRESHOLD_PCT
fixed_point32::multiply_u64(100, net_props_vs_leader) > TRAILING_VALIDATOR_THRESHOLD
} else { false }
}
}

0 comments on commit 61f594d

Please sign in to comment.