@@ -87,7 +87,7 @@ var initCmd = &cli.Command{
87
87
}
88
88
89
89
rcfg .ConfigVersion = config .CurrentVersion
90
- cerr = setMinerApiConfig (cctx , rcfg , true )
90
+ cerr = setMinerApiConfig (cctx , rcfg )
91
91
if cerr != nil {
92
92
return
93
93
}
@@ -118,9 +118,14 @@ var initCmd = &cli.Command{
118
118
return fmt .Errorf ("writing config file %s: %w" , string (newCfg ), err )
119
119
}
120
120
121
+ miner , err := address .NewFromString (curCfg .Wallets .Miner )
122
+ if err != nil {
123
+ return fmt .Errorf ("converting miner address: %w" , err )
124
+ }
125
+
121
126
// Add the miner address to the metadata datastore
122
- fmt .Printf ("Adding miner address %s to datastore\n " , bp . minerActor )
123
- err = addMinerAddressToDatastore (ds , bp . minerActor )
127
+ fmt .Printf ("Adding miner address %s to datastore\n " , miner )
128
+ err = addMinerAddressToDatastore (ds , miner )
124
129
if err != nil {
125
130
return err
126
131
}
@@ -140,10 +145,9 @@ var initCmd = &cli.Command{
140
145
}
141
146
142
147
type boostParams struct {
143
- repo * lotus_repo.FsRepo
144
- minerActor address.Address
145
- walletPSD address.Address
146
- walletCP address.Address
148
+ repo * lotus_repo.FsRepo
149
+ walletPSD address.Address
150
+ walletCP address.Address
147
151
}
148
152
149
153
func initBoost (ctx context.Context , cctx * cli.Context , marketsRepo lotus_repo.LockedRepo ) (* boostParams , error ) {
@@ -177,36 +181,6 @@ func initBoost(ctx context.Context, cctx *cli.Context, marketsRepo lotus_repo.Lo
177
181
}
178
182
defer closer ()
179
183
180
- var minerActor address.Address
181
- if marketsRepo == nil {
182
- // If this is not a migration from an existing repo, just query the
183
- // miner directly for the actor address
184
- smApi , smCloser , err := lcli .GetStorageMinerAPI (cctx )
185
- if err != nil {
186
- if strings .Contains (err .Error (), "could not get API info" ) {
187
- err = fmt .Errorf ("%w\n Do you need to set the environment variable MINER_API_INFO?" , err )
188
- }
189
- return nil , err
190
- }
191
- defer smCloser ()
192
-
193
- minerActor , err = smApi .ActorAddress (ctx )
194
- if err != nil {
195
- return nil , fmt .Errorf ("getting miner actor address: %w" , err )
196
- }
197
- } else {
198
- // This is a migration from an existing repo, so get the miner address
199
- // from the repo datastore
200
- ds , err := marketsRepo .Datastore (context .Background (), metadataNamespace )
201
- if err != nil {
202
- return nil , fmt .Errorf ("getting legacy repo datastore: %w" , err )
203
- }
204
- minerActor , err = getMinerAddressFromDatastore (ds )
205
- if err != nil {
206
- return nil , fmt .Errorf ("getting miner actor address: %w" , err )
207
- }
208
- }
209
-
210
184
fmt .Println ("Checking full node sync status" )
211
185
212
186
if err := lcli .SyncWait (ctx , & v0api.WrapperV1Full {FullNode : api }, false ); err != nil {
@@ -248,56 +222,46 @@ func initBoost(ctx context.Context, cctx *cli.Context, marketsRepo lotus_repo.Lo
248
222
}
249
223
250
224
return & boostParams {
251
- repo : r ,
252
- minerActor : minerActor ,
253
- walletPSD : walletPSD ,
254
- walletCP : walletCP ,
225
+ repo : r ,
226
+ walletPSD : walletPSD ,
227
+ walletCP : walletCP ,
255
228
}, nil
256
229
}
257
230
258
- func setMinerApiConfig (cctx * cli.Context , rcfg * config.Boost , dialCheck bool ) error {
231
+ func setMinerApiConfig (cctx * cli.Context , rcfg * config.Boost ) error {
259
232
ctx := cctx .Context
260
- asi , err := checkApiInfo (ctx , cctx .String ("api-sector-index" ), dialCheck )
233
+ asi , miner1 , err := checkApiInfo (ctx , cctx .String ("api-sector-index" ))
261
234
if err != nil {
262
235
return fmt .Errorf ("checking sector index API: %w" , err )
263
236
}
264
237
fmt .Printf ("Sector index api info: %s\n " , asi )
265
238
rcfg .SectorIndexApiInfo = asi
266
239
267
- ai , err := checkApiInfo (ctx , cctx .String ("api-sealer" ), dialCheck )
240
+ ai , miner2 , err := checkApiInfo (ctx , cctx .String ("api-sealer" ))
268
241
if err != nil {
269
242
return fmt .Errorf ("checking sealer API: %w" , err )
270
243
}
271
244
245
+ if miner1 != miner2 {
246
+ return errors .New ("sector index and sealer APIs belong to different miners" )
247
+ }
248
+
272
249
fmt .Printf ("Sealer api info: %s\n " , ai )
250
+ fmt .Printf ("Miner address: %s" , miner1 )
273
251
rcfg .SealerApiInfo = ai
252
+ rcfg .Wallets .Miner = miner1
274
253
275
254
return nil
276
255
}
277
256
278
257
func setCommonConfig (cctx * cli.Context , rcfg * config.Boost , bp * boostParams ) {
279
258
rcfg .Dealmaking .MaxStagingDealsBytes = cctx .Int64 ("max-staging-deals-bytes" )
280
- rcfg .Wallets .Miner = bp .minerActor .String ()
281
259
rcfg .Wallets .DealCollateral = bp .walletCP .String ()
282
260
rcfg .Wallets .PublishStorageDeals = bp .walletPSD .String ()
283
261
}
284
262
285
263
var minerAddrDSKey = datastore .NewKey ("miner-address" )
286
264
287
- func getMinerAddressFromDatastore (ds datastore.Batching ) (address.Address , error ) {
288
- addr , err := ds .Get (context .Background (), minerAddrDSKey )
289
- if err != nil {
290
- return address.Address {}, fmt .Errorf ("getting miner address from legacy datastore: %w" , err )
291
- }
292
-
293
- minerAddr , err := address .NewFromBytes (addr )
294
- if err != nil {
295
- return address.Address {}, fmt .Errorf ("parsing miner address from legacy datastore: %w" , err )
296
- }
297
-
298
- return minerAddr , nil
299
- }
300
-
301
265
func addMinerAddressToDatastore (ds datastore.Batching , minerActor address.Address ) error {
302
266
return ds .Put (context .Background (), minerAddrDSKey , minerActor .Bytes ())
303
267
}
@@ -328,33 +292,34 @@ func checkV1ApiSupport(ctx context.Context, cctx *cli.Context) error {
328
292
return nil
329
293
}
330
294
331
- func checkApiInfo (ctx context.Context , ai string , dialCheck bool ) (string , error ) {
295
+ func checkApiInfo (ctx context.Context , ai string ) (string , string , error ) {
332
296
ai = strings .TrimPrefix (strings .TrimSpace (ai ), "MINER_API_INFO=" )
333
297
info := cliutil .ParseApiInfo (ai )
334
298
addr , err := info .DialArgs ("v0" )
335
299
if err != nil {
336
- return "" , fmt .Errorf ("could not get DialArgs: %w" , err )
337
- }
338
-
339
- if ! dialCheck {
340
- return ai , nil
300
+ return "" , "" , fmt .Errorf ("could not get DialArgs: %w" , err )
341
301
}
342
302
343
303
fmt .Printf ("Checking miner api version of %s\n " , addr )
344
304
api , closer , err := client .NewStorageMinerRPCV0 (ctx , addr , info .AuthHeader ())
345
305
if err != nil {
346
- return "" , err
306
+ return "" , "" , err
347
307
}
348
308
defer closer ()
349
309
350
310
v , err := api .Version (ctx )
351
311
if err != nil {
352
- return "" , fmt .Errorf ("checking version: %w" , err )
312
+ return "" , "" , fmt .Errorf ("checking version: %w" , err )
353
313
}
354
314
355
315
if ! v .APIVersion .EqMajorMinor (lapi .MinerAPIVersion0 ) {
356
- return "" , fmt .Errorf ("remote service API version didn't match (expected %s, remote %s)" , lapi .MinerAPIVersion0 , v .APIVersion )
316
+ return "" , "" , fmt .Errorf ("remote service API version didn't match (expected %s, remote %s)" , lapi .MinerAPIVersion0 , v .APIVersion )
317
+ }
318
+
319
+ miner , err := api .ActorAddress (ctx )
320
+ if err != nil {
321
+ return "" , "" , fmt .Errorf ("getting miner address: %w" , err )
357
322
}
358
323
359
- return ai , nil
324
+ return ai , miner . String (), nil
360
325
}
0 commit comments