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

Split the Roles in three types #5492

Closed
wants to merge 16 commits into from
Closed

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Apr 1, 2020

This PR splits the Roles bitfield in three:

  • The existing Roles has been moved untouched into the sc_network::protocol::message module, where it continues to represent the data that is transferred on the wire.

  • sc_network::config now contains a new Role (note the lack of 's') enum whose variants are Full, Light, Sentry and Authority. It is more robust to misuse, as one can only pass a list of sentry nodes when using Authority, and a valiator when using Sentry.

  • The gossiping API now uses ObservedRole, which is an enum that can be one of Full, Light, OurSentry (for when you're a validator connecting to your sentry), OurGuardedValidator (for when you're a sentry connecting to your validator), or Authority (for third-party validators).

GrandPa has been adjusted to always gossip messages to nodes whose role is OurSentry or OurGuardedValidator. This fixes some issues with validators not receiving GrandPa messages from their sentries. This change is the original reason for this PR.

Additionally, the --sentry CLI option now accepts a multiaddress as parameter, representing the address of the validator we're protecting. This is a CLI breaking change.

While modifying the CLI code, I encountered some issues with how to properly build a Role::Authority when the parameter of --sentry is a String.
To fix that, I changed various Strings in the structopt structs in sc_cli to instead contain a Multiaddr or MultiaddrWithPeerId (a new type introduced in this PR).

Some other minor changes:

  • client/rpc/api/system::NodeRole now contains a Sentry variant. In other words, querying the node role from the RPC endpoint will now return "sentry" for sentries.
  • authority_discovery now accepts a Vec<MultiaddrWithPeerId> instead of a Vec<String> in accordance with the changes in the CLI.
  • The node_role Prometheus metric will now contain the value 3 for sentries, rather than 4 (4 meaning "authority").

polkadot companion: paritytech/polkadot#960

@tomaka tomaka added A0-please_review Pull request needs code review. B1-apinoteworthy labels Apr 1, 2020
@tomaka tomaka added this to the 2.0 milestone Apr 1, 2020
@tomaka tomaka requested a review from cecton April 1, 2020 17:17
Copy link
Contributor

@cecton cecton left a comment

Choose a reason for hiding this comment

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

This looks great! It seems simpler

Copy link
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

lgtm!

bin/node/cli/src/service.rs Outdated Show resolved Hide resolved
client/finality-grandpa/src/communication/gossip.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

Overall changes and logic LGTM. I still think we need to make the distinction more clear between network role and local role. Not sure if this is working properly right now due to the initial role setup.

client/cli/src/commands/runcmd.rs Outdated Show resolved Hide resolved
client/network/src/config.rs Show resolved Hide resolved
client/network/src/protocol/message.rs Show resolved Hide resolved
client/cli/src/commands/runcmd.rs Show resolved Hide resolved
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

LGTM!

@gavofyork
Copy link
Member

@tomaka @gabreal polkadot not building?

@tomaka
Copy link
Contributor Author

tomaka commented Apr 3, 2020

I think the script doesn't like the fact that it's on my fork repo. I opened #5520 instead.

@tomaka tomaka closed this Apr 3, 2020
@tomaka tomaka deleted the update-roles branch April 3, 2020 14:48
@@ -117,13 +117,7 @@ impl NetworkConfigurationParams {
config.network.non_reserved_mode = NonReservedPeerMode::Deny;
}

config.network.sentry_nodes.extend(self.sentry_nodes.clone());
Copy link
Contributor

Choose a reason for hiding this comment

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

@tomaka is it intended that you do not set NetworkConfiguration.sentry_nodes anymore??

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, you removed sentry_nodes from NetworkConfiguration. But then why is it still in the cli??

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind I will figure out

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I figured out. I think sentry_nodes should have been moved to runcmd. NetworkConfigurationParams is only supposed to populate the NetworkConfiguration. I've done it while fixing merge conflicts in #5271

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants