Skip to content
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

Improved error display #4209

Merged
merged 4 commits into from
Nov 10, 2023
Merged

Improved error display #4209

merged 4 commits into from
Nov 10, 2023

Conversation

syan095
Copy link
Contributor

@syan095 syan095 commented Nov 7, 2023

Pull Request

Closes: PRO-950

Checklist

Please conduct a thorough self-review before opening the PR.

  • I am confident that the code works.
  • I have updated documentation where appropriate.

Summary

Changed invalid BTC address error for lp_withdraw_asset from DispatchError::Other() to a pallet error, so it can be displayed on the front end properly.

Copy link

linear bot commented Nov 7, 2023

PRO-950 RPC result with a DispatchError::Other is empty

When a DispatchError::Other("some error") is returned as a DispatchResult to an RPC, the result is Other("").

You can see this bug if you try and call a withdraw_asset with a bad btc address.

> curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "lp_withdraw_asset", "params": ["1", "Btc", "not_a_btc_address"]}' http://localhost:10589

{"jsonrpc":"2.0","error":{"code":-32000,"message":"Other("")"},"id":1}%

I believe this bug is caused by the static str inside the Other variant not being serialised.

@syan095 syan095 requested review from j4m1ef0rd and kylezs November 7, 2023 05:07
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #4209 (4fac4b5) into main (2eb196d) will decrease coverage by 0%.
Report is 3 commits behind head on main.
The diff coverage is 22%.

@@          Coverage Diff          @@
##            main   #4209   +/-   ##
=====================================
- Coverage     71%     71%   -0%     
=====================================
  Files        383     383           
  Lines      62704   62744   +40     
  Branches   62704   62744   +40     
=====================================
+ Hits       44822   44845   +23     
- Misses     15550   15561   +11     
- Partials    2332    2338    +6     
Files Coverage Δ
state-chain/chains/src/deposit_channel.rs 37% <100%> (ø)
state-chain/chains/src/lib.rs 29% <ø> (ø)
state-chain/pallets/cf-ingress-egress/src/mock.rs 98% <100%> (ø)
...in/runtime/src/chainflip/address_derivation/eth.rs 98% <100%> (ø)
.../client/extrinsic_api/signed/submission_watcher.rs 21% <0%> (ø)
state-chain/chains/src/address.rs 62% <0%> (-<1%) ⬇️
state-chain/pallets/cf-account-roles/src/lib.rs 76% <0%> (ø)
state-chain/pallets/cf-swapping/src/lib.rs 84% <0%> (-<1%) ⬇️
state-chain/pallets/cf-lp/src/mock.rs 80% <0%> (ø)
...in/runtime/src/chainflip/address_derivation/btc.rs 97% <50%> (ø)
... and 3 more

... and 6 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@syan095 syan095 changed the title Improved error display for lp_withdraw_asset Improved error display Nov 9, 2023
MissingPolkadotVault,
/// Bitcoin's Vault key does not exist for the current epoch.
MissingBitcoinVault,
/// Intent ID is too large for Bitcoin address derivation
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Intent ID is too large for Bitcoin address derivation
/// Channel ID is too large for Bitcoin address derivation.

/// Bitcoin's Vault key does not exist for the current epoch.
MissingBitcoinVault,
/// Intent ID is too large for Bitcoin address derivation
BitcoinIntentIdTooLarge,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
BitcoinIntentIdTooLarge,
BitcoinChannelIdTooLarge,

Copy link
Collaborator

Choose a reason for hiding this comment

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

FWIW I think we should probably wrap the channel id counter instead of returning an error. Can wait for another PR.

UnauthorisedToModify,
// The Asset cannot be egressed to the destination chain.
/// The Asset cannot be egressed to the destination chain.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This message doesn't say anything about the address.

@syan095 syan095 enabled auto-merge (squash) November 10, 2023 00:03
@syan095 syan095 merged commit 2d6855c into main Nov 10, 2023
41 checks passed
@syan095 syan095 deleted the fix/improve-error branch November 10, 2023 00:44
dandanlen pushed a commit that referenced this pull request Nov 17, 2023
* Changed a DispatchError::Other() to a pallet error, so it can be displayed
on the front end properly.

* Replaced DispatchError::Other with module error for better display
Improved dry run's debug logging for more clarity

* minor rename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants