Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Define non-integer type #124

Merged
merged 4 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions specs/consensus.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` <!--TODO check some bounds here-->
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:
Expand Down Expand Up @@ -721,7 +722,7 @@ proposer.latestEntry += proposer.pendingRewards // proposer.votingPower
proposer.pendingRewards = 0

blockReward = state.activeValidatorSet.proposerBlockReward
commissionReward = proposer.commission * blockReward
commissionReward = proposer.commissionRate.numerator * blockReward // proposer.commissionRate.denominator
proposer.commissionRewards += commissionReward
proposer.pendingRewards += blockReward - commissionReward

Expand Down
7 changes: 6 additions & 1 deletion specs/data_structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a relatively big change compared to the SDK. I guess switching from the current implementation to this rational type is really low priority, right?

Copy link
Member Author

@adlerjohn adlerjohn Feb 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it doesn't affect the devnet at all. We can argue that with proper abstractions it doesn't even need to be done for first testnet. Both Decimal as it currently exists in the SDK and Rational (i.e. our Decimal type) would produce similar numbers, so it wouldn't even change the state transitions in anything but in some cases that required lots of precision.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes under "optional to implement until we there is nothing left to crunch on" :-D (tagging @evan-forbes s.t. he is also aware of this.


## Consensus Parameters

Expand Down