-
Notifications
You must be signed in to change notification settings - Fork 387
fix: make hive bee 2.6.0 backward compatible #5329
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4f00ce9
fix(p2p): handle pre-release versions in bee260 backward compatibilit…
gacevicljubisa e40a238
fix(libp2p): address comments
gacevicljubisa 8e603fb
fix: make hive bee 2.6.0 backward compatible
janos 027b36e
fix(hive): pass the correct variable
janos 459909c
feat(libp2p): add bee 2.6.0 compatibility cache
janos 9f3b9b1
chore: fix linter
janos 1c690d7
Merge branch 'master' into fix/bee260-semver-prerelease-comparison-hive
janos 399b772
fix: increase macos kern.ipc.maxsockbuf 7500000
janos e5a54c9
Revert "fix: increase macos kern.ipc.maxsockbuf 7500000"
janos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| // Copyright 2026 The Swarm Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style | ||
| // license that can be found in the LICENSE file. | ||
|
|
||
| package libp2p | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/ethersphere/bee/v2/pkg/crypto" | ||
| "github.com/ethersphere/bee/v2/pkg/log" | ||
| "github.com/ethersphere/bee/v2/pkg/statestore/mock" | ||
| "github.com/ethersphere/bee/v2/pkg/swarm" | ||
| libp2ppeer "github.com/libp2p/go-libp2p/core/peer" | ||
| ) | ||
|
|
||
| func TestBee260BackwardCompatibility(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| userAgent string | ||
| want bool | ||
| }{ | ||
| // Versions < 2.7.0 should require backward compatibility | ||
| { | ||
| name: "version 2.6.0", | ||
| userAgent: "bee/2.6.0 go1.22.0 linux/amd64", | ||
| want: true, | ||
| }, | ||
| { | ||
| name: "version 2.6.5", | ||
| userAgent: "bee/2.6.5 go1.22.0 linux/amd64", | ||
| want: true, | ||
| }, | ||
| { | ||
| name: "version 2.5.0", | ||
| userAgent: "bee/2.5.0 go1.21.0 linux/amd64", | ||
| want: true, | ||
| }, | ||
| { | ||
| name: "version 2.6.0-beta1", | ||
| userAgent: "bee/2.6.0-beta1 go1.22.0 linux/amd64", | ||
| want: true, | ||
| }, | ||
| // Versions >= 2.7.0 should NOT require backward compatibility | ||
| { | ||
| name: "version 2.7.0", | ||
| userAgent: "bee/2.7.0 go1.23.0 linux/amd64", | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "version 2.8.0", | ||
| userAgent: "bee/2.8.0 go1.23.0 linux/amd64", | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "version 3.0.0", | ||
| userAgent: "bee/3.0.0 go1.25.0 linux/amd64", | ||
| want: false, | ||
| }, | ||
| // Pre-release versions >= 2.7.0 should NOT require backward compatibility | ||
| // This is the critical fix: 2.7.0-rcX should be treated as >= 2.7.0 | ||
| { | ||
| name: "version 2.7.0-rc1", | ||
| userAgent: "bee/2.7.0-rc1 go1.23.0 linux/amd64", | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "version 2.7.0-rc12", | ||
| userAgent: "bee/2.7.0-rc12-b39629d5-dirty go1.25.6 linux/amd64", | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "version 2.7.0-beta1", | ||
| userAgent: "bee/2.7.0-beta1 go1.23.0 linux/amd64", | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "version 2.8.0-rc1", | ||
| userAgent: "bee/2.8.0-rc1 go1.24.0 linux/amd64", | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "version 2.9.0-beta1", | ||
| userAgent: "bee/2.9.0-beta1 go1.24.0 linux/amd64", | ||
| want: false, | ||
| }, | ||
| // Edge cases that should return false (not requiring backward compat) | ||
| { | ||
| name: "empty user agent", | ||
| userAgent: "", | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "malformed user agent missing space", | ||
| userAgent: "bee/2.6.0", | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "non-bee user agent", | ||
| userAgent: "other/1.0.0 go1.22.0 linux/amd64", | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "invalid version format", | ||
| userAgent: "bee/invalid go1.22.0 linux/amd64", | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "default libp2p user agent", | ||
| userAgent: "github.com/libp2p/go-libp2p", | ||
| want: false, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| // Create a service with minimal configuration | ||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| defer cancel() | ||
|
|
||
| swarmKey, err := crypto.GenerateSecp256k1Key() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| overlay := swarm.RandAddress(t) | ||
| addr := ":0" | ||
| networkID := uint64(1) | ||
|
|
||
| statestore := mock.NewStateStore() | ||
| defer statestore.Close() | ||
|
|
||
| s, err := New(ctx, crypto.NewDefaultSigner(swarmKey), networkID, overlay, addr, nil, statestore, nil, log.Noop, nil, Options{}) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| defer s.Close() | ||
|
|
||
| // Create a random test peer ID - we only need any valid libp2p peer ID | ||
| // The peerstore lookup will be mocked by setting the AgentVersion directly | ||
| libp2pPeerID, err := libp2ppeer.Decode("16Uiu2HAm3g4hXfCWTDhPBq3KkqpV3wGkPVgMJY3Jt8gGTYWiTWNZ") | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| // Set the user agent in the peerstore if provided | ||
| if tc.userAgent != "" { | ||
| if err := s.host.Peerstore().Put(libp2pPeerID, "AgentVersion", tc.userAgent); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| } | ||
|
|
||
| // Test the backward compatibility check | ||
| got := s.bee260BackwardCompatibility(libp2pPeerID) | ||
| if got != tc.want { | ||
| t.Errorf("bee260BackwardCompatibility() = %v, want %v (userAgent: %q)", got, tc.want, tc.userAgent) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Here we could only return TCP. It is prefered, but 2.6 doesn't support other transports, so we can send TCP only.
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.
makes sense