Skip to content

Commit f0cf57d

Browse files
authored
Merge pull request #654 from ipfs/release-v0.22.0
Release v0.22.0
2 parents 9555624 + 11ab1c1 commit f0cf57d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1270
-1385
lines changed

CHANGELOG.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,32 @@ The following emojis are used to highlight certain changes:
2424

2525
### Security
2626

27+
## [v0.22.0]
28+
29+
### Changed
30+
31+
- `go-libp2p` dependency updated to [v0.36 (release notes)](https://github.com/libp2p/go-libp2p/releases/tag/v0.36.1)
32+
- `bitswap/server` minor memory use and performance improvements
33+
- `bitswap` unify logger names to use uniform format bitswap/path/pkgname
34+
- `gateway` now always returns meaningful cache-control headers for generated HTML listings of UnixFS directories
35+
- generate random test data using `ipfs/go-test` instead of internal util code
36+
37+
### Removed
38+
39+
- `util` logic for generating random test data moved to [`ipfs/go-test/random`](https://github.com/ipfs/go-test)
40+
41+
### Fixed
42+
43+
- `boxo/gateway` now correctly returns 404 Status Not Found instead of 500 when the requested content cannot be found due to offline exchange, gateway running in no-fetch (non-recursive) mode, or a similar restriction that only serves a specific set of CIDs.
44+
- `bitswap/client` fix memory leak in BlockPresenceManager due to unlimited map growth.
45+
- `bitswap/network` fixed race condition when a timeout occurred before hole punching completed while establishing a first-time stream to a peer behind a NAT
46+
2747
## [v0.21.0]
2848

2949
### Changed
3050

3151
- `boxo/gateway` is now tested against [gateway-conformance v6](https://github.com/ipfs/gateway-conformance/releases/tag/v0.6.0)
32-
- `bitswap/client` supports additional tracing
52+
- `bitswap/client` supports additional tracing
3353

3454
### Removed
3555

@@ -39,6 +59,7 @@ The following emojis are used to highlight certain changes:
3959

4060
- `routing/http`: the `FindPeer` now returns `routing.ErrNotFound` when no addresses are found
4161
- `routing/http`: the `FindProvidersAsync` no longer causes a goroutine buildup
62+
- `bitswap`: wantlist overflow handling now cancels existing entries to make room for newer entries. This fix prevents the wantlist from filling up with CIDs that the server does not have.
4263

4364
## [v0.20.0]
4465

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Boxo includes high-quality components useful for interacting with IPFS protocols
8585
- Interacting with public and private IPFS networks
8686
- Working with content-addressed data
8787

88-
Boxo aims to provide a cohesive interface into these components. Note that not all of the underlying components necessarily reside in this respository.
88+
Boxo aims to provide a cohesive interface into these components. Note that not all of the underlying components necessarily reside in this repository.
8989

9090
### Does Boxo == IPFS?
9191

bitswap/benchmarks_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"testing"
1313
"time"
1414

15-
"github.com/ipfs/boxo/bitswap/internal/testutil"
1615
blocks "github.com/ipfs/go-block-format"
16+
"github.com/ipfs/go-test/random"
1717
protocol "github.com/libp2p/go-libp2p/core/protocol"
1818

1919
"github.com/ipfs/boxo/bitswap"
@@ -169,8 +169,8 @@ func BenchmarkFetchFromOldBitswap(b *testing.B) {
169169
testinstance.ConnectInstances(instances)
170170

171171
// Generate blocks, with a smaller root block
172-
rootBlock := testutil.GenerateBlocksOfSize(1, rootBlockSize)
173-
blocks := testutil.GenerateBlocksOfSize(bch.blockCount, stdBlockSize)
172+
rootBlock := random.BlocksOfSize(1, rootBlockSize)
173+
blocks := random.BlocksOfSize(bch.blockCount, stdBlockSize)
174174
blocks[0] = rootBlock[0]
175175

176176
// Run the distribution
@@ -300,7 +300,7 @@ func BenchmarkDatacenterMultiLeechMultiSeed(b *testing.B) {
300300
defer ig.Close()
301301

302302
instances := ig.Instances(numnodes)
303-
blocks := testutil.GenerateBlocksOfSize(numblks, blockSize)
303+
blocks := random.BlocksOfSize(numblks, int(blockSize))
304304
runDistributionMulti(b, instances[:3], instances[3:], blocks, bstoreLatency, df, ff)
305305
}
306306
})
@@ -317,8 +317,8 @@ func subtestDistributeAndFetch(b *testing.B, numnodes, numblks int, d delay.D, b
317317
ig := testinstance.NewTestInstanceGenerator(net, nil, nil)
318318

319319
instances := ig.Instances(numnodes)
320-
rootBlock := testutil.GenerateBlocksOfSize(1, rootBlockSize)
321-
blocks := testutil.GenerateBlocksOfSize(numblks, stdBlockSize)
320+
rootBlock := random.BlocksOfSize(1, rootBlockSize)
321+
blocks := random.BlocksOfSize(numblks, stdBlockSize)
322322
blocks[0] = rootBlock[0]
323323
runDistribution(b, instances, blocks, bstoreLatency, df, ff)
324324
ig.Close()
@@ -333,8 +333,8 @@ func subtestDistributeAndFetchRateLimited(b *testing.B, numnodes, numblks int, d
333333
defer ig.Close()
334334

335335
instances := ig.Instances(numnodes)
336-
rootBlock := testutil.GenerateBlocksOfSize(1, rootBlockSize)
337-
blocks := testutil.GenerateBlocksOfSize(numblks, blockSize)
336+
rootBlock := random.BlocksOfSize(1, rootBlockSize)
337+
blocks := random.BlocksOfSize(numblks, int(blockSize))
338338
blocks[0] = rootBlock[0]
339339
runDistribution(b, instances, blocks, bstoreLatency, df, ff)
340340
}

bitswap/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
"go.opentelemetry.io/otel/trace"
3939
)
4040

41-
var log = logging.Logger("bitswap-client")
41+
var log = logging.Logger("bitswap/client")
4242

4343
// Option defines the functional option type that can be used to configure
4444
// bitswap instances

bitswap/client/internal/blockpresencemanager/blockpresencemanager.go

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ type BlockPresenceManager struct {
1515
}
1616

1717
func New() *BlockPresenceManager {
18-
return &BlockPresenceManager{
19-
presence: make(map[cid.Cid]map[peer.ID]bool),
20-
}
18+
return &BlockPresenceManager{}
2119
}
2220

2321
// ReceiveFrom is called when a peer sends us information about which blocks
@@ -26,6 +24,10 @@ func (bpm *BlockPresenceManager) ReceiveFrom(p peer.ID, haves []cid.Cid, dontHav
2624
bpm.Lock()
2725
defer bpm.Unlock()
2826

27+
if bpm.presence == nil {
28+
bpm.presence = make(map[cid.Cid]map[peer.ID]bool)
29+
}
30+
2931
for _, c := range haves {
3032
bpm.updateBlockPresence(p, c, true)
3133
}
@@ -75,6 +77,10 @@ func (bpm *BlockPresenceManager) AllPeersDoNotHaveBlock(peers []peer.ID, ks []ci
7577
bpm.RLock()
7678
defer bpm.RUnlock()
7779

80+
if len(bpm.presence) == 0 {
81+
return nil
82+
}
83+
7884
var res []cid.Cid
7985
for _, c := range ks {
8086
if bpm.allDontHave(peers, c) {
@@ -90,6 +96,9 @@ func (bpm *BlockPresenceManager) allDontHave(peers []peer.ID, c cid.Cid) bool {
9096
if !cok {
9197
return false
9298
}
99+
if len(ps) == 0 {
100+
return false
101+
}
93102

94103
// Check if we explicitly know that all the given peers do not have the cid
95104
for _, p := range peers {
@@ -108,6 +117,25 @@ func (bpm *BlockPresenceManager) RemoveKeys(ks []cid.Cid) {
108117
for _, c := range ks {
109118
delete(bpm.presence, c)
110119
}
120+
if len(bpm.presence) == 0 {
121+
bpm.presence = nil
122+
}
123+
}
124+
125+
// RemovePeer removes the given peer from every cid key in the presence map.
126+
func (bpm *BlockPresenceManager) RemovePeer(p peer.ID) {
127+
bpm.Lock()
128+
defer bpm.Unlock()
129+
130+
for c, pm := range bpm.presence {
131+
delete(pm, p)
132+
if len(pm) == 0 {
133+
delete(bpm.presence, c)
134+
}
135+
}
136+
if len(bpm.presence) == 0 {
137+
bpm.presence = nil
138+
}
111139
}
112140

113141
// HasKey indicates whether the BlockPresenceManager is tracking the given key

0 commit comments

Comments
 (0)