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

Channel closing handshake #141

Merged
merged 1 commit into from
Jul 22, 2020
Merged

Channel closing handshake #141

merged 1 commit into from
Jul 22, 2020

Conversation

istoilkovska
Copy link
Contributor

Closes: #126

Description

A small PR that deals with creation and handling of channel closing datagrams in the relayer TLA+ specification.

Also, relayer-old is deleted.

Key points

  1. the environment non-deterministically sets two Boolean flags, closeChannelA and closeChannelB.
  2. a relayer reads the value of these flags, and sends ChanCloseInit to the appropirate chain once the flag is true.
  3. a relayer reads that a chain set its channel end state to CLOSED and that its counterparty channel end is not closed yet, and sends ChanCloseConfirm to the its counterparty chain
  4. a chain handles ChanCloseInit and ChanCloseConfirm by setting its channel end state to CLOSED

Properties

  • ChannelCloseSafety ensures that once a channel is closed, it is never open again.
  • ChanCloseInitDelivery ensures that once ChanCloseInit is sent, eventually both channel ends are closed.

For contributor use:

  • Unit tests written
  • Added test to CI if applicable
  • Updated CHANGELOG_PENDING.md
  • 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

@istoilkovska istoilkovska changed the title Channel closing handshake (#126) Channel closing handshake Jul 10, 2020
@@ -140,7 +140,64 @@ HandleChanOpenConfirm(chainID, chain, datagrams) ==
\* otherwise, do not update the chain
ELSE chain

\* Handle "ChanCloseInit" datagrams
Copy link
Member

Choose a reason for hiding this comment

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

The relayer algorithm for handling channel closing does not have an English specification in ICS 018 (at least in the master branch). Any idea where is the English high-level spec for this algorithm? I wanted to cross-check it with your TLA+ code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, it's missing in the ICS018, which is why channel closing wasn't added to the relayer spec until now. I've reverse engineered the datagram creation from the channel closure handlers.

\* if there are valid "ChanCloseInit" datagrams
IF /\ chanCloseInitDgrs /= {}
\* and the channel end is neither UNINIT nor CLOSED
/\ chain.connectionEnd.channelEnd.state \notin {"UNINIT", "CLOSED"}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is different from ICS04. I guess the reason is that they don't have UNINIT state?Is this the condition used in the Go implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both the ICS004 and the Go implementation checks if the channel end can be found in the store, i.e. if it is non-null. In the TLA+ specification, each channel end is in UNINIT in the initial state of the system (c.f. Chain.tla and RelayerDefinitions.tla), hence a channel (also connection) end in state UNINIT denotes a null channel (connection) end.

@istoilkovska istoilkovska merged commit d6c53f4 into master Jul 22, 2020
@istoilkovska istoilkovska deleted the ilina/closing_handshake branch July 22, 2020 12:50
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.

Specify channel closing handshake in TLA+
3 participants