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

Investigate using "tagged identifiers" in connection/channel handshake #201

Open
5 tasks
plafer opened this issue Oct 26, 2022 · 3 comments
Open
5 tasks
Labels
O: exploratory Objective: aims to investigate new ideas O: maintainability Objective: cause to ease modification, fault corrections and improve code understanding

Comments

@plafer
Copy link
Contributor

plafer commented Oct 26, 2022

We recently introduced this naming convention in the handshakes to facilitate understanding the logic. Correctness however still relies on the programmer. We could use "tagged identifiers" (see below) to let the type system tell us if we've made a mistake.

From @romac:

Also see the typestate pattern.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate milestone (priority) applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@plafer plafer added the O: new-feature Objective: aims to add new feature label Oct 26, 2022
@plafer
Copy link
Contributor Author

plafer commented Dec 13, 2022

Another potential use of the typestate pattern would be to tag data as:

  • Dirty: comes from user input (e.g. a message), and needs validation
  • Clean: has been validated

The goal would be to avoid at compile-time scenarios where e.g. we unwrap() user input (see #219).

Further discussion is required though to see if the added complexity is worth it.

@skaunov
Copy link

skaunov commented Dec 21, 2022

Should there be one typestate system, or two? (Or other number?)

Correct me if I wrong, please. [connection Opening handshake] defines state automaton with 5 states, and it's the automaton which is implemented by relayer. But in turn it's based on clients state defined in https://github.com/cosmos/ibc/tree/main/spec/core/ics-002-client-semantics#clientstate which also could be represented by an automaton, and these states are used in connection mod. So if typestates would implement [connection Opening handshake] automaton, the types of it would be parallel with State. On the other hand if implementation is based on the States, then the automaton defined in [connection Opening handshake] should be expressed as two interacting automatons, which would define it implementation for connection mod.
[connection Opening handshake]: https://github.com/cosmos/ibc/blob/main/spec/core/ics-003-connection-semantics/README.md#sub-protocols

@plafer
Copy link
Contributor Author

plafer commented Jan 3, 2023

I don't think the typestate pattern would apply to IBC's "handshake state machine", or at least with very little benefit, since only one step of the state machine is only ever executed at once (that is, per message processed).

Should there be one typestate system, or two? (Or other number?)

Indeed there could be more than 2; basically anywhere we find a new use case where the pattern could be useful.

@Farhad-Shabani Farhad-Shabani added O: maintainability Objective: cause to ease modification, fault corrections and improve code understanding and removed O: new-feature Objective: aims to add new feature labels Jan 5, 2023
@plafer plafer added the O: exploratory Objective: aims to investigate new ideas label Jan 12, 2023
@github-project-automation github-project-automation bot moved this to 📥 To Do in ibc-rs Feb 2, 2023
shuoer86 pushed a commit to shuoer86/ibc-rs that referenced this issue Nov 4, 2023
* docs: update changelog for v0.9.1 release

* Update CHANGELOG.md

* Update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O: exploratory Objective: aims to investigate new ideas O: maintainability Objective: cause to ease modification, fault corrections and improve code understanding
Projects
None yet
Development

No branches or pull requests

3 participants