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

Remove NetworkSpecialization #4665

Merged
merged 8 commits into from
Feb 21, 2020
Merged

Remove NetworkSpecialization #4665

merged 8 commits into from
Feb 21, 2020

Conversation

rphmeier
Copy link
Contributor

@rphmeier rphmeier commented Jan 17, 2020

This PR removes the NetworkSpecialization from the network service.
NetworkSpecialization was an early attempt at customizing the node's network behavior for Polkadot, but there are now better APIs for doing so (register_notifications_protocol).

Historical notes on backwards compatibility

This PR does not introduce network backwards-incompatibility. Potential network backwards incompatibility has been addressed by this series of issues:

  1. Polkadot: begin to ignore the chain_status parameter: Allow empty NetworkSpecialization handshake polkadot#779
  2. Substrate: begin to ignore the chain_status in the handshake when decoding: deprecate chain_status field of network handshake #4675
  3. A few releases down the road (once Polkadot no longer depends on it), remove the chain_status member from the handshake: Remove support of network protocols before 6 #4674

Breaking API Changes:
The service API is no longer the same. The construct_simple_protocol macro with_network_protocol function have been removed. Invocations of the macro and function should be deleted without loss of functionality (except when NetworkSpecialization was non-empty - then you need to port to the register_notifications_protocol).

@rphmeier rphmeier added A3-in_progress Pull request is in progress. No review needed at this stage. B8-breakseverything labels Jan 17, 2020
@rphmeier rphmeier requested a review from tomaka January 17, 2020 16:51
@rphmeier rphmeier added A0-please_review Pull request needs code review. A3-in_progress Pull request is in progress. No review needed at this stage. and removed A3-in_progress Pull request is in progress. No review needed at this stage. A0-please_review Pull request needs code review. labels Feb 5, 2020
Copy link
Contributor

@tomaka tomaka left a comment

Choose a reason for hiding this comment

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

Changes look good to me!
Huge +1 for the removal of that creature

@rphmeier
Copy link
Contributor Author

rphmeier commented Feb 6, 2020

Once paritytech/polkadot#788 is in we can start to look at merging this. It still needs a follow-up to enable the new network protocol.

Copy link
Contributor

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

For what my review is worth, this looks good to me. Just a small question related to tests:

for _ in 0..200 { // Note: don't make that number too high or the CPU usage will explode.
let msg = (0..10).map(|_| rand::random::<u8>()).collect::<Vec<_>>();
to_send.push(Message::<Block>::ChainSpecific(msg));
let req_id = loop {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to make sure I understand this correctly, you have witnessed a u64 collision repeatedly? Even with the birthday attack in mind, that is rather unlikely, no? Am I missing something?

https://en.wikipedia.org/wiki/Birthday_attack#Mathematics

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the diagram, this test would fail with a probability of about 1/10^15. So yeah, probably overkill. TBH, I thought that RequestId was u32 (and I suppose the type may yet change), so it seems safer to protect against that. If you push for it I'll change it.

@gnunicorn
Copy link
Contributor

paritytech/polkadot#788 has been merged into polkadot. Shall we try again to get this merged in substrate, too?

@rphmeier
Copy link
Contributor Author

@gnunicorn We need a non-trivial follow-up or it will break Polkadot master. I'm hoping to do that this week. Regardless, we should merge before feature-freeze.

@gnunicorn
Copy link
Contributor

Thanks for the update, @rphmeier .

One idea behind the freeze is to give us some time to upgrade any dependents accordingly without having many unrelated (API) changes... fixing Polkadot after the freeze/during alpha+beta is totally reasonable.

Could someone merge latest master in?

@tomaka
Copy link
Contributor

tomaka commented Feb 18, 2020

I don't think merging master is hard, but let me know if I should do it.

@rphmeier
Copy link
Contributor Author

rphmeier commented Feb 18, 2020

fixing Polkadot after the freeze/during alpha+beta is totally reasonable.

Our rule is usually to have a PR for Polkadot waiting. My TODO list is fairly long before I can get to that. We will probably have to make an exception here, because I'd like to remove NetworkSpecialization for 2.0.

@tomaka

I don't think merging master is hard, but let me know if I should do it.

Feel free! Thanks

@tomaka
Copy link
Contributor

tomaka commented Feb 19, 2020

Merged master.

@gnunicorn
Copy link
Contributor

@rphmeier anything else to do here before we can merge into substrate?

Re Polkadot: I think we can make an exception for the freeze.

@gnunicorn
Copy link
Contributor

needs another merge with master...

@rphmeier rphmeier added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Feb 19, 2020
@rphmeier
Copy link
Contributor Author

OK, shall we merge directly before the freeze? I'd like to minimize breakage in Polkadot as much as possible.

@andresilva
Copy link
Contributor

@rphmeier We can also exclude this PR when backporting to polkadot-master until we have support for this in polkadot.

@gnunicorn
Copy link
Contributor

icing until the freeze (pun intended)

@gnunicorn gnunicorn added this to the 2.0 milestone Feb 21, 2020
@gnunicorn gnunicorn added A3-in_progress Pull request is in progress. No review needed at this stage. and removed A1-onice labels Feb 21, 2020
@gnunicorn
Copy link
Contributor

could someone with enough expertise update to master, resolved the conflicts and merge this into master?

//cc @rphmeier, @tomaka

@tomaka
Copy link
Contributor

tomaka commented Feb 21, 2020

Master-merging round 3 done. Not totally sure that CI passes.

@gnunicorn gnunicorn added A4-awaitingci and removed A0-please_review Pull request needs code review. A3-in_progress Pull request is in progress. No review needed at this stage. labels Feb 21, 2020
@tomaka
Copy link
Contributor

tomaka commented Feb 21, 2020

The PR's ready to be merged. Since I haven't really followed the story regarding the Substrate freeze and Polkadot, I will let someone else do it.

@gnunicorn gnunicorn merged commit 3cc0973 into master Feb 21, 2020
@gnunicorn gnunicorn deleted the rh-remove-specialization branch February 21, 2020 13:02
@rphmeier
Copy link
Contributor Author

I have a PR in the works which adjusts Polkadot to use this.

bkchr added a commit that referenced this pull request Feb 27, 2020
General-Beck pushed a commit to General-Beck/substrate that referenced this pull request Mar 4, 2020
* remove networkspecialization

* Fix most of the fallout

* get all tests compiling

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
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.

None yet

5 participants