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

feat: warn users who are falling behind reprovides #9886

Merged
merged 3 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- 'master'

env:
GO_VERSION: 1.19.1
GO_VERSION: 1.19.x

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.1
go-version: 1.19.x
- uses: actions/checkout@v3
- run: docker build -t $IMAGE_NAME:$WIP_IMAGE_TAG .
2 changes: 1 addition & 1 deletion .github/workflows/gobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.1
go-version: 1.19.x
- uses: actions/checkout@v3
- uses: protocol/cache-go-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.1
go-version: 1.19.x
- uses: actions/checkout@v3
- uses: protocol/cache-go-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gotest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.1
go-version: 1.19.x
- name: Check out Kubo
uses: actions/checkout@v3
- name: Restore Go cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sharness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.1
go-version: 1.19.x
- name: Checkout Kubo
uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19.1-buster
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19-buster
LABEL maintainer="Steven Allen <[email protected]>"

ARG TARGETPLATFORM
Expand Down
3 changes: 3 additions & 0 deletions cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
case routingOptionNoneKwd:
ncfg.Routing = libp2p.NilRouterOption
case routingOptionCustomKwd:
if cfg.Routing.AcceleratedDHTClient {
return fmt.Errorf("Routing.AcceleratedDHTClient option is set even tho Routing.Type is custom, using custom .AcceleratedDHTClient needs to be set on DHT routers individually")
}
ncfg.Routing = libp2p.ConstructDelegatedRouting(
cfg.Routing.Routers,
cfg.Routing.Methods,
Expand Down
2 changes: 1 addition & 1 deletion config/experiments.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Experiments struct {
Libp2pStreamMounting bool
P2pHttpProxy bool //nolint
StrategicProviding bool
AcceleratedDHTClient bool
AcceleratedDHTClient experimentalAcceleratedDHTClient `json:",omitempty"`
OptimisticProvide bool
OptimisticProvideJobsPoolSize int
}
2 changes: 2 additions & 0 deletions config/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Routing struct {
// When "custom" is set, user-provided Routing.Routers is used.
Type *OptionalString `json:",omitempty"`

AcceleratedDHTClient bool

Routers Routers

Methods Methods
Expand Down
24 changes: 24 additions & 0 deletions config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,27 @@ func (swarmLimits) UnmarshalJSON(b []byte) error {
}
}
}

type experimentalAcceleratedDHTClient struct{}

var _ json.Unmarshaler = experimentalAcceleratedDHTClient{}

func (experimentalAcceleratedDHTClient) UnmarshalJSON(b []byte) error {
d := json.NewDecoder(bytes.NewReader(b))
for {
switch tok, err := d.Token(); err {
case io.EOF:
return nil
case nil:
switch tok {
case json.Delim('{'), json.Delim('}'):
// accept empty objects
continue
}
//nolint
return fmt.Errorf("The Experimental.AcceleratedDHTClient key has been moved to Routing.AcceleratedDHTClient in Kubo 0.21, please use this new key and remove the old one.")
default:
return err
}
}
}
17 changes: 6 additions & 11 deletions core/commands/stat_provide.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"time"

humanize "github.com/dustin/go-humanize"
"github.com/ipfs/boxo/provider"
cmds "github.com/ipfs/go-ipfs-cmds"
"github.com/ipfs/kubo/core/commands/cmdenv"

"github.com/ipfs/boxo/provider/batched"
"golang.org/x/exp/constraints"
)

var statProvideCmd = &cmds.Command{
Expand All @@ -34,12 +34,7 @@ This interface is not stable and may change from release to release.
return ErrNotOnline
}

sys, ok := nd.Provider.(*batched.BatchProvidingSystem)
if !ok {
return fmt.Errorf("can only return stats if Experimental.AcceleratedDHTClient is enabled")
}

stats, err := sys.Stat(req.Context)
stats, err := nd.Provider.Stat()
if err != nil {
return err
}
Expand All @@ -51,7 +46,7 @@ This interface is not stable and may change from release to release.
return nil
},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, s *batched.BatchedProviderStats) error {
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, s *provider.ReproviderStats) error {
wtr := tabwriter.NewWriter(w, 1, 2, 1, ' ', 0)
defer wtr.Flush()

Expand All @@ -62,14 +57,14 @@ This interface is not stable and may change from release to release.
return nil
}),
},
Type: batched.BatchedProviderStats{},
Type: provider.ReproviderStats{},
}

func humanDuration(val time.Duration) string {
return val.Truncate(time.Microsecond).String()
}

func humanNumber(n int) string {
func humanNumber[T constraints.Float | constraints.Integer](n T) string {
nf := float64(n)
str := humanSI(nf, 0)
fullStr := humanFull(nf, 0)
Expand Down
2 changes: 1 addition & 1 deletion core/coreapi/coreapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, e
return nil, fmt.Errorf("error constructing namesys: %w", err)
}

subAPI.provider = provider.NewOfflineProvider()
subAPI.provider = provider.NewNoopProvider()

subAPI.peerstore = nil
subAPI.peerHost = nil
Expand Down
9 changes: 2 additions & 7 deletions core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ func Online(bcfg *BuildCfg, cfg *config.Config, userResourceOverrides rcmgr.Part
LibP2P(bcfg, cfg, userResourceOverrides),
OnlineProviders(
cfg.Experimental.StrategicProviding,
cfg.Experimental.AcceleratedDHTClient,
cfg.Reprovider.Strategy.WithDefault(config.DefaultReproviderStrategy),
cfg.Reprovider.Interval.WithDefault(config.DefaultReproviderInterval),
cfg.Routing.AcceleratedDHTClient,
),
)
}
Expand All @@ -320,12 +320,7 @@ func Offline(cfg *config.Config) fx.Option {
fx.Provide(libp2p.Routing),
fx.Provide(libp2p.ContentRouting),
fx.Provide(libp2p.OfflineRouting),
OfflineProviders(
cfg.Experimental.StrategicProviding,
cfg.Experimental.AcceleratedDHTClient,
cfg.Reprovider.Strategy.WithDefault(config.DefaultReproviderStrategy),
cfg.Reprovider.Interval.WithDefault(config.DefaultReproviderInterval),
),
OfflineProviders(),
)
}

Expand Down
2 changes: 1 addition & 1 deletion core/node/libp2p/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func BaseRouting(cfg *config.Config) interface{} {
}
}

if dualDHT != nil && cfg.Experimental.AcceleratedDHTClient {
if dualDHT != nil && cfg.Routing.AcceleratedDHTClient {
cfg, err := in.Repo.Config()
if err != nil {
return out, err
Expand Down
Loading