From aa9972c3403f9bb6897d33e64eb3169703888023 Mon Sep 17 00:00:00 2001 From: tediou5 Date: Fri, 14 Mar 2025 15:19:21 +0800 Subject: [PATCH] feat(miner): remove batch balancer-related functionality (#12919) Closes: https://github.com/filecoin-project/lotus/issues/12902 --- CHANGELOG.md | 1 + chain/actors/policy/policy.go | 6 +++++- chain/actors/policy/policy.go.template | 6 ++++++ cli/spcli/sectors.go | 1 + cmd/lotus-sim/simulation/stages/precommit_stage.go | 3 +-- documentation/en/default-lotus-miner-config.toml | 2 ++ node/config/def.go | 4 ++-- node/config/doc_gen.go | 6 ++++-- node/config/types.go | 2 ++ storage/pipeline/commit_batch.go | 3 ++- storage/pipeline/precommit_batch.go | 13 +++++++------ storage/pipeline/sealiface/config.go | 4 +++- storage/pipeline/terminate_batch.go | 1 + storage/wdpost/wdpost_run.go | 1 + 14 files changed, 38 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5f4d04ec20..17530a880ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - `DealIDs` has now been removed from the public API's `SectorOnChainInfo` (was deprecated in FIP-0079) - Removed `--only-cc` from `spcli sectors extend` command - Change circulating supply calculation for calibnet, butterflynet and 2k for nv25 upgrade; see ([filecoin-project/lotus#12938](https://github.com/filecoin-project/lotus/pull/12938)) for more information +- feat(miner): remove batch balancer-related functionality ([filecoin-project/lotus#12919](https://github.com/filecoin-project/lotus/pull/12919)) # UNRELEASED v.1.32.0 diff --git a/chain/actors/policy/policy.go b/chain/actors/policy/policy.go index 17c966a2002..6efa7096bb8 100644 --- a/chain/actors/policy/policy.go +++ b/chain/actors/policy/policy.go @@ -79,6 +79,7 @@ const ( SealRandomnessLookback = ChainFinality PaychSettleDelay = paych16.SettleDelay MaxPreCommitRandomnessLookback = builtin16.EpochsInDay + SealRandomnessLookback + DeclarationsMax = 3000 ) var ( @@ -842,6 +843,9 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) { } } +// GetDeclarationsMax is deprecated +// +// DEPRECATED: remove after nv25 (FIP 0100) func GetDeclarationsMax(nwVer network.Version) (int, error) { v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { @@ -912,7 +916,7 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) { case actorstypes.Version16: - return miner16.DeclarationsMax, nil + return DeclarationsMax, nil default: return 0, xerrors.Errorf("unsupported network version") diff --git a/chain/actors/policy/policy.go.template b/chain/actors/policy/policy.go.template index 6ce6d76d5bd..76c92103e5e 100644 --- a/chain/actors/policy/policy.go.template +++ b/chain/actors/policy/policy.go.template @@ -37,6 +37,7 @@ const ( SealRandomnessLookback = ChainFinality PaychSettleDelay = paych{{.latestVersion}}.SettleDelay MaxPreCommitRandomnessLookback = builtin{{.latestVersion}}.EpochsInDay + SealRandomnessLookback + DeclarationsMax = 3000 ) var ( @@ -283,6 +284,9 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) { } } +// GetDeclarationsMax is deprecated +// +// DEPRECATED: remove after nv25 (FIP 0100) func GetDeclarationsMax(nwVer network.Version) (int, error) { v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { @@ -294,6 +298,8 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) { {{if (eq . 0)}} // TODO: Should we instead error here since the concept doesn't exist yet? return miner{{.}}.AddressedPartitionsMax, nil + {{else if (ge . 16)}} + return DeclarationsMax, nil {{else}} return miner{{.}}.DeclarationsMax, nil {{end}} diff --git a/cli/spcli/sectors.go b/cli/spcli/sectors.go index 1ba66a67c90..02c03487898 100644 --- a/cli/spcli/sectors.go +++ b/cli/spcli/sectors.go @@ -864,6 +864,7 @@ func SectorsExtendCmd(getActorAddress ActorAddressGetter) *cli.Command { return err } + // TODO: remove after nv25 (FIP 0100) declMax, err := policy.GetDeclarationsMax(nv) if err != nil { return err diff --git a/cmd/lotus-sim/simulation/stages/precommit_stage.go b/cmd/lotus-sim/simulation/stages/precommit_stage.go index 5cbe77a4f42..87b39ae6696 100644 --- a/cmd/lotus-sim/simulation/stages/precommit_stage.go +++ b/cmd/lotus-sim/simulation/stages/precommit_stage.go @@ -13,7 +13,6 @@ import ( "github.com/filecoin-project/go-state-types/builtin" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" - miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/aerrors" @@ -27,7 +26,7 @@ import ( const ( minPreCommitBatchSize = 1 - maxPreCommitBatchSize = miner5.PreCommitSectorBatchMaxSize + maxPreCommitBatchSize = 256 ) type PreCommitStage struct { diff --git a/documentation/en/default-lotus-miner-config.toml b/documentation/en/default-lotus-miner-config.toml index e03f9579af9..f92591aa578 100644 --- a/documentation/en/default-lotus-miner-config.toml +++ b/documentation/en/default-lotus-miner-config.toml @@ -381,6 +381,7 @@ # env var: LOTUS_SEALING_COMMITBATCHSLACK #CommitBatchSlack = "1h0m0s" + # DEPRECATED: remove after nv25 (FIP 0100) # network BaseFee below which to stop doing precommit batching, instead # sending precommit messages to the chain individually. When the basefee is # below this threshold, precommit messages will get sent out immediately. @@ -389,6 +390,7 @@ # env var: LOTUS_SEALING_BATCHPRECOMMITABOVEBASEFEE #BatchPreCommitAboveBaseFee = "0.00000000032 FIL" + # DEPRECATED: remove after nv25 (FIP 0100) # network BaseFee below which to stop doing commit aggregation, instead # submitting proofs to the chain individually # diff --git a/node/config/def.go b/node/config/def.go index e6bdc04bdb8..27c905cb26c 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -122,8 +122,8 @@ func DefaultStorageMiner() *StorageMiner { AvailableBalanceBuffer: types.FIL(big.Zero()), DisableCollateralFallback: false, - MaxPreCommitBatch: miner5.PreCommitSectorBatchMaxSize, // up to 256 sectors - PreCommitBatchWait: Duration(24 * time.Hour), // this should be less than 31.5 hours, which is the expiration of a precommit ticket + MaxPreCommitBatch: 256, + PreCommitBatchWait: Duration(24 * time.Hour), // this should be less than 31.5 hours, which is the expiration of a precommit ticket // XXX snap deals wait deals slack if first PreCommitBatchSlack: Duration(3 * time.Hour), // time buffer for forceful batch submission before sectors/deals in batch would start expiring, higher value will lower the chances for message fail due to expiration diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index 4d13a93ad26..7225d34b69f 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -1083,7 +1083,8 @@ This is useful for forcing all deals to be assigned as snap deals to sectors mar Name: "BatchPreCommitAboveBaseFee", Type: "types.FIL", - Comment: `network BaseFee below which to stop doing precommit batching, instead + Comment: `DEPRECATED: remove after nv25 (FIP 0100) +network BaseFee below which to stop doing precommit batching, instead sending precommit messages to the chain individually. When the basefee is below this threshold, precommit messages will get sent out immediately.`, }, @@ -1091,7 +1092,8 @@ below this threshold, precommit messages will get sent out immediately.`, Name: "AggregateAboveBaseFee", Type: "types.FIL", - Comment: `network BaseFee below which to stop doing commit aggregation, instead + Comment: `DEPRECATED: remove after nv25 (FIP 0100) +network BaseFee below which to stop doing commit aggregation, instead submitting proofs to the chain individually`, }, { diff --git a/node/config/types.go b/node/config/types.go index ce15554fb05..8ad2df37e10 100644 --- a/node/config/types.go +++ b/node/config/types.go @@ -294,11 +294,13 @@ type SealingConfig struct { // time buffer for forceful batch submission before sectors/deals in batch would start expiring CommitBatchSlack Duration + // DEPRECATED: remove after nv25 (FIP 0100) // network BaseFee below which to stop doing precommit batching, instead // sending precommit messages to the chain individually. When the basefee is // below this threshold, precommit messages will get sent out immediately. BatchPreCommitAboveBaseFee types.FIL + // DEPRECATED: remove after nv25 (FIP 0100) // network BaseFee below which to stop doing commit aggregation, instead // submitting proofs to the chain individually AggregateAboveBaseFee types.FIL diff --git a/storage/pipeline/commit_batch.go b/storage/pipeline/commit_batch.go index cf3d2e8e57a..f2d6d68ff1c 100644 --- a/storage/pipeline/commit_batch.go +++ b/storage/pipeline/commit_batch.go @@ -233,7 +233,8 @@ func (b *CommitBatcher) maybeStartBatch(notif bool) ([]sealiface.CommitBatchRes, individual := (total < cfg.MinCommitBatch) || (total < miner.MinAggregatedSectors) || blackedOut() || !cfg.AggregateCommits - if !individual && !cfg.AggregateAboveBaseFee.Equals(big.Zero()) { + // TODO: remove after nv25 (FIP 0100) + if !individual && !cfg.AggregateAboveBaseFee.Equals(big.Zero()) && nv < network.Version25 { if ts.MinTicketBlock().ParentBaseFee.LessThan(cfg.AggregateAboveBaseFee) { individual = true } diff --git a/storage/pipeline/precommit_batch.go b/storage/pipeline/precommit_batch.go index 492f3ffdd77..d18ffd6c725 100644 --- a/storage/pipeline/precommit_batch.go +++ b/storage/pipeline/precommit_batch.go @@ -196,8 +196,14 @@ func (b *PreCommitBatcher) maybeStartBatch(notif bool) ([]sealiface.PreCommitBat return nil, err } + nv, err := b.api.StateNetworkVersion(b.mctx, ts.Key()) + if err != nil { + return nil, xerrors.Errorf("couldn't get network version: %w", err) + } + + // TODO: remove after nv25 (FIP 0100) curBasefeeLow := false - if !cfg.BatchPreCommitAboveBaseFee.Equals(big.Zero()) && ts.MinTicketBlock().ParentBaseFee.LessThan(cfg.BatchPreCommitAboveBaseFee) { + if !cfg.BatchPreCommitAboveBaseFee.Equals(big.Zero()) && ts.MinTicketBlock().ParentBaseFee.LessThan(cfg.BatchPreCommitAboveBaseFee) && nv < network.Version25 { curBasefeeLow = true } @@ -207,11 +213,6 @@ func (b *PreCommitBatcher) maybeStartBatch(notif bool) ([]sealiface.PreCommitBat return nil, nil } - nv, err := b.api.StateNetworkVersion(b.mctx, ts.Key()) - if err != nil { - return nil, xerrors.Errorf("couldn't get network version: %w", err) - } - // For precommits the only method to precommit sectors after nv21(22?) is to use the new precommit_batch2 method // So we always batch res, err := b.processBatch(cfg, ts.Key(), ts.MinTicketBlock().ParentBaseFee, nv) diff --git a/storage/pipeline/sealiface/config.go b/storage/pipeline/sealiface/config.go index 2ac6e0d588f..69def52042c 100644 --- a/storage/pipeline/sealiface/config.go +++ b/storage/pipeline/sealiface/config.go @@ -52,7 +52,9 @@ type Config struct { CommitBatchWait time.Duration CommitBatchSlack time.Duration - AggregateAboveBaseFee abi.TokenAmount + // DEPRECATED: remove after nv25 (FIP 0100) + AggregateAboveBaseFee abi.TokenAmount + // DEPRECATED: remove after nv25 (FIP 0100) BatchPreCommitAboveBaseFee abi.TokenAmount MaxSectorProveCommitsSubmittedPerEpoch uint64 diff --git a/storage/pipeline/terminate_batch.go b/storage/pipeline/terminate_batch.go index b52cb3d7979..1964dfad12c 100644 --- a/storage/pipeline/terminate_batch.go +++ b/storage/pipeline/terminate_batch.go @@ -197,6 +197,7 @@ func (b *TerminateBatcher) processBatch(notif, after bool) (*cid.Cid, error) { break } + // TODO: remove after nv25 (FIP 0100) if len(params.Terminations) >= miner.DeclarationsMax { break } diff --git a/storage/wdpost/wdpost_run.go b/storage/wdpost/wdpost_run.go index 11eff7ee3a2..df3b8f636f6 100644 --- a/storage/wdpost/wdpost_run.go +++ b/storage/wdpost/wdpost_run.go @@ -544,6 +544,7 @@ func (s *WindowPoStScheduler) BatchPartitions(partitions []api.Partition, nv net return nil, xerrors.Errorf("getting sectors per partition: %w", err) } + // TODO: remove after nv25 (FIP 0100) // Also respect the AddressedPartitionsMax (which is the same as DeclarationsMax (which is all really just MaxPartitionsPerDeadline)) declMax, err := policy.GetDeclarationsMax(nv) if err != nil {