-
Notifications
You must be signed in to change notification settings - Fork 368
feat: use composable, non conflicting hyperlane metadata wire format to store forward memo and kaspa gadgets #1889
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
Conversation
x/forward/hyperlane.go
Outdated
func (k Forward) OnHyperlaneMessage(goCtx context.Context, args warpkeeper.OnHyperlaneMessageArgs) error { | ||
ctx := sdk.UnwrapSDKContext(goCtx) | ||
|
||
memo := args.Metadata | ||
if len(memo) == 0 { | ||
hlMetadata, err := types.UnpackHLMetadata(args.Metadata) | ||
if err != nil { | ||
return errorsmod.Wrap(err, "unpack hl metadata") | ||
} | ||
|
||
if hlMetadata == nil || len(hlMetadata.HookForwardToIbc) == 0 { | ||
// Equivalent to the vanilla token standard. | ||
return nil | ||
} | ||
|
||
// if it fails, the original hyperlane transfer recipient got the funds anyway so no need to do anything special (relying on frontend here) | ||
k.executeWithErrEvent(ctx, func() error { | ||
d, err := types.UnpackForwardToIBC(memo) | ||
d, err := types.UnpackForwardToIBC(hlMetadata.HookForwardToIbc) | ||
if err != nil { | ||
return errorsmod.Wrap(err, "unpack memo from hyperlane") | ||
} |
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 meat of the pr
x/forward/types/dt.pb.go
Outdated
// optional, can be empty | ||
HookForwardToIbc []byte `protobuf:"bytes,1,opt,name=hook_forward_to_ibc,json=hookForwardToIbc,proto3" json:"hook_forward_to_ibc,omitempty"` | ||
// optional, can be empty | ||
// see https://www.notion.so/dymension/ADR-Kaspa-Bridge-Implementation-206a4a51f86a803980aec7099c826fb4?source=copy_link#208a4a51f86a8093a843cf4b5e903588 | ||
Kaspa []byte `protobuf:"bytes,2,opt,name=kaspa,proto3" json:"kaspa,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.
assuming they are mutually exclusive, wouldn't it be cleaner to have it as type
and data
(also going forward(?
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.
they aren't mutually exclusive
// was it actually a forward operation? (maybe not if they dont include forward memo) | ||
bool was_forwarded = 3; |
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.
whats the use of this was_forwarded? seems like this event simply shouldn't be emitted if it's not forwarded no?
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 a bit awkward because IMO something should be emitted if the memo isn't parseable, and at that point you don't know if a forward is intended or not
Description
Closes #1888
@anhductn2001 in this PR I've had to change the encoding format for the memo that needs to be included in transfers from Ethereum/Solana -> Dymension via Hyperlane. I'll probably need to update the example memos in the manual tests.
Possibly you'll need to update the e2e as well? Let me know if it suddenly fails and if you need help.
I've updated the toolling so that it's possiblett to generate the new format with cli (q forward ...)
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.
PR review checkboxes:
I have...
Unreleased
section inCHANGELOG.md
godoc
commentsSDK Checklist
map
time.Now()
sendCoin
and notSendCoins
Full security checklist here
For Reviewer:
After reviewer approval: