From 29c771efd5e8fe0ed5a894c61243d89ac47d627e Mon Sep 17 00:00:00 2001 From: John Adler Date: Wed, 10 Feb 2021 15:12:25 -0500 Subject: [PATCH 1/4] Use rational number representation for Decimal type. --- specs/data_structures.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/specs/data_structures.md b/specs/data_structures.md index a6402f3..7553a92 100644 --- a/specs/data_structures.md +++ b/specs/data_structures.md @@ -930,7 +930,12 @@ For explanation on entries, see the [reward distribution rationale document](../ ### Decimal -TODO define a format for numbers in the range `[0,1]` +| name | type | description | +| ------------- | ------ | --------------------- | +| `numerator` | uint64 | Rational numerator. | +| `denominator` | uint64 | Rational denominator. | + +Represents a (potentially) non-integer number. ## Consensus Parameters From 7d4f3e684a5fe6f514b44fa3aaa514ca8790627f Mon Sep 17 00:00:00 2001 From: John Adler Date: Wed, 10 Feb 2021 15:15:34 -0500 Subject: [PATCH 2/4] Add check for commission rate bounds. --- specs/consensus.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specs/consensus.md b/specs/consensus.md index 1db7d01..533941f 100644 --- a/specs/consensus.md +++ b/specs/consensus.md @@ -303,7 +303,8 @@ The following checks must be `true`: 1. `tx.fee.tipRateMax` >= `block.header.feeHeader.tipRate`. 1. `totalCost(0, bytesPaid)` <= `state.accounts[sender].balance`. 1. `tx.nonce` == `state.accounts[sender].nonce + 1`. -1. `tx.commissionRate` +1. `tx.commissionRate.denominator > 0`. +1. `tx.commissionRate.numerator <= tx.commissionRate.denominator`. 1. `state.accounts[sender].status` == `AccountStatus.None`. Apply the following to the state: From c61b59f28ebde173796186e4cce65cf34ccd487d Mon Sep 17 00:00:00 2001 From: John Adler Date: Wed, 10 Feb 2021 15:15:53 -0500 Subject: [PATCH 3/4] Fix reference to commissionRate field for proposer. --- specs/consensus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/consensus.md b/specs/consensus.md index 533941f..b42f548 100644 --- a/specs/consensus.md +++ b/specs/consensus.md @@ -722,7 +722,7 @@ proposer.latestEntry += proposer.pendingRewards // proposer.votingPower proposer.pendingRewards = 0 blockReward = state.activeValidatorSet.proposerBlockReward -commissionReward = proposer.commission * blockReward +commissionReward = proposer.commissionRate * blockReward proposer.commissionRewards += commissionReward proposer.pendingRewards += blockReward - commissionReward From 41f3d6c44d98087491a3d04f3eccafdedb1862a4 Mon Sep 17 00:00:00 2001 From: John Adler Date: Wed, 10 Feb 2021 15:16:52 -0500 Subject: [PATCH 4/4] Compute commission reward using rational rate. --- specs/consensus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/consensus.md b/specs/consensus.md index b42f548..e2c8afb 100644 --- a/specs/consensus.md +++ b/specs/consensus.md @@ -722,7 +722,7 @@ proposer.latestEntry += proposer.pendingRewards // proposer.votingPower proposer.pendingRewards = 0 blockReward = state.activeValidatorSet.proposerBlockReward -commissionReward = proposer.commissionRate * blockReward +commissionReward = proposer.commissionRate.numerator * blockReward // proposer.commissionRate.denominator proposer.commissionRewards += commissionReward proposer.pendingRewards += blockReward - commissionReward