d7076778e2
This commit removes badger from the deal-making processes, and moves to a new architecture with the dagstore as the cental component on the miner-side, and CARv2s on the client-side. Every deal that has been handed off to the sealing subsystem becomes a shard in the dagstore. Shards are mounted via the LotusMount, which teaches the dagstore how to load the related piece when serving retrievals. When the miner starts the Lotus for the first time with this patch, we will perform a one-time migration of all active deals into the dagstore. This is a lightweight process, and it consists simply of registering the shards in the dagstore. Shards are backed by the unsealed copy of the piece. This is currently a CARv1. However, the dagstore keeps CARv2 indices for all pieces, so when it's time to acquire a shard to serve a retrieval, the unsealed CARv1 is joined with its index (safeguarded by the dagstore), to form a read-only blockstore, thus taking the place of the monolithic badger. Data transfers have been adjusted to interface directly with CARv2 files. On inbound transfers (client retrievals, miner storage deals), we stream the received data into a CARv2 ReadWrite blockstore. On outbound transfers (client storage deals, miner retrievals), we serve the data off a CARv2 ReadOnly blockstore. Client-side imports are managed by the refactored *imports.Manager component (when not using IPFS integration). Just like it before, we use the go-filestore library to avoid duplicating the data from the original file in the resulting UnixFS DAG (concretely the leaves). However, the target of those imports are what we call "ref-CARv2s": CARv2 files placed under the `$LOTUS_PATH/imports` directory, containing the intermediate nodes in full, and the leaves as positional references to the original file on disk. Client-side retrievals are placed into CARv2 files in the location: `$LOTUS_PATH/retrievals`. A new set of `Dagstore*` JSON-RPC operations and `lotus-miner dagstore` subcommands have been introduced on the miner-side to inspect and manage the dagstore. Despite moving to a CARv2-backed system, the IPFS integration has been respected, and it continues to be possible to make storage deals with data held in an IPFS node, and to perform retrievals directly into an IPFS node. NOTE: because the "staging" and "client" Badger blockstores are no longer used, existing imports on the client will be rendered useless. On startup, Lotus will enumerate all imports and print WARN statements on the log for each import that needs to be reimported. These log lines contain these messages: - import lacks carv2 path; import will not work; please reimport - import has missing/broken carv2; please reimport At the end, we will print a "sanity check completed" message indicating the count of imports found, and how many were deemed broken. Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com> Co-authored-by: Dirk McCormick <dirkmdev@gmail.com> Co-authored-by: Raúl Kripalani <raul@protocol.ai> Co-authored-by: Dirk McCormick <dirkmdev@gmail.com>
227 lines
7.1 KiB
Go
227 lines
7.1 KiB
Go
package config
|
|
|
|
import (
|
|
"encoding"
|
|
"time"
|
|
|
|
"github.com/ipfs/go-cid"
|
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
"github.com/filecoin-project/go-state-types/big"
|
|
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
|
|
)
|
|
|
|
const (
|
|
// RetrievalPricingDefault configures the node to use the default retrieval pricing policy.
|
|
RetrievalPricingDefaultMode = "default"
|
|
// RetrievalPricingExternal configures the node to use the external retrieval pricing script
|
|
// configured by the user.
|
|
RetrievalPricingExternalMode = "external"
|
|
)
|
|
|
|
func (b *BatchFeeConfig) FeeForSectors(nSectors int) abi.TokenAmount {
|
|
return big.Add(big.Int(b.Base), big.Mul(big.NewInt(int64(nSectors)), big.Int(b.PerSector)))
|
|
}
|
|
|
|
func defCommon() Common {
|
|
return Common{
|
|
API: API{
|
|
ListenAddress: "/ip4/127.0.0.1/tcp/1234/http",
|
|
Timeout: Duration(30 * time.Second),
|
|
},
|
|
Libp2p: Libp2p{
|
|
ListenAddresses: []string{
|
|
"/ip4/0.0.0.0/tcp/0",
|
|
"/ip6/::/tcp/0",
|
|
},
|
|
AnnounceAddresses: []string{},
|
|
NoAnnounceAddresses: []string{},
|
|
|
|
ConnMgrLow: 150,
|
|
ConnMgrHigh: 180,
|
|
ConnMgrGrace: Duration(20 * time.Second),
|
|
},
|
|
Pubsub: Pubsub{
|
|
Bootstrapper: false,
|
|
DirectPeers: nil,
|
|
},
|
|
}
|
|
|
|
}
|
|
|
|
var DefaultDefaultMaxFee = types.MustParseFIL("0.07")
|
|
var DefaultSimultaneousTransfers = uint64(20)
|
|
|
|
// DefaultFullNode returns the default config
|
|
func DefaultFullNode() *FullNode {
|
|
return &FullNode{
|
|
Common: defCommon(),
|
|
Fees: FeeConfig{
|
|
DefaultMaxFee: DefaultDefaultMaxFee,
|
|
},
|
|
Client: Client{
|
|
SimultaneousTransfers: DefaultSimultaneousTransfers,
|
|
},
|
|
Chainstore: Chainstore{
|
|
EnableSplitstore: false,
|
|
Splitstore: Splitstore{
|
|
ColdStoreType: "universal",
|
|
HotStoreType: "badger",
|
|
MarkSetType: "map",
|
|
|
|
HotStoreFullGCFrequency: 20,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func DefaultStorageMiner() *StorageMiner {
|
|
cfg := &StorageMiner{
|
|
Common: defCommon(),
|
|
|
|
Sealing: SealingConfig{
|
|
MaxWaitDealsSectors: 2, // 64G with 32G sectors
|
|
MaxSealingSectors: 0,
|
|
MaxSealingSectorsForDeals: 0,
|
|
WaitDealsDelay: Duration(time.Hour * 6),
|
|
AlwaysKeepUnsealedCopy: true,
|
|
FinalizeEarly: false,
|
|
|
|
CollateralFromMinerBalance: false,
|
|
AvailableBalanceBuffer: types.FIL(big.Zero()),
|
|
DisableCollateralFallback: false,
|
|
|
|
BatchPreCommits: true,
|
|
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
|
|
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
|
|
|
|
CommittedCapacitySectorLifetime: Duration(builtin.EpochDurationSeconds * policy.GetMaxSectorExpirationExtension()),
|
|
|
|
AggregateCommits: true,
|
|
MinCommitBatch: miner5.MinAggregatedSectors, // per FIP13, we must have at least four proofs to aggregate, where 4 is the cross over point where aggregation wins out on single provecommit gas costs
|
|
MaxCommitBatch: miner5.MaxAggregatedSectors, // maximum 819 sectors, this is the maximum aggregation per FIP13
|
|
CommitBatchWait: Duration(24 * time.Hour), // this can be up to 30 days
|
|
CommitBatchSlack: Duration(1 * 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
|
|
|
|
AggregateAboveBaseFee: types.FIL(types.BigMul(types.PicoFil, types.NewInt(150))), // 0.15 nFIL
|
|
|
|
TerminateBatchMin: 1,
|
|
TerminateBatchMax: 100,
|
|
TerminateBatchWait: Duration(5 * time.Minute),
|
|
},
|
|
|
|
Storage: sectorstorage.SealerConfig{
|
|
AllowAddPiece: true,
|
|
AllowPreCommit1: true,
|
|
AllowPreCommit2: true,
|
|
AllowCommit: true,
|
|
AllowUnseal: true,
|
|
|
|
// Default to 10 - tcp should still be able to figure this out, and
|
|
// it's the ratio between 10gbit / 1gbit
|
|
ParallelFetchLimit: 10,
|
|
|
|
// By default use the hardware resource filtering strategy.
|
|
ResourceFiltering: sectorstorage.ResourceFilteringHardware,
|
|
},
|
|
|
|
Dealmaking: DealmakingConfig{
|
|
ConsiderOnlineStorageDeals: true,
|
|
ConsiderOfflineStorageDeals: true,
|
|
ConsiderOnlineRetrievalDeals: true,
|
|
ConsiderOfflineRetrievalDeals: true,
|
|
ConsiderVerifiedStorageDeals: true,
|
|
ConsiderUnverifiedStorageDeals: true,
|
|
PieceCidBlocklist: []cid.Cid{},
|
|
// TODO: It'd be nice to set this based on sector size
|
|
MaxDealStartDelay: Duration(time.Hour * 24 * 14),
|
|
ExpectedSealDuration: Duration(time.Hour * 24),
|
|
PublishMsgPeriod: Duration(time.Hour),
|
|
MaxDealsPerPublishMsg: 8,
|
|
MaxProviderCollateralMultiplier: 2,
|
|
|
|
SimultaneousTransfers: DefaultSimultaneousTransfers,
|
|
|
|
RetrievalPricing: &RetrievalPricing{
|
|
Strategy: RetrievalPricingDefaultMode,
|
|
Default: &RetrievalPricingDefault{
|
|
VerifiedDealsFreeTransfer: true,
|
|
},
|
|
External: &RetrievalPricingExternal{
|
|
Path: "",
|
|
},
|
|
},
|
|
},
|
|
|
|
Subsystems: MinerSubsystemConfig{
|
|
EnableMining: true,
|
|
EnableSealing: true,
|
|
EnableSectorStorage: true,
|
|
EnableMarkets: true,
|
|
},
|
|
|
|
Fees: MinerFeeConfig{
|
|
MaxPreCommitGasFee: types.MustParseFIL("0.025"),
|
|
MaxCommitGasFee: types.MustParseFIL("0.05"),
|
|
|
|
MaxPreCommitBatchGasFee: BatchFeeConfig{
|
|
Base: types.MustParseFIL("0"),
|
|
PerSector: types.MustParseFIL("0.02"),
|
|
},
|
|
MaxCommitBatchGasFee: BatchFeeConfig{
|
|
Base: types.MustParseFIL("0"),
|
|
PerSector: types.MustParseFIL("0.03"), // enough for 6 agg and 1nFIL base fee
|
|
},
|
|
|
|
MaxTerminateGasFee: types.MustParseFIL("0.5"),
|
|
MaxWindowPoStGasFee: types.MustParseFIL("5"),
|
|
MaxPublishDealsFee: types.MustParseFIL("0.05"),
|
|
MaxMarketBalanceAddFee: types.MustParseFIL("0.007"),
|
|
},
|
|
|
|
Addresses: MinerAddressConfig{
|
|
PreCommitControl: []string{},
|
|
CommitControl: []string{},
|
|
TerminateControl: []string{},
|
|
DealPublishControl: []string{},
|
|
},
|
|
|
|
DAGStore: DAGStoreConfig{
|
|
MaxConcurrentIndex: 5,
|
|
MaxConcurrencyStorageCalls: 100,
|
|
GCInterval: Duration(1 * time.Minute),
|
|
},
|
|
}
|
|
cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http"
|
|
cfg.Common.API.RemoteListenAddress = "127.0.0.1:2345"
|
|
return cfg
|
|
}
|
|
|
|
var _ encoding.TextMarshaler = (*Duration)(nil)
|
|
var _ encoding.TextUnmarshaler = (*Duration)(nil)
|
|
|
|
// Duration is a wrapper type for time.Duration
|
|
// for decoding and encoding from/to TOML
|
|
type Duration time.Duration
|
|
|
|
// UnmarshalText implements interface for TOML decoding
|
|
func (dur *Duration) UnmarshalText(text []byte) error {
|
|
d, err := time.ParseDuration(string(text))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
*dur = Duration(d)
|
|
return err
|
|
}
|
|
|
|
func (dur Duration) MarshalText() ([]byte, error) {
|
|
d := time.Duration(dur)
|
|
return []byte(d.String()), nil
|
|
}
|