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

TRN-609 Improve transact error handling #893

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

JCSanPedro
Copy link
Collaborator

@JCSanPedro JCSanPedro commented Oct 10, 2024

Front-end developers often encountered a misleading error message 1010: Invalid Transaction: Transaction has a bad signature when working the xrpl pallet. This would usually be due to an unrelated problem, such as the sending account not having sufficient balance to pay for the extrinsic. Seeing the incorrect error message could be very confusing.

The above error message is correlated with the error InvalidTransaction::BadProof. The runtime would mistakingly return this error because the xrpl (and doughnut) pallet have additional extrinsic validation applied to their runtime calls, implemented via the SelfContainedCall trait that was returning the wrong value. The method validate_self_contained returns a type Option<TransactionValidityError>, where if the return value was None, the validate implementation for CheckedExtrinsics from evm frontier would default to InvalidTransaction::BadProof https://github.com/polkadot-evm/frontier/blob/master/primitives/self-contained/src/checked_extrinsic.rs#L93-L95.

This PR aims to ensure the correct InvalidTransaction variant is propagated when the runtime call is validated.

Release Notes

Error Messages:

Changed:

doughtnut: Invalid transactions should be correct variant instead of catch-all BadProof
xrpl: Invalid transactions should be correct variant instead of catch-all BadProof

Copy link
Contributor

@zees-dev zees-dev left a comment

Choose a reason for hiding this comment

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

Nice; LGTM 👍

pallet/xrpl/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@JasonTulp JasonTulp left a comment

Choose a reason for hiding this comment

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

lgtm, nice work! Will definitely make it more clear to external devs. Although interesting that only one test needs changing in doughnuts, is this an indication that we need better test coverage?

@JCSanPedro JCSanPedro force-pushed the TRN-609-transact-err-handling branch from 301d5f2 to ff7e854 Compare October 16, 2024 21:15
@JCSanPedro
Copy link
Collaborator Author

Although interesting that only one test needs changing in doughnuts, is this an indication that we need better test coverage

Yes I think so. I found that for the Doughnut pallet tests, the tx would fail at check_self_contained before failing at validate_self_contained. Needs more exploration to figure out how to correctly write the tests so that it hits the code we expect it to.

@JCSanPedro JCSanPedro merged commit 5928785 into main Nov 4, 2024
2 checks passed
@JCSanPedro JCSanPedro deleted the TRN-609-transact-err-handling branch November 4, 2024 21:27
@surangap surangap mentioned this pull request Nov 6, 2024
4 tasks
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