Skip to content

Commit 54a45db

Browse files
authored
remove one-last-thing guided-setup step (#640)
* remove one-last-thing guided-setup step * linty stuff
1 parent 5aa0c82 commit 54a45db

File tree

4 files changed

+48
-152
lines changed

4 files changed

+48
-152
lines changed

cmd/curio/guidedsetup/guidedsetup.go

Lines changed: 1 addition & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@
66
package guidedsetup
77

88
import (
9-
"bytes"
109
"context"
1110
"crypto/rand"
1211
"encoding/base64"
13-
"encoding/json"
1412
"fmt"
1513
"io"
16-
"math/bits"
17-
"net/http"
1814
"os"
1915
"os/signal"
2016
"path"
@@ -35,15 +31,13 @@ import (
3531
"github.com/filecoin-project/go-state-types/abi"
3632

3733
"github.com/filecoin-project/curio/api"
38-
"github.com/filecoin-project/curio/build"
3934
"github.com/filecoin-project/curio/cmd/curio/internal/translations"
4035
"github.com/filecoin-project/curio/deps"
4136
"github.com/filecoin-project/curio/deps/config"
4237
"github.com/filecoin-project/curio/harmony/harmonydb"
4338
"github.com/filecoin-project/curio/lib/createminer"
4439

4540
lapi "github.com/filecoin-project/lotus/api"
46-
"github.com/filecoin-project/lotus/chain/types"
4741
cliutil "github.com/filecoin-project/lotus/cli/util"
4842
"github.com/filecoin-project/lotus/node/repo"
4943
)
@@ -177,7 +171,6 @@ var migrationSteps = []migrationStep{
177171
yugabyteConnect, // Miner is updated
178172
configToDB, // work on base configuration migration.
179173
doc,
180-
oneLastThing,
181174
complete,
182175
afterRan,
183176
}
@@ -189,7 +182,6 @@ var newMinerSteps = []newMinerStep{
189182
stepCreateActor,
190183
stepNewMinerConfig,
191184
doc,
192-
oneLastThing,
193185
completeInit,
194186
afterRan,
195187
}
@@ -200,7 +192,6 @@ var nonSPSteps = []nonSPStep{
200192
stepPresteps,
201193
stepNewMinerConfig,
202194
doc,
203-
oneLastThing,
204195
completeNonSP,
205196
afterRan,
206197
}
@@ -318,101 +309,6 @@ func configToDB(d *MigrationData) {
318309
}
319310
}
320311

321-
// bucket returns the power's 4 highest bits (rounded down).
322-
func bucket(power *lapi.MinerPower) uint64 {
323-
rawQAP := power.TotalPower.QualityAdjPower.Uint64()
324-
magnitude := lo.Max([]int{bits.Len64(rawQAP), 5})
325-
326-
// shifting erases resolution so we cannot distinguish SPs of similar scales.
327-
return rawQAP >> (uint64(magnitude) - 4) << (uint64(magnitude - 4))
328-
}
329-
330-
type uploadType int
331-
332-
const uploadTypeIndividual uploadType = 0
333-
const uploadTypeAggregate uploadType = 1
334-
335-
// const uploadTypeHint uploadType = 2
336-
const uploadTypeNothing uploadType = 3
337-
338-
func oneLastThing(d *MigrationData) {
339-
d.say(section, "The Curio team wants to improve the software you use. Tell the team you're using `%s`.", "curio")
340-
i, _, err := (&promptui.Select{
341-
Label: d.T("Select what you want to share with the Curio team."),
342-
Items: []string{
343-
d.T("Individual Data: Miner ID, Curio version, chain (%s or %s). Signed.", "mainnet", "calibration"),
344-
d.T("Aggregate-Anonymous: version, chain, and Miner power (bucketed)."),
345-
d.T("Hint: I am someone running Curio on whichever chain."),
346-
d.T("Nothing.")},
347-
Templates: d.selectTemplates,
348-
}).Run()
349-
preference := uploadType(i)
350-
if err != nil {
351-
d.say(notice, "Aborting remaining steps.", err.Error())
352-
os.Exit(1)
353-
}
354-
if preference != uploadTypeNothing {
355-
msgMap := map[string]any{
356-
"domain": "curio-newuser",
357-
"net": build.BuildTypeString(),
358-
}
359-
if preference == uploadTypeIndividual || preference == uploadTypeAggregate {
360-
// articles of incorporation
361-
power, err := d.full.StateMinerPower(context.Background(), d.MinerID, types.EmptyTSK)
362-
if err != nil {
363-
d.say(notice, "Error getting miner power: %s", err.Error())
364-
os.Exit(1)
365-
}
366-
msgMap["version"] = build.BuildVersion
367-
msgMap["net"] = build.BuildType
368-
msgMap["power"] = map[uploadType]uint64{
369-
uploadTypeIndividual: power.MinerPower.QualityAdjPower.Uint64(),
370-
uploadTypeAggregate: bucket(power)}[preference]
371-
372-
if preference == uploadTypeIndividual { // Sign it
373-
msgMap["miner_id"] = d.MinerID
374-
msg, err := json.Marshal(msgMap)
375-
if err != nil {
376-
d.say(notice, "Error marshalling message: %s", err.Error())
377-
os.Exit(1)
378-
}
379-
mi, err := d.full.StateMinerInfo(context.Background(), d.MinerID, types.EmptyTSK)
380-
if err != nil {
381-
d.say(notice, "Error getting miner info: %s", err.Error())
382-
os.Exit(1)
383-
}
384-
sig, err := d.full.WalletSign(context.Background(), mi.Worker, msg)
385-
if err != nil {
386-
d.say(notice, "Error signing message: %s", err.Error())
387-
os.Exit(1)
388-
}
389-
msgMap["signature"] = base64.StdEncoding.EncodeToString(sig.Data)
390-
}
391-
}
392-
msg, err := json.Marshal(msgMap)
393-
if err != nil {
394-
d.say(notice, "Error marshalling message: %s", err.Error())
395-
os.Exit(1)
396-
}
397-
398-
resp, err := http.DefaultClient.Post(DeveloperFocusRequestURL, "application/json", bytes.NewReader(msg))
399-
if err != nil {
400-
d.say(notice, "Error sending message: %s", err.Error())
401-
}
402-
if resp != nil {
403-
defer func() { _ = resp.Body.Close() }()
404-
if resp.StatusCode != 200 {
405-
b, err := io.ReadAll(resp.Body)
406-
if err == nil {
407-
d.say(notice, "Error sending message: Status %s, Message: ", resp.Status, string(b))
408-
}
409-
} else {
410-
stepCompleted(d, d.T("Message sent."))
411-
}
412-
}
413-
}
414-
}
415-
416312
func doc(d *MigrationData) {
417313
d.say(plain, "Documentation: ")
418314
d.say(plain, "The '%s' layer stores common configuration. All curio instances can include it in their %s argument.", "base", "--layers")
@@ -445,7 +341,7 @@ func readMinerConfig(d *MigrationData) {
445341
return err
446342
}
447343

448-
dirs := map[string]struct{}{"~/.lotusminer": struct{}{}, "~/.lotus-miner-local-net": struct{}{}}
344+
dirs := map[string]struct{}{"~/.lotusminer": {}, "~/.lotus-miner-local-net": {}}
449345
if v := os.Getenv("LOTUS_MINER_PATH"); v != "" {
450346
dirs[v] = struct{}{}
451347
}

lib/paths/local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ func (st *Local) ReadSnapVanillaProof(ctx context.Context, sr storiface.SectorRe
11941194

11951195
var supraC1Token = make(chan struct{}, 1)
11961196

1197-
func (st *Local) supraPoRepVanillaProof(src storiface.SectorPaths, sr storiface.SectorRef, sealed, unsealed cid.Cid, ticket abi.SealRandomness, seed abi.InteractiveSealRandomness) ([]byte, error) {
1197+
func (st *Local) supraPoRepVanillaProof(src storiface.SectorPaths, sr storiface.SectorRef, _, unsealed cid.Cid, ticket abi.SealRandomness, seed abi.InteractiveSealRandomness) ([]byte, error) {
11981198
batchMetaPath := filepath.Join(src.Cache, BatchMetaFile)
11991199
bmdata, err := os.ReadFile(batchMetaPath)
12001200
if err != nil {

0 commit comments

Comments
 (0)