Skip to content

fix(test): fix HD Wallet message signing tests#2474

Merged
shamardy merged 9 commits intodevfrom
hd-sign-msg-fix
May 31, 2025
Merged

fix(test): fix HD Wallet message signing tests#2474
shamardy merged 9 commits intodevfrom
hd-sign-msg-fix

Conversation

@borngraced
Copy link
Copy Markdown

No description provided.

@borngraced borngraced requested a review from shamardy May 29, 2025 18:47
Comment on lines +5413 to +5416
// This should fail: signature was created with pubkey from m/49'/141'/0'/0/0,
// but we are now resolving address from m/84'/141'/0'/0/0
assert!(
!verify_response.result.is_valid,
"Expected verification to fail due to derivation path mismatch"
verify_response.result.is_valid,
Copy link
Copy Markdown
Collaborator

@mariocynicys mariocynicys May 29, 2025

Choose a reason for hiding this comment

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

checked the CI. it fails. and is_valid = false.
let's forget about the CI/test failure/passing now and keep the notion around the is_valid variable.

imo, i think is_valid is supposed to be false. i.e. if is_valid were true then this is a bug.

i will say why is that my belief and please tell me yours @borngraced:

we signed a message using pubkey = m/49'/141'/0'/0/0, and we are trying to verify it with pubkey = m/84'/141'/0'/0/0. and one can not sign a message and verify that signature from two different pubkeys. so i expect is_valid to be false (i.e., i see no bug).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

actually I think I get your point 💯 and that's because of the flow of the test...I will modify and hope you understand better

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

at this point tbh my head is spinning hard. i would much rather prefer u to answer my question/tell me ur pov rather than change the test again :(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

i will say why is that my belief and please tell me yours

I guess the test is too explicit and didn't capture what I wanted to portray in a dynamic way...

So the test is supposed to activate COIN, do some signing and verification which should work, then, deactivate theCOIN, and reactivate again with new derivation path(without stopping MM2).. do some signing and verification which should now fail assuming we reuse sam DB path in the test.

In conclusion, I think the test is not 100% doing what I want it to do.

Copy link
Copy Markdown
Author

@borngraced borngraced May 29, 2025

Choose a reason for hiding this comment

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

Please recheck the test

@shamardy shamardy added priority: urgent Critical tasks requiring immediate action. 2.5.0-beta status: pending review labels May 29, 2025
shamardy
shamardy previously approved these changes May 29, 2025
Copy link
Copy Markdown
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

LGTM! Only one nit.

@shamardy
Copy link
Copy Markdown
Collaborator

shamardy commented May 29, 2025

@mariocynicys once all your comments are resolved plus this #2474 (comment) , please merge the PR after your approval.

Copy link
Copy Markdown
Collaborator

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

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

that's a starter quick review. since the test was ignored in the same commit it was modified in, there is no CI test runs of it.
so will unignore and try it locally and continue the review 👍

}

/// Needs attention after [issue #2470](https://github.com/KomodoPlatform/komodo-defi-framework/issues/2470) is resolved.
/// Should not fail after [issue #2470](https://github.com/KomodoPlatform/komodo-defi-framework/issues/2470) is resolved.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: let's reword this to "This test fails until issue ...... is resolved"

@mariocynicys
Copy link
Copy Markdown
Collaborator

mariocynicys commented May 30, 2025

nvm my previous comment about signing.
could u take a look at this commit 43454d2

it exploits the bug without signing and verifying.

@borngraced
Copy link
Copy Markdown
Author

nvm my previous comments about signing. could u take a look at this commit 43454d2

it exploits the bug without signing and verifying.

It definitely makes more sense to write the test the same way it was discovered IMO..can just include assert_eq old and new addrees[0] rather than changing the test

@mariocynicys
Copy link
Copy Markdown
Collaborator

It definitely makes more sense to write the test the same way it was discovered IMO

i don't think we have to encode a complicated history of how the bug was discovered into the test (any first eye would be confused why we signing. let alone i was super confused to get started with this bug and i am supposedly following from the beginning).
the test should rather serve as a minimal reproducible example that demonstrate the bug. any extra routes are extra confusion to what this problem is related to.

can just include assert_eq old and new addrees[0] rather than changing the test

i think u mean assert_ne. then that's enough though to show the bug. the first panic gonna trigger anyway.
i mean we can also add a withdraw snippet to the test that exploits the bug. we could probably add a swap or two in addition to all of that to exploit the bug and tons of other things that the reader of the test will think they are related to the bug, but the bug in fact is solely in the HD Wallet code.

Copy link
Copy Markdown
Collaborator

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!
LGTM!

Copy link
Copy Markdown
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Thanks a lot @borngraced @mariocynicys !

@shamardy shamardy changed the title fix(test): fix eth hd message sign and verify test fix(test): fix HD Wallet message signing tests May 31, 2025
@shamardy shamardy merged commit 923eb0b into dev May 31, 2025
24 of 25 checks passed
@shamardy shamardy deleted the hd-sign-msg-fix branch May 31, 2025 02:56
dimxy pushed a commit that referenced this pull request Jun 3, 2025
* dev:
  feat(walletconnect): add WalletConnect v2 support for EVM and Cosmos (#2223)
  feat(ibc-routing-part-1): supporting entire Cosmos network for swaps (#2459)
  fix(test): fix HD Wallet message signing tests (#2474)
  improvement(builds): enable static CRT linking for MSVC builds (#2464)
  feat(wallet): implement HD multi-address support for message signing (#2432)
dimxy pushed a commit to dimxy/komodo-defi-framework that referenced this pull request Jun 8, 2025
* lr-swap-wip: (37 commits)
  fix custom token error name
  fix getting chain_id from protocol_data
  refactor (review): use dedicated large error cfg, add new fn to FromApiValueError, fix TODO, use experimental namespace for lr rpc, more Ticker alias
  feat(walletconnect): add WalletConnect v2 support for EVM and Cosmos (GLEECBTC#2223)
  feat(ibc-routing-part-1): supporting entire Cosmos network for swaps (GLEECBTC#2459)
  fix(test): fix HD Wallet message signing tests (GLEECBTC#2474)
  improvement(builds): enable static CRT linking for MSVC builds (GLEECBTC#2464)
  feat(wallet): implement HD multi-address support for message signing (GLEECBTC#2432)
  fix(p2pk): validate expected pubkey correctly for p2pk inputs (GLEECBTC#2408)
  chore(docs): update old urls referencing atomicdex or old docs pages (GLEECBTC#2428)
  improvement(p2p): remove hardcoded seeds (GLEECBTC#2439)
  fix(evm-api): find enabled erc20 token using platform ticker (GLEECBTC#2445)
  chore(docs): add DeepWiki badge to README (GLEECBTC#2463)
  chore(core): organize deps using workspace.dependencies (GLEECBTC#2449)
  feat(db-arch): more dbdir to address_dir replacements (GLEECBTC#2398)
  chore(build-artifacts): remove duplicated mm2 build artifacts (GLEECBTC#2448)
  feat(pubkey-banning): expirable bans (GLEECBTC#2455)
  fix(eth-balance-events): serialize eth address using AddrToString (GLEECBTC#2440)
  chore(deps): remove base58 and replace it completely with bs58 (GLEECBTC#2427)
  feat(tron): initial groundwork for full TRON integration (GLEECBTC#2425)
  ...
dimxy pushed a commit to dimxy/komodo-defi-framework that referenced this pull request Jun 27, 2025
* dev: (30 commits)
  chore(core): replace hash_raw_entry with stable entry() API (GLEECBTC#2473)
  chore(core): adapt `MmError` and usages for compatibility with new rustc versions (GLEECBTC#2443)
  feat(wallet): add `delete_wallet` RPC (GLEECBTC#2497)
  chore(release): add changelog entries for v2.5.0-beta (GLEECBTC#2494)
  chore(release): bump kdf version to 2.5.0-beta (GLEECBTC#2492)
  feat(tests): zcoin unit test to validate dex fee (GLEECBTC#2460)
  fix(zcoin): correctly track unconfirmed z-coin notes (GLEECBTC#2331)
  improvement(orders): remove BTC specific volume from min_trading_vol logic (GLEECBTC#2483)
  feat(ibc-routing-part-2): supporting entire Cosmos network for swaps (GLEECBTC#2476)
  fix(startup): don't initialize WalletConnect during startup (GLEECBTC#2485)
  fix(dns): better ip resolution (GLEECBTC#2487)
  improvement(event-streaming): strong type streamer IDs (GLEECBTC#2441)
  bump timed-map to `1.4.1` (GLEECBTC#2481)
  improvement(RPC): unified interface for legacy and current RPC interfaces (GLEECBTC#2450)
  improvement(tendermint): `tendermint_tx_internal_id` helper (GLEECBTC#2438)
  feat(walletconnect): add WalletConnect v2 support for EVM and Cosmos (GLEECBTC#2223)
  feat(ibc-routing-part-1): supporting entire Cosmos network for swaps (GLEECBTC#2459)
  fix(test): fix HD Wallet message signing tests (GLEECBTC#2474)
  improvement(builds): enable static CRT linking for MSVC builds (GLEECBTC#2464)
  feat(wallet): implement HD multi-address support for message signing (GLEECBTC#2432)
  ...

# Conflicts:
#	mm2src/coins/qrc20.rs
#	mm2src/mm2_main/src/lp_swap/maker_swap.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: urgent Critical tasks requiring immediate action. status: pending review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants