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

Allow sub-contexts to have different Error types with functions to inject errors into Self::Error #2932

Merged
merged 4 commits into from
Dec 12, 2022

Conversation

soareschen
Copy link
Contributor

Closes: #2844


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests: integration (for Hermes) or unit/mock tests (for modules).
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

Only remaining fix needed is the same error constraint in BatchContext,
which can be fixed in #2816.
@netlify
Copy link

netlify bot commented Dec 8, 2022

Deploy Preview for ibc-rs ready!

Name Link
🔨 Latest commit 30928a4
🔍 Latest deploy log https://app.netlify.com/sites/ibc-rs/deploys/63972aa43f44640008310105
😎 Deploy Preview https://deploy-preview-2932--ibc-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Relay::SrcChain: OfaFullChain,
// TODO: do not require the chain error to be the same as relay error.
// this can be fixed in #2816.
Relay::SrcChain: OfaFullChain<Error = Relay::Error>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This requires refactoring on the batch context, but the batch context can be removed through #2816. So we will leave it to #2816 to fix this final limitation.


fn runtime(&self) -> &Self::Runtime;

fn runtime_error(e: <Self::Runtime as HasErrorType>::Error) -> Self::Error;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally wanted HasRuntime to has InjectError<<Self::Runtime as HasError>::Error> as the supertrait. But I realized that it would require the implementor to have a generic implementation of InjectError, which is not allowed by Rust due to overlapping implementations.

So instead we would have explicit conversion methods for the sub-error types.

@soareschen soareschen added the O: relayer-next Objective: work toward relayer v2 label Dec 9, 2022
Copy link
Contributor

@ljoss17 ljoss17 left a comment

Choose a reason for hiding this comment

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

Seems great! Just curious about your opinion on the implementation of From

}
}

#[async_trait]
impl<Error> OfaRuntime for TokioRuntimeContext<Error>
where
Error: From<TokioError> + Debug + Async,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the constraint From<TokioError> is removed, should the implementation, https://github.com/informalsystems/hermes/blob/soares/explicit-error-injection/crates/relayer-cosmos/src/base/error.rs#L59, be kept or not ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, it can be removed if there is no compile error. Thanks for pointing out!

@soareschen soareschen merged commit 05d635c into soares/relayer-next Dec 12, 2022
@soareschen soareschen deleted the soares/explicit-error-injection branch December 12, 2022 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O: relayer-next Objective: work toward relayer v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants