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 header decoding errors #1343

Merged
merged 4 commits into from
Sep 14, 2021
Merged

Fix header decoding errors #1343

merged 4 commits into from
Sep 14, 2021

Conversation

adizere
Copy link
Member

@adizere adizere commented Sep 13, 2021

Closes: #1342

Description


For contributor use:

  • Added a changelog entry, using unclog.
  • 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.

Copy link
Member

@romac romac left a comment

Choose a reason for hiding this comment

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

Thanks @ancazamfir for jumping on this so quickly 🙏

@@ -71,8 +71,14 @@ pub fn extract_header_from_tx(event: &tendermint::abci::Event) -> Option<AnyHead
let value = tag.value.as_ref();
if let HEADER = key {
let header_bytes = hex::decode(value).unwrap();
let header: AnyHeader = Protobuf::decode(header_bytes.as_ref()).unwrap();
return Some(header);
let result = match Protobuf::decode(header_bytes.as_ref()) {
Copy link
Member

Choose a reason for hiding this comment

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

How about we just return Result directly and let the calling code in the relayer trace the underlying error?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe try_from_tx should see its signature changed from

pub fn try_from_tx(event: &tendermint::abci::Event) -> Option<IbcEvent> 

to

pub fn try_from_tx(event: &tendermint::abci::Event) -> (Option<IbcEvent>, Vec<Error>)

so that we can still build the IbcEvent even if the header decoding failed, but also return any errors encountered (eg. the header decoding error itself).

@romac
Copy link
Member

romac commented Sep 13, 2021

While we're at it, we should perhaps also address the unwraps in extract_attributes_from_tx just to be sure:

https://github.com/informalsystems/ibc-rs/pull/1343/files#diff-4443bc0aab1af2440761561a3f6099a9f96ef775af44ac5321233d534d4ccb36R57-R60

@romac
Copy link
Member

romac commented Sep 14, 2021

Let's address my comments in a follow-up PR.

@romac romac merged commit 62b0744 into master Sep 14, 2021
@romac romac deleted the anca/header_error branch September 14, 2021 12:43
@romac romac mentioned this pull request Sep 14, 2021
10 tasks
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* Return None when header cannot be decoded

* More details in misbehaviour error

* Set the event height and include it in the error

* Add .changelog entry

Co-authored-by: Anca Zamfir <zamfiranca@gmail.com>
Co-authored-by: Romain Ruetschi <romain@informal.systems>
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.

Header parsing panic kills chain runtime
3 participants