-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
R4R: Distr-PR-5 Implement Distribution #2236
Merged
Merged
Changes from 1 commit
Commits
Show all changes
121 commits
Select commit
Hold shift + click to select a range
b2eab0d
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 469334d
Merge branch 'rigel/piggy-bank-fee-spec' into rigel/fee-distribution
rigelrozanski d7794b4
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 9a2aee8
working
rigelrozanski 48aa9a6
working, moved WIP distribution spec to attic
rigelrozanski 4ddf6ca
undo spec move for PR clarity
rigelrozanski 43ab066
move WIP-lamborghini-distribution
rigelrozanski 38c6090
Merge branch 'rigel/move-spec' into rigel/fee-distribution
rigelrozanski 53253aa
working
rigelrozanski aebd36f
...
rigelrozanski 8ab25fa
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski e2b5b9b
...
rigelrozanski b409099
update spec
rigelrozanski cbb5a50
work on allocate fees
rigelrozanski e498d43
dec coins, refactoring distr
rigelrozanski 7d864fe
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 922eb5e
...
rigelrozanski a153088
...
rigelrozanski 46db96b
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski dae32a3
...
rigelrozanski d60f620
working
rigelrozanski 2eff69a
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 431fdb8
hook, genesis, and withdraw address
rigelrozanski 24e43b9
hookwork
rigelrozanski bb9e647
add in basic commission stuff
rigelrozanski a18b895
handler, tags, msgs, codec
rigelrozanski e3cf4f6
cli transactions
rigelrozanski 73c5fdf
more cli related
rigelrozanski de4071f
aliases, errors
rigelrozanski 97f7dbc
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 7688299
alias work, working on compiling
rigelrozanski df9c8db
working through compile errors
rigelrozanski d9396ed
working compile errors
rigelrozanski 7002438
compile debugging
rigelrozanski 18fdccf
...
rigelrozanski 5dabd1b
the errors never want to seem to end...
rigelrozanski 5790f33
...
rigelrozanski 251a81f
yay it compiles
rigelrozanski d360304
breakout use of GetValidatorByConsAddr
rigelrozanski 0d9105c
...
rigelrozanski 0867ce8
...
rigelrozanski 4e4749d
pulling in stuff from fee-distr PR
rigelrozanski ab61695
PENDING
rigelrozanski 0f903bd
finished pulling in, compiles
rigelrozanski 9e2b8e4
revert some gov changes
rigelrozanski 1243507
no more compile errors in tests
rigelrozanski 787a2f9
fix using cons address, also remove old commented distr code
rigelrozanski 72e3025
doc update
rigelrozanski b212470
revert some accidental stuff
rigelrozanski a2b2ef9
Merge remote-tracking branch 'origin/develop' into rigel/stake-cons-addr
rigelrozanski 14792f2
val comments
rigelrozanski d428317
import decimal from fee-distr PR
rigelrozanski 79cfee9
pending
rigelrozanski 6012a25
...
rigelrozanski 6f35822
import hook from fee-distr
rigelrozanski 1b485bb
pending
rigelrozanski df0d582
add staking hooks to staking spec
rigelrozanski 9dfeeb0
address bez comments
rigelrozanski afe179e
remove GetValidatorByConsPubKey
rigelrozanski 16594f7
Merge remote-tracking branch 'origin/develop' into rigel/stake-cons-addr
rigelrozanski dad4253
merge fix
rigelrozanski ff8d748
Merge branch 'rigel/stake-cons-addr' into rigel/truncate-decimal
rigelrozanski f5116b9
Merge branch 'rigel/truncate-decimal' into rigel/new-hooks
rigelrozanski ca2fc77
update commission hook for new commission work
rigelrozanski 5be5ea3
comment update
rigelrozanski 380d3e1
pull a bunch from develop
rigelrozanski 47e899b
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski d3146bf
...
rigelrozanski 910af20
Merge commit '5be5ea3' into rigel/new-hooks
rigelrozanski 9e9756a
Merge remote-tracking branch 'origin/develop' into rigel/new-hooks
rigelrozanski 4929b02
mini-fix
rigelrozanski 3846894
Merge branch 'rigel/new-hooks' into rigel/fee-distribution
rigelrozanski 0436f50
...
rigelrozanski 436d2a0
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 956566d
proser
rigelrozanski 60a3541
major debugs
rigelrozanski 7ab02ae
lcd tests to include proposer
rigelrozanski 733b616
disable endblock for lcd
rigelrozanski e223ead
types msg tests
rigelrozanski 064f8b0
dec coin tests
rigelrozanski 16f5d69
types fee pool test
rigelrozanski dcf0dda
...
rigelrozanski 1e74da1
validator_info tests
rigelrozanski 4d4de3a
delegator_dist_info tests
rigelrozanski 3a9102e
fix
rigelrozanski eb01cb4
checkout distr types PR updates
rigelrozanski 45f0dd0
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 20a51e5
fix compile errors
rigelrozanski 17dc812
fix distribution endblocker issues
rigelrozanski 81d0f5f
add wanted final test case functions
rigelrozanski 83c2781
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski e304b9c
debugging simulation
rigelrozanski 142f42e
...
rigelrozanski 6005325
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 46fe52b
create test initialization for distr
rigelrozanski c973032
...
rigelrozanski 6d4975e
R4R: Fix simulation proposer (#2460)
cwgoes fc9bafb
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 151a81e
staking changes test_cover fixes
rigelrozanski ace19d9
Merge branch 'rigel/fee-distribution' of https://github.com/cosmos/co…
rigelrozanski 52316d9
fix initialization of the test
rigelrozanski 22de856
fix distr initialization
rigelrozanski 3b5e57b
ctx with proposer, working through allocation test
rigelrozanski 900a5f4
keeper_test
rigelrozanski f4f39ae
allocation tests
rigelrozanski 8e378e2
got basic delegation tests working
rigelrozanski 8cb6d10
TestWithdrawDelegationRewardWithCommission
rigelrozanski f3c0496
TestWithdrawDelegationRewardsAll
rigelrozanski a60b91b
bugfix form TestWithdrawDelegationRewardTwoDelegatorsUneven
rigelrozanski 94731a5
some validator dist tests
rigelrozanski 7b1f4a8
finished off validator tests
rigelrozanski dba20d1
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 06fa518
address @cwgoes comments, add in precommit calculation
rigelrozanski 2ece2ff
address @cwgoes comments
rigelrozanski 5de0c9a
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 2f4a01b
address @ValarDragon comments, param store update
rigelrozanski 43e4396
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski 076053d
proposer reward params to global param
rigelrozanski eaecde2
test_utils >:(
rigelrozanski 03b9260
oh
rigelrozanski 32e0f14
rework to correctly use previous vote info
rigelrozanski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
dec coins, refactoring distr
- Loading branch information
commit e498d43d03569dc8dbd7cc19c0e95844c9b31988
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,89 @@ | ||
package types | ||
|
||
import sdk "github.com/cosmos/cosmos-sdk/types" | ||
import ( | ||
"strings" | ||
|
||
// coins with decimal | ||
type DecCoins []DecCoin | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// Coins which can have additional decimal points | ||
type DecCoin struct { | ||
Amount sdk.Dec `json:"amount"` | ||
Denom string `json:"denom"` | ||
Amount sdk.Dec `json:"amount"` | ||
} | ||
|
||
func NewDecCoin(coin sdk.Coin) DecCoin { | ||
return DecCoins{ | ||
Amount: sdk.NewDec(coin.Amount), | ||
Denom: coin.Denom, | ||
Amount: sdk.NewDec(coin.Amount), | ||
} | ||
} | ||
|
||
// Adds amounts of two coins with same denom | ||
func (coin DecCoin) Plus(coinB DecCoin) DecCoin { | ||
if !(coin.Denom == coinB.Denom) { | ||
return coin | ||
} | ||
return Coin{coin.Denom, coin.Amount.Add(coinB.Amount)} | ||
} | ||
|
||
// return the decimal coins with trunctated decimals | ||
func (coin DecCoin) TruncateDecimal() sdk.Coin { | ||
return sdk.NewCoin(coin.Denom, coin.Amount.TruncateInt()) | ||
} | ||
|
||
//_______________________________________________________________________ | ||
|
||
// coins with decimal | ||
type DecCoins []DecCoin | ||
|
||
func NewDecCoins(coins sdk.Coins) DecCoins { | ||
|
||
dcs := make(DecCoins, len(coins)) | ||
for i, coin := range coins { | ||
dcs[i] = NewDecCoin(coin) | ||
} | ||
} | ||
|
||
// return the decimal coins with trunctated decimals | ||
func (coins DecCoins) TruncateDecimal() sdk.Coins { | ||
out := make(DecCoins, len(coins)) | ||
for i, coin := range coins { | ||
out[i] = coin.TruncateDecimal() | ||
} | ||
} | ||
|
||
// Plus combines two sets of coins | ||
// CONTRACT: Plus will never return Coins where one Coin has a 0 amount. | ||
func (coins DecCoins) Plus(coinsB DecCoins) DecCoins { | ||
sum := ([]DecCoin)(nil) | ||
indexA, indexB := 0, 0 | ||
lenA, lenB := len(coins), len(coinsB) | ||
for { | ||
if indexA == lenA { | ||
if indexB == lenB { | ||
return sum | ||
} | ||
return append(sum, coinsB[indexB:]...) | ||
} else if indexB == lenB { | ||
return append(sum, coins[indexA:]...) | ||
} | ||
coinA, coinB := coins[indexA], coinsB[indexB] | ||
switch strings.Compare(coinA.Denom, coinB.Denom) { | ||
case -1: | ||
sum = append(sum, coinA) | ||
indexA++ | ||
case 0: | ||
if coinA.Amount.Add(coinB.Amount).IsZero() { | ||
// ignore 0 sum coin type | ||
} else { | ||
sum = append(sum, coinA.Plus(coinB)) | ||
} | ||
indexA++ | ||
indexB++ | ||
case 1: | ||
sum = append(sum, coinB) | ||
indexB++ | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
DecCoin{}
notCoin
right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah these types of error's are riddled throughout - I haven't gotten this to compile yet - still WIP on that front