Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
4bf7f27
feat: prototype autoclient library
lidel Jul 18, 2025
a72b8e1
feat(config): prototype autoconfig profile
lidel Jul 18, 2025
120bb82
feat: prototype embedded repo migrations
lidel Jul 18, 2025
51a49f9
feat: prototype of `ipfs config` support for `auto`
lidel Jul 24, 2025
a860748
docs: MustGetConfigWithMainnetFallbacks
lidel Jul 24, 2025
302dcdf
chore: lint + cleanup redundant tests
lidel Jul 24, 2025
d23374c
refactor: use const with profile names
lidel Jul 24, 2025
355bc3d
refactor: cfg.BootstrapPeers returns raw Bootstrap
lidel Jul 24, 2025
626a99f
fix: use resolved versions for making decisions
lidel Jul 24, 2025
1d91f11
refactor: Β Bootstrap[Peers]WithAutoConfig
lidel Jul 24, 2025
f629d8b
fix(cli): bootstrap cmd with auto
lidel Jul 24, 2025
0e75e4f
refactor: cleanup
lidel Jul 25, 2025
e711c3c
test: multiple consecutive --expand-auto calls
lidel Jul 25, 2025
d18a1fe
refactor: dry and useful logs
lidel Jul 25, 2025
7088d88
refactor: autoconfig .last-refresh
lidel Jul 25, 2025
e1e4e23
fix: `ipfs bootstrap add auto`
lidel Jul 26, 2025
53a642c
docs: AutoConfig in changelog
lidel Jul 26, 2025
273e18e
chore: update func name
lidel Jul 26, 2025
24d552d
refactor: schema v4
lidel Jul 30, 2025
e2476e9
test: DNSResolver validation
lidel Jul 30, 2025
e9f8ce9
docs: autoconfig changelog
lidel Jul 30, 2025
3d34f41
test: basic ipns publishing work in ci (offline)
lidel Jul 30, 2025
e4eb581
chore: cleanup to use testdata
lidel Jul 30, 2025
2a196dc
test(coreapi): ipns name
lidel Jul 30, 2025
a68d581
fix(docker): copy boxo/autoconfig
lidel Jul 30, 2025
8fa6527
fix(autoconfig): real ipni fallback
lidel Jul 30, 2025
a57df38
fix: restore legacy defaultRepo
lidel Jul 31, 2025
9480b93
test: restore coreiface from master
lidel Jul 31, 2025
85e80d4
chore: restore previous namesys wiring
lidel Jul 31, 2025
7585807
refactor: simplify constructDefaultHTTPRouters
lidel Jul 31, 2025
b3975a2
refactor: cleanup config/autoconfig.go
lidel Jul 31, 2025
00c9d9c
fix: thread-safe cache
lidel Jul 31, 2025
82f2b59
refactor: MustGetConfig fallback handling
lidel Aug 1, 2025
2e22eba
test: ParseAndValidateRoutingURL
lidel Aug 1, 2025
24e6aa4
fix: simpler cache dir
lidel Aug 1, 2025
cf8b596
refactor(config): remove need for passing repoPath
lidel Aug 1, 2025
374ba05
chore: collapse diffs of generated data
lidel Aug 1, 2025
1df21cd
chore: restore master code
lidel Aug 1, 2025
f7c2112
test: error cases for autoconfig.json fetch
lidel Aug 1, 2025
f5fe36f
chore: placeholder
lidel Aug 1, 2025
e52befe
refactor: clenup startAutoConfigUpdater
lidel Aug 1, 2025
03a2a3c
test(autoconfig): ipfs swarm connect
lidel Aug 1, 2025
146ef49
refactor: better names for Must* funcs
lidel Aug 1, 2025
3e4a854
fix(fx): ClearCachedNode
lidel Aug 1, 2025
ef98774
test: TestHTTPCachingBehavior and cleanup
lidel Aug 1, 2025
1a7230c
test: TestAutoConfigIPNS
lidel Aug 1, 2025
814723e
test(autoconfig) Routing.Type=auto|delegated
lidel Aug 2, 2025
36acffe
fix: go vet
lidel Aug 2, 2025
332ab2f
test: migration and autoconfig sharness
lidel Aug 3, 2025
a5f6777
fix: sync.RWMutex
lidel Aug 3, 2025
70dbdc8
test(cli): migration_legacy_15_to_17_test.go
lidel Aug 4, 2025
44dec15
test: testCLIUsesCacheOnlyDaemonUpdatesBackground
lidel Aug 4, 2025
e77f434
fix: t0066-migration.sh
lidel Aug 4, 2025
a6efc94
refactor: autoconfig β†’ autoconf
lidel Aug 4, 2025
35e521d
fix: validate AutoConfSchema 1
lidel Aug 4, 2025
1a73236
docs: highlights and deprecations
lidel Aug 4, 2025
7f3bcea
test: testAutoConfWithHTTPS
lidel Aug 4, 2025
5a6c5ab
docs: boxo/autoconf
lidel Aug 4, 2025
491b1c3
docs: examples in boxo/autoconf/README.md
lidel Aug 5, 2025
c71e9d8
Merge branch 'master' into feat-mainnet-autoconfig
gammazero Aug 11, 2025
6a32e60
remove unused import
gammazero Aug 11, 2025
ea6c3e4
Merge branch 'master' into feat-mainnet-autoconfig
gammazero Aug 11, 2025
285be62
Merge branch 'master' into feat-mainnet-autoconfig
gammazero Aug 11, 2025
13357e3
chore: config β†’ conf
lidel Aug 12, 2025
8fd1829
refactor: boxo/autoconf extraction prep
lidel Aug 13, 2025
ebb948f
refactor: boxo/autoconf cleanup, part 1
lidel Aug 13, 2025
95065fd
Merge branch 'master' into feat-mainnet-autoconfig
lidel Aug 13, 2025
564382f
tests: switch to testify
lidel Aug 13, 2025
d88c0d0
fix: log warn when no cache available
lidel Aug 13, 2025
c2129d7
refactor: improve lock scopes
lidel Aug 13, 2025
a4e0671
chore: move atomicfile
lidel Aug 13, 2025
cfa0bcc
refactor: simplify the path operations
lidel Aug 13, 2025
70860e0
refactor: code simplifications
lidel Aug 13, 2025
0a9a5b7
refactor: reuse buildEndpointURL
lidel Aug 13, 2025
a0bac20
fix: Errorf
lidel Aug 13, 2025
c890bfd
chore: remove FromCache
lidel Aug 13, 2025
c0269f4
fix: panic on nil client
lidel Aug 13, 2025
3a6ec69
chore: preallocate slice
lidel Aug 13, 2025
62f67d6
refactor: slices.Contains
lidel Aug 13, 2025
af51a49
refactor: review feedback cleanup
lidel Aug 13, 2025
54df810
refactor: core/node/libp2p/host.go
lidel Aug 13, 2025
b0cdf44
refactor: move autoclient to boxo#997
lidel Aug 13, 2025
1946d45
fix: restore dockerfile
lidel Aug 13, 2025
5d4275e
chore: gofmt
lidel Aug 13, 2025
66fe0a8
Merge branch 'master' into feat-mainnet-autoconfig
gammazero Aug 14, 2025
2176ae4
merge: origin/master into feat-mainnet-autoconfig
lidel Aug 15, 2025
7f027e4
docs: concise changelog
lidel Aug 15, 2025
9321e46
chore: update to latest boxo#997
lidel Aug 15, 2025
018b73b
chore: update to boxo@main
lidel Aug 15, 2025
e4e08a3
merge: origin/master into feat-mainnet-autoconfig
lidel Aug 18, 2025
f2ca7d9
fix: telemetry bootstrap check for autoconf
lidel Aug 18, 2025
f3b8ed3
feat: autoconf telemetry
lidel Aug 18, 2025
2bb5276
test: telemetry schema regression guard
lidel Aug 18, 2025
f0314d0
test: use atomic.Int32 for cleaner counter handling
lidel Aug 18, 2025
0eb4a02
test: remove emojis from test logs
lidel Aug 18, 2025
dc41fbb
test: clarify bootstrap peer round-trip test
lidel Aug 18, 2025
9ffbf88
test: simplify IPNS error tests
lidel Aug 18, 2025
a7b0b21
refactor: rename --delegated-only to --allow-delegated
lidel Aug 19, 2025
470d4db
refactor: make AutoConf.URL implicit like AutoTLS
lidel Aug 19, 2025
0da54e0
fix: sort profile names in config help output
lidel Aug 19, 2025
8ec830b
test: AutoConf in bootstrap add default test
lidel Aug 19, 2025
ccd2388
fix: allow ipfs repo migrate to run without daemon
lidel Aug 19, 2025
6e75456
refactor: make Migration config optional
lidel Aug 19, 2025
d028a23
Merge branch 'master' into feat-mainnet-autoconfig
lidel Aug 19, 2025
2b32db3
fix(migration): use implicit defaults for AutoConf fields
lidel Aug 20, 2025
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
Prev Previous commit
Next Next commit
refactor: better names for Must* funcs
  • Loading branch information
