diff --git a/CHANGELOG.md b/CHANGELOG.md index b088da64ddc..03836c83080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - https://github.com/filecoin-project/lotus/pull/12285 Set up OpenTelemetry metrics reporting to prometheus - https://github.com/filecoin-project/lotus/pull/12279 Upgrade to go-f3 v0.0.5 - https://github.com/filecoin-project/lotus/pull/12295 Upgrade to go-f3 v0.0.6 +- https://github.com/filecoin-project/lotus/pull/12292: feat: p2p: allow overriding bootstrap nodes with environmemnt variable ## New features diff --git a/build/bootstrap.go b/build/bootstrap.go index d6f8864c645..da8ffc6dfa5 100644 --- a/build/bootstrap.go +++ b/build/bootstrap.go @@ -3,6 +3,7 @@ package build import ( "context" "embed" + "os" "path" "strings" @@ -12,6 +13,10 @@ import ( "github.com/filecoin-project/lotus/lib/addrutil" ) +const ( + BootstrappersOverrideEnvVarKey = "LOTUS_P2P_BOOTSTRAPPERS" +) + //go:embed bootstrap var bootstrapfs embed.FS @@ -19,6 +24,10 @@ func BuiltinBootstrap() ([]peer.AddrInfo, error) { if DisableBuiltinAssets { return nil, nil } + if bootstrappers, found := os.LookupEnv(BootstrappersOverrideEnvVarKey); found { + log.Infof("Using bootstrap nodes overridden by environment variable %s", BootstrappersOverrideEnvVarKey) + return addrutil.ParseAddresses(context.TODO(), strings.Split(strings.TrimSpace(bootstrappers), ",")) + } if buildconstants.BootstrappersFile != "" { spi, err := bootstrapfs.ReadFile(path.Join("bootstrap", buildconstants.BootstrappersFile)) if err != nil {