-
Notifications
You must be signed in to change notification settings - Fork 202
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
Fix claim bug #70
Fix claim bug #70
Conversation
…cause we need keeper access)
recordstypes "github.com/Stride-Labs/stride/x/records/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
var WHITELIST = map[string]bool{ | ||
"stride159atdlc3ksl50g0659w5tq42wwer334ajl7xnq": true, | ||
"stride1uk4ze0x4nvh4fk0xm4jdud58eqn4yxhrt52vv7": 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.
what is whitelist address ?
If this is what it need in advance. it would be better on the params.
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 think, at least, this address should exist as a parameter in the module.
so that it must be changed only by governance proposal.
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.
Great question! This is an admin account that's here for testnet purposes, good point about parameters. We appreciate the reviews, please keep them coming! By the way, if you want to get in touch please DM us on Discord, we'd love to chat more 👍
…odule stakeibc --no-message --index sequence, change userRedemptionRecordIds to list type, move Records message to genesis proto
// grab necessary fields to construct ICA call | ||
var msgs []sdk.Msg | ||
redemptionAccount, found := k.GetRedemptionAccount(ctx, hostZone) | ||
hostZone, found := k.GetHostZone(ctx, msg.HostZoneId) |
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 we move this check to the top?
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.
Can you elaborate on this?
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.
part of my PR that does validation on inputs was to check the validity of hostzones in each msg_server that has a hostZone in its msg (like this msg_server). I always do that at the top of the msg_server. Mostly for consistency
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.
got it - I think this should still fail if the host zone doesn't exist! there isn't any substantive logic above it, just checks on UserRedemptionRecords. slight preference to keep this here so the sections of the function are
- Checks on UserRedemptionRecord
- Checks on all fields required for the ICA
- Constructing and sending the transaction, updating state
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 overall! few minor questions
* Added more data to starname chain.json * Added explorers for starname
Summary
i. Remove
claimableRecordIds
fromHostZone
ii. Remove records in ack
6d5da1
iii. Add
PendingClaims
data structure to enable ICA callbacksNote:
Changes (part 1 and 2)
Input validation:
[note: would ideally move all validation logic to ValidateBasic(), but we can't access the keeper from there, and we need the keeper to validate hostZone]
bech32prefix
field to the hostZone proto (necessary for validating foreign zone addresses from Stride) and add bech32prefix args to all registerHostZone messages, types and invocationsutils.go
and parametrize it by hostZone so we can invoke it for any hostZone when we'd like to check the validity of an arbitrary address (note this assumes len 20 addresses, so will fail with ICA accounts; should be OK, we don't need to redeem to those accounts but maybe worth revisiting)msg_server_redeem_stake.go
, check the receiver address is a valid address on the specified host zone, after checking the host zone exists.message_redeem_stake.go
, check amount is > 0Test plan
To test input validation, attempt to submit an incorrectly formatted redeem-stake message!
The following redeem-stake command should succeed (be sure to run
1.sh
and2.sh
beforehand as setup.The following should fail:
Changes (claim bug fix)
PendingClaims
to enable ICA callbacks (ca71746
). This maps IBC packet sequence number to a claimable record id (note: for now, this maps to a single record, but this could be extended to process multiple claims in a single transaction)ClaimUndelegatedTokens
(x/stakeibc/keeper/msg_server_claim_undelegated_tokens.go
)HandleSend
in ack to deletePendingClaims
on failure, and to delete bothPendingClaims
andUserRedemptionRecords
on successTest plan (claim bug fix)
Run 1.sh, 2.sh, 3.sh then claim the first record with 4.sh
Run 3.sh twice more to create records two and three, claim record three with 4.sh
Run 4.sh one last time to claim record two