-
Notifications
You must be signed in to change notification settings - Fork 608
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
[ValSet-Pref] Add WithdrawDelegationRewards
message
#3686
Conversation
e96b5e4
to
ef78748
Compare
@@ -19,3 +19,10 @@ type StakingInterface interface { | |||
type BankKeeper interface { | |||
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin | |||
} | |||
|
|||
type CommunityPoolKeeper 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.
type CommunityPoolKeeper interface { | |
// For testing only | |
type DistributionKeeper 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.
Why for testing only?
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.
Its only used in testing? The main logic shouldn't use it?
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.
makes sense
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.
We are using WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error)
in code that falls under this 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.
logic LGTM, but needs more entries in table test case, at minimum for no valset set, no delegations, no valset explicitly set, one existing delegation
ef78748
to
1cbc820
Compare
@ValarDragon @czarcas7ic added more tests coverage as you suggested |
x/valset-pref/msg_server_test.go
Outdated
name: "Withdraw all rewards with existing delegation", | ||
delegator: sdk.AccAddress([]byte("addr1---------------")), | ||
coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), // delegate 20osmo | ||
setValSet: true, |
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.
Should be false, 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.
or we need a test case with both this set, and it not set?
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.
in this context "existing delegation" is "existing valset delegations"
The WithdrawLogic also only check rewards from existing valset delegations
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, I would expect it to work s.t. if I have no valset explicitly set, it infers my valset is my existing delegation set, and withdraws from everyone via that
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.
Yea i can get that to work, the only thing is that GetDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16)
takes in uint16 and we might have to pass math.MaxUint16
that could get a little expensive
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.
Just added withdraw existing delegation reward!
@ValarDragon @czarcas7ic added test cases and logic for existing staking position that's not valset. lmk what you think |
delegations := k.stakingKeeper.GetDelegatorDelegations(ctx, delegator, math.MaxUint16) | ||
|
||
// get the existing validator set preference | ||
existingSet, found := k.GetValidatorSetPreference(ctx, delegatorAddr) |
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.
I guess I'm confused -- I thought the module design was always such that GetValidatorSetPreference
returns your existing staking distribution if you haven't set one.
Is that not the case or only in query logic?
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.
Unfortunately that is not the case, GetValidatorSetPreference
only returns val-set staking distributions
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.
ok, imo we need to change that (which I thought was the initial design for valset pref)
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.
for sure, it wont be a massive change tbh. Logic will be something like.
func GetValidatorSetPreference() dels{
valsetDels, vsFound := getvalsetDels(...)
if !vsFound {
existingstakingDels, stFound := getstakingDels(...)
if !stFound {
return err ("No delegations")
}
return existingstakingDels
}
return valsetDels
}
Few questions;
- What about cases where we need both existing valset and staking position or either or? 2. For instance: In SetValSet, we donot care about existingstakingDels, same with delegateToValSet, but undelegate, withdraw and redelegate will need both
- Also non valset positions will not have weights but the current code expects weights for every validator
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.
- if a valset is set return that. (ignore staking position, that may diverge)
- You can derive the weight on the fly based on ratio of staked amounts
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.
I'm down to merge this PR, but lets do the above as a release blocking feature.
Can you make an issue? Then we can merge this PR
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.
added issue #3848
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.
LGTM, now that issue has been created, I will merge this
Part of : #2579
What is the purpose of the change
Adds new message
WithdrawDelegationRewards
.Brief Changelog
n/a
Testing and Verifying
Added msg_server test for to check functionality
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? (yes / no)x/<module>/spec/
) / Osmosis docs repo / not documented)