-
Notifications
You must be signed in to change notification settings - Fork 3
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
GMP message handler #27
Conversation
This reverts commit 444d0fb.
* [docker] Add dockerfile * [docker] Expose additional ports
* enable ledger in makefile * bump ledger packages
* Initial commit for public repo standards * Updates based on rkollar review --------- Co-authored-by: Ashish Chandra <ashish@saga.xyz>
@luckychess please add a description of what this PR does and also indicate whether CI tests are enough or is there anything we should specifically test. |
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.
Have not tested but looks good otherwise.
SourceChain string `json:"source_chain"` | ||
SourceAddress string `json:"source_address"` | ||
Payload []byte `json:"payload"` | ||
Type int64 `json:"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.
Shouldn't it be MessageType?
Also it should probably be just uint8 considering the possible values.
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.
Yep, good point, I followed the example integration and it was declared and not used there. The int64 type also comes from the example and I think that's how it's defined in Axelar core.
|
||
const ( | ||
// TypeUnrecognized means coin type is unrecognized | ||
TypeUnrecognized = iota |
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 TypeUnrecognized MessageType = iota
to use the type.
|
||
var data transfertypes.FungibleTokenPacketData | ||
var err error | ||
if err := types.ModuleCdc.UnmarshalJSON(modulePacket.GetData(), &data); err != 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.
No need to create another local err var.
x/gmp/module_ibc.go
Outdated
ctx.Logger().Info(fmt.Sprintf("failed to unpack: %s", err.Error())) | ||
return channeltypes.NewErrorAcknowledgement(cosmossdkerrors.Wrapf(transfertypes.ErrInvalidMemo, "unable to unpack payload (%s)", err.Error())) | ||
} | ||
ctx.Logger().Info(fmt.Sprintf("Unpacked data: %+v", args)) |
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 would probably be better to have this kind of debugging messages as a lower loglevel, not info.
x/gmp/types/errors.go
Outdated
|
||
// x/gmp module sentinel errors | ||
var ( | ||
ErrSample = cosmossdkerrors.Register(ModuleName, 1100, "sample 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.
Not used.
x/gmp/client/cli/query.go
Outdated
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
// "github.com/cosmos/cosmos-sdk/client/flags" | ||
// sdk "github.com/cosmos/cosmos-sdk/types" |
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 just removed if unused.
x/gmp/client/cli/tx.go
Outdated
) | ||
|
||
var ( | ||
DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) |
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.
No need to cast an untyped constant.
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.
The funny part is that it was generated this way.
x/gmp/genesis.go
Outdated
// InitGenesis initializes the module's state from a provided genesis state. | ||
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { | ||
// this line is used by starport scaffolding # genesis/module/init | ||
k.SetPort(ctx, genState.PortId) |
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.
Incorrect indentation. There are also other formatting errors across the entire module. Please run gofmt on every file in this PR (except generated files).
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!
This PR introduces a GMP middleware for Axelar transactions. The main goal is to make possible to transfer funds from Ethereum to chainlets and vice versa. The basic docs for GMP could be found at https://docs.axelar.dev/dev/cosmos-gmp/overview/, a sample implementation which the current one is based on is https://github.com/axelarnetwork/evm-cosmos-gmp-sample/blob/main/native-integration/multi-send/cosmos/gmp_middleware.go.