-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Staking Implementation #540
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #540 +/- ##
===========================================
- Coverage 63.3% 59.32% -3.99%
===========================================
Files 44 62 +18
Lines 2055 3255 +1200
===========================================
+ Hits 1301 1931 +630
- Misses 639 1183 +544
- Partials 115 141 +26 |
355a1dc
to
6eb2a12
Compare
What's the message for Unbonding as a Candidate? |
fbb9b83
to
c5b6490
Compare
x/stake/handler.go
Outdated
if msg.Description.Details != "" { | ||
candidate.Description.Details = msg.Description.Details | ||
} | ||
|
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.
Do we care about candidates having the ability to clear previously set metadata?
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.
opening an issue
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.
} | ||
store := ctx.KVStore(k.storeKey) | ||
b := store.Get(ParamKey) | ||
if b == nil { |
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.
Desirable to move store initialization logic into a single function for clarity? Also avoids strange results were a store to return nil incorrectly.
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.
created an issue, I think this can wait until after the MVP though #724
Inflation: sdk.NewRat(7, 100), | ||
} | ||
} | ||
|
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.
Desirable to load default staking params / pool params from a config file? That way clients can customize without recompiling.
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.
same as previous response above ^
x/stake/handler.go
Outdated
// Perform all the actions required to bond tokens to a delegator bond from their account | ||
func (k Keeper) BondCoins(ctx sdk.Context, bond DelegatorBond, candidate Candidate, amount sdk.Coin) sdk.Error { | ||
|
||
_, err := k.coinKeeper.SubtractCoins(ctx, bond.DelegatorAddr, sdk.Coins{amount}) |
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.
Spec says coins should be transferred to pool account - is that account not necessary to track explicitly?
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.
Discussed; spec should change @milosevic - no longer a need for a pool account.
receivedGlobalShares = k.addTokensUnbonded(ctx, amount) | ||
} | ||
candidate.Assets = candidate.Assets.Add(receivedGlobalShares) | ||
|
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.
Spec defines issuedShares
and receivedGlobalShares
as two different variables, but the latter is used nowhere else in the spec - are they supposed to be the same (as they are here)?
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.
they are not the same here - can go over with you tomorrow
x/stake/handler.go
Outdated
bond.Shares = bond.Shares.Sub(shares) | ||
|
||
// get pubKey candidate | ||
candidate, found := k.GetCandidate(ctx, msg.CandidateAddr) |
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.
Do we want to also check candidate existence in CheckTx
calls?
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.
yes - resolved
} | ||
|
||
// deduct shares from the candidate | ||
if candidate.Liabilities.IsZero() { |
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.
Per spec, this check should be for candidate.Assets
(globalStakeShares
)
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.
conceptually makes more sense yes - although I think both should work
c2acefb
to
8c7b126
Compare
type MsgEditCandidacy struct { | ||
Description | ||
CandidateAddr sdk.Address `json:"address"` | ||
} |
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.
Spec also includes provision for changingcommission
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.
commission not yet implemented
x/stake/handler.go
Outdated
} | ||
|
||
// subtract bond tokens from delegator bond | ||
if bond.Shares.LT(shares) { // bond shares < msg shares |
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.
Check redundant? Either bond.Shares.GT(shares)
is true or shares == bond.Shares
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.
cool was partially redundant, moved stuff around to make clear / remove redundancy
Many issues: #713 |
df41b76
to
41e009f
Compare
... ...
... ...
e965e9b
to
aa4bd05
Compare
x/stake/handler.go
Outdated
//_______________________________________________________________________ | ||
|
||
// DelegatedProofOfStake - interface to enforce delegation stake | ||
type delegatedProofOfStake interface { |
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.
nice!
pre-MVP staking logic