Merge PR #3400: power reduction for Tendermint

* add uncompiled power functionality

* fix some compile errors

* Power -> TendermintPower

* tests rename GetTendermintPower

* test fix

* working

* fix delegation tests

* fix slash tests

* staking/keeper tests passing

* docs reversion

* debuggin workin

* x/staking test pass

* fix gov tests

* fix x/slashing tests

* working distribution test fixes

* fix distribution tests

* lint

* fix lcd tests

* fix gov test

* lint

* CLI fixes, rm stakingTypes

* typos

* working cli fixes

* cli test fix

* cli tests fixed

* testnet creation modification

* typo

* pending

* Sanitize Dec.Roundint64 (#3475)

* merge fixes

* @cwgoes comments

* fix tests

* change power reduction to 10^-6

* option to turn off minting for LCD tests
This commit is contained in:
frog power 4000
2019-02-05 21:30:48 -08:00
committed by GitHub
parent df94f522f9
commit 52f2ec71a9
56 changed files with 1159 additions and 955 deletions
+16
View File
@@ -249,6 +249,16 @@ func (d Dec) MulInt(i Int) Dec {
return Dec{mul}
}
// MulInt64 - multiplication with int64
func (d Dec) MulInt64(i int64) Dec {
mul := new(big.Int).Mul(d.Int, big.NewInt(i))
if mul.BitLen() > 255+DecimalPrecisionBits {
panic("Int overflow")
}
return Dec{mul}
}
// quotient
func (d Dec) Quo(d2 Dec) Dec {
@@ -287,6 +297,12 @@ func (d Dec) QuoInt(i Int) Dec {
return Dec{mul}
}
// QuoInt64 - quotient with int64
func (d Dec) QuoInt64(i int64) Dec {
mul := new(big.Int).Quo(d.Int, big.NewInt(i))
return Dec{mul}
}
// is integer, e.g. decimals are zero
func (d Dec) IsInteger() bool {
return new(big.Int).Rem(d.Int, precisionReuse).Sign() == 0
+3 -2
View File
@@ -42,8 +42,9 @@ type Validator interface {
GetOperator() ValAddress // operator address to receive/return validators coins
GetConsPubKey() crypto.PubKey // validation consensus pubkey
GetConsAddr() ConsAddress // validation consensus address
GetPower() Int // validation power
GetTokens() Int // validation tokens
GetBondedTokens() Int // validator bonded tokens
GetTendermintPower() int64 // validation power in tendermint
GetCommission() Dec // validator commission rate
GetDelegatorShares() Dec // total outstanding delegator shares
GetBondHeight() int64 // height in which the validator became active
@@ -54,7 +55,7 @@ type Validator interface {
func ABCIValidator(v Validator) abci.Validator {
return abci.Validator{
Address: v.GetConsPubKey().Address(),
Power: v.GetPower().Int64(),
Power: v.GetTendermintPower(),
}
}