Skip to content

Commit

Permalink
fix: Memo in ibc transfer to axelar (#335)
Browse files Browse the repository at this point in the history
## Description

closes: #XXXX

---

### Author Checklist

_All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues._

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] added appropriate labels to the PR
- [ ] targeted the correct branch
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### 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...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
rbajollari authored Dec 13, 2023
1 parent 71f1f9c commit 7835c97
Show file tree
Hide file tree
Showing 9 changed files with 391 additions and 39 deletions.
11 changes: 11 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (app App) RegisterUpgradeHandlers() {
app.registerUpgrade0_3_0(upgradeInfo)
app.registerUpgrade0_3_0Rc2(upgradeInfo)
app.registerUpgrade0_3_0Rc3(upgradeInfo)
app.registerUpgrade0_3_0Rc4(upgradeInfo)
}

// performs upgrade from v0.1.3 to v0.1.4
Expand Down Expand Up @@ -172,6 +173,16 @@ func (app *App) registerUpgrade0_3_0Rc3(_ upgradetypes.Plan) {
)
}

func (app *App) registerUpgrade0_3_0Rc4(_ upgradetypes.Plan) {
const planName = "v0.3.0-rc4"
app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Upgrade handler execution", "name", planName)
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
},
)
}

// helper function to check if the store loader should be upgraded
func (app *App) storeUpgrade(planName string, ui upgradetypes.Plan, stores storetypes.StoreUpgrades) {
if ui.Name == planName && !app.UpgradeKeeper.IsSkipHeight(ui.Height) {
Expand Down
15 changes: 15 additions & 0 deletions proto/ojo/gmp/v1/gmp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ message Params {

// The amount of time we'll wait for a response from axelar before timing out.
int64 gmp_timeout = 3;

// The axelar address of the fee recipient.
string fee_recipient = 4;
}

// GmpMessage defines the GMP message that we encode in the
Expand All @@ -35,4 +38,16 @@ message GmpMessage {

// type is an enum that specifies the type of message
int64 type = 4;

// fee is the fee payed to a relayer on the Axelar network
GmpFee fee = 5;
}

// GMPFee defines the fee field message inside of GMPMessage.
message GmpFee {
// Fee amount
string amount = 1;

// Recipient of fee; should be fee_recipient.
string recipient = 2;
}
2 changes: 1 addition & 1 deletion x/gmp/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func GetCmdRelay() *cobra.Command {
tokens := sdk.Coin{}
// normalize the coin denom
if args[4] != "" {
coin, err := sdk.ParseCoinNormalized(args[7])
coin, err := sdk.ParseCoinNormalized(args[4])
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions x/gmp/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ func (k Keeper) BuildGmpRequest(
DestinationAddress: msg.OjoContractAddress,
Payload: payload,
Type: types.TypeGeneralMessage,
}
bz, err := message.Marshal()
if err != nil {
return nil, err
Fee: &types.GmpFee{
Amount: "1000000",
Recipient: params.FeeRecipient,
},
}

// submit IBC transfer
Expand All @@ -167,7 +167,7 @@ func (k Keeper) BuildGmpRequest(
params.GmpAddress,
clienttypes.ZeroHeight(),
uint64(ctx.BlockTime().Add(time.Duration(params.GmpTimeout)*time.Hour).UnixNano()),
string(bz),
message.String(),
)
return transferMsg, nil
}
6 changes: 5 additions & 1 deletion x/gmp/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ func (s *IntegrationTestSuite) TestMsgServer_SetParams() {
gmpChannel := "channel-1"
gmpAddress := "axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5"
timeout := int64(1)
SetParams(s, gmpAddress, gmpChannel, timeout)
feeRecipient := "axelar1zl3rxpp70lmte2xr6c4lgske2fyuj3hupcsvcd"
SetParams(s, gmpAddress, gmpChannel, timeout, feeRecipient)

params := types.DefaultParams()

Expand All @@ -33,15 +34,18 @@ func SetParams(
gmpAddress string,
gmpChannel string,
gmpTimeout int64,
feeRecipient string,
) {
params := types.DefaultParams()
params.GmpAddress = gmpAddress
params.FeeRecipient = feeRecipient
authority := s.app.GovKeeper.GetGovernanceAccount(s.ctx).GetAddress().String()

msg := types.NewMsgSetParams(
params.GmpAddress,
params.GmpChannel,
params.GmpTimeout,
params.FeeRecipient,
authority,
)

Expand Down
8 changes: 5 additions & 3 deletions x/gmp/keeper/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ func (s *IntegrationTestSuite) TestSetAndGetParams() {
app, ctx := s.app, s.ctx

params := types.Params{
GmpChannel: "channel-101",
GmpAddress: "gmpaddress",
GmpTimeout: int64(101),
GmpChannel: "channel-101",
GmpAddress: "gmpaddress",
GmpTimeout: int64(101),
FeeRecipient: "feerecipient",
}

app.GmpKeeper.SetParams(ctx, params)
Expand All @@ -18,4 +19,5 @@ func (s *IntegrationTestSuite) TestSetAndGetParams() {
s.Require().Equal(params2.GmpAddress, params.GmpAddress)
s.Require().Equal(params2.GmpChannel, params.GmpChannel)
s.Require().Equal(params2.GmpTimeout, params.GmpTimeout)
s.Require().Equal(params2.FeeRecipient, params.FeeRecipient)
}
Loading

0 comments on commit 7835c97

Please sign in to comment.