-
Notifications
You must be signed in to change notification settings - Fork 204
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
Autopilot enhancement #771
Conversation
…atible with json formula
@@ -27,8 +27,10 @@ type ModuleRoutingInfo interface { | |||
|
|||
// Packet metadata info specific to Stakeibc (e.g. 1-click liquid staking) | |||
type StakeibcPacketMetadata struct { | |||
Action string `json:"action"` | |||
StrideAddress string `json:"stride_address"` | |||
Action string `json:"action"` |
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 not use an enum
here?
IbcReceiver string `json:"ibc_receiver,omitempty"` | ||
TransferChannel string `json:"transfer_channel,omitempty"` |
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 these are empty it's assumed that the token is returned to the original sender over the same source channel?
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.
Correct. These are omitted only when the receiver is original sender through original transfer channel.
case "LiquidStake": | ||
case "RedeemStake": |
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.
these seem that are not set up
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.
It's validation if the action is one of LiquidStake or RedeemStake, more could be added later and just used this format for validation
@@ -27,8 +27,10 @@ type ModuleRoutingInfo interface { | |||
|
|||
// Packet metadata info specific to Stakeibc (e.g. 1-click liquid staking) | |||
type StakeibcPacketMetadata struct { |
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.
nit
type StakeibcPacketMetadata struct { | |
type StakeIBCPacketMetadata struct { |
case "RedeemStake": | ||
// Try to redeem stake - return an ack error if it fails, otherwise return the ack generated from the earlier packet propogation | ||
if err := im.keeper.TryRedeemStake(ctx, packet, newData, routingInfo); err != nil { | ||
im.keeper.Logger(ctx).Error(fmt.Sprintf("Error redeem staking packet from autopilot for %s: %s", newData.Sender, err.Error())) |
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.
im.keeper.Logger(ctx).Error(fmt.Sprintf("Error redeem staking packet from autopilot for %s: %s", newData.Sender, err.Error())) | |
im.keeper.Logger(ctx).Debug("failed redeem staking packet from autopilot", "sender" newData.Sender.String(), "error", err.Error()) |
voucherPrefix := transfertypes.GetDenomPrefix(packet.GetSourcePort(), packet.GetSourceChannel()) | ||
stAssetDenom := newData.Denom[len(voucherPrefix):] |
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.
pretty sure there is a util for this
if !transfertypes.ReceiverChainIsSource(packet.GetSourcePort(), packet.GetSourceChannel(), newData.Denom) { | ||
return fmt.Errorf("the ibc tokens are not supported for redeem stake") | ||
} |
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's the redeem stake flow? isn't the receiver chain in this case Stride?
x/autopilot/keeper/redeemstake.go
Outdated
} | ||
|
||
// Note: newData.denom is ibc denom for st assets - e.g. ibc/xxx | ||
var token = sdk.NewCoin(newData.Denom, 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.
double-check if the packet data is validated, otherwise this line panics if the denom or amount are invalid
return k.RunRedeemStake(ctx, strideAddress, packetMetadata.IbcReceiver, hostZoneDenom, token, []metrics.Label{}) | ||
} | ||
|
||
func (k Keeper) RunRedeemStake(ctx sdk.Context, addr sdk.AccAddress, receiver string, hostZoneDenom string, token sdk.Coin, labels []metrics.Label) error { |
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.
highly recommend using the spread operator for optional slices
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
…nit test failure for total escrow amount set on ibc escrow mock
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
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.
Reviewed "remove stride_address field on functional info" commit 088fb2d. Looks good.
IbcReceiver string `json:"ibc_receiver,omitempty"` | ||
TransferChannel string `json:"transfer_channel,omitempty"` | ||
} | ||
|
||
// Packet metadata info specific to Claim (e.g. airdrops for non-118 coins) | ||
type ClaimPacketMetadata struct { | ||
StrideAddress string | ||
} | ||
|
||
// Validate stakeibc packet metadata fields | ||
// including the stride address and action type |
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.
nit: rm "stride address and"
@@ -57,10 +51,6 @@ func (m StakeibcPacketMetadata) Validate() error { | |||
|
|||
// Validate claim packet metadata includes the stride address | |||
func (m ClaimPacketMetadata) Validate() error { |
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 this fn be removed now that it validates nothing?
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
@@ -38,9 +38,16 @@ func (k Keeper) TryLiquidStaking( | |||
} | |||
|
|||
// Note: newData.denom is base denom e.g. uatom - not ibc/xxx | |||
var token = sdk.NewCoin(newData.Denom, amount) | |||
var token = sdk.Coin{ |
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.
Not needed afaict
Closes: #771 ## Context and purpose of the change Add `RedeemStake` to autopilot. ## Brief Changelog * Add integration test for `RedeemStake` * Add unittest for `RedeemStake` * Integrate with autopilot module
Context and purpose of the change
The goal of this PR is to support two more features on autopilot module
Note: This PR moved from #626
Brief Changelog
Author's Checklist
I have...
If skipped any of the tests above, explain.
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
How to test integration test on local
DefaultStakeibcActive
totrue
atx/autopilot/types/params.go
skip "DefaultActive set to false, skip test"
ondockernet/tests/integration_tests.bats
make build-docker build=s
make start-docker
make test-integration-docker
How to test Hub -> Stride -> Osmosis
dockernet/config.sh
toHOST_CHAINS=(GAIA OSMO)
make start-docker build=sgor
Documentation and Release Note
Unreleased
section inCHANGELOG.md
?How is the feature or change documented?
XXX
x/<module>/spec/
)