Skip to content

Commit 5cebd3b

Browse files
committed
refactor config
1 parent a7073d8 commit 5cebd3b

File tree

15 files changed

+264
-315
lines changed

15 files changed

+264
-315
lines changed

cmd/curio/tasks/tasks.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,12 @@ func addSealingTasks(
250250

251251
var sp *seal.SealPoller
252252
var slr *ffi.SealCalls
253+
var err error
253254
if hasAnySealingTask {
254-
sp = seal.NewPoller(db, full, cfg)
255+
sp, err = seal.NewPoller(db, full, cfg)
256+
if err != nil {
257+
return nil, xerrors.Errorf("creating seal poller: %w", err)
258+
}
255259
go sp.RunPoller(ctx)
256260

257261
slr = must.One(slrLazy.Val())

deps/config/doc_gen.go

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

deps/config/types.go

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/filecoin-project/go-state-types/abi"
77
"github.com/filecoin-project/go-state-types/big"
8-
"github.com/filecoin-project/go-state-types/builtin/v15/miner"
98

109
"github.com/filecoin-project/lotus/chain/types"
1110
)
@@ -76,14 +75,14 @@ func DefaultCurioConfig() *CurioConfig {
7675
},
7776
Batching: CurioBatchingConfig{
7877
PreCommit: PreCommitBatchingConfig{
79-
MaxPreCommitBatch: miner.PreCommitSectorBatchMaxSize,
80-
PreCommitBatchSlack: Duration(6 * time.Hour),
81-
BaseFeeThreshold: types.MustParseFIL("0.005"),
78+
BaseFeeThreshold: types.MustParseFIL("0.005"),
79+
Timeout: Duration(4 * time.Hour),
80+
Slack: Duration(6 * time.Hour),
8281
},
8382
Commit: CommitBatchingConfig{
84-
MaxCommitBatch: miner.MaxAggregatedSectors,
85-
CommitBatchSlack: Duration(1 * time.Hour),
8683
BaseFeeThreshold: types.MustParseFIL("0.005"),
84+
Timeout: Duration(1 * time.Hour),
85+
Slack: Duration(1 * time.Hour),
8786
},
8887
},
8988
}
@@ -531,31 +530,23 @@ type CurioBatchingConfig struct {
531530
}
532531

533532
type PreCommitBatchingConfig struct {
534-
// Enable / Disable Precommit aggregation
535-
AggregatePreCommits bool
533+
// Base fee value below which we should try to send Precommit messages immediately
534+
BaseFeeThreshold types.FIL
536535

537-
// Maximum precommit batch size - batches will be sent immediately above this size if BaseFeeThreshold is higher
538-
// than the current base fee. If not then we will wait batch if forced due to PreCommitBatchSlack
539-
MaxPreCommitBatch int
536+
// Maximum amount of time any given sector in the batch can wait for the batch to accumulate
537+
Timeout Duration
540538

541539
// Time buffer for forceful batch submission before sectors/deal in batch would start expiring
542-
PreCommitBatchSlack Duration
543-
544-
// Base fee value below which we should try to send Precommit message. This will be ignored if PreCommitBatchSlack has reached
545-
BaseFeeThreshold types.FIL
540+
Slack Duration
546541
}
547542

548543
type CommitBatchingConfig struct {
549-
// Enable / Disable commit aggregation
550-
AggregateCommits bool
544+
// Base fee value below which we should try to send Commit messages immediately
545+
BaseFeeThreshold types.FIL
551546

552-
// Maximum batched commit size - batches will be sent immediately above this size if BaseFeeThreshold is higher
553-
// // than the current base fee. If not then we will wait batch if forced due to CommitBatchSlack
554-
MaxCommitBatch int
547+
// Maximum amount of time any given sector in the batch can wait for the batch to accumulate
548+
Timeout Duration
555549

556550
// Time buffer for forceful batch submission before sectors/deals in batch would start expiring
557-
CommitBatchSlack Duration
558-
559-
// Base fee value below which we should try to send Commit message. This will be ignored if CommitBatchSlack has reached
560-
BaseFeeThreshold types.FIL
551+
Slack Duration
561552
}

deps/deps.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,6 @@ func (deps *Deps) PopulateRemainingDeps(ctx context.Context, cctx *cli.Context,
227227
if err != nil {
228228
return xerrors.Errorf("populate config: %w", err)
229229
}
230-
if deps.Cfg.Batching.Commit.AggregateCommits && deps.Cfg.Batching.Commit.MaxCommitBatch < miner.MinAggregatedSectors {
231-
return xerrors.Errorf("commit batch size less than minimum required for aggregation")
232-
}
233230
}
234231

235232
log.Debugw("config", "config", deps.Cfg)

documentation/en/configuration/default-curio-configuration.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -505,47 +505,35 @@ description: The default curio configuration
505505

506506
[Batching]
507507
[Batching.PreCommit]
508-
# Enable / Disable Precommit aggregation
508+
# Base fee value below which we should try to send Precommit messages immediately
509509
#
510-
# type: bool
511-
#AggregatePreCommits = false
510+
# type: types.FIL
511+
#BaseFeeThreshold = "0.005 FIL"
512512

513-
# Maximum precommit batch size - batches will be sent immediately above this size if BaseFeeThreshold is higher
514-
# than the current base fee. If not then we will wait batch if forced due to PreCommitBatchSlack
513+
# Maximum amount of time any given sector in the batch can wait for the batch to accumulate
515514
#
516-
# type: int
517-
#MaxPreCommitBatch = 256
515+
# type: Duration
516+
#Timeout = "4h0m0s"
518517

519518
# Time buffer for forceful batch submission before sectors/deal in batch would start expiring
520519
#
521520
# type: Duration
522-
#PreCommitBatchSlack = "6h0m0s"
521+
#Slack = "6h0m0s"
523522

524-
# Base fee value below which we should try to send Precommit message. This will be ignored if PreCommitBatchSlack has reached
523+
[Batching.Commit]
524+
# Base fee value below which we should try to send Commit messages immediately
525525
#
526526
# type: types.FIL
527527
#BaseFeeThreshold = "0.005 FIL"
528528

529-
[Batching.Commit]
530-
# Enable / Disable commit aggregation
531-
#
532-
# type: bool
533-
#AggregateCommits = false
534-
535-
# Maximum batched commit size - batches will be sent immediately above this size if BaseFeeThreshold is higher
536-
# // than the current base fee. If not then we will wait batch if forced due to CommitBatchSlack
529+
# Maximum amount of time any given sector in the batch can wait for the batch to accumulate
537530
#
538-
# type: int
539-
#MaxCommitBatch = 819
531+
# type: Duration
532+
#Timeout = "1h0m0s"
540533

541534
# Time buffer for forceful batch submission before sectors/deals in batch would start expiring
542535
#
543536
# type: Duration
544-
#CommitBatchSlack = "1h0m0s"
545-
546-
# Base fee value below which we should try to send Commit message. This will be ignored if CommitBatchSlack has reached
547-
#
548-
# type: types.FIL
549-
#BaseFeeThreshold = "0.005 FIL"
537+
#Slack = "1h0m0s"
550538

551539
```

harmony/harmonydb/sql/20231217-sdr-pipeline.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ create table sectors_sdr_pipeline (
3636
after_tree_r bool not null default false,
3737

3838
-- synthetic proofs (Added in 20240617-synthetic-proofs.sql)
39-
-- task_id_synth bigint,
40-
-- after_synth bool not null default false,
39+
-- task_id_synth bigint,
40+
-- after_synth bool not null default false,
41+
42+
-- precommit_ready_at (Added in 20241210-sdr-batching.sql)
4143

4244
-- precommit message sending
4345
precommit_msg_cid text,
@@ -66,6 +68,8 @@ create table sectors_sdr_pipeline (
6668
task_id_move_storage bigint,
6769
after_move_storage bool not null default false,
6870

71+
-- commit_ready_at (Added in 20241210-sdr-batching.sql)
72+
6973
-- Commit message sending
7074
commit_msg_cid text,
7175

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE sectors_sdr_pipeline ADD COLUMN precommit_ready_at TIMESTAMPTZ;
2+
ALTER TABLE sectors_sdr_pipeline ADD COLUMN commit_ready_at TIMESTAMPTZ;

itests/curio_test.go

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ func TestCurioHappyPath(t *testing.T) {
158158

159159
require.Contains(t, baseCfg.Addresses[0].MinerAddresses, maddr.String())
160160

161+
//baseCfg.Batching.PreCommit.BaseFeeThreshold = types.MustParseFIL("100")
162+
baseCfg.Batching.PreCommit.Timeout = config.Duration(5 * time.Minute)
163+
//baseCfg.Batching.Commit.BaseFeeThreshold = types.MustParseFIL("100")
164+
baseCfg.Batching.Commit.Timeout = config.Duration(5 * time.Minute)
165+
161166
temp := os.TempDir()
162167
dir, err := os.MkdirTemp(temp, "curio")
163168
require.NoError(t, err)
@@ -182,22 +187,7 @@ func TestCurioHappyPath(t *testing.T) {
182187
spt, err := miner2.PreferredSealProofTypeFromWindowPoStType(nv, wpt, false)
183188
require.NoError(t, err)
184189

185-
num, err := seal.AllocateSectorNumbers(ctx, full, db, maddr, 1, func(tx *harmonydb.Tx, numbers []abi.SectorNumber) (bool, error) {
186-
for _, n := range numbers {
187-
_, err := tx.Exec("insert into sectors_sdr_pipeline (sp_id, sector_number, reg_seal_proof) values ($1, $2, $3)", mid, n, spt)
188-
if err != nil {
189-
return false, xerrors.Errorf("inserting into sectors_sdr_pipeline: %w", err)
190-
}
191-
}
192-
return true, nil
193-
})
194-
require.NoError(t, err)
195-
require.Len(t, num, 1)
196-
197-
spt, err = miner2.PreferredSealProofTypeFromWindowPoStType(nv, wpt, true)
198-
require.NoError(t, err)
199-
200-
num, err = seal.AllocateSectorNumbers(ctx, full, db, maddr, 1, func(tx *harmonydb.Tx, numbers []abi.SectorNumber) (bool, error) {
190+
num, err := seal.AllocateSectorNumbers(ctx, full, db, maddr, 5, func(tx *harmonydb.Tx, numbers []abi.SectorNumber) (bool, error) {
201191
for _, n := range numbers {
202192
_, err := tx.Exec("insert into sectors_sdr_pipeline (sp_id, sector_number, reg_seal_proof) values ($1, $2, $3)", mid, n, spt)
203193
if err != nil {
@@ -207,7 +197,22 @@ func TestCurioHappyPath(t *testing.T) {
207197
return true, nil
208198
})
209199
require.NoError(t, err)
210-
require.Len(t, num, 1)
200+
require.Len(t, num, 5)
201+
202+
//spt, err = miner2.PreferredSealProofTypeFromWindowPoStType(nv, wpt, true)
203+
//require.NoError(t, err)
204+
//
205+
//num, err = seal.AllocateSectorNumbers(ctx, full, db, maddr, 0, func(tx *harmonydb.Tx, numbers []abi.SectorNumber) (bool, error) {
206+
// for _, n := range numbers {
207+
// _, err := tx.Exec("insert into sectors_sdr_pipeline (sp_id, sector_number, reg_seal_proof) values ($1, $2, $3)", mid, n, spt)
208+
// if err != nil {
209+
// return false, xerrors.Errorf("inserting into sectors_sdr_pipeline: %w", err)
210+
// }
211+
// }
212+
// return true, nil
213+
//})
214+
//require.NoError(t, err)
215+
//require.Len(t, num, 0)
211216
// TODO: add DDO deal, f05 deal 2 MiB each in the sector
212217

213218
var sectorParamsArr []struct {
@@ -225,13 +230,13 @@ func TestCurioHappyPath(t *testing.T) {
225230
FROM sectors_sdr_pipeline
226231
WHERE after_commit_msg_success = True`)
227232
require.NoError(t, err)
228-
return len(sectorParamsArr) == 2
233+
return len(sectorParamsArr) == 6
229234
}, 10*time.Minute, 1*time.Second, "sector did not finish sealing in 5 minutes")
230235

231-
require.Equal(t, sectorParamsArr[0].SectorNumber, int64(0))
232-
require.Equal(t, sectorParamsArr[0].SpID, int64(mid))
233-
require.Equal(t, sectorParamsArr[1].SectorNumber, int64(1))
234-
require.Equal(t, sectorParamsArr[1].SpID, int64(mid))
236+
//require.Equal(t, sectorParamsArr[0].SectorNumber, int64(0))
237+
//require.Equal(t, sectorParamsArr[0].SpID, int64(mid))
238+
//require.Equal(t, sectorParamsArr[1].SectorNumber, int64(1))
239+
//require.Equal(t, sectorParamsArr[1].SpID, int64(mid))
235240

236241
_ = capi.Shutdown(ctx)
237242

0 commit comments

Comments
 (0)