Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identity Provider #1133

Merged
merged 74 commits into from Sep 2, 2021
Merged

Identity Provider #1133

merged 74 commits into from Sep 2, 2021

Conversation

synzhu
Copy link
Contributor

@synzhu synzhu commented Aug 13, 2021

closes https://github.com/dapperlabs/flow-go/issues/5735
closes https://github.com/dapperlabs/flow-go/issues/5739

TODO:

Write tests for:

  • filtered provider
  • fixed provider
  • hierarchical translator
  • peerstore provider
  • protocol state provider
  • test UpdateNodeAddresses
  • Write comments
  • make it clear UpdatableIDProvider is test-only, or test it

For a follow-up PR (?):

- create a default for repeated instances of id.NewFilteredIdentifierProvider(... (made obsolete by the SyncEngineIdentifierProvider in #1186

@synzhu
Copy link
Contributor Author

synzhu commented Aug 13, 2021

bors try

bors bot added a commit that referenced this pull request Aug 13, 2021
@bors
Copy link
Contributor

bors bot commented Aug 13, 2021

try

Build failed:

cmd/scaffold.go Outdated
@@ -203,8 +198,7 @@ func (fnb *FlowNodeBuilder) EnqueueNetworkInit(ctx context.Context) {

fnb.Network = net

idRefresher := p2p.NewNodeIDRefresher(fnb.Logger, fnb.State, net.SetIDs)
idEvents := gadgets.NewIdentityDeltas(idRefresher.OnIdentityTableChanged)
idEvents := gadgets.NewIdentityDeltas(fnb.Middleware.UpdateAllowList)
Copy link
Contributor

Choose a reason for hiding this comment

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

so originally, the gadget used to update the network with the new ids and the network would then update middleware.
Why are we directly updating middleware here, wouldn't the overlay be out of sync at that point with the change.

Instead, if the IdentifierProvider provided a way to update its list, then both middleware and network could use it.

@synzhu
Copy link
Contributor Author

synzhu commented Aug 18, 2021

@huitseeker Documenting our offline conversation:

TODO: Not only do staked AN's need to use the HierarchicalIDTranslator, but unstaked nodes also do. Otherwise, they will not be able to translate the peer ID's of staked AN's or other staked nodes into flow ID's since the networking key format is different.

Comment on lines 46 to 48
// timeout for FindPeer queries to the DHT
// TODO: is this a sensible value?
findPeerQueryTimeout = 15 * time.Second
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤷‍♂️

Comment on lines 363 to 365
// TODO: why were we doing this? Is it okay to remove?
// remove the peer from the peer store if present
n.host.Peerstore().ClearAddrs(peerID)
// n.host.Peerstore().ClearAddrs(peerID)
Copy link
Contributor Author

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.

this was done to avoid libp2p doing any exponential backoffs for a connection it tried earlier and failed but still has an entry for it in the peer store.
I can check if it is still needed or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh I see... Okay let me know.

Comment on lines +180 to +184
// We probably don't need to fail the entire function here, since the other
// translations may still succeed
m.log.Err(err).Str("flowID", fid.String()).Msg("failed to translate to peer ID")
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.

Just wanted to raise awareness here, I'm open to the argument that we actually should fail here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In particular, because the new behavior will likely differ a bit from the old behavior: https://github.com/onflow/flow-go/pull/1133/files#r691579930

I feel that the new behavior is actually better, but I'm not super confident on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general, my thinking was that returning a partial list of peer IDs is at least better than completely failing because a single flow ID couldn't be translated.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, dont need to fail - I had to change the return earlier on v0.20 and master

Comment on lines +31 to +36
p.logger.Err(err).Str("peerID", pid.Pretty()).Msg("failed to translate to Flow ID")
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.

Same here.

Comment on lines +82 to +87
p.logger.Err(err).Interface("identity", identity).Msg("failed to extract peer ID from network key")
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.

same here


// if some ids didn't translate to peer.AddrInfo, return error
if len(invalidIDs) != 0 {
return NewUnconvertableIdentitiesError(invalidIDs)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here.

@synzhu
Copy link
Contributor Author

synzhu commented Aug 21, 2021

96cf07f

I realized the origin ID checks need to use the ID translator instead of Overlay.Identities, because the latter only returns the protocol state identities.

This would not work for staked AN or unstaked nodes, because the validation would fail for everyone else.

@codecov-commenter
Copy link

codecov-commenter commented Aug 21, 2021

Codecov Report

Merging #1133 (7f2fc0b) into master (0714d5a) will increase coverage by 0.16%.
The diff coverage is 54.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1133      +/-   ##
==========================================
+ Coverage   56.06%   56.23%   +0.16%     
==========================================
  Files         487      495       +8     
  Lines       29951    30124     +173     
==========================================
+ Hits        16793    16940     +147     
- Misses      10870    10885      +15     
- Partials     2288     2299      +11     
Flag Coverage Δ
unittests 56.23% <54.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/collection/main.go 2.85% <0.00%> (ø)
cmd/consensus/main.go 3.34% <0.00%> (ø)
engine/access/ping/engine.go 0.00% <ø> (ø)
engine/channels.go 85.07% <0.00%> (-2.62%) ⬇️
engine/common/splitter/engine.go 54.90% <ø> (-2.51%) ⬇️
model/flow/identifierList.go 27.02% <0.00%> (-8.69%) ⬇️
network/p2p/identity_provider_translator.go 0.00% <0.00%> (ø)
network/p2p/libp2pConnector.go 0.00% <0.00%> (ø)
network/p2p/middleware.go 0.00% <0.00%> (ø)
network/p2p/network.go 0.00% <0.00%> (ø)
... and 36 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81ec901...7f2fc0b. Read the comment docs.

@synzhu synzhu changed the title Smnzhu/identity provider Identity Provider Aug 21, 2021
@synzhu synzhu marked this pull request as ready for review August 21, 2021 22:30
Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

I think there's a bunch of followups, but this otherwise LGTM!
🚀

builder.bootstrapIdentites = ids
dhtOptions = append(dhtOptions, bootstrapPeersOpt)

connManager := p2p.NewConnManager(builder.Logger, builder.Metrics.Network, p2p.TrackUnstakedConnections(builder.IdentityProvider))
Copy link
Contributor

Choose a reason for hiding this comment

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

@vishalchangrani we may want to open a follow-up issue to do what you had in mind, i.e. making Stream establishment non-dependent on Protect calls for nodes that don't have connection gating

Comment on lines +50 to +52
// timeout for FindPeer queries to the DHT
// TODO: is this a sensible value?
findPeerQueryTimeout = 10 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

We're already tracking this in essentially #1184 . I think this value is a good start, but we may want to rename the issue @smnzhu

@@ -0,0 +1,129 @@
package p2p
Copy link
Contributor

Choose a reason for hiding this comment

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

I think our friends working on epochs would <3 a heads up (off-PR) on the overlap between this and the epoch_transition_test @smnzhu

@synzhu synzhu merged commit 4b25ece into master Sep 2, 2021
@bors bors bot deleted the smnzhu/identity-provider branch September 2, 2021 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants