Skip to content

Commit 007eb89

Browse files
committed
update to v0.6.1 and fix lints
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
1 parent 3e4417c commit 007eb89

6 files changed

Lines changed: 43 additions & 27 deletions

File tree

api/server/server.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,17 @@ func NewServer(conf Config) (*Server, error) {
128128
if err != nil {
129129
return nil, fmt.Errorf("creating lotus client builder: %s", err)
130130
}
131-
c1, cls1, err := clientBuilder()
131+
lotus.MonitorLotusSync(clientBuilder)
132+
133+
c, cls, err := clientBuilder()
132134
if err != nil {
133135
return nil, fmt.Errorf("connecting to lotus node: %s", err)
134136
}
135137

136138
if conf.Devnet {
137139
// Wait for the devnet to bootstrap completely and generate at least 1 block.
138140
time.Sleep(time.Second * 6)
139-
if masterAddr, err = c1.WalletDefaultAddress(context.Background()); err != nil {
141+
if masterAddr, err = c.WalletDefaultAddress(context.Background()); err != nil {
140142
return nil, fmt.Errorf("getting default wallet addr as masteraddr: %s", err)
141143
}
142144
} else {
@@ -147,11 +149,12 @@ func NewServer(conf Config) (*Server, error) {
147149

148150
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
149151
defer cancel()
150-
network, err := c1.StateNetworkName(ctx)
152+
network, err := c.StateNetworkName(ctx)
151153
if err != nil {
152154
return nil, fmt.Errorf("getting Lotus network name: %s", err)
153155
}
154-
cls1()
156+
cls()
157+
155158
networkName := string(network)
156159
log.Infof("Detected Lotus node connected to network: %s", networkName)
157160

docker/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ localnet:
1616

1717

1818
up: down
19-
LOTUS_IMAGE_TAG=v0.6.0 \
19+
LOTUS_IMAGE_TAG=v0.6.1 \
2020
docker-compose \
2121
-p testnet \
2222
-f docker-compose.yaml \
@@ -26,7 +26,7 @@ up: down
2626
.PHONY: up
2727

2828
down:
29-
LOTUS_IMAGE_TAG=v0.6.0 \
29+
LOTUS_IMAGE_TAG=v0.6.1 \
3030
docker-compose \
3131
-p testnet \
3232
-f docker-compose.yaml \

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/filecoin-project/go-jsonrpc v0.1.2-0.20200822201400-474f4fdccc52
1313
github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20
1414
github.com/filecoin-project/go-state-types v0.0.0-20200905071437-95828685f9df
15-
github.com/filecoin-project/lotus v0.6.0
15+
github.com/filecoin-project/lotus v0.6.1
1616
github.com/filecoin-project/specs-actors v0.9.7
1717
github.com/gin-contrib/location v0.0.2
1818
github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ github.com/filecoin-project/lotus v0.5.8-0.20200901153315-fa4000663a61/go.mod h1
327327
github.com/filecoin-project/lotus v0.5.8-0.20200902130912-0962292f920e/go.mod h1:OkZ5aUqs+fFnJOq9243WJDsTa9c3/Ae67NIAwVhAB+0=
328328
github.com/filecoin-project/lotus v0.5.8-0.20200903221953-ada5e6ae68cf/go.mod h1:wxuzS4ozpCFThia18G+J5P0Jp/DSiq9ezzJF1yvZuP4=
329329
github.com/filecoin-project/lotus v0.5.11-0.20200907070510-420a8706da6d/go.mod h1:SVrkI6GQzqSeSuaZ6KsHih4Dh800q9HSFQCtBnyMYBI=
330-
github.com/filecoin-project/lotus v0.6.0 h1:vfpT+3Aq+5wqIGjrLjV+gNUs/dN8u9xCMeejWgh89e4=
331-
github.com/filecoin-project/lotus v0.6.0/go.mod h1:CNyCPW7bHSmaPrBMfoOEDFTfVewTRQefDrWpY/epU0I=
330+
github.com/filecoin-project/lotus v0.6.1 h1:+dzkzGzwZlngYniXQNU2PZk6Cz5WQSiQo3JFhXliJMM=
331+
github.com/filecoin-project/lotus v0.6.1/go.mod h1:rCWYipXCekaw1Iom3Yfw+KYxS79Pfkfc1uWk0gVou1E=
332332
github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15/go.mod h1:salgVdX7qeXFo/xaiEQE29J4pPkjn71T0kt0n+VDBzo=
333333
github.com/filecoin-project/sector-storage v0.0.0-20200730050024-3ee28c3b6d9a/go.mod h1:oOawOl9Yk+qeytLzzIryjI8iRbqo+qzS6EEeElP4PWA=
334334
github.com/filecoin-project/sector-storage v0.0.0-20200810171746-eac70842d8e0 h1:E1fZ27fhKK05bhZItfTwqr1i05vXnEZJznQFEYwEEUU=

index/faults/module/faults.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/textileio/powergate/lotus"
1717
"github.com/textileio/powergate/signaler"
1818
txndstr "github.com/textileio/powergate/txndstransform"
19-
"github.com/textileio/powergate/util"
2019
"go.opencensus.io/stats"
2120
)
2221

@@ -30,6 +29,12 @@ var (
3029
// chain reorgs.
3130
hOffset = abi.ChainEpoch(20)
3231

32+
// updateInterval is the interval duration where the fault index
33+
// will be updated.
34+
// Note: currently the Fault index is disabled until Lotus re-enables
35+
// StateAllMinersFaults() API.
36+
updateInterval = time.Hour * 24 * 365
37+
3338
log = logging.Logger("index-faults")
3439
)
3540

@@ -71,7 +76,9 @@ func New(ds datastore.TxnDatastore, clientBuilder lotus.ClientBuilder) (*Index,
7176
if err := s.loadFromDS(); err != nil {
7277
return nil, err
7378
}
79+
7480
go s.start()
81+
7582
return s, nil
7683
}
7784

@@ -116,7 +123,6 @@ func (s *Index) Close() error {
116123
// start is a long running job that keeps the index up to date with chain updates.
117124
func (s *Index) start() {
118125
defer close(s.finished)
119-
return // Disabled until Lotus fixes its Faults APIs.
120126
if err := s.updateIndex(); err != nil {
121127
log.Errorf("initial updating faults index: %s", err)
122128
}
@@ -125,7 +131,7 @@ func (s *Index) start() {
125131
case <-s.ctx.Done():
126132
log.Info("graceful shutdown of background faults updater")
127133
return
128-
case <-time.After(util.AvgBlockTime):
134+
case <-time.After(updateInterval):
129135
if err := s.updateIndex(); err != nil {
130136
log.Errorf("updating faults history: %s", err)
131137
continue

lotus/client.go

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import (
1313

1414
"github.com/textileio/powergate/util"
1515
"go.opencensus.io/stats"
16+
"go.opencensus.io/stats/view"
1617
)
1718

1819
var (
19-
lotusSyncStatusInterval = time.Second * 10
20-
log = logging.Logger("lotus-client")
20+
heightProbingInterval = time.Second * 10
21+
log = logging.Logger("lotus-client")
2122
)
2223

2324
// ClientBuilder creates a new Lotus client.
@@ -57,23 +58,29 @@ func NewBuilder(maddr ma.Multiaddr, authToken string, connRetries int) (ClientBu
5758
}, nil
5859
}
5960

60-
func monitorLotusSync(ctx context.Context, c *apistruct.FullNodeStruct) {
61-
refreshHeightMetric(ctx, c)
62-
for {
63-
select {
64-
case <-ctx.Done():
65-
log.Debug("closing lotus sync monitor")
66-
return
67-
case <-time.After(lotusSyncStatusInterval):
68-
refreshHeightMetric(ctx, c)
69-
}
61+
// MonitorLotusSync fires a goroutine that will generate
62+
// metrics with Lotus node height.
63+
func MonitorLotusSync(clientBuilder ClientBuilder) {
64+
if err := view.Register(vHeight); err != nil {
65+
log.Fatalf("register metrics views: %v", err)
7066
}
67+
go func() {
68+
for {
69+
refreshHeightMetric(clientBuilder)
70+
time.Sleep(heightProbingInterval)
71+
}
72+
}()
7173
}
7274

73-
func refreshHeightMetric(ctx context.Context, c *apistruct.FullNodeStruct) {
74-
heaviest, err := c.ChainHead(ctx)
75+
func refreshHeightMetric(clientBuilder ClientBuilder) {
76+
c, cls, err := clientBuilder()
77+
if err != nil {
78+
log.Error("creating lotus client for monitoring: %s", err)
79+
}
80+
defer cls()
81+
heaviest, err := c.ChainHead(context.Background())
7582
if err != nil {
76-
log.Errorf("error when getting lotus sync status: %s", err)
83+
log.Errorf("get lotus sync status: %s", err)
7784
return
7885
}
7986
stats.Record(context.Background(), mLotusHeight.M(int64(heaviest.Height())))

0 commit comments

Comments
 (0)