Skip to content

Commit 90dd8d2

Browse files
authored
Merge pull request #621 from data-preservation-programs/feat/pdp-scheduling-runner
Implement PDP schedule execution path and config wiring
2 parents d8088ee + 079efe2 commit 90dd8d2

5 files changed

Lines changed: 472 additions & 54 deletions

File tree

cmd/run/dealpusher.go

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package run
22

33
import (
4+
"time"
5+
46
"github.com/cockroachdb/errors"
57
"github.com/data-preservation-programs/singularity/database"
68
"github.com/data-preservation-programs/singularity/service"
@@ -25,6 +27,26 @@ var DealPusherCmd = &cli.Command{
2527
Aliases: []string{"M"},
2628
DefaultText: "Unlimited",
2729
},
30+
&cli.IntFlag{
31+
Name: "pdp-batch-size",
32+
Usage: "Number of roots to include in each PDP add-roots transaction",
33+
Value: 128,
34+
},
35+
&cli.Uint64Flag{
36+
Name: "pdp-gas-limit",
37+
Usage: "Gas limit for PDP on-chain transactions",
38+
Value: 5000000,
39+
},
40+
&cli.Uint64Flag{
41+
Name: "pdp-confirmation-depth",
42+
Usage: "Number of block confirmations required for PDP transactions",
43+
Value: 5,
44+
},
45+
&cli.DurationFlag{
46+
Name: "pdp-poll-interval",
47+
Usage: "Polling interval for PDP transaction confirmation checks",
48+
Value: 30 * time.Second,
49+
},
2850
},
2951
Action: func(c *cli.Context) error {
3052
db, closer, err := database.OpenFromCLI(c)
@@ -39,7 +61,24 @@ var DealPusherCmd = &cli.Command{
3961
return errors.WithStack(err)
4062
}
4163

42-
dm, err := dealpusher.NewDealPusher(db, c.String("lotus-api"), c.String("lotus-token"), c.Uint("deal-attempts"), c.Uint("max-replication-factor"))
64+
pdpCfg := dealpusher.PDPSchedulingConfig{
65+
BatchSize: c.Int("pdp-batch-size"),
66+
GasLimit: c.Uint64("pdp-gas-limit"),
67+
ConfirmationDepth: c.Uint64("pdp-confirmation-depth"),
68+
PollingInterval: c.Duration("pdp-poll-interval"),
69+
}
70+
if err := pdpCfg.Validate(); err != nil {
71+
return errors.WithStack(err)
72+
}
73+
74+
dm, err := dealpusher.NewDealPusher(
75+
db,
76+
c.String("lotus-api"),
77+
c.String("lotus-token"),
78+
c.Uint("deal-attempts"),
79+
c.Uint("max-replication-factor"),
80+
dealpusher.WithPDPSchedulingConfig(pdpCfg),
81+
)
4382
if err != nil {
4483
return errors.WithStack(err)
4584
}

docs/en/cli-reference/run/deal-pusher.md

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service/dealpusher/dealpusher.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/data-preservation-programs/singularity/service/healthcheck"
1717
"github.com/data-preservation-programs/singularity/util"
1818
"github.com/data-preservation-programs/singularity/util/keystore"
19-
"github.com/filecoin-project/go-address"
2019
"github.com/filecoin-project/go-state-types/crypto"
2120
"github.com/google/uuid"
2221
"github.com/ipfs/go-cid"
@@ -458,39 +457,6 @@ func (d *DealPusher) resolveScheduleDealType(schedule *model.Schedule) model.Dea
458457
return d.scheduleDealTypeResolver(schedule)
459458
}
460459

461-
func defaultPDPSchedulingConfig() PDPSchedulingConfig {
462-
return PDPSchedulingConfig{
463-
BatchSize: 128,
464-
GasLimit: 5_000_000,
465-
ConfirmationDepth: 5,
466-
PollingInterval: 30 * time.Second,
467-
}
468-
}
469-
470-
// inferScheduleDealType uses the provider address protocol as the discriminator:
471-
// delegated (f4) addresses are FEVM contracts that speak PDP, everything else
472-
// is a traditional miner actor that speaks market deals.
473-
func inferScheduleDealType(schedule *model.Schedule) model.DealType {
474-
if schedule == nil {
475-
return model.DealTypeMarket
476-
}
477-
providerAddr, err := address.NewFromString(schedule.Provider)
478-
if err != nil {
479-
return model.DealTypeMarket
480-
}
481-
if providerAddr.Protocol() == address.Delegated {
482-
return model.DealTypePDP
483-
}
484-
return model.DealTypeMarket
485-
}
486-
487-
func (d *DealPusher) runPDPSchedule(_ context.Context, _ *model.Schedule) (model.ScheduleState, error) {
488-
if d.pdpProofSetManager == nil || d.pdpTxConfirmer == nil {
489-
return model.ScheduleError, errors.New("pdp scheduling dependencies are not configured")
490-
}
491-
return model.ScheduleError, errors.New("pdp scheduling path is not implemented")
492-
}
493-
494460
func NewDealPusher(db *gorm.DB, lotusURL string,
495461
lotusToken string, numAttempts uint, maxReplicas uint, opts ...Option,
496462
) (*DealPusher, error) {

0 commit comments

Comments
 (0)