Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

fix: keepkey swaps from RUNE #1231

Merged
merged 8 commits into from
Apr 4, 2023
Merged

Conversation

BitHighlander
Copy link
Contributor

@BitHighlander BitHighlander commented Apr 3, 2023

Fixes swaps from RUNE when using a KeepKey.
Uses "THOR.RUNE" as a thorchain/MsgDeposit MsgType coin asset, as defined in the THORChain protocol:

https://dev.thorchain.org/thorchain-dev/concepts/memos#asset-notation

The reason is hdwallet-keepkey has stronger validation, and the rune coin asset we currently use doesn't pass validation there:

https://github.com/shapeshift/hdwallet/blob/925de40aac9a2e3cafe09c5f33f5cc42417461bd/packages/hdwallet-keepkey/src/thorchain.ts#L96-L98

See the shape of a "valid" message (in hdwallet-keepkey terms) here: https://github.com/shapeshift/hdwallet/blob/925de40aac9a2e3cafe09c5f33f5cc42417461bd/integration/src/thorchain/tx01.mainnet.thorchain.swap.json#L15-L29

Note that this is NOT a limitation of the network. This is actually an arbitrary check of hdwallet-keepkey, and both rune and THOR.RUNE are actually valid variants in the Thorchain world, see: https://gitlab.com/thorchain/thornode/-/blob/622179d8bf966f7a14ea8074e521914461d521ce/common/asset_test.go#L31-33

Unfortunately, confirmed by monkey-patching hdwallet-keepkey to allow rune instead of THOR.RUNE that KeepKey produces an invalid signature while using the rune variant, which seems to indicate a firmware arbitrary limitation.

use coinAsset as "THOR.RUNE" as defined in the thorchain swap protocol
@BitHighlander BitHighlander requested a review from a team as a code owner April 3, 2023 18:52
@0xApotheosis 0xApotheosis changed the title Fix rune deposits fix: rune deposits Apr 3, 2023
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regression tested while linked in web while manually applying this diff in the chain-adapters dist. This can't be tested by linking, nor installing built module as this check fails (this is an issue I've definitely seen previously):

if (this.providers.http instanceof unchained.thorchain.V1Api) {

Develop

Swap to RUNE

image

Swap from RUNE

image

  • Doesn't go past the "Thorchain Account" step on the KK

This diff's chain-adapters "linked"

Swap to RUNE

image

Swap from RUNE

image

@gomesalexandre gomesalexandre changed the title fix: rune deposits fix: swaps from RUNE Apr 4, 2023
@gomesalexandre gomesalexandre changed the title fix: swaps from RUNE fix: keepkey swaps from RUNE Apr 4, 2023
@gomesalexandre gomesalexandre enabled auto-merge (squash) April 4, 2023 14:00
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we simply can't loosen (i.e remove) the check in hdwallet-keepkey which would result in invalid signatures for rune as a coinAsset, this is our best bet for now.

get in

@gomesalexandre gomesalexandre merged commit eb889d6 into shapeshift:main Apr 4, 2023
shapeshift-ci-bot pushed a commit that referenced this pull request Apr 4, 2023
@shapeshift-ci-bot
Copy link
Member

🎉 This PR is included in version @shapeshiftoss/chain-adapters-v11.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants