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

Change on-the-wire protocol names to include genesis hash & fork id #11938

Merged
merged 12 commits into from
Aug 5, 2022

Conversation

dmitry-markin
Copy link
Contributor

@dmitry-markin dmitry-markin commented Jul 29, 2022

This PR implements #7746 for transactions, block-announces, sync, sync/warp, state, and light protocols.

polkadot companion: paritytech/polkadot#5849

@dmitry-markin dmitry-markin added A0-please_review Pull request needs code review. B3-apinoteworthy C1-low PR touches the given topic and has a low impact on builders. labels Jul 29, 2022
Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

Would be nice if you could add at least one of block-announces, sync, sync/warp, state, and light protocols to this PR to see how it'll be used. Although, come to think about it we already have GRANDPA and BEEFY as showcases.

@acatangiu acatangiu requested review from tomaka and bkchr August 1, 2022 13:40
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.

I don't really see the need for these standard_protocol_name and legacy_protocol_name functions. You're saving literally two lines of code.
Plus, it is in no way guaranteed that every protocol name follows the same pattern. The fact that they do should be seen as a happy coincidence.
Furthermore, moving this code to a separate function IMO decreases readability. If you want to figure out which protocol name GrandPa has, there is now even one more additional step.
I think it's a mistake to see multiple pieces of code that look the same and immediately jump to the conclusion "we should merge these pieces into one because DRY". Applying DRY has a lot of cons.

But since I'm not maintaining this code, I'm not going to be opposed to it.

@dmitry-markin
Copy link
Contributor Author

dmitry-markin commented Aug 1, 2022

@acatangiu Added block-announces protocol to this PR as another example.

@tomaka We will have the similar pattern of /{genesis_hash}/{fork_id}/{short_name} and /{protocol_id}/{short_name} in 8 places after I create the remaining PRs, and I thought it'd be better to standardize the protocol name in one place. Nevertheless, I can copy these lines to every protocol if you think this is better. What should I do?

@dmitry-markin dmitry-markin changed the title Change transactions on-the-wire protocol name to include genesis hash & fork id Change notifications on-the-wire protocol names to include genesis hash & fork id Aug 1, 2022
@tomaka
Copy link
Contributor

tomaka commented Aug 1, 2022

in 8 places after I create the remaining PRs, and I thought it'd be better to standardize the protocol name in one place.

To rephrase my point: what's the advantage of standardizing the protocol name in one place? None that I can see. We might specifically need in the future to change the pattern of one protocol name without touching the 7 others. For example, we might want to upgrade to /<genesis_hash>/transactions/2 but include /<genesis_hash>/transactions/1 in the legacy names.

What should I do?

Decision isn't mine here

@dmitry-markin dmitry-markin changed the title Change notifications on-the-wire protocol names to include genesis hash & fork id Change on-the-wire protocol names to include genesis hash & fork id Aug 1, 2022
@dmitry-markin
Copy link
Contributor Author

I've updated sync, sync/warp, state, and light protocol names to match the same pattern. Also got rid of common protocol_name generation functions, as was suggested by @tomaka

@acatangiu and @tomaka , could you please re-review?

@dmitry-markin
Copy link
Contributor Author

@tomaka Should we also update polkadot protocol names, e.g. /polkadot/validation/1, /polkadot/req_chunk/1, etc.?

@tomaka
Copy link
Contributor

tomaka commented Aug 2, 2022

cc @eskimor @ordian

I believe that it would make sense to do so. This way, we automatically include in the request the chain that we are targeting.
This makes it possible, in theory, to have a single node validate on multiple relay chains at the same time.

@ordian
Copy link
Member

ordian commented Aug 2, 2022

cc @eskimor @ordian

I believe that it would make sense to do so. This way, we automatically include in the request the chain that we are targeting. This makes it possible, in theory, to have a single node validate on multiple relay chains at the same time.

To clarify, you're suggesting this as a follow-up PR to the companion PR to replace "/polkadot/etc" with "/{genesis_hash}/etc" and with fallback to the current names ("/polkadot/etc")? Sounds reasonable to me.

Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@dmitry-markin
Copy link
Contributor Author

This PR has 2 approving reviews, and the companion PR is approved. Why Check reviews CI stage is failing?

@tomaka
Copy link
Contributor

tomaka commented Aug 4, 2022

It is off-topic why, but my reviews don't technically count

Copy link
Member

@ordian ordian left a comment

Choose a reason for hiding this comment

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

An approval on behalf of @tomaka.

@dmitry-markin
Copy link
Contributor Author

bot merge

@paritytech-processbot paritytech-processbot bot merged commit 6527f0c into master Aug 5, 2022
@paritytech-processbot paritytech-processbot bot deleted the dm-transactions-protocol-name branch August 5, 2022 06:50
@dmitry-markin dmitry-markin added A8-mergeoncegreen and removed A0-please_review Pull request needs code review. labels Aug 5, 2022
@ordian
Copy link
Member

ordian commented Aug 5, 2022

Seems like this assertion is now wrong?

debug_assert!(negotiated_fallback.is_none());

DaviRain-Su pushed a commit to octopus-network/substrate that referenced this pull request Aug 23, 2022
…aritytech#11938)

* Rename transactions protocol to include genesis hash

* Add protocol name generation to sc_network::utils

* Use utils functions for transactions protocol name generation

* Extract protocol name generation into public module

* Use sc_network::protocol_name::standard_protocol_name() for BEEFY and GRANDPA

* minor: add missing newline at EOF

* Change block-announces protocol name to include genesis_hash & fork_id

* Change protocol names to include genesis hash and fork id

Protocols changed:
    - sync
    - state
    - light
    - sync/warp

* Revert "Use sc_network::protocol_name::standard_protocol_name() for BEEFY and GRANDPA"

This reverts commit 29aa556.

* Get rid of `protocol_name` module
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…aritytech#11938)

* Rename transactions protocol to include genesis hash

* Add protocol name generation to sc_network::utils

* Use utils functions for transactions protocol name generation

* Extract protocol name generation into public module

* Use sc_network::protocol_name::standard_protocol_name() for BEEFY and GRANDPA

* minor: add missing newline at EOF

* Change block-announces protocol name to include genesis_hash & fork_id

* Change protocol names to include genesis hash and fork id

Protocols changed:
    - sync
    - state
    - light
    - sync/warp

* Revert "Use sc_network::protocol_name::standard_protocol_name() for BEEFY and GRANDPA"

This reverts commit 29aa556.

* Get rid of `protocol_name` module
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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.

4 participants