Skip to content

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

Merged
merged 6 commits into from
Jun 12, 2025

Conversation

danwt
Copy link
Contributor

@danwt danwt commented Jun 4, 2025

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

  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Targeted PR against the correct branch
  • included the correct type prefix in the PR title
  • Linked to the GitHub issue with discussion and accepted design
  • Targets only one GitHub issue
  • Wrote unit and integration tests
  • Wrote relevant migration scripts if necessary
  • All CI checks have passed
  • Added relevant godoc comments
  • Updated the scripts for local run, e.g genesis_config_commands.sh if the PR changes parameters
  • Add an issue in the e2e-tests repo if necessary

SDK Checklist

  • Import/Export Genesis
  • Registered Invariants
  • Registered Events
  • Updated openapi.yaml
  • No usage of go map
  • No usage of time.Now()
  • Used fixed point arithmetic and not float arithmetic
  • Avoid panicking in Begin/End block as much as possible
  • No unexpected math Overflow
  • Used sendCoin and not SendCoins
  • Out-of-block compute is bounded
  • No serialized ID at the end of store keys
  • UInt to byte conversion should use BigEndian

Full security checklist here


For Reviewer:

  • Confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • Confirmed all author checklist items have been addressed

After reviewer approval:

  • In case the PR targets the main branch, PR should not be squash merge in order to keep meaningful git history.
  • In case the PR targets a release branch, PR must be rebased.

@danwt danwt requested a review from a team as a code owner June 4, 2025 15:04
Comment on lines 17 to 35
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")
}
Copy link
Contributor Author

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

@danwt danwt changed the title feat: use a composable and non conflicting hyperlane metadata format to wrap forward and kaspa gadgets feat: use composable, non conflicting hyperlane metadata wire format to store forward memo and kaspa gadgets Jun 4, 2025
Comment on lines 118 to 122
// 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"`
Copy link
Contributor

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(?

Copy link
Contributor Author

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

Comment on lines 12 to 13
// was it actually a forward operation? (maybe not if they dont include forward memo)
bool was_forwarded = 3;
Copy link
Contributor

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?

Copy link
Contributor Author

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

@danwt danwt requested a review from omritoptix June 11, 2025 15:01
@mtsitrin mtsitrin merged commit a42d949 into main Jun 12, 2025
5 of 7 checks passed
@mtsitrin mtsitrin deleted the danwt/kas-bridge-1888 branch June 12, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: robust hyperlane metadata parsing
3 participants