paramfetch: Only pull necessary params
This commit is contained in:
parent
b8646405ce
commit
3daf9103a8
@ -39,7 +39,7 @@ type fetch struct {
|
||||
errs []error
|
||||
}
|
||||
|
||||
func GetParams(storage bool, tests bool) error {
|
||||
func GetParams(storageSize uint64) error {
|
||||
if err := os.Mkdir(paramdir, 0755); err != nil && !os.IsExist(err) {
|
||||
return err
|
||||
}
|
||||
@ -54,10 +54,7 @@ func GetParams(storage bool, tests bool) error {
|
||||
ft := &fetch{}
|
||||
|
||||
for name, info := range params {
|
||||
if !(SupportedSectorSize(info.SectorSize) || (tests && info.SectorSize == 1<<10)) {
|
||||
continue
|
||||
}
|
||||
if !storage && strings.HasSuffix(name, ".params") {
|
||||
if storageSize != info.SectorSize && strings.HasSuffix(name, ".params") {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -83,8 +80,8 @@ func (ft *fetch) maybeFetchAsync(name string, info paramFile) {
|
||||
return
|
||||
}
|
||||
|
||||
ft.fetchLk.Lock()
|
||||
defer ft.fetchLk.Unlock()
|
||||
/*ft.fetchLk.Lock()
|
||||
defer ft.fetchLk.Unlock()*/
|
||||
|
||||
if err := doFetch(path, info); err != nil {
|
||||
ft.errs = append(ft.errs, xerrors.Errorf("fetching file %s failed: %w", path, err))
|
||||
|
@ -10,17 +10,13 @@ var fetchParamCmd = &cli.Command{
|
||||
Name: "fetch-params",
|
||||
Usage: "Fetch proving parameters",
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "only-verify-keys",
|
||||
Usage: "only download the verify keys",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "include-test-params",
|
||||
Usage: "download params used for tests",
|
||||
&cli.Uint64Flag{
|
||||
Name: "proving-params",
|
||||
Usage: "download params used creating proofs for given size",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
err := build.GetParams(!cctx.Bool("only-verify-keys"), cctx.Bool("include-test-params"))
|
||||
err := build.GetParams(cctx.Uint64("proving-params"))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
if err := build.GetParams(true, false); err != nil {
|
||||
if err := build.GetParams(sectorSize); err != nil {
|
||||
return xerrors.Errorf("getting params: %w", err)
|
||||
}
|
||||
sb, err := sectorbuilder.New(cfg, mds)
|
||||
|
@ -48,7 +48,7 @@ func PreSeal(maddr address.Address, ssize uint64, sectors int, sbroot string, pr
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := build.GetParams(true, false); err != nil {
|
||||
if err := build.GetParams(ssize); err != nil {
|
||||
return nil, xerrors.Errorf("getting params: %w", err)
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,10 @@ var initCmd = &cli.Command{
|
||||
Action: func(cctx *cli.Context) error {
|
||||
log.Info("Initializing lotus storage miner")
|
||||
|
||||
ssize := cctx.Uint64("sector-size")
|
||||
|
||||
log.Info("Checking proof parameters")
|
||||
if err := build.GetParams(true, false); err != nil {
|
||||
if err := build.GetParams(ssize); err != nil {
|
||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||
}
|
||||
|
||||
@ -152,7 +154,7 @@ var initCmd = &cli.Command{
|
||||
}
|
||||
|
||||
oldsb, err := sectorbuilder.New(§orbuilder.Config{
|
||||
SectorSize: 1024,
|
||||
SectorSize: ssize,
|
||||
WorkerThreads: 2,
|
||||
SealedDir: filepath.Join(pssb, "sealed"),
|
||||
CacheDir: filepath.Join(pssb, "cache"),
|
||||
@ -164,7 +166,7 @@ var initCmd = &cli.Command{
|
||||
}
|
||||
|
||||
nsb, err := sectorbuilder.New(§orbuilder.Config{
|
||||
SectorSize: 1024,
|
||||
SectorSize: ssize,
|
||||
WorkerThreads: 2,
|
||||
SealedDir: filepath.Join(lr.Path(), "sealed"),
|
||||
CacheDir: filepath.Join(lr.Path(), "cache"),
|
||||
|
@ -41,10 +41,6 @@ var runCmd = &cli.Command{
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
if err := build.GetParams(true, false); err != nil {
|
||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||
}
|
||||
|
||||
if !cctx.Bool("enable-gpu-proving") {
|
||||
os.Setenv("BELLMAN_NO_GPU", "true")
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ var DaemonCmd = &cli.Command{
|
||||
return xerrors.Errorf("repo init error: %w", err)
|
||||
}
|
||||
|
||||
if err := build.GetParams(false, false); err != nil {
|
||||
if err := build.GetParams(0); err != nil {
|
||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ func TestSealAndVerify(t *testing.T) {
|
||||
|
||||
build.SectorSizes = []uint64{sectorSize}
|
||||
|
||||
if err := build.GetParams(true, true); err != nil {
|
||||
if err := build.GetParams(sectorSize); err != nil {
|
||||
t.Fatalf("%+v", err)
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ func TestSealPoStNoCommit(t *testing.T) {
|
||||
|
||||
build.SectorSizes = []uint64{sectorSize}
|
||||
|
||||
if err := build.GetParams(true, true); err != nil {
|
||||
if err := build.GetParams(sectorSize); err != nil {
|
||||
t.Fatalf("%+v", err)
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ func TestSealAndVerify2(t *testing.T) {
|
||||
|
||||
build.SectorSizes = []uint64{sectorSize}
|
||||
|
||||
if err := build.GetParams(true, true); err != nil {
|
||||
if err := build.GetParams(sectorSize); err != nil {
|
||||
t.Fatalf("%+v", err)
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,7 @@ const (
|
||||
RegisterClientValidatorKey
|
||||
|
||||
// storage miner
|
||||
GetParamsKey
|
||||
HandleDealsKey
|
||||
HandleRetrievalKey
|
||||
RunSectorServiceKey
|
||||
@ -250,6 +251,7 @@ func Online() Option {
|
||||
Override(new(*deals.Provider), deals.NewProvider),
|
||||
Override(RegisterProviderValidatorKey, modules.RegisterProviderValidator),
|
||||
Override(HandleRetrievalKey, modules.HandleRetrieval),
|
||||
Override(GetParamsKey, modules.GetParams),
|
||||
Override(HandleDealsKey, modules.HandleDeals),
|
||||
Override(new(gen.ElectionPoStProver), storage.NewElectionPoStProver),
|
||||
Override(new(*miner.Miner), modules.SetupBlockProducer),
|
||||
|
@ -44,6 +44,14 @@ func minerAddrFromDS(ds dtypes.MetadataDS) (address.Address, error) {
|
||||
return address.NewFromBytes(maddrb)
|
||||
}
|
||||
|
||||
func GetParams(sbc *sectorbuilder.Config) error {
|
||||
if err := build.GetParams(sbc.SectorSize); err != nil {
|
||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func SectorBuilderConfig(storagePath string, threads uint) func(dtypes.MetadataDS, api.FullNode) (*sectorbuilder.Config, error) {
|
||||
return func(ds dtypes.MetadataDS, api api.FullNode) (*sectorbuilder.Config, error) {
|
||||
minerAddr, err := minerAddrFromDS(ds)
|
||||
|
Loading…
Reference in New Issue
Block a user