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 Feb 12, 2021

Cleans up protocol.rs by extracting all the transactions-related code to a new transactions.rs module.
In this PR, I've done the minimal amount of changes to make sure to not break anything. Later PRs can add more changes, such as switching from write_notification to some properly-back-pressured alternative.

Before this PR, the various layers go like this: (outside) <-> service.rs <-> behaviour.rs <-> protocol.rs <-> generic_proto.rs

This PR moves the transaction handling from protocol.rs to (outside). It is now a background task that interacts with the NetworkService in service.rs.
A new transactions_handler_executor field has been added to the network parameters. It is used to spawn that task.

This background task is spawned by service.rs after the service creation. Again, I want to minimize the surface of the changes.
I have in mind to later do the same with the syncing protocol later, and completely eliminate protocol.rs.

The main advantage, beyond code clean up, is that the transactions sizes and rates are now treated the same as GrandPa, collation and validation messages, and are reported on Prometheus.

Two misc. notes:

  • Before this PR the transactions code halts gossiping if we're not fully synced. In this PR, I've abstracted over this with a gossip_disabled variable that is updated with whenever we're full synced when polling the network worker.
  • This breaks gossiping transactions over the legacy protocol. The legacy protocol is no longer in use for at least the past 6 months to a year.

@tomaka tomaka added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Feb 12, 2021
@tomaka tomaka requested review from NikVolf and romanb February 12, 2021 13:25
@tomaka
Copy link
Contributor Author

tomaka commented Feb 12, 2021

Note for self: I've just realized that this wasn't compatible with the current network, because the handshake of all notifications, by default, is an encoded Role, while for transactions it's currently nothing.
Will need more changes.

@tomaka
Copy link
Contributor Author

tomaka commented Feb 12, 2021

Fixing this transaction would be way easier if #8079 was in. I'm going to push for that PR to be merged.

Copy link
Contributor

@romanb romanb left a comment

Choose a reason for hiding this comment

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

The direction looks good to me, conceptually (I did not look at the control flow in detail).

@tomaka
Copy link
Contributor Author

tomaka commented Feb 18, 2021

Updated the burn-in PR after the commit I've just pushed and will see if everything looks normal before merging.

@tomaka tomaka merged commit 2c99434 into paritytech:master Feb 18, 2021
@tomaka tomaka deleted the extract-tx-protocol branch February 18, 2021 16:04
KalitaAlexey pushed a commit to KalitaAlexey/substrate that referenced this pull request Jul 9, 2021
* Extract transactions handling from protocol.rs

* Oops, boolean

* Do this better

* Update client/network/src/transactions.rs

Co-authored-by: Nikolay Volf <[email protected]>

* [WIP] Fix handshake

* Finish handshake change

* Bugfix

Co-authored-by: Nikolay Volf <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants