Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RRR4R: rational -> decimal #1819

Merged
merged 54 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
abf9a65
changelog
rigelrozanski Jul 25, 2018
84c7fab
...
rigelrozanski Jul 25, 2018
c9ed668
decimal func working
rigelrozanski Jul 27, 2018
e4e78b4
decimal complete, untested
rigelrozanski Jul 27, 2018
206ed8b
fixing tests
rigelrozanski Jul 27, 2018
6cbe1ee
Merge remote-tracking branch 'origin/develop' into rigel/decimal
rigelrozanski Jul 27, 2018
ee627ed
decimal compile errors resolved
rigelrozanski Jul 27, 2018
2f130bb
test compile errors
rigelrozanski Jul 27, 2018
a2ced74
precision multiplier test
rigelrozanski Jul 27, 2018
1aa00b7
1% laptop battery
rigelrozanski Jul 27, 2018
9ffbf40
fixed TestNewDecFromStr
rigelrozanski Jul 27, 2018
f8be905
equalities working
rigelrozanski Jul 27, 2018
a598efb
fix bankers round chop
rigelrozanski Jul 27, 2018
697bb2e
...
rigelrozanski Jul 27, 2018
20486a9
working, some decimal issues resolved
rigelrozanski Jul 27, 2018
173acc9
fix rounding error
rigelrozanski Jul 28, 2018
44f24ac
rounding works
rigelrozanski Jul 28, 2018
34a9978
decimal works
rigelrozanski Jul 28, 2018
6b2dab7
...
rigelrozanski Jul 28, 2018
ee0e179
deleted rational
rigelrozanski Jul 28, 2018
546a4ca
rational conversion working
rigelrozanski Jul 28, 2018
5015fd4
revert changelog
rigelrozanski Jul 28, 2018
d2bf108
code compiles (not tests)
rigelrozanski Jul 28, 2018
3f4bb2e
went through all NewDec, made sure they were converted from NewRat pr…
rigelrozanski Jul 28, 2018
12e4022
test debugging
rigelrozanski Jul 28, 2018
d605058
all testing bugs besides the json marshalling fixed
rigelrozanski Aug 1, 2018
0a247fd
json unmarshal
rigelrozanski Aug 1, 2018
40d49bf
lint
rigelrozanski Aug 1, 2018
73c5d9c
Merge remote-tracking branch 'origin/develop' into rigel/decimal
rigelrozanski Aug 1, 2018
89dd6e4
document update
rigelrozanski Aug 1, 2018
5d939f8
Merge remote-tracking branch 'origin/develop' into rigel/decimal
rigelrozanski Aug 3, 2018
e5f2faf
fix lcd test
rigelrozanski Aug 3, 2018
09e7e25
cli test fix
rigelrozanski Aug 3, 2018
196fcce
mostly undo Dece -> Rate
rigelrozanski Aug 3, 2018
f43bf90
val comments
rigelrozanski Aug 3, 2018
16bc41e
Efficiency improvements
ValarDragon Aug 4, 2018
9c954ce
Cache another precisionInt() call.
ValarDragon Aug 4, 2018
9859476
Improve banker rounding efficiency
ValarDragon Aug 5, 2018
348cb1d
remove defer, make negation in-place.
ValarDragon Aug 5, 2018
e26a87d
chris val comments
rigelrozanski Aug 11, 2018
1e57807
bez comments
rigelrozanski Aug 11, 2018
609e07d
Aditya comments
rigelrozanski Aug 11, 2018
81e96e8
...
rigelrozanski Aug 11, 2018
fd52603
val comments
rigelrozanski Aug 13, 2018
b7aaac5
rebasing start
rigelrozanski Aug 13, 2018
e9900a3
Merge remote-tracking branch 'origin/develop' into rigel/decimal
rigelrozanski Aug 13, 2018
18b4826
...
rigelrozanski Aug 13, 2018
b77fc51
compiling
rigelrozanski Aug 13, 2018
24ce274
tests pass
rigelrozanski Aug 13, 2018
b600f71
cli fix
rigelrozanski Aug 13, 2018
d81775b
anton, cwgoes, val comments
rigelrozanski Aug 14, 2018
af48ed2
val and jae comments
rigelrozanski Aug 14, 2018
db72022
type
rigelrozanski Aug 14, 2018
fa57c38
undo reuse quo
rigelrozanski Aug 14, 2018
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
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ BREAKING CHANGES
* `gaiacli gov vote --voter`
* [x/gov] Added tags sub-package, changed tags to use dash-case
* [x/gov] Governance parameters are now stored in globalparams store
* [core] \#1807 Switch from use of rational to decimal
* [lcd] \#1866 Updated lcd /slashing/signing_info endpoint to take cosmosvalpub instead of cosmosvaladdr
* [types] sdk.NewCoin now takes sdk.Int, sdk.NewInt64Coin takes int64
* [cli] Genesis/key creation (`init`) now supports user-provided key passwords
Expand Down
5 changes: 3 additions & 2 deletions client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ func TestValidatorsQuery(t *testing.T) {
require.True(t, foundVal, "pkBech %v, owner %v", pkBech, validators[0].Owner)
}

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxx
Copy link
Contributor

