-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(config): ability to disable Bitswap fully or just server #10782
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
Conversation
lidel
left a comment
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.
Thank you @gystemd, this partially works, but does not fully disable the server (it is still possible for other peers to send us WANT and GET for CIDs we dont have).
See ideas (A) and (B) below, I suspect we will end up with (B) but let's see what is easier.
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.
We need a test that confirms ipfs id peerid no longer includes /ipfs/bitswap protocols when Bitswap.ServerEnabled is set to false (ensuring we no longer announce ourselves as server)
Original PR: #10782 This pull request introduces changes to the Bitswap configuration and functionality, including the addition of new configuration options, modifications to the Bitswap server/client behavior, and the inclusion of new tests to verify these changes. * Added a new `BitswapConfig` struct in `config/bitswap.go` to hold Bitswap configuration options, including `Enabled` and `ServerEnabled` flags. * Updated the `Config` struct in `config/config.go` to include the new `BitswapConfig` field. * Modified the `Bitswap` function in `core/node/bitswap.go` to respect the `ServerEnabled` flag, using an empty blockstore when the server is disabled to prevent serving blocks to other peers. * Updated the `OnlineExchange` function to return a no-op exchange when Bitswap is disabled. * Added a `noopExchange` struct to handle cases where Bitswap is disabled, ensuring no blocks are served or retrieved. * Introduced a new test file `test/cli/bitswap_config_test.go` with multiple test cases to verify the behavior of Bitswap configuration, including scenarios where the server is enabled, disabled, or Bitswap is completely disabled. - Closes #10717 - Depends on ipfs/boxo#912
Original PR: #10782 This pull request introduces changes to the Bitswap configuration and functionality, including the addition of new configuration options, modifications to the Bitswap server/client behavior, and the inclusion of new tests to verify these changes. * Added a new `BitswapConfig` struct in `config/bitswap.go` to hold Bitswap configuration options, including `Enabled` and `ServerEnabled` flags. * Updated the `Config` struct in `config/config.go` to include the new `BitswapConfig` field. * Modified the `Bitswap` function in `core/node/bitswap.go` to respect the `ServerEnabled` flag, using an empty blockstore when the server is disabled to prevent serving blocks to other peers. * Updated the `OnlineExchange` function to return a no-op exchange when Bitswap is disabled. * Added a `noopExchange` struct to handle cases where Bitswap is disabled, ensuring no blocks are served or retrieved. * Introduced a new test file `test/cli/bitswap_config_test.go` with multiple test cases to verify the behavior of Bitswap configuration, including scenarios where the server is enabled, disabled, or Bitswap is completely disabled. - Closes #10717 - Depends on ipfs/boxo#912
core/node/bitswap.go
Outdated
| func (e *noopExchange) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error) { | ||
| return nil, 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.
Tested latest commit 258fb25 and not returning error here seems to be why we have a panic when executing ipfs cat when Bitswap.Enabled is set to false:
$ ipfs daemon
...
Daemon is ready
... ipfs cat for lon-local cid is executed from other terminal
2025-04-30T17:00:40.931+0200 ERROR cmds/http http/handler.go:96 a panic has occurred in the commands handler!
2025-04-30T17:00:40.931+0200 ERROR cmds/http http/handler.go:97 runtime error: invalid memory address or nil pointer dereference
2025-04-30T17:00:40.933+0200 ERROR cmds/http http/handler.go:98 stack trace:
goroutine 50865 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x5e
github.com/ipfs/go-ipfs-cmds/http.(*handler).ServeHTTP.func1()
github.com/ipfs/[email protected]/http/handler.go:98 +0xef
panic({0x2e5e7c0?, 0x4b6e100?})
runtime/panic.go:792 +0x132
github.com/ipfs/boxo/blockstore.(*idstore).Put(0xc0011d9400, {0x385dbf0, 0xc002d40060}, {0x0, 0x0})
github.com/ipfs/[email protected]/blockstore/idstore.go:93 +0x27
github.com/ipfs/boxo/blockservice.getBlock({0x385dbf0, 0xc002d40060}, {{0xc0022d8fc0?, 0x1d?}}, {0x3871b68, 0xc00130a270}, 0xc001462740)
github.com/ipfs/[email protected]/blockservice/blockservice.go:278 +0x242
github.com/ipfs/boxo/blockservice.(*Session).GetBlock(0xc002e559c0, {0x385dbf0, 0xc0004afe00}, {{0xc0022d8fc0?, 0x248f580?}})
github.com/ipfs/[email protected]/blockservice/blockservice.go:462 +0x33c
github.com/ipfs/boxo/ipld/merkledag.(*sesGetter).Get(0xc002ed7940, {0x385dbf0, 0xc0004afe00}, {{0xc0022d8fc0?, 0xc001462788?}})
github.com/ipfs/[email protected]/ipld/merkledag/merkledag.go:143 +0x2e
github.com/ipfs/boxo/ipld/merkledag.(*ComboService).Get(0xc002356300?, {0x385dbf0?, 0xc0004afe00?}, {{0xc0022d8fc0?, 0xc00074cdc0?}})
github.com/ipfs/[email protected]/ipld/merkledag/rwservice.go:31 +0x2a
github.com/ipfs/kubo/core/coreapi.(*CoreAPI).ResolveNode(0xc002356300, {0x385dbf0, 0xc0004afdd0}, {0x385db48, 0xc00074cdc0})
github.com/ipfs/kubo/core/coreapi/path.go:31 +0x338
github.com/ipfs/kubo/core/coreapi.(*UnixfsAPI).Get(0xc000b48480, {0x385dc28, 0xc0042f09b0}, {0x385db48, 0xc00074cdc0})
github.com/ipfs/kubo/core/coreapi/unixfs.go:210 +0x318
github.com/ipfs/kubo/core/commands.cat({0x385dc28, 0xc0042f09b0}, {0x387bba0, 0xc000b48480}, {0xc002ed7840, 0x1, 0x0?}, 0x0, 0xffffffffffffffff)
github.com/ipfs/kubo/core/commands/cat.go:136 +0x17bSeems to be an easy fix, I'll push one soon.
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.
Fix: b11a65a
Fixes panic described in: ipfs#10782 (comment)
7b862f5 to
0473134
Compare
lidel
left a comment
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.
Thank you for your work and patience @gystemd.
- Since we switched to latest boxo release, we don't need non-fork local branch PR anymore, using this one
- Pushed small fix for a panic described in #10782 (comment) and extra test check, but overall lgtm.
- We may want to move
noopExchangetoboxo/exchangein the future, but fine to keep it here for now (not worth blocking this PR on that). - This is good enough for testing, we can tackle removal of libp2p identify announcement when
Bitswap.Enabled=falsein future PR.
I'm merging this to include in 0.35.0-rc1 and do some tests in staging environment.
we have those in section above
Replaced by #10793
This pull request introduces changes to the Bitswap configuration and functionality, including the addition of new configuration options, modifications to the Bitswap server/client behavior, and the inclusion of new tests to verify these changes.
Bitswap Configuration Enhancements:
BitswapConfigstruct inconfig/bitswap.goto hold Bitswap configuration options, includingEnabledandServerEnabledflags.Configstruct inconfig/config.goto include the newBitswapConfigfield.Bitswap Server/Client Behavior:
Bitswapfunction incore/node/bitswap.goto respect theServerEnabledflag, using an empty blockstore when the server is disabled to prevent serving blocks to other peers.OnlineExchangefunction to return a no-op exchange when Bitswap is disabled.noopExchangestruct to handle cases where Bitswap is disabled, ensuring no blocks are served or retrieved.Testing:
test/cli/bitswap_config_test.gowith multiple test cases to verify the behavior of Bitswap configuration, including scenarios where the server is enabled, disabled, or Bitswap is completely disabled.