-
Notifications
You must be signed in to change notification settings - Fork 181
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
[Network] upgrade libp2p and libp2p-pubsub libraries #6963
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6963 +/- ##
==========================================
- Coverage 41.15% 41.15% -0.01%
==========================================
Files 2131 2131
Lines 186855 186911 +56
==========================================
+ Hits 76899 76919 +20
- Misses 103516 103556 +40
+ Partials 6440 6436 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -68,7 +67,7 @@ func NewGossipSubRouterSpammerWithRpcInspector(t *testing.T, | |||
// ctlMessages is the list of spam messages to send to the victim node. | |||
func (s *GossipSubRouterSpammer) SpamControlMessage(t *testing.T, victim p2p.LibP2PNode, ctlMessages []pb.ControlMessage, msgs ...*pb.Message) { | |||
for _, ctlMessage := range ctlMessages { | |||
require.True(t, s.router.Get().SendControl(victim.ID(), &ctlMessage, msgs...)) | |||
s.router.Get().SendControl(victim.ID(), &ctlMessage, msgs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only difference between the mainline and forked version of pubsub was that in the fork SendControl
returned a boolean. Since that was only used in this test, I'm removing the check to simplify our dependency management.
@@ -211,7 +212,7 @@ func (builder *LibP2PNodeBuilder) Build() (p2p.LibP2PNode, error) { | |||
return nil, fmt.Errorf("could not create resolver: %w", err) | |||
} | |||
|
|||
opts = append(opts, libp2p.MultiaddrResolver(resolver)) | |||
opts = append(opts, libp2p.MultiaddrResolver(swarm.ResolverFromMaDNS{Resolver: resolver})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was required for the libp2p/go-libp2p
upgrade
@@ -199,7 +199,7 @@ func (suite *NetworkTestSuite) TestUpdateNodeAddresses() { | |||
|
|||
// create a new staked identity | |||
ids, libP2PNodes := testutils.LibP2PNodeForNetworkFixture(suite.T(), suite.sporkId, 1) | |||
idProvider := unittest.NewUpdatableIDProvider(ids) | |||
idProvider := unittest.NewUpdatableIDProvider(append(suite.ids, ids...)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea how this test originally worked since it was completely broken. maybe the networking logic was so slow that the message was never actually delivered. 🤷
@@ -319,7 +314,31 @@ func createConcurrentStreams(t *testing.T, ctx context.Context, nodes []p2p.LibP | |||
// in 2 connections 1 created by each node, this happens because we are calling CreateStream concurrently. | |||
time.Sleep(500 * time.Millisecond) | |||
} | |||
unittest.RequireReturnsBefore(t, wg.Wait, 3*time.Second, "could not create streams on time") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test started running faster, so this check started to fail because it got here sooner and had to wait for the context timeout.
@@ -487,7 +488,7 @@ func (b *LibP2PNodeBuilder) configureRoutingSystem( | |||
} else { | |||
// bitswap requires a content routing system. this returns a stub instead of a full DHT | |||
b.SetRoutingSystem(func(ctx context.Context, host host.Host) (routing.Routing, error) { | |||
return none.ConstructNilRouting(ctx, host, nil, nil) | |||
return routinghelpers.Null{}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we ok with updating |
We needed a change that was merged after the tagged release to remove our forked version. I can poke the team about pushing a new tag. |
@@ -115,7 +116,9 @@ func testGossipSubInvalidMessageDeliveryScoring(t *testing.T, spamMsgFactory fun | |||
t.Name(), | |||
idProvider, | |||
p2ptest.WithRole(role), | |||
p2ptest.OverrideFlowConfig(cfg)) | |||
p2ptest.OverrideFlowConfig(cfg), | |||
p2ptest.WithValidateQueueSize(3000), // prevent node from dropping messages on slow CI machines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the invalid signature test seems to run slower on the new version. Added this to prevent the victim node from dropping too many messages during the test.
Co-authored-by: Leo Zhang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you for fixing broken tests. 🥇
|
||
spammerScore, ok := victimNode.PeerScoreExposer().GetScore(spammer.SpammerNode.ID()) | ||
require.True(t, ok) | ||
t.Logf("spammer score: %f", spammerScore) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still need this or this was debugging code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not strictly. they're only logged in verbose mode and I think they are helpful to debug the test.
// when this is run against an Access node with indexing enabled, occasionally the indexed height | ||
// lags behind the sealed height, especially after first starting up (like in a test). | ||
// Retry using the same block until we get the account. | ||
for { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually operations like this have an upper time limit so we don't run it indefinitely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, I left it to the context to manage that. the caller uses a 5 second timeout
// cancel the context to trigger streams to shutdown | ||
cancel() | ||
|
||
unittest.RequireReturnsBefore(t, wg.Wait, 1*time.Second, "could not shutdown streams on time") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice sequence
network/test/cohort1/network_test.go
Outdated
_, err = newNet.Register(channels.TestNetworkChannel, newEngine) | ||
require.NoError(suite.T(), err) | ||
newEngine.On("Process", channels.TestNetworkChannel, suite.ids[0].NodeID, mockery.Anything).Return(nil) | ||
|
||
callCount := 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it safe to use a non-atomic here? Do we have a guarantee that everything runs in the same goroutine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, this could cause flakiness. ee0881e
Replaces: #6821
Upgrade libp2p and libp2p-pubsub to the latest versions.
github.com/libp2p/go-libp2p
v0.32.2
=>v0.38.2
github.com/libp2p/go-libp2p-pubsub
v0.10.0
=>v0.13.0