lidel committed Aug 1, 2025
commit 146ef494e7a05cb4f20ec61a782b0712e545e89e
4 changes: 2 additions & 2 deletions boxo/autoconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ $CACHE_DIR/
The client implements graceful fallback:
1. Try to fetch from remote URL
2. If remote fails, fall back to latest cached version
3. If no cache exists, fall back to provided defaults (when using `MustGetConfig`)
3. If no cache exists, fall back to provided defaults (when using `MustGetConfigCached` or `MustGetConfigWithRefresh`)

Note: `GetLatest()` returns errors, while `MustGetConfig()` never fails and always returns usable configuration.
Note: `GetLatest()` returns errors, while `MustGetConfigCached()` and `MustGetConfigWithRefresh()` never fail and always return usable configuration.

## Testing

Expand Down
40 changes: 22 additions & 18 deletions boxo/autoconfig/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ func (c *Client) getLatest(ctx context.Context, configURL string, refreshInterva
// Check if we have cached data that's still within refreshInterval
cachedResp, cacheErr := c.getCached(cacheDir)
if cacheErr == nil && cachedResp.CacheAge < refreshInterval {
freshFor := refreshInterval - cachedResp.CacheAge
log.Debugf("using cached autoconfig (age: %s, fresh for %s)", formatDuration(cachedResp.CacheAge), formatDuration(freshFor))
log.Debugf("using cached autoconfig within refresh interval")
return cachedResp, nil
}

// Cache is stale or doesn't exist, try to fetch from remote
if cacheErr == nil {
log.Debugf("cache stale (age: %s), checking for updates", formatDuration(cachedResp.CacheAge))
log.Debugf("cache stale, checking for updates")
}
resp, err := c.fetchFromRemote(ctx, configURL, cacheDir)
if err != nil {
Expand All @@ -59,19 +58,17 @@ func (c *Client) getLatest(ctx context.Context, configURL string, refreshInterva
if resp.Config != nil && cacheErr == nil {
effectiveInterval := calculateEffectiveRefreshInterval(refreshInterval, resp.Config.CacheTTL)
if effectiveInterval < refreshInterval {
log.Debugf("server CacheTTL (%ds) is shorter than user refresh interval (%s), using effective interval %s",
resp.Config.CacheTTL, refreshInterval, effectiveInterval)
log.Debugf("server CacheTTL is shorter than user refresh interval, using server CacheTTL")

// Re-check if cached version is still fresh under the effective (shorter) interval
if cachedResp.CacheAge < effectiveInterval {
log.Debugf("cached config is still fresh under server CacheTTL (%s)", effectiveInterval)
log.Debugf("cached config is still fresh under server CacheTTL")
return cachedResp, nil
}
// If cached version is also stale under server TTL, continue with newly fetched config
log.Debugf("cached config is stale even under server CacheTTL, using newly fetched config")
} else {
log.Debugf("using user refresh interval (%s), server CacheTTL (%ds) is longer or not specified",
refreshInterval, resp.Config.CacheTTL)
log.Debugf("using user refresh interval, server CacheTTL is longer or not specified")
}
}

Expand All @@ -83,11 +80,11 @@ func (c *Client) getLatest(ctx context.Context, configURL string, refreshInterva
return resp, nil
}

// MustGetConfigOffline returns config from cache or fallback without any network I/O.
// MustGetConfigCached returns config from cache or fallback without any network I/O.
//
// This method guarantees no network operations will be performed, making it safe to
// call from any context, including offline nodes and config validation routines.
// It follows this priority order:
// call from any context where network access should be avoided. It only uses locally
// cached data or the provided fallback. It follows this priority order:
//
// 1. Return cached config if available (regardless of age)
// 2. Call provided fallback function if cache miss occurs
Expand All @@ -96,10 +93,10 @@ func (c *Client) getLatest(ctx context.Context, configURL string, refreshInterva
// This method is essential for preventing network blocking during config reads,
// especially in scenarios where autoconfig is enabled but network access should
// be avoided (e.g., config validation, offline node construction).
func (c *Client) MustGetConfigOffline(configURL string, fallbackFunc func() *Config) *Config {
func (c *Client) MustGetConfigCached(configURL string, fallbackFunc func() *Config) *Config {
cacheDir, err := c.getCacheDir(configURL)
if err != nil {
log.Debugf("MustGetConfigOffline: cache dir error: %v, using fallback", err)
log.Debugf("MustGetConfigCached: cache dir error: %v, using fallback", err)
if fallbackFunc != nil {
return fallbackFunc()
}
Expand All @@ -109,18 +106,18 @@ func (c *Client) MustGetConfigOffline(configURL string, fallbackFunc func() *Con
// Try to get from cache only
config, err := c.getCachedConfig(cacheDir)
if err != nil {
log.Debugf("MustGetConfigOffline: cache miss or error: %v, using fallback", err)
log.Debugf("MustGetConfigCached: cache miss or error: %v, using fallback", err)
if fallbackFunc != nil {
return fallbackFunc()
}
return GetMainnetFallbackConfig()
}

log.Debugf("MustGetConfigOffline: returning cached config")
log.Debugf("MustGetConfigCached: returning cached config")
return config
}

// MustGetConfigOnline fetches the latest config from network with fallback handling.
// MustGetConfigWithRefresh fetches the latest config from network with fallback handling.
//
// This method will attempt to fetch fresh config from the network, respecting the
// refreshInterval for cache freshness. If network fetch fails, it falls back to:
Expand All @@ -129,22 +126,29 @@ func (c *Client) MustGetConfigOffline(configURL string, fallbackFunc func() *Con
// 3. Default mainnet fallback
//
// This method may block on network I/O and should be used when network operations
// are acceptable. For config reads that must avoid network I/O, use MustGetConfigOffline.
func (c *Client) MustGetConfigOnline(ctx context.Context, configURL string, refreshInterval time.Duration, fallbackFunc func() *Config) *Config {
// are acceptable. For config reads that must avoid network I/O, use MustGetConfigCached.
func (c *Client) MustGetConfigWithRefresh(ctx context.Context, configURL string, refreshInterval time.Duration, fallbackFunc func() *Config) *Config {
resp, err := c.getLatest(ctx, configURL, refreshInterval)
if err != nil {
log.Errorf("AutoConfig fetch failed: %v, falling back to provided fallback config", err)
} else if resp == nil || resp.Config == nil {
log.Errorf("AutoConfig fetch returned nil response or config, falling back to provided fallback config")
} else {
// Return the fetched config as-is without any modification
if resp.FromCache {
log.Debugf("MustGetConfigWithRefresh: returning cached config")
} else {
log.Debugf("MustGetConfigWithRefresh: returning fresh config from network")
}
return resp.Config
}

// Use the provided fallback function if available, otherwise use default mainnet fallback
if fallbackFunc != nil {
log.Debugf("MustGetConfigWithRefresh: returning provided fallback config")
return fallbackFunc()
}
log.Debugf("MustGetConfigWithRefresh: returning default mainnet fallback config")
return GetMainnetFallbackConfig()
}

Expand Down
4 changes: 2 additions & 2 deletions boxo/autoconfig/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (u *BackgroundUpdater) Start(ctx context.Context) error {
u.wg.Add(1)
go u.runUpdater()

log.Debugf("started autoconfig background updater with interval %v", u.updateInterval)
log.Debugf("started autoconfig background updater")
return nil
}

Expand Down Expand Up @@ -167,7 +167,7 @@ func (u *BackgroundUpdater) runUpdater() {
} else {
// Success - reset failure count
if failureCount > 0 {
log.Debugf("autoconfig background update succeeded after %d failed attempts", failureCount)
log.Debugf("autoconfig background update succeeded after retries")
failureCount = 0
} else {
log.Debug("autoconfig background update succeeded")
Expand Down
2 changes: 1 addition & 1 deletion cmd/ipfs/kubo/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ func startAutoConfigUpdater(ctx context.Context, cfg *config.Config, userAgent s
primeCtx, cancel := context.WithTimeout(ctx, config.DefaultAutoconfigTimeout)
defer cancel()

result := client.MustGetConfigOnline(primeCtx, autoConfigURL, refreshInterval, autoconfig.GetMainnetFallbackConfig)
result := client.MustGetConfigWithRefresh(primeCtx, autoConfigURL, refreshInterval, autoconfig.GetMainnetFallbackConfig)
if result != nil {
autoconfigLog.Debugf("successfully primed autoconfig cache with version %d", result.AutoConfigVersion)
}
Expand Down
11 changes: 5 additions & 6 deletions config/autoconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ func (c *Config) BootstrapWithAutoConfig() []string {
routingType := c.Routing.Type.WithDefault(DefaultRoutingType)
nativeSystems := GetNativeSystems(routingType)
autoConfigData = autoConfig.GetBootstrapPeers(nativeSystems)
log.Debugf("BootstrapWithAutoConfig: routingType=%s nativeSystems=%v peers=%d",
routingType, nativeSystems, len(autoConfigData))
log.Debugf("BootstrapWithAutoConfig: processing with routing type: %s", routingType)
} else {
log.Debugf("BootstrapWithAutoConfig: autoConfig disabled, using original config")
}
Expand Down Expand Up @@ -306,11 +305,11 @@ func (c *Config) getAutoConfig() *autoconfig.Config {
return nil
}

// Use MustGetConfigOffline to avoid network I/O during config operations
// This ensures offline nodes don't block on network operations
result := client.MustGetConfigOffline(c.AutoConfig.URL, autoconfig.GetMainnetFallbackConfig)
// Use MustGetConfigCached to avoid network I/O during config operations
// This ensures config retrieval doesn't block on network operations
result := client.MustGetConfigCached(c.AutoConfig.URL, autoconfig.GetMainnetFallbackConfig)

log.Debugf("getAutoConfig: returning config with %d DelegatedEndpoints", len(result.DelegatedEndpoints))
log.Debugf("getAutoConfig: returning autoconfig data")
return result
}

Expand Down
4 changes: 2 additions & 2 deletions config/autoconfig_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ func NewAutoConfigClientWithConfig(repoPath string, cfg interface{}, userAgent s
}

// GetAutoConfig is a convenience function to get the latest config with a default client
// Uses the default check interval - for user-configured intervals, use MustGetConfigOnline directly
// Uses the default check interval - for user-configured intervals, use MustGetConfigWithRefresh directly
func GetAutoConfig(ctx context.Context, configURL, repoPath, userAgent string) (*autoconfig.Config, error) {
client, err := NewAutoConfigClient(repoPath, userAgent)
if err != nil {
return nil, err
}
return client.MustGetConfigOnline(ctx, configURL, autoconfig.DefaultRefreshInterval, autoconfig.GetMainnetFallbackConfig), nil
return client.MustGetConfigWithRefresh(ctx, configURL, autoconfig.DefaultRefreshInterval, autoconfig.GetMainnetFallbackConfig), nil
}


Expand Down
4 changes: 2 additions & 2 deletions test/cli/autoconfig/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func testAutoConfigWithFallbackAndTimeout(t *testing.T, serverURL string, expect
client, err := autoconfig.NewClient(autoconfig.WithUserAgent("test-agent"))
require.NoError(t, err)

// Use fallback detection to test error conditions with MustGetConfigOnline
// Use fallback detection to test error conditions with MustGetConfigWithRefresh
fallbackUsed := false
fallbackConfig := &autoconfig.Config{
AutoConfigVersion: -999, // Special marker to detect fallback usage
Expand All @@ -34,7 +34,7 @@ func testAutoConfigWithFallbackAndTimeout(t *testing.T, serverURL string, expect

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
result := client.MustGetConfigOnline(ctx, serverURL, autoconfig.DefaultRefreshInterval, func() *autoconfig.Config {
result := client.MustGetConfigWithRefresh(ctx, serverURL, autoconfig.DefaultRefreshInterval, func() *autoconfig.Config {
fallbackUsed = true
return fallbackConfig
})
Expand Down