Choose a reason for hiding this comment

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

Could a note be added here instead of a bunch of X's?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad, this was left over from debugging

func TestBonding(t *testing.T) {
name, password, denom := "test", "1234567890", "steak"
addr, seed := CreateAddr(t, "test", password, GetKeyBase(t))
Expand All @@ -398,7 +399,7 @@ func TestBonding(t *testing.T) {

// query validator
bond := getDelegation(t, port, addr, validator1Owner)
require.Equal(t, "60/1", bond.Shares.String())
require.Equal(t, "60.0000000000", bond.Shares.String())

//////////////////////
// testing unbonding
Expand All @@ -409,7 +410,7 @@ func TestBonding(t *testing.T) {

// query validator
bond = getDelegation(t, port, addr, validator1Owner)
require.Equal(t, "30/1", bond.Shares.String())
require.Equal(t, "30.0000000000", bond.Shares.String())

// check if tx was committed
require.Equal(t, uint32(0), resultTx.CheckTx.Code)
Expand Down
2 changes: 1 addition & 1 deletion client/lcd/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress
accAuth.Coins = sdk.Coins{sdk.NewInt64Coin("steak", 100)}
acc := gapp.NewGenesisAccount(&accAuth)
genesisState.Accounts = append(genesisState.Accounts, acc)
genesisState.StakeData.Pool.LooseTokens = genesisState.StakeData.Pool.LooseTokens.Add(sdk.NewRat(100))
genesisState.StakeData.Pool.LooseTokens = genesisState.StakeData.Pool.LooseTokens.Add(sdk.NewDec(100, 0))
}

appState, err := wire.MarshalJSONIndent(cdc, genesisState)
Expand Down
6 changes: 3 additions & 3 deletions cmd/gaia/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,18 @@ func GaiaAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (genesisState
}
acc := NewGenesisAccount(&accAuth)
genaccs[i] = acc
stakeData.Pool.LooseTokens = stakeData.Pool.LooseTokens.Add(sdk.NewRat(freeFermionsAcc)) // increase the supply
stakeData.Pool.LooseTokens = stakeData.Pool.LooseTokens.Add(sdk.NewDec(freeFermionsAcc, 0)) // increase the supply

// add the validator
if len(genTx.Name) > 0 {
desc := stake.NewDescription(genTx.Name, "", "", "")
validator := stake.NewValidator(genTx.Address,
sdk.MustGetAccPubKeyBech32(genTx.PubKey), desc)

stakeData.Pool.LooseTokens = stakeData.Pool.LooseTokens.Add(sdk.NewRat(freeFermionVal)) // increase the supply
stakeData.Pool.LooseTokens = stakeData.Pool.LooseTokens.Add(sdk.NewDec(freeFermionVal, 0)) // increase the supply

// add some new shares to the validator
var issuedDelShares sdk.Rat
var issuedDelShares sdk.Dec
validator, stakeData.Pool, issuedDelShares = validator.AddTokensFromDel(stakeData.Pool, freeFermionVal)
stakeData.Validators = append(stakeData.Validators, validator)

Expand Down
2 changes: 1 addition & 1 deletion cmd/gaia/app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func appStateFn(r *rand.Rand, accs []sdk.AccAddress) json.RawMessage {

// Default genesis state
stakeGenesis := stake.DefaultGenesisState()
stakeGenesis.Pool.LooseTokens = sdk.NewRat(1000)
stakeGenesis.Pool.LooseTokens = sdk.NewDec(1000, 0)
genesis := GenesisState{
Accounts: genesisAccounts,
StakeData: stakeGenesis,
Expand Down
4 changes: 2 additions & 2 deletions cmd/gaia/cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {

validator := executeGetValidator(t, fmt.Sprintf("gaiacli stake validator %s --output=json %v", barAddr, flags))
require.Equal(t, validator.Owner, barAddr)
require.True(sdk.RatEq(t, sdk.NewRat(2), validator.Tokens))
require.True(sdk.DecEq(t, sdk.NewDec(2, 0), validator.Tokens))

// unbond a single share
unbondStr := fmt.Sprintf("gaiacli stake unbond begin %v", flags)
Expand All @@ -149,7 +149,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {
require.Equal(t, int64(9), barAcc.GetCoins().AmountOf("steak").Int64(), "%v", barAcc)
*/
validator = executeGetValidator(t, fmt.Sprintf("gaiacli stake validator %s --output=json %v", barAddr, flags))
require.Equal(t, "1/1", validator.Tokens.String())
require.Equal(t, "1.0000000000", validator.Tokens.String())
}

func TestGaiaCLISubmitProposal(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/whitepaper.md
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ in the case of a successful double-spend attack.

Building on an approach pioneered by Ripple, Stellar [\[13\]][13] refined a
model of Federated Byzantine Agreement wherein the processes participating in
consensus do not constitute a fixed and globally known set. Rather, each
consensus do not constitute a fixed and globally known set. Decher, each
Copy link
Contributor

Choose a reason for hiding this comment

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

sed gone wrong lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted all instances (and all cases)

process node curates one or more "quorum slices", each constituting a set of
trusted processes. A "quorum" in Stellar is defined to be a set of nodes that
contain at least one quorum slice for each node in the set, such that agreement
Expand Down
2 changes: 1 addition & 1 deletion docs/sdk/core/app3.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ accounts.
We use this `Keeper` paradigm extensively in the SDK as the way to define what
kind of functionality each module gets access to. In particular, we try to
follow the *principle of least authority*.
Rather than providing full blown access to the `KVStore` or the `AccountMapper`,
Decher than providing full blown access to the `KVStore` or the `AccountMapper`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Sed caught something it shouldn't have XD

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addessed all

we restrict access to a small number of functions that do very specific things.

## App3
Expand Down
18 changes: 9 additions & 9 deletions docs/spec/governance/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ type VotingProcedure struct {

```go
type TallyingProcedure struct {
Threshold rational.Rational // Minimum propotion of Yes votes for proposal to pass. Initial value: 0.5
Veto rational.Rational // Minimum proportion of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3
GovernancePenalty sdk.Rat // Penalty if validator does not vote
Threshold sdk.Dec // Minimum propotion of Yes votes for proposal to pass. Initial value: 0.5
Veto sdk.Dec // Minimum proportion of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3
GovernancePenalty sdk.Dec // Penalty if validator does not vote
GracePeriod int64 // If validator entered validator set in this period of blocks before vote ended, governance penalty does not apply
}
```
Expand Down Expand Up @@ -81,7 +81,7 @@ This type is used in a temp map when tallying

```go
type ValidatorGovInfo struct {
Minus sdk.Rat
Minus sdk.Dec
Vote Vote
}
```
Expand All @@ -103,17 +103,17 @@ type Proposal struct {
VotingStartBlock int64 // Height of the block where MinDeposit was reached. -1 if MinDeposit is not reached
CurrentStatus ProposalStatus // Current status of the proposal

YesVotes sdk.Rat
NoVotes sdk.Rat
NoWithVetoVotes sdk.Rat
AbstainVotes sdk.Rat
YesVotes sdk.Dec
NoVotes sdk.Dec
NoWithVetoVotes sdk.Dec
AbstainVotes sdk.Dec
}
```

We also mention a method to update the tally for a given proposal:

```go
func (proposal Proposal) updateTally(vote byte, amount sdk.Rat)
func (proposal Proposal) updateTally(vote byte, amount sdk.Dec)
```

### Stores
Expand Down
4 changes: 2 additions & 2 deletions docs/spec/ibc/appendices.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ See [binary format as protobuf specification](./protobuf/queue.proto)
A Merkle tree (or a trie) generates a single hash that can be used to prove any element of the tree. In order to generate this hash, we first hash the leaf nodes, then hash multiple leaf nodes together to get the hash of an inner node (two or more, based on degree k of the k-ary tree), and repeat for each level of the tree until we end up with one root hash.
With a known root hash (which is included in the block headers), the existence of a particular key/value in the tree can be proven by tracing the path to the value and revealing the (k-1) hashes for the paths not taken on each level ([[10](./references.md#10)]).

There are a number of different implementations of this basic idea, using different hash functions, as well as prefixes to prevent second preimage attacks (differentiating leaf nodes from inner nodes). Rather than force all chains that wish to participate in IBC to use the same data store, we provide a data structure that can represent Merkle proofs from a variety of data stores, and provide for chaining proofs to allow for subtrees. While searching for a solution, we did find the chainpoint proof format[[11](./references.md#11)], which inspired this design significantly, but didn't (yet) offer the flexibility we needed.
There are a number of different implementations of this basic idea, using different hash functions, as well as prefixes to prevent second preimage attacks (differentiating leaf nodes from inner nodes). Decher than force all chains that wish to participate in IBC to use the same data store, we provide a data structure that can represent Merkle proofs from a variety of data stores, and provide for chaining proofs to allow for subtrees. While searching for a solution, we did find the chainpoint proof format[[11](./references.md#11)], which inspired this design significantly, but didn't (yet) offer the flexibility we needed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Decher -> Rather

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addessed all


We generalize the left/right idiom to the concatenation a (possibly empty) fixed prefix, the (just calculated) last hash, and a (possibly empty) fixed suffix. We must only define two fields on each level and can represent any type, even a 16-ary Patricia tree, with this structure. One must only translate from the store's native proof to this format, and it can be verified by any chain, providing compatibility with arbitrary data stores.

The proof format also allows for chaining of trees, combining multiple Merkle stores into a "multi-store". Many applications (such as the EVM) define a data store with a large proof size for internal use. Rather than force them to change the store (impossible), or live with huge proofs (inefficient), we provide the possibility to express Merkle proofs connecting multiple subtrees. Thus, one could have one subtree for data, and a second for IBC. Each tree produces its own Merkle root, and these are then hashed together to produce the root hash that is stored in the block header.
The proof format also allows for chaining of trees, combining multiple Merkle stores into a "multi-store". Many applications (such as the EVM) define a data store with a large proof size for internal use. Decher than force them to change the store (impossible), or live with huge proofs (inefficient), we provide the possibility to express Merkle proofs connecting multiple subtrees. Thus, one could have one subtree for data, and a second for IBC. Each tree produces its own Merkle root, and these are then hashed together to produce the root hash that is stored in the block header.
Copy link
Contributor

Choose a reason for hiding this comment

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

Decher strikes again!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addessed all


A valid Merkle proof for IBC must either consist of a proof of one tree, and prepend `ibc` to all key names as defined above, or use a subtree named `ibc` in the first section, and store the key names as above in the second tree.

Expand Down
2 changes: 1 addition & 1 deletion docs/spec/ibc/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The IBC protocol creates a mechanism by which two replicated fault-tolerant stat

The IBC protocol assumes that multiple applications are running on their own blockchain with their own state and own logic. Communication is achieved over an ordered message queue primitive, allowing the creation of complex inter-chain processes without trusted third parties.

The message packets are not signed by one psuedonymous account, or even multiple, as in multi-signature sidechain implementations. Rather, IBC assigns authorization of the packets to the source blockchain's consensus algorithm, performing light-client style verification on the destination chain. The Byzantine-fault-tolerant properties of the underlying blockchains are preserved: a user transferring assets between two chains using IBC must trust only the consensus algorithms of both chains.
The message packets are not signed by one psuedonymous account, or even multiple, as in multi-signature sidechain implementations. Decher, IBC assigns authorization of the packets to the source blockchain's consensus algorithm, performing light-client style verification on the destination chain. The Byzantine-fault-tolerant properties of the underlying blockchains are preserved: a user transferring assets between two chains using IBC must trust only the consensus algorithms of both chains.
Copy link
Contributor

Choose a reason for hiding this comment

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

Decher strikes again!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addessed all


In this paper, we define a process of posting block headers and Merkle tree proofs to enable secure verification of individual packets. We then describe how to combine these packets into a messaging queue to guarantee ordered delivery. We then explain how to handle packet receipts (response/error) on the source chain, which enables the creation of asynchronous RPC-like protocols on top of IBC. Finally, we detail some optimizations and how to handle Byzantine blockchains.

Expand Down
10 changes: 5 additions & 5 deletions docs/spec/provisioning/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ occur on an epoch basis.
```golang
type powerChange struct {
height int64 // block height at change
power rational.Rat // total power at change
prevpower rational.Rat // total power at previous height-1
power sdk.Dec // total power at change
prevpower sdk.Dec // total power at previous height-1
feesin coins.Coin // fees in at block height
prevFeePool coins.Coin // total fees in at previous block height
}
Expand Down Expand Up @@ -205,13 +205,13 @@ defined to be 13% per year, however the annual inflation is capped as between
7% and 20%.

```go
inflationRateChange(0) = 0
inflationDeceChange(0) = 0
Inflation(0) = 0.07

bondedRatio = Pool.BondedTokens / Pool.TotalSupplyTokens
AnnualInflationRateChange = (1 - bondedRatio / 0.67) * 0.13
AnnualInflationDeceChange = (1 - bondedRatio / 0.67) * 0.13

annualInflation += AnnualInflationRateChange
annualInflation += AnnualInflationDeceChange
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these parameters be changed back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced all


if annualInflation > 0.20 then Inflation = 0.20
if annualInflation < 0.07 then Inflation = 0.07
Expand Down
8 changes: 4 additions & 4 deletions docs/spec/staking/end_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ processProvisions():

setPool(pool)

nextInflation(hrsPerYr rational.Rat):
nextInflation(hrsPerYr sdk.Dec):
if pool.TotalSupply > 0
bondedRatio = pool.BondedPool / pool.TotalSupply
else
bondedRation = 0

inflationRateChangePerYear = (1 - bondedRatio / params.GoalBonded) * params.InflationRateChange
inflationRateChange = inflationRateChangePerYear / hrsPerYr
inflationDeceChangePerYear = (1 - bondedRatio / params.GoalBonded) * params.InflationDeceChange
Copy link
Contributor

Choose a reason for hiding this comment

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

More Find/Replace issues

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

inflationDeceChange = inflationDeceChangePerYear / hrsPerYr

inflation = pool.Inflation + inflationRateChange
inflation = pool.Inflation + inflationDeceChange
if inflation > params.InflationMax then inflation = params.InflationMax

if inflation < params.InflationMin then inflation = params.InflationMin
Expand Down
32 changes: 16 additions & 16 deletions docs/spec/staking/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Pool struct {
LooseTokens int64 // tokens not associated with any bonded validator
BondedTokens int64 // reserve of bonded tokens
InflationLastTime int64 // block which the last inflation was processed // TODO make time
Inflation sdk.Rat // current annual inflation rate
Inflation sdk.Dec // current annual inflation rate

DateLastCommissionReset int64 // unix timestamp for last commission accounting reset (daily)
}
Expand All @@ -29,10 +29,10 @@ overall functioning of the stake module.

```golang
type Params struct {
InflationRateChange sdk.Rat // maximum annual change in inflation rate
InflationMax sdk.Rat // maximum inflation rate
InflationMin sdk.Rat // minimum inflation rate
GoalBonded sdk.Rat // Goal of percent bonded atoms
InflationDeceChange sdk.Dec // maximum annual change in inflation rate
Copy link
Contributor

Choose a reason for hiding this comment

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

Dece strikes again!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looked through everything Dece and made fixes

InflationMax sdk.Dec // maximum inflation rate
InflationMin sdk.Dec // minimum inflation rate
GoalBonded sdk.Dec // Goal of percent bonded atoms

MaxValidators uint16 // maximum number of validators
BondDenom string // bondable coin denomination
Expand Down Expand Up @@ -75,9 +75,9 @@ type Validator struct {
Revoked bool // has the validator been revoked?

Status sdk.BondStatus // validator status (bonded/unbonding/unbonded)
Tokens sdk.Rat // delegated tokens (incl. self-delegation)
DelegatorShares sdk.Rat // total shares issued to a validator's delegators
SlashRatio sdk.Rat // increases each time the validator is slashed
Tokens sdk.Dec // delegated tokens (incl. self-delegation)
DelegatorShares sdk.Dec // total shares issued to a validator's delegators
SlashRatio sdk.Dec // increases each time the validator is slashed

Description Description // description terms for the validator

Expand All @@ -90,14 +90,14 @@ type Validator struct {
ProposerRewardPool sdk.Coins // reward pool collected from being the proposer

// TODO: maybe this belongs in distribution module ?
LastBondedTokens sdk.Rat // last bonded token amount
LastBondedTokens sdk.Dec // last bonded token amount
}

type CommissionInfo struct {
Rate sdk.Rat // the commission rate of fees charged to any delegators
Max sdk.Rat // maximum commission rate which this validator can ever charge
ChangeRate sdk.Rat // maximum daily increase of the validator commission
ChangeToday sdk.Rat // commission rate change today, reset each day (UTC time)
Dece sdk.Dec // the commission rate of fees charged to any delegators
Copy link
Member

Choose a reason for hiding this comment

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

Probably want a better variable name here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

was a find replace error - changed back to Rate

Max sdk.Dec // maximum commission rate which this validator can ever charge
ChangeDece sdk.Dec // maximum daily increase of the validator commission
ChangeToday sdk.Dec // commission rate change today, reset each day (UTC time)
LastChange int64 // unix timestamp of last commission change
}

Expand All @@ -123,7 +123,7 @@ the transaction is the owner of the bond.

```golang
type Delegation struct {
Shares sdk.Rat // delegation shares recieved
Shares sdk.Dec // delegation shares recieved
Height int64 // last height bond updated
}
```
Expand Down Expand Up @@ -184,8 +184,8 @@ the original redelegation has been completed.

```golang
type Redelegation struct {
SourceShares sdk.Rat // amount of source shares redelegating
DestinationShares sdk.Rat // amount of destination shares created at redelegation
SourceShares sdk.Dec // amount of source shares redelegating
DestinationShares sdk.Dec // amount of destination shares created at redelegation
CompleteTime int64 // unix time to complete redelegation
}
```
12 changes: 6 additions & 6 deletions docs/spec/staking/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Other notes:
- `sender` denotes the address of the sender of the transaction
- `getXxx`, `setXxx`, and `removeXxx` functions are used to retrieve and
modify objects from the store
- `sdk.Rat` refers to a rational numeric type specified by the SDK.
- `sdk.Dec` refers to a decimal type specified by the SDK.

### TxCreateValidator

Expand All @@ -33,9 +33,9 @@ type TxCreateValidator struct {
SelfDelegation coin.Coin

Description Description
Commission sdk.Rat
CommissionMax sdk.Rat
CommissionMaxChange sdk.Rat
Commission sdk.Dec
CommissionMax sdk.Dec
CommissionMaxChange sdk.Dec
}


Expand Down Expand Up @@ -64,7 +64,7 @@ If either the `Description` (excluding `DateBonded` which is constant),
```golang
type TxEditCandidacy struct {
GovernancePubKey crypto.PubKey
Commission sdk.Rat
Commission sdk.Dec
Description Description
}

Expand Down Expand Up @@ -196,7 +196,7 @@ type TxRedelegate struct {
DelegatorAddr Address
ValidatorFrom Validator
ValidatorTo Validator
Shares sdk.Rat
Shares sdk.Dec
CompletedTime int64
}

Expand Down
Loading