diff --git a/cmd/go-filecoin/inspector_integration_test.go b/cmd/go-filecoin/inspector_integration_test.go deleted file mode 100644 index 4573808c65..0000000000 --- a/cmd/go-filecoin/inspector_integration_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package commands_test - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - tf "github.com/filecoin-project/go-filecoin/internal/pkg/testhelpers/testflags" - "github.com/filecoin-project/go-filecoin/tools/fast" - "github.com/filecoin-project/go-filecoin/tools/fast/fastesting" -) - -func TestInspectConfig(t *testing.T) { - tf.IntegrationTest(t) - t.Skip("Not working") - - ctx, env := fastesting.NewTestEnvironment(context.Background(), t, fast.FilecoinOpts{}) - - // Teardown after test ends - defer func() { - err := env.Teardown(ctx) - require.NoError(t, err) - }() - - nd := env.RequireNewNodeStarted() - - icfg, err := nd.InspectConfig(ctx) - require.NoError(t, err) - - rcfg, err := nd.Config() - require.NoError(t, err) - - // API is not the same since the FAST plugin reads the config file from disk, - // this is a limitation of FAST. - // FAST sets API.Address to /ip4/0.0.0.0/0 in the config file to avoid port collisions. - // The Inspector returns an in memory representation of the config that has - // received a port assignment from the kernel, meaning it is no longer /ip4/0.0.0.0/0 - assert.Equal(t, rcfg.Bootstrap, icfg.Bootstrap) - assert.Equal(t, rcfg.Datastore, icfg.Datastore) - assert.Equal(t, rcfg.Swarm, icfg.Swarm) - assert.Equal(t, rcfg.Mining, icfg.Mining) - assert.Equal(t, rcfg.Wallet, icfg.Wallet) - assert.Equal(t, rcfg.Heartbeat, icfg.Heartbeat) - assert.Equal(t, rcfg.Mpool, icfg.Mpool) -} diff --git a/go.sum b/go.sum index d9edca3718..ccdc8106cc 100644 --- a/go.sum +++ b/go.sum @@ -192,6 +192,7 @@ github.com/filecoin-project/sector-storage v0.0.0-20200508203401-a74812ba12f3/go github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA= github.com/filecoin-project/specs-actors v0.0.0-20200409043918-e569f4a2f504/go.mod h1:mdJraXq5vMy0+/FqVQIrnNlpQ/Em6zeu06G/ltQ0/lA= github.com/filecoin-project/specs-actors v0.3.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y= +github.com/filecoin-project/specs-actors v0.4.1-0.20200509020627-3c96f54f3d7d/go.mod h1:UW3ft23q6VS8wQoNqLWjENsu9gu1uh6lxOd+H8cwhT8= github.com/filecoin-project/specs-actors v0.5.2/go.mod h1:r5btrNzZD0oBkEz1pohv80gSCXQnqGrD0kYwOTiExyE= github.com/filecoin-project/specs-actors v0.5.3 h1:fdq8Gx0izhnUKl6sYEtI4SUEjT2U6W2w06HeqLz5vmw= github.com/filecoin-project/specs-actors v0.5.3/go.mod h1:r5btrNzZD0oBkEz1pohv80gSCXQnqGrD0kYwOTiExyE= diff --git a/internal/app/go-filecoin/node/node.go b/internal/app/go-filecoin/node/node.go index a29be123bd..238aaa81f4 100644 --- a/internal/app/go-filecoin/node/node.go +++ b/internal/app/go-filecoin/node/node.go @@ -3,7 +3,6 @@ package node import ( "context" "fmt" - "os" "reflect" "runtime" @@ -23,7 +22,6 @@ import ( "github.com/filecoin-project/go-filecoin/internal/pkg/cborutil" "github.com/filecoin-project/go-filecoin/internal/pkg/chain" "github.com/filecoin-project/go-filecoin/internal/pkg/clock" - "github.com/filecoin-project/go-filecoin/internal/pkg/config" "github.com/filecoin-project/go-filecoin/internal/pkg/consensus" "github.com/filecoin-project/go-filecoin/internal/pkg/message" "github.com/filecoin-project/go-filecoin/internal/pkg/metrics" @@ -156,10 +154,6 @@ func (node *Node) Start(ctx context.Context) error { return err } - if err := node.setupHeartbeatServices(ctx); err != nil { - return errors.Wrap(err, "failed to start heartbeat services") - } - // Start node discovery if err := node.Discovery.Start(node); err != nil { return err @@ -186,38 +180,6 @@ func (node *Node) pubsubscribe(ctx context.Context, topic *pubsub.Topic, handler return sub, nil } -func (node *Node) setupHeartbeatServices(ctx context.Context) error { - mag := func() address.Address { - addr, err := node.MiningAddress() - // the only error MiningAddress() returns is ErrNoMinerAddress. - // if there is no configured miner address, simply send a zero - // address across the wire. - if err != nil { - return address.Undef - } - return addr - } - - // start the primary heartbeat service - if len(node.Repo.Config().Heartbeat.BeatTarget) > 0 { - hbs := metrics.NewHeartbeatService(node.Host(), node.chain.ChainReader.GenesisCid(), node.Repo.Config().Heartbeat, node.PorcelainAPI.ChainHead, metrics.WithMinerAddressGetter(mag)) - go hbs.Start(ctx) - } - - // check if we want to connect to an alert service. An alerting service is a heartbeat - // service that can trigger alerts based on the contents of heatbeats. - if alertTarget := os.Getenv("FIL_HEARTBEAT_ALERTS"); len(alertTarget) > 0 { - ahbs := metrics.NewHeartbeatService(node.Host(), node.chain.ChainReader.GenesisCid(), &config.HeartbeatConfig{ - BeatTarget: alertTarget, - BeatPeriod: "10s", - ReconnectPeriod: "10s", - Nickname: node.Repo.Config().Heartbeat.Nickname, - }, node.PorcelainAPI.ChainHead, metrics.WithMinerAddressGetter(mag)) - go ahbs.Start(ctx) - } - return nil -} - func (node *Node) setIsMining(isMining bool) { node.BlockMining.Mining.Lock() defer node.BlockMining.Mining.Unlock() diff --git a/internal/app/go-filecoin/plumbing/cfg/config_test.go b/internal/app/go-filecoin/plumbing/cfg/config_test.go index f39ee798c2..5dc76b7540 100644 --- a/internal/app/go-filecoin/plumbing/cfg/config_test.go +++ b/internal/app/go-filecoin/plumbing/cfg/config_test.go @@ -86,10 +86,6 @@ func TestConfigSet(t *testing.T) { require.NoError(t, err) assert.Equal(t, testSwarmAddr, cfg.Swarm.Address) - err = cfgAPI.Set("heartbeat.nickname", "Nickleless") - require.NoError(t, err) - assert.Equal(t, "Nickleless", cfg.Heartbeat.Nickname) - err = cfgAPI.Set("datastore.path", "/dev/null") require.NoError(t, err) assert.Equal(t, "/dev/null", cfg.Datastore.Path) @@ -122,12 +118,4 @@ func TestConfigSet(t *testing.T) { assert.EqualError(t, err, address.ErrUnknownProtocol.Error()) }) - t.Run("validates the node nickname", func(t *testing.T) { - repo := repo.NewInMemoryRepo() - cfgAPI := NewConfig(repo) - - err := cfgAPI.Set("heartbeat.nickname", "Bad Nickname") - - assert.EqualError(t, err, `"heartbeat.nickname" must only contain letters`) - }) } diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index 4b8a8013d0..f11aff24a4 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -22,7 +22,6 @@ type Config struct { Bootstrap *BootstrapConfig `json:"bootstrap"` Datastore *DatastoreConfig `json:"datastore"` Drand *DrandConfig `json:"drand"` - Heartbeat *HeartbeatConfig `json:"heartbeat"` Mining *MiningConfig `json:"mining"` Mpool *MessagePoolConfig `json:"mpool"` NetworkParams *NetworkParamsConfig `json:"parameters"` @@ -172,15 +171,6 @@ type HeartbeatConfig struct { Nickname string `json:"nickname"` } -func newDefaultHeartbeatConfig() *HeartbeatConfig { - return &HeartbeatConfig{ - BeatTarget: "", - BeatPeriod: "3s", - ReconnectPeriod: "10s", - Nickname: "", - } -} - // ObservabilityConfig is a container for configuration related to observables. type ObservabilityConfig struct { Metrics *MetricsConfig `json:"metrics"` @@ -291,7 +281,6 @@ func NewDefaultConfig() *Config { Bootstrap: newDefaultBootstrapConfig(), Datastore: newDefaultDatastoreConfig(), Drand: newDefaultDrandConfig(), - Heartbeat: newDefaultHeartbeatConfig(), Mining: newDefaultMiningConfig(), Mpool: newDefaultMessagePoolConfig(), NetworkParams: newDefaultNetworkParamsConfig(), diff --git a/internal/pkg/config/config_test.go b/internal/pkg/config/config_test.go index 8f283da91d..dc41b158ac 100644 --- a/internal/pkg/config/config_test.go +++ b/internal/pkg/config/config_test.go @@ -51,20 +51,6 @@ func TestWriteFile(t *testing.T) { assert.NoError(t, os.Remove(filepath.Join(dir, "config.json"))) } -func TestSetRejectsInvalidNicks(t *testing.T) { - tf.UnitTest(t) - - cfg := NewDefaultConfig() - - // sic: json includes the quotes in the value - err := cfg.Set("heartbeat.nickname", "\"goodnick\"") - assert.NoError(t, err) - err = cfg.Set("heartbeat.nickname", "bad nick

") - assert.Error(t, err) - err = cfg.Set("heartbeat", `{"heartbeat": "bad nick"}`) - assert.Error(t, err) -} - func TestConfigRoundtrip(t *testing.T) { tf.UnitTest(t)