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

[Context] Issues caused by improper output signatures of provable store readers #607

Open
Farhad-Shabani opened this issue Apr 5, 2023 · 0 comments
Labels
A: critical Admin: critical or Important O: logic Objective: aims for better implementation logic O: security Objective: aims to enhance security and improve safety S: errors Scope: related to error handlings

Comments

@Farhad-Shabani
Copy link
Member

Farhad-Shabani commented Apr 5, 2023

Problem Statement

There is a discrepancy between the output signature/type of methods (under ValidationContext) that retrieve datagrams from a provable store, e.g.:

  • For the next_consensus_state and prev_consensus_state interfaces we have Result<Option<Output>, ContextError>
  • Other places, reader methods use Result<Output, ContextError> type

Meaning sometimes we denote unavailability with None and other times as an Error


Why does this matter and should a consistent approach be taken? and clearly differentiate cases where an output represents (1) existence/absence of a state in storage and any other errors that show (2) failure scenarios (like broken storage, etc) when performing a query?

  • Looking into the acceptable absences
    There are places we operate based on a lack of datagrams and treat them as an expected/acceptable execution route, like:

  • Needing self-contained approach
    The correctness of our operations relies on implementors. Hoping they select the right error variant and do not use any other errors under the ContextError enum, too. E.g. here

  • Moving towards errors with concerns separated
    This is consistent with the view presented here splitting errors into categories of protocol-specific and host-related errors, where:

    1. The first will be responsible for handling (1) Option<Output> concerned only with the IBC implementation
    2. The latter deals with (2) propagating errors of the Result<Option<Output>, Error> type that occurred in hosts' boundary
  • Avoiding side effects
    And, with the current signature, our error system becomes useless and fails to propagate the correct failure reason in a bunch of places, as we eventually map them to our assumed/desired errors like here & here

Proposal

  • Leaving with the Result<Option<Output>, Error> signature for the reader methods (It might not apply to all, but seems like it should)
  • Why not Result<Result<Output, ProtocolError> HostError> instead?
    1. As mentioned, some places treat the absence of a datagram as a reasonable/expected behavior
    2. Requires implementors to introduce an additional ProtocolError everywhere, which must be exactly the same as the one we defined to represent that non-existence case. (means they have no other options). This shouldn't be their concern and better to be handled internally.

Remark

  • Separated from Make core Error enums less specific #270 due to critical issues associated with this and needs to be fixed before that. We are unsure how different hosts have handled errors, and some of their error scenarios may bypass the cases mentioned above, particularly during packet processings.
@Farhad-Shabani Farhad-Shabani added A: critical Admin: critical or Important O: logic Objective: aims for better implementation logic S: errors Scope: related to error handlings O: security Objective: aims to enhance security and improve safety labels Apr 5, 2023
@Farhad-Shabani Farhad-Shabani moved this to 📥 To Do in ibc-rs Apr 5, 2023
@Farhad-Shabani Farhad-Shabani changed the title [Context] Issues caused by inappropriate output signatures of provable store reader methods [Context] Issues caused by improper output signatures of provable store readers Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: critical Admin: critical or Important O: logic Objective: aims for better implementation logic O: security Objective: aims to enhance security and improve safety S: errors Scope: related to error handlings
Projects
Status: 📥 To Do
Development

No branches or pull requests

1 participant