2019-07-03 16:59:49 +00:00
package config
2019-10-30 16:38:39 +00:00
import (
"encoding"
"time"
2020-04-03 04:54:07 +00:00
2020-06-18 20:15:18 +00:00
"github.com/ipfs/go-cid"
2021-06-08 13:43:43 +00:00
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
2021-05-19 12:32:41 +00:00
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
2020-08-12 17:47:00 +00:00
"github.com/filecoin-project/lotus/chain/types"
2020-08-17 13:39:33 +00:00
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
2019-10-30 16:38:39 +00:00
)
2019-07-03 16:59:49 +00:00
2019-10-30 16:38:39 +00:00
// Common is common config between full node and miner
type Common struct {
2019-07-04 12:04:39 +00:00
API API
2021-03-09 21:33:01 +00:00
Backup Backup
2019-07-04 12:04:39 +00:00
Libp2p Libp2p
2020-05-04 15:30:54 +00:00
Pubsub Pubsub
2019-10-30 16:38:39 +00:00
}
2019-10-11 02:45:45 +00:00
2019-10-30 16:38:39 +00:00
// FullNode is a full node config
type FullNode struct {
Common
2021-03-02 13:45:36 +00:00
Client Client
Metrics Metrics
Wallet Wallet
Fees FeeConfig
Chainstore Chainstore
2019-07-03 16:59:49 +00:00
}
2019-11-12 17:59:38 +00:00
// // Common
2021-03-09 21:33:01 +00:00
type Backup struct {
DisableMetadataLog bool
}
2020-07-11 08:55:13 +00:00
// StorageMiner is a miner config
2019-10-30 16:38:39 +00:00
type StorageMiner struct {
Common
2019-11-12 17:59:38 +00:00
2020-08-12 17:47:00 +00:00
Dealmaking DealmakingConfig
2020-08-18 14:20:31 +00:00
Sealing SealingConfig
2020-08-12 17:47:00 +00:00
Storage sectorstorage . SealerConfig
Fees MinerFeeConfig
2020-12-02 18:58:00 +00:00
Addresses MinerAddressConfig
2020-06-11 18:29:59 +00:00
}
2020-06-11 19:15:28 +00:00
type DealmakingConfig struct {
2020-12-02 06:21:29 +00:00
ConsiderOnlineStorageDeals bool
ConsiderOfflineStorageDeals bool
ConsiderOnlineRetrievalDeals bool
ConsiderOfflineRetrievalDeals bool
ConsiderVerifiedStorageDeals bool
ConsiderUnverifiedStorageDeals bool
PieceCidBlocklist [ ] cid . Cid
ExpectedSealDuration Duration
2021-01-08 15:28:38 +00:00
// The amount of time to wait for more deals to arrive before
// publishing
2021-02-01 09:23:05 +00:00
PublishMsgPeriod Duration
2021-01-08 15:28:38 +00:00
// The maximum number of deals to include in a single PublishStorageDeals
// message
2021-02-01 09:23:05 +00:00
MaxDealsPerPublishMsg uint64
2021-03-02 09:24:57 +00:00
// The maximum collateral that the provider will put up against a deal,
// as a multiplier of the minimum collateral bound
MaxProviderCollateralMultiplier uint64
2020-07-30 17:36:31 +00:00
2020-10-16 15:30:55 +00:00
Filter string
RetrievalFilter string
2019-10-30 16:38:39 +00:00
}
2020-08-18 14:20:31 +00:00
type SealingConfig struct {
// 0 = no limit
MaxWaitDealsSectors uint64
// includes failed, 0 = no limit
MaxSealingSectors uint64
2020-08-18 17:52:20 +00:00
// includes failed, 0 = no limit
MaxSealingSectorsForDeals uint64
2020-08-18 14:20:31 +00:00
WaitDealsDelay Duration
2021-01-18 13:26:03 +00:00
2021-01-26 16:50:31 +00:00
AlwaysKeepUnsealedCopy bool
2021-02-03 13:01:56 +00:00
2021-06-11 09:41:28 +00:00
// Run sector finalization before submitting sector proof to the chain
FinalizeEarly bool
2021-05-25 14:20:49 +00:00
// enable / disable precommit batching (takes effect after nv13)
2021-05-25 14:26:59 +00:00
BatchPreCommits bool
2021-05-25 14:20:49 +00:00
// maximum precommit batch size - batches will be sent immediately above this size
2021-05-25 14:26:59 +00:00
MaxPreCommitBatch int
MinPreCommitBatch int
2021-05-25 14:20:49 +00:00
// how long to wait before submitting a batch after crossing the minimum batch size
2021-05-25 14:26:59 +00:00
PreCommitBatchWait Duration
2021-06-09 22:04:11 +00:00
// time buffer for forceful batch submission before sectors/deal in batch would start expiring
2021-05-18 14:51:06 +00:00
PreCommitBatchSlack Duration
2021-05-25 14:20:49 +00:00
// enable / disable commit aggregation (takes effect after nv13)
2021-03-10 15:16:44 +00:00
AggregateCommits bool
2021-05-25 14:20:49 +00:00
// maximum batched commit size - batches will be sent immediately above this size
2021-05-25 14:26:59 +00:00
MinCommitBatch int
MaxCommitBatch int
2021-05-25 14:20:49 +00:00
// how long to wait before submitting a batch after crossing the minimum batch size
2021-05-25 14:26:59 +00:00
CommitBatchWait Duration
2021-06-09 22:04:11 +00:00
// time buffer for forceful batch submission before sectors/deals in batch would start expiring
2021-05-18 14:51:06 +00:00
CommitBatchSlack Duration
TerminateBatchMax uint64
TerminateBatchMin uint64
TerminateBatchWait Duration
2021-03-10 15:16:44 +00:00
2021-01-18 13:26:03 +00:00
// Keep this many sectors in sealing pipeline, start CC if needed
// todo TargetSealingSectors uint64
// todo TargetSectors - stop auto-pleding new sectors after this many sectors are sealed, default CC upgrade for deals sectors if above
2020-08-18 14:20:31 +00:00
}
2021-06-08 13:43:43 +00:00
type BatchFeeConfig struct {
Base types . FIL
PerSector types . FIL
}
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 ) ) )
}
2020-08-12 17:47:00 +00:00
type MinerFeeConfig struct {
2021-06-08 13:43:43 +00:00
MaxPreCommitGasFee types . FIL
MaxCommitGasFee types . FIL
// maxBatchFee = maxBase + maxPerSector * nSectors
MaxPreCommitBatchGasFee BatchFeeConfig
MaxCommitBatchGasFee BatchFeeConfig
2021-01-12 23:42:01 +00:00
MaxTerminateGasFee types . FIL
2020-10-02 16:34:50 +00:00
MaxWindowPoStGasFee types . FIL
MaxPublishDealsFee types . FIL
MaxMarketBalanceAddFee types . FIL
2020-08-12 17:47:00 +00:00
}
2020-12-02 18:58:00 +00:00
type MinerAddressConfig struct {
PreCommitControl [ ] string
CommitControl [ ] string
2021-02-17 15:56:32 +00:00
TerminateControl [ ] string
// DisableOwnerFallback disables usage of the owner address for messages
// sent automatically
DisableOwnerFallback bool
// DisableWorkerFallback disables usage of the worker address for messages
2021-03-09 22:42:08 +00:00
// sent automatically, if control addresses are configured.
// A control address that doesn't have enough funds will still be chosen
// over the worker address if this flag is set.
2021-02-17 15:56:32 +00:00
DisableWorkerFallback bool
2020-12-02 18:58:00 +00:00
}
2019-07-03 16:59:49 +00:00
// API contains configs for API endpoint
type API struct {
2020-04-03 04:54:07 +00:00
ListenAddress string
RemoteListenAddress string
Timeout Duration
2019-07-03 16:59:49 +00:00
}
2019-07-04 12:04:39 +00:00
// Libp2p contains configs for libp2p
type Libp2p struct {
2020-06-09 00:03:11 +00:00
ListenAddresses [ ] string
AnnounceAddresses [ ] string
NoAnnounceAddresses [ ] string
BootstrapPeers [ ] string
ProtectedPeers [ ] string
2019-12-17 16:09:43 +00:00
ConnMgrLow uint
ConnMgrHigh uint
ConnMgrGrace Duration
2019-07-04 12:04:39 +00:00
}
2020-05-04 15:30:54 +00:00
type Pubsub struct {
2021-03-06 18:05:32 +00:00
Bootstrapper bool
DirectPeers [ ] string
IPColocationWhitelist [ ] string
RemoteTracer string
2020-05-04 15:30:54 +00:00
}
2021-03-02 13:45:36 +00:00
type Chainstore struct {
2021-02-27 13:20:14 +00:00
EnableSplitstore bool
Splitstore Splitstore
}
type Splitstore struct {
2021-02-28 07:59:11 +00:00
HotStoreType string
TrackingStoreType string
2021-03-02 00:47:21 +00:00
MarkSetType string
2021-02-27 13:20:14 +00:00
EnableFullCompaction bool
EnableGC bool // EXPERIMENTAL
Archival bool
2021-02-26 13:45:30 +00:00
}
2019-11-12 17:59:38 +00:00
// // Full Node
2019-10-11 02:45:45 +00:00
type Metrics struct {
2020-05-04 15:30:54 +00:00
Nickname string
HeadNotifs bool
2019-10-11 02:45:45 +00:00
}
2020-04-29 23:51:55 +00:00
type Client struct {
2020-11-24 22:32:30 +00:00
UseIpfs bool
IpfsOnlineMode bool
IpfsMAddr string
IpfsUseForRetrieval bool
SimultaneousTransfers uint64
2020-04-29 23:51:55 +00:00
}
2020-09-05 19:36:32 +00:00
type Wallet struct {
RemoteBackend string
2020-10-10 22:08:12 +00:00
EnableLedger bool
DisableLocal bool
2020-09-05 19:36:32 +00:00
}
2020-10-29 19:50:04 +00:00
type FeeConfig struct {
DefaultMaxFee types . FIL
}
2019-10-30 16:38:39 +00:00
func defCommon ( ) Common {
return Common {
2019-07-03 16:59:49 +00:00
API : API {
2020-04-03 23:56:52 +00:00
ListenAddress : "/ip4/127.0.0.1/tcp/1234/http" ,
Timeout : Duration ( 30 * time . Second ) ,
2019-07-03 16:59:49 +00:00
} ,
2019-07-04 12:04:39 +00:00
Libp2p : Libp2p {
ListenAddresses : [ ] string {
2019-07-09 13:46:55 +00:00
"/ip4/0.0.0.0/tcp/0" ,
"/ip6/::/tcp/0" ,
2019-07-04 12:04:39 +00:00
} ,
2020-06-09 00:03:11 +00:00
AnnounceAddresses : [ ] string { } ,
NoAnnounceAddresses : [ ] string { } ,
2019-12-17 16:09:43 +00:00
2019-12-18 15:38:58 +00:00
ConnMgrLow : 150 ,
ConnMgrHigh : 180 ,
2019-12-17 16:09:43 +00:00
ConnMgrGrace : Duration ( 20 * time . Second ) ,
2019-07-04 12:04:39 +00:00
} ,
2020-05-04 15:30:54 +00:00
Pubsub : Pubsub {
Bootstrapper : false ,
DirectPeers : nil ,
2020-08-24 15:01:52 +00:00
RemoteTracer : "/dns4/pubsub-tracer.filecoin.io/tcp/4001/p2p/QmTd6UvR47vUidRNZ1ZKXHrAFhqTJAD27rKL9XYghEKgKX" ,
2020-05-04 15:30:54 +00:00
} ,
2019-07-03 16:59:49 +00:00
}
2019-10-30 16:38:39 +00:00
2019-07-03 16:59:49 +00:00
}
2021-04-16 22:35:40 +00:00
var DefaultDefaultMaxFee = types . MustParseFIL ( "0.07" )
2020-11-24 22:32:30 +00:00
var DefaultSimultaneousTransfers = uint64 ( 20 )
2020-10-29 19:50:04 +00:00
2020-04-03 23:56:52 +00:00
// DefaultFullNode returns the default config
2019-10-30 16:38:39 +00:00
func DefaultFullNode ( ) * FullNode {
return & FullNode {
Common : defCommon ( ) ,
2020-10-29 19:50:04 +00:00
Fees : FeeConfig {
DefaultMaxFee : DefaultDefaultMaxFee ,
} ,
2020-11-24 22:32:30 +00:00
Client : Client {
SimultaneousTransfers : DefaultSimultaneousTransfers ,
} ,
2021-03-02 13:45:36 +00:00
Chainstore : Chainstore {
EnableSplitstore : false ,
Splitstore : Splitstore {
HotStoreType : "badger" ,
} ,
} ,
2019-10-30 16:38:39 +00:00
}
}
func DefaultStorageMiner ( ) * StorageMiner {
2019-11-12 18:31:17 +00:00
cfg := & StorageMiner {
2019-10-30 16:38:39 +00:00
Common : defCommon ( ) ,
2020-08-18 16:27:28 +00:00
2020-08-18 14:20:31 +00:00
Sealing : SealingConfig {
2020-08-18 17:52:20 +00:00
MaxWaitDealsSectors : 2 , // 64G with 32G sectors
MaxSealingSectors : 0 ,
MaxSealingSectorsForDeals : 0 ,
2020-09-10 18:34:18 +00:00
WaitDealsDelay : Duration ( time . Hour * 6 ) ,
2021-03-08 15:35:46 +00:00
AlwaysKeepUnsealedCopy : true ,
2021-06-11 09:45:20 +00:00
FinalizeEarly : false ,
2021-03-10 15:16:44 +00:00
2021-05-18 14:51:06 +00:00
BatchPreCommits : true ,
2021-06-09 22:04:11 +00:00
MinPreCommitBatch : 1 , // we must have at least one precommit to batch
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
2021-05-18 14:51:06 +00:00
AggregateCommits : true ,
2021-06-09 22:04:11 +00:00
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
2021-05-18 14:51:06 +00:00
2021-05-18 11:30:47 +00:00
TerminateBatchMin : 1 ,
TerminateBatchMax : 100 ,
2021-05-18 14:51:06 +00:00
TerminateBatchWait : Duration ( 5 * time . Minute ) ,
2020-08-18 14:20:31 +00:00
} ,
2019-11-12 17:59:38 +00:00
2020-03-27 20:08:06 +00:00
Storage : sectorstorage . SealerConfig {
2020-08-17 09:39:29 +00:00
AllowAddPiece : true ,
2020-03-24 19:38:00 +00:00
AllowPreCommit1 : true ,
AllowPreCommit2 : true ,
AllowCommit : true ,
2020-05-26 08:20:32 +00:00
AllowUnseal : true ,
2020-07-24 15:07:31 +00:00
// Default to 10 - tcp should still be able to figure this out, and
// it's the ratio between 10gbit / 1gbit
ParallelFetchLimit : 10 ,
2020-03-24 19:38:00 +00:00
} ,
2020-06-11 19:15:28 +00:00
Dealmaking : DealmakingConfig {
2020-12-02 06:21:29 +00:00
ConsiderOnlineStorageDeals : true ,
ConsiderOfflineStorageDeals : true ,
ConsiderOnlineRetrievalDeals : true ,
ConsiderOfflineRetrievalDeals : true ,
ConsiderVerifiedStorageDeals : true ,
ConsiderUnverifiedStorageDeals : true ,
PieceCidBlocklist : [ ] cid . Cid { } ,
2020-07-12 17:54:53 +00:00
// TODO: It'd be nice to set this based on sector size
2021-03-02 09:24:57 +00:00
ExpectedSealDuration : Duration ( time . Hour * 24 ) ,
PublishMsgPeriod : Duration ( time . Hour ) ,
MaxDealsPerPublishMsg : 8 ,
MaxProviderCollateralMultiplier : 2 ,
2020-06-11 19:15:28 +00:00
} ,
2020-07-06 18:39:26 +00:00
2020-08-12 17:47:00 +00:00
Fees : MinerFeeConfig {
2021-06-08 13:43:43 +00:00
MaxPreCommitGasFee : types . MustParseFIL ( "0.025" ) ,
MaxCommitGasFee : types . MustParseFIL ( "0.05" ) ,
MaxPreCommitBatchGasFee : BatchFeeConfig {
2021-06-22 16:05:14 +00:00
Base : types . MustParseFIL ( "0" ) ,
PerSector : types . MustParseFIL ( "0.02" ) ,
2021-06-08 13:43:43 +00:00
} ,
MaxCommitBatchGasFee : BatchFeeConfig {
2021-06-22 16:05:14 +00:00
Base : types . MustParseFIL ( "0" ) ,
PerSector : types . MustParseFIL ( "0.03" ) , // enough for 6 agg and 1nFIL base fee
2021-06-08 13:43:43 +00:00
} ,
2021-01-12 23:42:01 +00:00
MaxTerminateGasFee : types . MustParseFIL ( "0.5" ) ,
2020-10-15 00:46:47 +00:00
MaxWindowPoStGasFee : types . MustParseFIL ( "5" ) ,
MaxPublishDealsFee : types . MustParseFIL ( "0.05" ) ,
MaxMarketBalanceAddFee : types . MustParseFIL ( "0.007" ) ,
2020-08-12 17:47:00 +00:00
} ,
2020-12-02 20:54:38 +00:00
Addresses : MinerAddressConfig {
PreCommitControl : [ ] string { } ,
CommitControl : [ ] string { } ,
} ,
2019-10-30 16:38:39 +00:00
}
2019-11-12 21:42:26 +00:00
cfg . Common . API . ListenAddress = "/ip4/127.0.0.1/tcp/2345/http"
2020-04-03 23:56:52 +00:00
cfg . Common . API . RemoteListenAddress = "127.0.0.1:2345"
2019-11-12 18:31:17 +00:00
return cfg
2019-10-30 16:38:39 +00:00
}
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
2019-07-03 16:59:49 +00:00
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
}
2019-10-30 16:38:39 +00:00
func ( dur Duration ) MarshalText ( ) ( [ ] byte , error ) {
d := time . Duration ( dur )
return [ ] byte ( d . String ( ) ) , nil
}