Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Conversation

@tomaka
Copy link
Contributor

@tomaka tomaka commented Mar 23, 2020

Extends the "notifications protocol" system introduced in #4284 and #4909, which are already used for GrandPa and Polkadot-specific protocols, to block announces and transactions.

This should normally be the last step to the transition to the new parachain-friendly networking protocol and the deeper integration with the libp2p protocol.
The next changes to sc_network should normally only be clean-ups.

Changes:

  • protocol.rs now registers two notifications protocols: /<chainid>/block-announces/1 and /<chainid>/transactions/1.
  • In order to propagate extrinsics or announce blocks, it now sends a notification rather than sending a message on the legacy single substream. This is backwards-compatible, as we use the legacy substream as a fallback in case the remote doesn't support our notifications protocol. For simplicity, I kept the same message formats.
  • Rather than passing a ConsensusEngineId to the handler to use as a fallback, we pass a full fallback message.
  • In protocol.rs we register, for each notifications protocol, how to interpret it. This is done with the Fallback enum. When we decode a block announce or list of transactions, we do the same thing as for the legacy protocol.

Dangerosity of the change

This change is fully backwards-compatible, and is using the same mechanism for notifications as is used by GrandPa right now on the live network. #5201 suggests that there is a hidden bug somewhere, but it happens very rarely and I will spend the next days trying to find out what is happening.
I also tried on a local network (with --dev), and everything works fine.
Additionally, all the tests have passed on first try, which gives even more confidence.

Because of all this, I think the change should be quite smooth.

@tomaka tomaka added A0-please_review Pull request needs code review. B1-clientnoteworthy labels Mar 23, 2020
@tomaka tomaka requested a review from twittner March 23, 2020 14:51
@tomaka tomaka added this to the 2.0 milestone Mar 23, 2020
for handler in &mut self.out_handlers {
if handler.protocol_name() != &protocol_name[..] {
break;
continue;
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 is a bugfix. This loop tries all the protocols that have been registered. If it can't find any, it uses the legacy substream itself. Because of this break, we were using the legacy substream for all notification protocols expect the first one.

@gavofyork
Copy link
Member

check-polkadot needs to pass first :-P

@gavofyork gavofyork added A7-needspolkadotpr and removed A0-please_review Pull request needs code review. labels Mar 26, 2020
@gnunicorn gnunicorn merged commit 4b65f17 into paritytech:master Mar 30, 2020
@tomaka tomaka deleted the blocks-transactions-notifs branch March 30, 2020 08:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants