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

Fix for relayer::error displays #559

Merged
merged 8 commits into from
Jan 28, 2021
Merged

Fix for relayer::error displays #559

merged 8 commits into from
Jan 28, 2021

Conversation

adizere
Copy link
Member

@adizere adizere commented Jan 26, 2021

Description


For contributor use:

  • Updated the Unreleased section of CHANGELOG.md with the issue.
  • If applicable: Unit tests written, added test to CI.
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments.
  • Re-reviewed Files changed in the Github PR explorer.

@adizere adizere marked this pull request as ready for review January 27, 2021 09:19
@adizere adizere mentioned this pull request Jan 27, 2021
5 tasks
Comment on lines +22 to +23
// TODO: refactor commands: why is chain_id an `Option`? simpler to give it `ChainId` type.
// see the tx/client.rs or tx/packet.rs for simpler approaches.
Copy link
Member

Choose a reason for hiding this comment

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

That's because gumdrop requires types used in options to have a Default instance: https://gist.github.com/romac/23db89d7c5971b0e591a11286fc259a6

While this makes sense for options which are not marked required, it's beyond me why the requirement subsists for required options.

As such, I am not even sure we need the required annotation since we end up checking for the Option to be defined anyway but I guess it does not hurt if the error message thrown by gumdrop is good enough.

Copy link
Member

Choose a reason for hiding this comment

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

Oh but we have a Default instance for ChainId. Then yeah we don't need the option and can instead just use required.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We added Default -s for everything when we started to use types in the CLI options. I think we should consider moving to something else in V1 (maybe directly gumdrop) as we need more flexibility.

Copy link
Member Author

Choose a reason for hiding this comment

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

As such, I am not even sure we need the required annotation since we end up checking for the Option to be defined anyway but I guess it does not hurt if the error message thrown by gumdrop is good enough.

The error message from gumdrop is a bit.. underwhelming. But it helps still. It says only:

error: missing required free argument

Was looking at ways to parametrize this, but did not find anything.

The way I understand it, with 'required' we now have two levels of checks:

  1. gumdrop enforces some (any) value to be present
  2. in our validate_options methods we parse and do additional checks on the field.

We added Default -s for everything when we started to use types in the CLI options. I think we should consider moving to something else in V1 (maybe directly gumdrop) as we need more flexibility.

Sounds like a plan.

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened an issue to continue discussion, if necessary, and track this

#573

relayer-cli/src/conclude.rs Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Jan 27, 2021

Codecov Report

Merging #559 (4d78ed0) into master (b1b37f5) will increase coverage by 32.6%.
The diff coverage is 67.4%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #559      +/-   ##
=========================================
+ Coverage    13.6%   46.3%   +32.6%     
=========================================
  Files          69     138      +69     
  Lines        3752    9172    +5420     
  Branches     1374       0    -1374     
=========================================
+ Hits          513    4251    +3738     
- Misses       2618    4921    +2303     
+ Partials      621       0     -621     
Impacted Files Coverage Δ
...application/ics20_fungible_token_transfer/error.rs 0.0% <0.0%> (ø)
...pplication/ics20_fungible_token_transfer/events.rs 0.0% <ø> (ø)
...ion/ics20_fungible_token_transfer/msgs/transfer.rs 0.0% <0.0%> (ø)
modules/src/events.rs 0.0% <0.0%> (ø)
modules/src/ics02_client/error.rs 100.0% <ø> (ø)
modules/src/ics02_client/raw.rs 0.0% <0.0%> (ø)
modules/src/ics03_connection/error.rs 100.0% <ø> (+66.6%) ⬆️
modules/src/ics03_connection/msgs/conn_open_try.rs 86.7% <ø> (ø)
modules/src/ics03_connection/version.rs 97.6% <ø> (ø)
modules/src/ics04_channel/channel.rs 77.2% <ø> (+62.1%) ⬆️
... and 257 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d57e89c...2ec0e85. Read the comment docs.

Copy link
Collaborator

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

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

Looks good, thanks Adi!

@adizere adizere merged commit 4e13a10 into master Jan 28, 2021
@adizere adizere deleted the adi/555_err branch January 28, 2021 12:26
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* Include cause in Failed errors (informalsystems#555). Double-checking 'required' tag.

* Finished adding 'required' tag to commands

* Last nits around error messages.

* Changelog

* Change doctests in conclude to ignore

* Remove Option from chain_id parameter in client queries

Co-authored-by: Anca Zamfir <zamfiranca@gmail.com>
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.

Problems with relayer::error display for CLIs
4 participants