Skip to content

Commit 61f594d

Browse files
0o-de-lallynonastsm86
committed
[move] patch arithmetic issue on net_val_reward 6.9.2 (#142)
Co-authored-by: 0o-de-lally <1364012+0o-de-lally@users.noreply.github.com> Co-authored-by: Nonast <nakib@live.nl> Co-authored-by: sh1hsh1nk <13179671+sm86@users.noreply.github.com>
1 parent bc94e27 commit 61f594d

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

.github/actions/build_env/action.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ description: initialize ubuntu environment
33
runs:
44
using: composite
55
steps:
6-
76
- name: free disk space
87
uses: jlumbroso/free-disk-space@main
98
with:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ In general, we have a light touch approach with our upstream dependencies, and o
2323

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

26-
Core Devs should [start here](./docs/core_devs/dev_quick_start.md).
26+
Core Devs should [start here](./docs/core_devs/dev_quick_start.md).

framework/libra-framework/sources/ol_sources/epoch_boundary.move

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -268,19 +268,21 @@ module diem_framework::epoch_boundary {
268268

269269
// since we reserved some fees to go to the oracle miners
270270
// we take the NET REWARD of the validators, since it is the equivalent of what the validator would earn net of entry fee.
271-
let net_val_reward = nominal_reward_to_vals - entry_fee;
272-
273-
if (coin::value(&all_fees) > net_val_reward) {
274-
let oracle_budget = coin::extract(&mut all_fees, net_val_reward);
275-
status.oracle_budget = coin::value(&oracle_budget);
276-
277-
let (count, amount) = oracle::epoch_boundary(root, &mut oracle_budget);
278-
status.oracle_pay_count = count;
279-
status.oracle_pay_amount = amount;
280-
status.oracle_pay_success = (amount > 0);
281-
// in case there is any dust left
282-
ol_account::merge_coins(&mut all_fees, oracle_budget);
283-
};
271+
if (nominal_reward_to_vals > entry_fee) {
272+
let net_val_reward = nominal_reward_to_vals - entry_fee;
273+
274+
if (coin::value(&all_fees) > net_val_reward) {
275+
let oracle_budget = coin::extract(&mut all_fees, net_val_reward);
276+
status.oracle_budget = coin::value(&oracle_budget);
277+
278+
let (count, amount) = oracle::epoch_boundary(root, &mut oracle_budget);
279+
status.oracle_pay_count = count;
280+
status.oracle_pay_amount = amount;
281+
status.oracle_pay_success = (amount > 0);
282+
// in case there is any dust left
283+
ol_account::merge_coins(&mut all_fees, oracle_budget);
284+
};
285+
};
284286

285287
// remainder gets burnt according to fee maker preferences
286288
let (b_success, b_fees) = burn::epoch_burn_fees(root, &mut all_fees);

framework/libra-framework/sources/ol_sources/grade.move

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ module ol_framework::grade {
1717
/// one validator before jailing?
1818
const FAILED_PROPS_THRESHOLD_PCT: u64 =20;
1919

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

@@ -90,7 +91,7 @@ module ol_framework::grade {
9091
let net = proposed - failed;
9192
let net_props_vs_leader= fixed_point32::create_from_rational(net,
9293
highest_net_props);
93-
fixed_point32::multiply_u64(100, net_props_vs_leader) > FAILED_PROPS_THRESHOLD_PCT
94+
fixed_point32::multiply_u64(100, net_props_vs_leader) > TRAILING_VALIDATOR_THRESHOLD
9495
} else { false }
9596
}
9697
}

0 commit comments

Comments
 (0)