lotus/node/config/def.go

220 lines
4.8 KiB
Go
Raw Normal View History

package config
import (
"encoding"
"time"
"github.com/ipfs/go-cid"
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"
)
// Common is common config between full node and miner
type Common struct {
API API
Libp2p Libp2p
2020-05-04 15:30:54 +00:00
Pubsub Pubsub
}
2019-10-11 02:45:45 +00:00
// FullNode is a full node config
type FullNode struct {
Common
Client Client
2019-10-11 02:45:45 +00:00
Metrics Metrics
2020-09-05 19:36:32 +00:00
Wallet Wallet
}
2019-11-12 17:59:38 +00:00
// // Common
// StorageMiner is a miner config
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
}
type DealmakingConfig struct {
ConsiderOnlineStorageDeals bool
ConsiderOfflineStorageDeals bool
ConsiderOnlineRetrievalDeals bool
ConsiderOfflineRetrievalDeals bool
PieceCidBlocklist []cid.Cid
ExpectedSealDuration Duration
2020-07-30 17:36:31 +00:00
Filter string
RetrievalFilter string
}
2020-08-18 14:20:31 +00:00
type SealingConfig struct {
// 0 = no limit
MaxWaitDealsSectors uint64
// includes failed, 0 = no limit
MaxSealingSectors uint64
// includes failed, 0 = no limit
MaxSealingSectorsForDeals uint64
2020-08-18 14:20:31 +00:00
WaitDealsDelay Duration
}
2020-08-12 17:47:00 +00:00
type MinerFeeConfig struct {
2020-10-02 16:34:50 +00:00
MaxPreCommitGasFee types.FIL
MaxCommitGasFee types.FIL
MaxWindowPoStGasFee types.FIL
MaxPublishDealsFee types.FIL
MaxMarketBalanceAddFee types.FIL
2020-08-12 17:47:00 +00:00
}
// API contains configs for API endpoint
type API struct {
ListenAddress string
RemoteListenAddress string
Timeout Duration
}
// Libp2p contains configs for libp2p
type Libp2p struct {
ListenAddresses []string
AnnounceAddresses []string
NoAnnounceAddresses []string
BootstrapPeers []string
ProtectedPeers []string
2019-12-17 16:09:43 +00:00
ConnMgrLow uint
ConnMgrHigh uint
ConnMgrGrace Duration
}
2020-05-04 15:30:54 +00:00
type Pubsub struct {
Bootstrapper bool
DirectPeers []string
RemoteTracer string
}
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
}
type Client struct {
UseIpfs bool
IpfsOnlineMode bool
IpfsMAddr string
IpfsUseForRetrieval bool
}
2020-09-05 19:36:32 +00:00
type Wallet struct {
RemoteBackend string
EnableLedger bool
DisableLocal bool
2020-09-05 19:36:32 +00:00
}
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{},
2019-12-17 16:09:43 +00:00
ConnMgrLow: 150,
ConnMgrHigh: 180,
2019-12-17 16:09:43 +00:00
ConnMgrGrace: Duration(20 * time.Second),
},
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
},
}
}
// DefaultFullNode returns the default config
func DefaultFullNode() *FullNode {
return &FullNode{
Common: defCommon(),
}
}
func DefaultStorageMiner() *StorageMiner {
cfg := &StorageMiner{
Common: defCommon(),
2020-08-18 16:27:28 +00:00
2020-08-18 14:20:31 +00:00
Sealing: SealingConfig{
MaxWaitDealsSectors: 2, // 64G with 32G sectors
MaxSealingSectors: 0,
MaxSealingSectorsForDeals: 0,
WaitDealsDelay: Duration(time.Hour * 6),
2020-08-18 14:20:31 +00:00
},
2019-11-12 17:59:38 +00:00
Storage: sectorstorage.SealerConfig{
2020-08-17 09:39:29 +00:00
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,
},
Dealmaking: DealmakingConfig{
ConsiderOnlineStorageDeals: true,
ConsiderOfflineStorageDeals: true,
ConsiderOnlineRetrievalDeals: true,
ConsiderOfflineRetrievalDeals: true,
PieceCidBlocklist: []cid.Cid{},
// TODO: It'd be nice to set this based on sector size
ExpectedSealDuration: Duration(time.Hour * 24),
},
2020-08-12 17:47:00 +00:00
Fees: MinerFeeConfig{
2020-10-15 00:46:47 +00:00
MaxPreCommitGasFee: types.MustParseFIL("0.025"),
MaxCommitGasFee: types.MustParseFIL("0.05"),
MaxWindowPoStGasFee: types.MustParseFIL("5"),
MaxPublishDealsFee: types.MustParseFIL("0.05"),
MaxMarketBalanceAddFee: types.MustParseFIL("0.007"),
2020-08-12 17:47:00 +00:00
},
}
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
}