Merge branch 'master' into feat/replace-multistore-carv2
This commit is contained in:
+5
-3
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/node/impl/net"
|
||||
metricsi "github.com/ipfs/go-metrics-interface"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
@@ -36,7 +37,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/markets/storageadapter"
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
"github.com/filecoin-project/lotus/node/impl/common"
|
||||
"github.com/filecoin-project/lotus/node/impl/common/mock"
|
||||
"github.com/filecoin-project/lotus/node/modules"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
@@ -245,11 +245,11 @@ func ConfigCommon(cfg *config.Common, enableLibp2pNode bool) Option {
|
||||
}),
|
||||
ApplyIf(func(s *Settings) bool { return s.Base }), // apply only if Base has already been applied
|
||||
If(!enableLibp2pNode,
|
||||
Override(new(common.NetAPI), From(new(mock.MockNetAPI))),
|
||||
Override(new(api.Net), new(api.NetStub)),
|
||||
Override(new(api.Common), From(new(common.CommonAPI))),
|
||||
),
|
||||
If(enableLibp2pNode,
|
||||
Override(new(common.NetAPI), From(new(common.Libp2pNetAPI))),
|
||||
Override(new(api.Net), From(new(net.NetAPI))),
|
||||
Override(new(api.Common), From(new(common.CommonAPI))),
|
||||
Override(StartListeningKey, lp2p.StartListening(cfg.Libp2p.ListenAddresses)),
|
||||
Override(ConnectionManagerKey, lp2p.ConnectionManager(
|
||||
@@ -312,12 +312,14 @@ func Repo(r repo.Repo) Option {
|
||||
Override(new(dtypes.BasicStateBlockstore), modules.StateSplitBlockstore),
|
||||
Override(new(dtypes.BaseBlockstore), From(new(dtypes.SplitBlockstore))),
|
||||
Override(new(dtypes.ExposedBlockstore), modules.ExposedSplitBlockstore),
|
||||
Override(new(dtypes.GCReferenceProtector), modules.SplitBlockstoreGCReferenceProtector),
|
||||
),
|
||||
If(!cfg.EnableSplitstore,
|
||||
Override(new(dtypes.BasicChainBlockstore), modules.ChainFlatBlockstore),
|
||||
Override(new(dtypes.BasicStateBlockstore), modules.StateFlatBlockstore),
|
||||
Override(new(dtypes.BaseBlockstore), From(new(dtypes.UniversalBlockstore))),
|
||||
Override(new(dtypes.ExposedBlockstore), From(new(dtypes.UniversalBlockstore))),
|
||||
Override(new(dtypes.GCReferenceProtector), modules.NoopGCReferenceProtector),
|
||||
),
|
||||
|
||||
Override(new(dtypes.ChainBlockstore), From(new(dtypes.BasicChainBlockstore))),
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func run() error {
|
||||
tfb, err := ioutil.ReadFile("./node/config/types.go")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// could use the ast lib, but this is simpler
|
||||
|
||||
type st int
|
||||
const (
|
||||
stGlobal st = iota // looking for typedef
|
||||
stType st = iota // in typedef
|
||||
)
|
||||
|
||||
lines := strings.Split(string(tfb), "\n")
|
||||
state := stGlobal
|
||||
|
||||
type field struct {
|
||||
Name string
|
||||
Type string
|
||||
Comment string
|
||||
}
|
||||
|
||||
var currentType string
|
||||
var currentComment []string
|
||||
|
||||
out := map[string][]field{}
|
||||
|
||||
for l := range lines {
|
||||
line := strings.TrimSpace(lines[l])
|
||||
|
||||
switch state {
|
||||
case stGlobal:
|
||||
if strings.HasPrefix(line, "type ") {
|
||||
currentType = line
|
||||
currentType = strings.TrimPrefix(currentType, "type")
|
||||
currentType = strings.TrimSuffix(currentType, "{")
|
||||
currentType = strings.TrimSpace(currentType)
|
||||
currentType = strings.TrimSuffix(currentType, "struct")
|
||||
currentType = strings.TrimSpace(currentType)
|
||||
currentComment = nil
|
||||
state = stType
|
||||
continue
|
||||
}
|
||||
case stType:
|
||||
if strings.HasPrefix(line, "// ") {
|
||||
cline := strings.TrimSpace(strings.TrimPrefix(line, "//"))
|
||||
currentComment = append(currentComment, cline)
|
||||
continue
|
||||
}
|
||||
|
||||
comment := currentComment
|
||||
currentComment = nil
|
||||
|
||||
if strings.HasPrefix(line, "}") {
|
||||
state = stGlobal
|
||||
continue
|
||||
}
|
||||
|
||||
f := strings.Fields(line)
|
||||
if len(f) < 2 { // empty or embedded struct
|
||||
continue
|
||||
}
|
||||
|
||||
name := f[0]
|
||||
typ := f[1]
|
||||
|
||||
out[currentType] = append(out[currentType], field{
|
||||
Name: name,
|
||||
Type: typ,
|
||||
Comment: strings.Join(comment, "\n"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var outt []string
|
||||
for t := range out {
|
||||
outt = append(outt, t)
|
||||
}
|
||||
sort.Strings(outt)
|
||||
|
||||
fmt.Print(`// Code generated by github.com/filecoin-project/lotus/node/config/cfgdocgen. DO NOT EDIT.
|
||||
|
||||
package config
|
||||
|
||||
type DocField struct {
|
||||
Name string
|
||||
Type string
|
||||
Comment string
|
||||
}
|
||||
|
||||
var Doc = map[string][]DocField{
|
||||
`)
|
||||
|
||||
for _, typeName := range outt {
|
||||
typ := out[typeName]
|
||||
|
||||
fmt.Printf("\t\"%s\": []DocField{\n", typeName)
|
||||
|
||||
for _, f := range typ {
|
||||
fmt.Println("\t\t{")
|
||||
fmt.Printf("\t\t\tName: \"%s\",\n", f.Name)
|
||||
fmt.Printf("\t\t\tType: \"%s\",\n\n", f.Type)
|
||||
fmt.Printf("\t\t\tComment: `%s`,\n", f.Comment)
|
||||
fmt.Println("\t\t},")
|
||||
}
|
||||
|
||||
fmt.Printf("\t},\n")
|
||||
}
|
||||
|
||||
fmt.Println(`}`)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := run(); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -22,262 +22,10 @@ const (
|
||||
RetrievalPricingExternalMode = "external"
|
||||
)
|
||||
|
||||
// Common is common config between full node and miner
|
||||
type Common struct {
|
||||
API API
|
||||
Backup Backup
|
||||
Libp2p Libp2p
|
||||
Pubsub Pubsub
|
||||
}
|
||||
|
||||
// FullNode is a full node config
|
||||
type FullNode struct {
|
||||
Common
|
||||
Client Client
|
||||
Metrics Metrics
|
||||
Wallet Wallet
|
||||
Fees FeeConfig
|
||||
Chainstore Chainstore
|
||||
}
|
||||
|
||||
// // Common
|
||||
|
||||
type Backup struct {
|
||||
DisableMetadataLog bool
|
||||
}
|
||||
|
||||
// StorageMiner is a miner config
|
||||
type StorageMiner struct {
|
||||
Common
|
||||
|
||||
Subsystems MinerSubsystemConfig
|
||||
Dealmaking DealmakingConfig
|
||||
Sealing SealingConfig
|
||||
Storage sectorstorage.SealerConfig
|
||||
Fees MinerFeeConfig
|
||||
Addresses MinerAddressConfig
|
||||
}
|
||||
|
||||
type MinerSubsystemConfig struct {
|
||||
EnableMining bool
|
||||
EnableSealing bool
|
||||
EnableSectorStorage bool
|
||||
EnableMarkets bool
|
||||
|
||||
SealerApiInfo string // if EnableSealing == false
|
||||
SectorIndexApiInfo string // if EnableSectorStorage == false
|
||||
}
|
||||
|
||||
type DealmakingConfig struct {
|
||||
ConsiderOnlineStorageDeals bool
|
||||
ConsiderOfflineStorageDeals bool
|
||||
ConsiderOnlineRetrievalDeals bool
|
||||
ConsiderOfflineRetrievalDeals bool
|
||||
ConsiderVerifiedStorageDeals bool
|
||||
ConsiderUnverifiedStorageDeals bool
|
||||
PieceCidBlocklist []cid.Cid
|
||||
ExpectedSealDuration Duration
|
||||
// Maximum amount of time proposed deal StartEpoch can be in future
|
||||
MaxDealStartDelay Duration
|
||||
// The amount of time to wait for more deals to arrive before
|
||||
// publishing
|
||||
PublishMsgPeriod Duration
|
||||
// The maximum number of deals to include in a single PublishStorageDeals
|
||||
// message
|
||||
MaxDealsPerPublishMsg uint64
|
||||
// The maximum collateral that the provider will put up against a deal,
|
||||
// as a multiplier of the minimum collateral bound
|
||||
MaxProviderCollateralMultiplier uint64
|
||||
|
||||
// The maximum number of parallel online data transfers (storage+retrieval)
|
||||
SimultaneousTransfers uint64
|
||||
|
||||
Filter string
|
||||
RetrievalFilter string
|
||||
|
||||
RetrievalPricing *RetrievalPricing
|
||||
}
|
||||
|
||||
type RetrievalPricing struct {
|
||||
Strategy string // possible values: "default", "external"
|
||||
|
||||
Default *RetrievalPricingDefault
|
||||
External *RetrievalPricingExternal
|
||||
}
|
||||
|
||||
type RetrievalPricingExternal struct {
|
||||
// Path of the external script that will be run to price a retrieval deal.
|
||||
// This parameter is ONLY applicable if the retrieval pricing policy strategy has been configured to "external".
|
||||
Path string
|
||||
}
|
||||
|
||||
type RetrievalPricingDefault struct {
|
||||
// VerifiedDealsFreeTransfer configures zero fees for data transfer for a retrieval deal
|
||||
// of a payloadCid that belongs to a verified storage deal.
|
||||
// This parameter is ONLY applicable if the retrieval pricing policy strategy has been configured to "default".
|
||||
// default value is true
|
||||
VerifiedDealsFreeTransfer bool
|
||||
}
|
||||
|
||||
type SealingConfig struct {
|
||||
// 0 = no limit
|
||||
MaxWaitDealsSectors uint64
|
||||
|
||||
// includes failed, 0 = no limit
|
||||
MaxSealingSectors uint64
|
||||
|
||||
// includes failed, 0 = no limit
|
||||
MaxSealingSectorsForDeals uint64
|
||||
|
||||
WaitDealsDelay Duration
|
||||
|
||||
AlwaysKeepUnsealedCopy bool
|
||||
|
||||
// Run sector finalization before submitting sector proof to the chain
|
||||
FinalizeEarly bool
|
||||
|
||||
// Whether to use available miner balance for sector collateral instead of sending it with each message
|
||||
CollateralFromMinerBalance bool
|
||||
// Minimum available balance to keep in the miner actor before sending it with messages
|
||||
AvailableBalanceBuffer types.FIL
|
||||
// Don't send collateral with messages even if there is no available balance in the miner actor
|
||||
DisableCollateralFallback bool
|
||||
|
||||
// enable / disable precommit batching (takes effect after nv13)
|
||||
BatchPreCommits bool
|
||||
// maximum precommit batch size - batches will be sent immediately above this size
|
||||
MaxPreCommitBatch int
|
||||
// how long to wait before submitting a batch after crossing the minimum batch size
|
||||
PreCommitBatchWait Duration
|
||||
// time buffer for forceful batch submission before sectors/deal in batch would start expiring
|
||||
PreCommitBatchSlack Duration
|
||||
|
||||
// enable / disable commit aggregation (takes effect after nv13)
|
||||
AggregateCommits bool
|
||||
// maximum batched commit size - batches will be sent immediately above this size
|
||||
MinCommitBatch int
|
||||
MaxCommitBatch int
|
||||
// how long to wait before submitting a batch after crossing the minimum batch size
|
||||
CommitBatchWait Duration
|
||||
// time buffer for forceful batch submission before sectors/deals in batch would start expiring
|
||||
CommitBatchSlack Duration
|
||||
|
||||
// network BaseFee below which to stop doing commit aggregation, instead
|
||||
// submitting proofs to the chain individually
|
||||
AggregateAboveBaseFee types.FIL
|
||||
|
||||
TerminateBatchMax uint64
|
||||
TerminateBatchMin uint64
|
||||
TerminateBatchWait Duration
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
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)))
|
||||
}
|
||||
|
||||
type MinerFeeConfig struct {
|
||||
MaxPreCommitGasFee types.FIL
|
||||
MaxCommitGasFee types.FIL
|
||||
|
||||
// maxBatchFee = maxBase + maxPerSector * nSectors
|
||||
MaxPreCommitBatchGasFee BatchFeeConfig
|
||||
MaxCommitBatchGasFee BatchFeeConfig
|
||||
|
||||
MaxTerminateGasFee types.FIL
|
||||
MaxWindowPoStGasFee types.FIL
|
||||
MaxPublishDealsFee types.FIL
|
||||
MaxMarketBalanceAddFee types.FIL
|
||||
}
|
||||
|
||||
type MinerAddressConfig struct {
|
||||
PreCommitControl []string
|
||||
CommitControl []string
|
||||
TerminateControl []string
|
||||
DealPublishControl []string
|
||||
|
||||
// DisableOwnerFallback disables usage of the owner address for messages
|
||||
// sent automatically
|
||||
DisableOwnerFallback bool
|
||||
// DisableWorkerFallback disables usage of the worker address for messages
|
||||
// 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.
|
||||
DisableWorkerFallback bool
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
ConnMgrLow uint
|
||||
ConnMgrHigh uint
|
||||
ConnMgrGrace Duration
|
||||
}
|
||||
|
||||
type Pubsub struct {
|
||||
Bootstrapper bool
|
||||
DirectPeers []string
|
||||
IPColocationWhitelist []string
|
||||
RemoteTracer string
|
||||
}
|
||||
|
||||
type Chainstore struct {
|
||||
EnableSplitstore bool
|
||||
Splitstore Splitstore
|
||||
}
|
||||
|
||||
type Splitstore struct {
|
||||
ColdStoreType string
|
||||
HotStoreType string
|
||||
MarkSetType string
|
||||
}
|
||||
|
||||
// // Full Node
|
||||
|
||||
type Metrics struct {
|
||||
Nickname string
|
||||
HeadNotifs bool
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
UseIpfs bool
|
||||
IpfsOnlineMode bool
|
||||
IpfsMAddr string
|
||||
IpfsUseForRetrieval bool
|
||||
SimultaneousTransfers uint64
|
||||
}
|
||||
|
||||
type Wallet struct {
|
||||
RemoteBackend string
|
||||
EnableLedger bool
|
||||
DisableLocal bool
|
||||
}
|
||||
|
||||
type FeeConfig struct {
|
||||
DefaultMaxFee types.FIL
|
||||
}
|
||||
|
||||
func defCommon() Common {
|
||||
return Common{
|
||||
API: API{
|
||||
|
||||
@@ -0,0 +1,767 @@
|
||||
// Code generated by github.com/filecoin-project/lotus/node/config/cfgdocgen. DO NOT EDIT.
|
||||
|
||||
package config
|
||||
|
||||
type DocField struct {
|
||||
Name string
|
||||
Type string
|
||||
Comment string
|
||||
}
|
||||
|
||||
var Doc = map[string][]DocField{
|
||||
"API": []DocField{
|
||||
{
|
||||
Name: "ListenAddress",
|
||||
Type: "string",
|
||||
|
||||
Comment: `Binding address for the Lotus API`,
|
||||
},
|
||||
{
|
||||
Name: "RemoteListenAddress",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Timeout",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"Backup": []DocField{
|
||||
{
|
||||
Name: "DisableMetadataLog",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `Note that in case of metadata corruption it might be much harder to recover
|
||||
your node if metadata log is disabled`,
|
||||
},
|
||||
},
|
||||
"BatchFeeConfig": []DocField{
|
||||
{
|
||||
Name: "Base",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "PerSector",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"Chainstore": []DocField{
|
||||
{
|
||||
Name: "EnableSplitstore",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Splitstore",
|
||||
Type: "Splitstore",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"Client": []DocField{
|
||||
{
|
||||
Name: "UseIpfs",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "IpfsOnlineMode",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "IpfsMAddr",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "IpfsUseForRetrieval",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "SimultaneousTransfers",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: `The maximum number of simultaneous data transfers between the client
|
||||
and storage providers`,
|
||||
},
|
||||
},
|
||||
"Common": []DocField{
|
||||
{
|
||||
Name: "API",
|
||||
Type: "API",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Backup",
|
||||
Type: "Backup",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Libp2p",
|
||||
Type: "Libp2p",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Pubsub",
|
||||
Type: "Pubsub",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"DealmakingConfig": []DocField{
|
||||
{
|
||||
Name: "ConsiderOnlineStorageDeals",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `When enabled, the miner can accept online deals`,
|
||||
},
|
||||
{
|
||||
Name: "ConsiderOfflineStorageDeals",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `When enabled, the miner can accept offline deals`,
|
||||
},
|
||||
{
|
||||
Name: "ConsiderOnlineRetrievalDeals",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `When enabled, the miner can accept retrieval deals`,
|
||||
},
|
||||
{
|
||||
Name: "ConsiderOfflineRetrievalDeals",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `When enabled, the miner can accept offline retrieval deals`,
|
||||
},
|
||||
{
|
||||
Name: "ConsiderVerifiedStorageDeals",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `When enabled, the miner can accept verified deals`,
|
||||
},
|
||||
{
|
||||
Name: "ConsiderUnverifiedStorageDeals",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `When enabled, the miner can accept unverified deals`,
|
||||
},
|
||||
{
|
||||
Name: "PieceCidBlocklist",
|
||||
Type: "[]cid.Cid",
|
||||
|
||||
Comment: `A list of Data CIDs to reject when making deals`,
|
||||
},
|
||||
{
|
||||
Name: "ExpectedSealDuration",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: `Maximum expected amount of time getting the deal into a sealed sector will take
|
||||
This includes the time the deal will need to get transferred and published
|
||||
before being assigned to a sector`,
|
||||
},
|
||||
{
|
||||
Name: "MaxDealStartDelay",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: `Maximum amount of time proposed deal StartEpoch can be in future`,
|
||||
},
|
||||
{
|
||||
Name: "PublishMsgPeriod",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: `When a deal is ready to publish, the amount of time to wait for more
|
||||
deals to be ready to publish before publishing them all as a batch`,
|
||||
},
|
||||
{
|
||||
Name: "MaxDealsPerPublishMsg",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: `The maximum number of deals to include in a single PublishStorageDeals
|
||||
message`,
|
||||
},
|
||||
{
|
||||
Name: "MaxProviderCollateralMultiplier",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: `The maximum collateral that the provider will put up against a deal,
|
||||
as a multiplier of the minimum collateral bound`,
|
||||
},
|
||||
{
|
||||
Name: "SimultaneousTransfers",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: `The maximum number of parallel online data transfers (storage+retrieval)`,
|
||||
},
|
||||
{
|
||||
Name: "Filter",
|
||||
Type: "string",
|
||||
|
||||
Comment: `A command used for fine-grained evaluation of storage deals
|
||||
see https://docs.filecoin.io/mine/lotus/miner-configuration/#using-filters-for-fine-grained-storage-and-retrieval-deal-acceptance for more details`,
|
||||
},
|
||||
{
|
||||
Name: "RetrievalFilter",
|
||||
Type: "string",
|
||||
|
||||
Comment: `A command used for fine-grained evaluation of retrieval deals
|
||||
see https://docs.filecoin.io/mine/lotus/miner-configuration/#using-filters-for-fine-grained-storage-and-retrieval-deal-acceptance for more details`,
|
||||
},
|
||||
{
|
||||
Name: "RetrievalPricing",
|
||||
Type: "*RetrievalPricing",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"FeeConfig": []DocField{
|
||||
{
|
||||
Name: "DefaultMaxFee",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"FullNode": []DocField{
|
||||
{
|
||||
Name: "Client",
|
||||
Type: "Client",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Metrics",
|
||||
Type: "Metrics",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Wallet",
|
||||
Type: "Wallet",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Fees",
|
||||
Type: "FeeConfig",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Chainstore",
|
||||
Type: "Chainstore",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"Libp2p": []DocField{
|
||||
{
|
||||
Name: "ListenAddresses",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: `Binding address for the libp2p host - 0 means random port.
|
||||
Format: multiaddress; see https://multiformats.io/multiaddr/`,
|
||||
},
|
||||
{
|
||||
Name: "AnnounceAddresses",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: `Addresses to explicitally announce to other peers. If not specified,
|
||||
all interface addresses are announced
|
||||
Format: multiaddress`,
|
||||
},
|
||||
{
|
||||
Name: "NoAnnounceAddresses",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: `Addresses to not announce
|
||||
Format: multiaddress`,
|
||||
},
|
||||
{
|
||||
Name: "BootstrapPeers",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "ProtectedPeers",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "ConnMgrLow",
|
||||
Type: "uint",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "ConnMgrHigh",
|
||||
Type: "uint",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "ConnMgrGrace",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"Metrics": []DocField{
|
||||
{
|
||||
Name: "Nickname",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "HeadNotifs",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"MinerAddressConfig": []DocField{
|
||||
{
|
||||
Name: "PreCommitControl",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: `Addresses to send PreCommit messages from`,
|
||||
},
|
||||
{
|
||||
Name: "CommitControl",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: `Addresses to send Commit messages from`,
|
||||
},
|
||||
{
|
||||
Name: "TerminateControl",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "DealPublishControl",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "DisableOwnerFallback",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `DisableOwnerFallback disables usage of the owner address for messages
|
||||
sent automatically`,
|
||||
},
|
||||
{
|
||||
Name: "DisableWorkerFallback",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `DisableWorkerFallback disables usage of the worker address for messages
|
||||
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.`,
|
||||
},
|
||||
},
|
||||
"MinerFeeConfig": []DocField{
|
||||
{
|
||||
Name: "MaxPreCommitGasFee",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "MaxCommitGasFee",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "MaxPreCommitBatchGasFee",
|
||||
Type: "BatchFeeConfig",
|
||||
|
||||
Comment: `maxBatchFee = maxBase + maxPerSector * nSectors`,
|
||||
},
|
||||
{
|
||||
Name: "MaxCommitBatchGasFee",
|
||||
Type: "BatchFeeConfig",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "MaxTerminateGasFee",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "MaxWindowPoStGasFee",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: `WindowPoSt is a high-value operation, so the default fee should be high.`,
|
||||
},
|
||||
{
|
||||
Name: "MaxPublishDealsFee",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "MaxMarketBalanceAddFee",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"MinerSubsystemConfig": []DocField{
|
||||
{
|
||||
Name: "EnableMining",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "EnableSealing",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "EnableSectorStorage",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "EnableMarkets",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "SealerApiInfo",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "SectorIndexApiInfo",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"Pubsub": []DocField{
|
||||
{
|
||||
Name: "Bootstrapper",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `Run the node in bootstrap-node mode`,
|
||||
},
|
||||
{
|
||||
Name: "DirectPeers",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: `DirectPeers specifies peers with direct peering agreements. These peers are
|
||||
connected outside of the mesh, with all (valid) message unconditionally
|
||||
forwarded to them. The router will maintain open connections to these peers.
|
||||
Note that the peering agreement should be reciprocal with direct peers
|
||||
symmetrically configured at both ends.
|
||||
Type: Array of multiaddress peerinfo strings, must include peerid (/p2p/12D3K...`,
|
||||
},
|
||||
{
|
||||
Name: "IPColocationWhitelist",
|
||||
Type: "[]string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "RemoteTracer",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"RetrievalPricing": []DocField{
|
||||
{
|
||||
Name: "Strategy",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Default",
|
||||
Type: "*RetrievalPricingDefault",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "External",
|
||||
Type: "*RetrievalPricingExternal",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"RetrievalPricingDefault": []DocField{
|
||||
{
|
||||
Name: "VerifiedDealsFreeTransfer",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `VerifiedDealsFreeTransfer configures zero fees for data transfer for a retrieval deal
|
||||
of a payloadCid that belongs to a verified storage deal.
|
||||
This parameter is ONLY applicable if the retrieval pricing policy strategy has been configured to "default".
|
||||
default value is true`,
|
||||
},
|
||||
},
|
||||
"RetrievalPricingExternal": []DocField{
|
||||
{
|
||||
Name: "Path",
|
||||
Type: "string",
|
||||
|
||||
Comment: `Path of the external script that will be run to price a retrieval deal.
|
||||
This parameter is ONLY applicable if the retrieval pricing policy strategy has been configured to "external".`,
|
||||
},
|
||||
},
|
||||
"SealingConfig": []DocField{
|
||||
{
|
||||
Name: "MaxWaitDealsSectors",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: `Upper bound on how many sectors can be waiting for more deals to be packed in it before it begins sealing at any given time.
|
||||
If the miner is accepting multiple deals in parallel, up to MaxWaitDealsSectors of new sectors will be created.
|
||||
If more than MaxWaitDealsSectors deals are accepted in parallel, only MaxWaitDealsSectors deals will be processed in parallel
|
||||
Note that setting this number too high in relation to deal ingestion rate may result in poor sector packing efficiency
|
||||
0 = no limit`,
|
||||
},
|
||||
{
|
||||
Name: "MaxSealingSectors",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: `Upper bound on how many sectors can be sealing at the same time when creating new CC sectors (0 = unlimited)`,
|
||||
},
|
||||
{
|
||||
Name: "MaxSealingSectorsForDeals",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: `Upper bound on how many sectors can be sealing at the same time when creating new sectors with deals (0 = unlimited)`,
|
||||
},
|
||||
{
|
||||
Name: "WaitDealsDelay",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: `Period of time that a newly created sector will wait for more deals to be packed in to before it starts to seal.
|
||||
Sectors which are fully filled will start sealing immediately`,
|
||||
},
|
||||
{
|
||||
Name: "AlwaysKeepUnsealedCopy",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `Whether to keep unsealed copies of deal data regardless of whether the client requested that. This lets the miner
|
||||
avoid the relatively high cost of unsealing the data later, at the cost of more storage space`,
|
||||
},
|
||||
{
|
||||
Name: "FinalizeEarly",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `Run sector finalization before submitting sector proof to the chain`,
|
||||
},
|
||||
{
|
||||
Name: "CollateralFromMinerBalance",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `Whether to use available miner balance for sector collateral instead of sending it with each message`,
|
||||
},
|
||||
{
|
||||
Name: "AvailableBalanceBuffer",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: `Minimum available balance to keep in the miner actor before sending it with messages`,
|
||||
},
|
||||
{
|
||||
Name: "DisableCollateralFallback",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `Don't send collateral with messages even if there is no available balance in the miner actor`,
|
||||
},
|
||||
{
|
||||
Name: "BatchPreCommits",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `enable / disable precommit batching (takes effect after nv13)`,
|
||||
},
|
||||
{
|
||||
Name: "MaxPreCommitBatch",
|
||||
Type: "int",
|
||||
|
||||
Comment: `maximum precommit batch size - batches will be sent immediately above this size`,
|
||||
},
|
||||
{
|
||||
Name: "PreCommitBatchWait",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: `how long to wait before submitting a batch after crossing the minimum batch size`,
|
||||
},
|
||||
{
|
||||
Name: "PreCommitBatchSlack",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: `time buffer for forceful batch submission before sectors/deal in batch would start expiring`,
|
||||
},
|
||||
{
|
||||
Name: "AggregateCommits",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `enable / disable commit aggregation (takes effect after nv13)`,
|
||||
},
|
||||
{
|
||||
Name: "MinCommitBatch",
|
||||
Type: "int",
|
||||
|
||||
Comment: `maximum batched commit size - batches will be sent immediately above this size`,
|
||||
},
|
||||
{
|
||||
Name: "MaxCommitBatch",
|
||||
Type: "int",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "CommitBatchWait",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: `how long to wait before submitting a batch after crossing the minimum batch size`,
|
||||
},
|
||||
{
|
||||
Name: "CommitBatchSlack",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: `time buffer for forceful batch submission before sectors/deals in batch would start expiring`,
|
||||
},
|
||||
{
|
||||
Name: "AggregateAboveBaseFee",
|
||||
Type: "types.FIL",
|
||||
|
||||
Comment: `network BaseFee below which to stop doing commit aggregation, instead
|
||||
submitting proofs to the chain individually`,
|
||||
},
|
||||
{
|
||||
Name: "TerminateBatchMax",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "TerminateBatchMin",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "TerminateBatchWait",
|
||||
Type: "Duration",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"Splitstore": []DocField{
|
||||
{
|
||||
Name: "ColdStoreType",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "HotStoreType",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "MarkSetType",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "HotStoreMessageRetention",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"StorageMiner": []DocField{
|
||||
{
|
||||
Name: "Subsystems",
|
||||
Type: "MinerSubsystemConfig",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Dealmaking",
|
||||
Type: "DealmakingConfig",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Sealing",
|
||||
Type: "SealingConfig",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Storage",
|
||||
Type: "sectorstorage.SealerConfig",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Fees",
|
||||
Type: "MinerFeeConfig",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Addresses",
|
||||
Type: "MinerAddressConfig",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"Wallet": []DocField{
|
||||
{
|
||||
Name: "RemoteBackend",
|
||||
Type: "string",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "EnableLedger",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "DisableLocal",
|
||||
Type: "bool",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func findDoc(root interface{}, section, name string) *DocField {
|
||||
rt := fmt.Sprintf("%T", root)[len("*config."):]
|
||||
|
||||
doc := findDocSect(rt, section, name)
|
||||
if doc != nil {
|
||||
return doc
|
||||
}
|
||||
|
||||
return findDocSect("Common", section, name)
|
||||
}
|
||||
|
||||
func findDocSect(root string, section, name string) *DocField {
|
||||
path := strings.Split(section, ".")
|
||||
|
||||
docSection := Doc[root]
|
||||
for _, e := range path {
|
||||
if docSection == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, field := range docSection {
|
||||
if field.Name == e {
|
||||
docSection = Doc[field.Type]
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for _, df := range docSection {
|
||||
if df.Name == name {
|
||||
return &df
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
+115
-10
@@ -5,6 +5,10 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/kelseyhightower/envconfig"
|
||||
@@ -42,15 +46,116 @@ func FromReader(reader io.Reader, def interface{}) (interface{}, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func ConfigComment(t interface{}) ([]byte, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
_, _ = buf.WriteString("# Default config:\n")
|
||||
e := toml.NewEncoder(buf)
|
||||
if err := e.Encode(t); err != nil {
|
||||
return nil, xerrors.Errorf("encoding config: %w", err)
|
||||
func ConfigUpdate(cfgCur, cfgDef interface{}, comment bool) ([]byte, error) {
|
||||
var nodeStr, defStr string
|
||||
if cfgDef != nil {
|
||||
buf := new(bytes.Buffer)
|
||||
e := toml.NewEncoder(buf)
|
||||
if err := e.Encode(cfgDef); err != nil {
|
||||
return nil, xerrors.Errorf("encoding default config: %w", err)
|
||||
}
|
||||
|
||||
defStr = buf.String()
|
||||
}
|
||||
b := buf.Bytes()
|
||||
b = bytes.ReplaceAll(b, []byte("\n"), []byte("\n#"))
|
||||
b = bytes.ReplaceAll(b, []byte("#["), []byte("["))
|
||||
return b, nil
|
||||
|
||||
{
|
||||
buf := new(bytes.Buffer)
|
||||
e := toml.NewEncoder(buf)
|
||||
if err := e.Encode(cfgCur); err != nil {
|
||||
return nil, xerrors.Errorf("encoding node config: %w", err)
|
||||
}
|
||||
|
||||
nodeStr = buf.String()
|
||||
}
|
||||
|
||||
if comment {
|
||||
// create a map of default lines so we can comment those out later
|
||||
defLines := strings.Split(defStr, "\n")
|
||||
defaults := map[string]struct{}{}
|
||||
for i := range defLines {
|
||||
l := strings.TrimSpace(defLines[i])
|
||||
if len(l) == 0 {
|
||||
continue
|
||||
}
|
||||
if l[0] == '#' || l[0] == '[' {
|
||||
continue
|
||||
}
|
||||
defaults[l] = struct{}{}
|
||||
}
|
||||
|
||||
nodeLines := strings.Split(nodeStr, "\n")
|
||||
var outLines []string
|
||||
|
||||
sectionRx := regexp.MustCompile(`\[(.+)]`)
|
||||
var section string
|
||||
|
||||
for i, line := range nodeLines {
|
||||
// if this is a section, track it
|
||||
trimmed := strings.TrimSpace(line)
|
||||
if len(trimmed) > 0 {
|
||||
if trimmed[0] == '[' {
|
||||
m := sectionRx.FindSubmatch([]byte(trimmed))
|
||||
if len(m) != 2 {
|
||||
return nil, xerrors.Errorf("section didn't match (line %d)", i)
|
||||
}
|
||||
section = string(m[1])
|
||||
|
||||
// never comment sections
|
||||
outLines = append(outLines, line)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
pad := strings.Repeat(" ", len(line)-len(strings.TrimLeftFunc(line, unicode.IsSpace)))
|
||||
|
||||
// see if we have docs for this field
|
||||
{
|
||||
lf := strings.Fields(line)
|
||||
if len(lf) > 1 {
|
||||
doc := findDoc(cfgCur, section, lf[0])
|
||||
|
||||
if doc != nil {
|
||||
// found docfield, emit doc comment
|
||||
if len(doc.Comment) > 0 {
|
||||
for _, docLine := range strings.Split(doc.Comment, "\n") {
|
||||
outLines = append(outLines, pad+"# "+docLine)
|
||||
}
|
||||
outLines = append(outLines, pad+"#")
|
||||
}
|
||||
|
||||
outLines = append(outLines, pad+"# type: "+doc.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if there is the same line in the default config, comment it out it output
|
||||
if _, found := defaults[strings.TrimSpace(nodeLines[i])]; (cfgDef == nil || found) && len(line) > 0 {
|
||||
line = pad + "#" + line[len(pad):]
|
||||
}
|
||||
outLines = append(outLines, line)
|
||||
if len(line) > 0 {
|
||||
outLines = append(outLines, "")
|
||||
}
|
||||
}
|
||||
|
||||
nodeStr = strings.Join(outLines, "\n")
|
||||
}
|
||||
|
||||
// sanity-check that the updated config parses the same way as the current one
|
||||
if cfgDef != nil {
|
||||
cfgUpdated, err := FromReader(strings.NewReader(nodeStr), cfgDef)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("parsing updated config: %w", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(cfgCur, cfgUpdated) {
|
||||
return nil, xerrors.Errorf("updated config didn't match current config")
|
||||
}
|
||||
}
|
||||
|
||||
return []byte(nodeStr), nil
|
||||
}
|
||||
|
||||
func ConfigComment(t interface{}) ([]byte, error) {
|
||||
return ConfigUpdate(t, nil, true)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
|
||||
)
|
||||
|
||||
// // NOTE: ONLY PUT STRUCT DEFINITIONS IN THIS FILE
|
||||
// //
|
||||
// // After making edits here, run 'make cfgdoc-gen' (or 'make gen')
|
||||
|
||||
// Common is common config between full node and miner
|
||||
type Common struct {
|
||||
API API
|
||||
Backup Backup
|
||||
Libp2p Libp2p
|
||||
Pubsub Pubsub
|
||||
}
|
||||
|
||||
// FullNode is a full node config
|
||||
type FullNode struct {
|
||||
Common
|
||||
Client Client
|
||||
Metrics Metrics
|
||||
Wallet Wallet
|
||||
Fees FeeConfig
|
||||
Chainstore Chainstore
|
||||
}
|
||||
|
||||
// // Common
|
||||
|
||||
type Backup struct {
|
||||
// When set to true disables metadata log (.lotus/kvlog). This can save disk
|
||||
// space by reducing metadata redundancy.
|
||||
//
|
||||
// Note that in case of metadata corruption it might be much harder to recover
|
||||
// your node if metadata log is disabled
|
||||
DisableMetadataLog bool
|
||||
}
|
||||
|
||||
// StorageMiner is a miner config
|
||||
type StorageMiner struct {
|
||||
Common
|
||||
|
||||
Subsystems MinerSubsystemConfig
|
||||
Dealmaking DealmakingConfig
|
||||
Sealing SealingConfig
|
||||
Storage sectorstorage.SealerConfig
|
||||
Fees MinerFeeConfig
|
||||
Addresses MinerAddressConfig
|
||||
}
|
||||
|
||||
type MinerSubsystemConfig struct {
|
||||
EnableMining bool
|
||||
EnableSealing bool
|
||||
EnableSectorStorage bool
|
||||
EnableMarkets bool
|
||||
|
||||
SealerApiInfo string // if EnableSealing == false
|
||||
SectorIndexApiInfo string // if EnableSectorStorage == false
|
||||
}
|
||||
|
||||
type DealmakingConfig struct {
|
||||
// When enabled, the miner can accept online deals
|
||||
ConsiderOnlineStorageDeals bool
|
||||
// When enabled, the miner can accept offline deals
|
||||
ConsiderOfflineStorageDeals bool
|
||||
// When enabled, the miner can accept retrieval deals
|
||||
ConsiderOnlineRetrievalDeals bool
|
||||
// When enabled, the miner can accept offline retrieval deals
|
||||
ConsiderOfflineRetrievalDeals bool
|
||||
// When enabled, the miner can accept verified deals
|
||||
ConsiderVerifiedStorageDeals bool
|
||||
// When enabled, the miner can accept unverified deals
|
||||
ConsiderUnverifiedStorageDeals bool
|
||||
// A list of Data CIDs to reject when making deals
|
||||
PieceCidBlocklist []cid.Cid
|
||||
// Maximum expected amount of time getting the deal into a sealed sector will take
|
||||
// This includes the time the deal will need to get transferred and published
|
||||
// before being assigned to a sector
|
||||
ExpectedSealDuration Duration
|
||||
// Maximum amount of time proposed deal StartEpoch can be in future
|
||||
MaxDealStartDelay Duration
|
||||
// When a deal is ready to publish, the amount of time to wait for more
|
||||
// deals to be ready to publish before publishing them all as a batch
|
||||
PublishMsgPeriod Duration
|
||||
// The maximum number of deals to include in a single PublishStorageDeals
|
||||
// message
|
||||
MaxDealsPerPublishMsg uint64
|
||||
// The maximum collateral that the provider will put up against a deal,
|
||||
// as a multiplier of the minimum collateral bound
|
||||
MaxProviderCollateralMultiplier uint64
|
||||
|
||||
// The maximum number of parallel online data transfers (storage+retrieval)
|
||||
SimultaneousTransfers uint64
|
||||
|
||||
// A command used for fine-grained evaluation of storage deals
|
||||
// see https://docs.filecoin.io/mine/lotus/miner-configuration/#using-filters-for-fine-grained-storage-and-retrieval-deal-acceptance for more details
|
||||
Filter string
|
||||
// A command used for fine-grained evaluation of retrieval deals
|
||||
// see https://docs.filecoin.io/mine/lotus/miner-configuration/#using-filters-for-fine-grained-storage-and-retrieval-deal-acceptance for more details
|
||||
RetrievalFilter string
|
||||
|
||||
RetrievalPricing *RetrievalPricing
|
||||
}
|
||||
|
||||
type RetrievalPricing struct {
|
||||
Strategy string // possible values: "default", "external"
|
||||
|
||||
Default *RetrievalPricingDefault
|
||||
External *RetrievalPricingExternal
|
||||
}
|
||||
|
||||
type RetrievalPricingExternal struct {
|
||||
// Path of the external script that will be run to price a retrieval deal.
|
||||
// This parameter is ONLY applicable if the retrieval pricing policy strategy has been configured to "external".
|
||||
Path string
|
||||
}
|
||||
|
||||
type RetrievalPricingDefault struct {
|
||||
// VerifiedDealsFreeTransfer configures zero fees for data transfer for a retrieval deal
|
||||
// of a payloadCid that belongs to a verified storage deal.
|
||||
// This parameter is ONLY applicable if the retrieval pricing policy strategy has been configured to "default".
|
||||
// default value is true
|
||||
VerifiedDealsFreeTransfer bool
|
||||
}
|
||||
|
||||
type SealingConfig struct {
|
||||
// Upper bound on how many sectors can be waiting for more deals to be packed in it before it begins sealing at any given time.
|
||||
// If the miner is accepting multiple deals in parallel, up to MaxWaitDealsSectors of new sectors will be created.
|
||||
// If more than MaxWaitDealsSectors deals are accepted in parallel, only MaxWaitDealsSectors deals will be processed in parallel
|
||||
// Note that setting this number too high in relation to deal ingestion rate may result in poor sector packing efficiency
|
||||
// 0 = no limit
|
||||
MaxWaitDealsSectors uint64
|
||||
|
||||
// Upper bound on how many sectors can be sealing at the same time when creating new CC sectors (0 = unlimited)
|
||||
MaxSealingSectors uint64
|
||||
|
||||
// Upper bound on how many sectors can be sealing at the same time when creating new sectors with deals (0 = unlimited)
|
||||
MaxSealingSectorsForDeals uint64
|
||||
|
||||
// Period of time that a newly created sector will wait for more deals to be packed in to before it starts to seal.
|
||||
// Sectors which are fully filled will start sealing immediately
|
||||
WaitDealsDelay Duration
|
||||
|
||||
// Whether to keep unsealed copies of deal data regardless of whether the client requested that. This lets the miner
|
||||
// avoid the relatively high cost of unsealing the data later, at the cost of more storage space
|
||||
AlwaysKeepUnsealedCopy bool
|
||||
|
||||
// Run sector finalization before submitting sector proof to the chain
|
||||
FinalizeEarly bool
|
||||
|
||||
// Whether to use available miner balance for sector collateral instead of sending it with each message
|
||||
CollateralFromMinerBalance bool
|
||||
// Minimum available balance to keep in the miner actor before sending it with messages
|
||||
AvailableBalanceBuffer types.FIL
|
||||
// Don't send collateral with messages even if there is no available balance in the miner actor
|
||||
DisableCollateralFallback bool
|
||||
|
||||
// enable / disable precommit batching (takes effect after nv13)
|
||||
BatchPreCommits bool
|
||||
// maximum precommit batch size - batches will be sent immediately above this size
|
||||
MaxPreCommitBatch int
|
||||
// how long to wait before submitting a batch after crossing the minimum batch size
|
||||
PreCommitBatchWait Duration
|
||||
// time buffer for forceful batch submission before sectors/deal in batch would start expiring
|
||||
PreCommitBatchSlack Duration
|
||||
|
||||
// enable / disable commit aggregation (takes effect after nv13)
|
||||
AggregateCommits bool
|
||||
// maximum batched commit size - batches will be sent immediately above this size
|
||||
MinCommitBatch int
|
||||
MaxCommitBatch int
|
||||
// how long to wait before submitting a batch after crossing the minimum batch size
|
||||
CommitBatchWait Duration
|
||||
// time buffer for forceful batch submission before sectors/deals in batch would start expiring
|
||||
CommitBatchSlack Duration
|
||||
|
||||
// network BaseFee below which to stop doing commit aggregation, instead
|
||||
// submitting proofs to the chain individually
|
||||
AggregateAboveBaseFee types.FIL
|
||||
|
||||
TerminateBatchMax uint64
|
||||
TerminateBatchMin uint64
|
||||
TerminateBatchWait Duration
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
type BatchFeeConfig struct {
|
||||
Base types.FIL
|
||||
PerSector types.FIL
|
||||
}
|
||||
|
||||
type MinerFeeConfig struct {
|
||||
MaxPreCommitGasFee types.FIL
|
||||
MaxCommitGasFee types.FIL
|
||||
|
||||
// maxBatchFee = maxBase + maxPerSector * nSectors
|
||||
MaxPreCommitBatchGasFee BatchFeeConfig
|
||||
MaxCommitBatchGasFee BatchFeeConfig
|
||||
|
||||
MaxTerminateGasFee types.FIL
|
||||
// WindowPoSt is a high-value operation, so the default fee should be high.
|
||||
MaxWindowPoStGasFee types.FIL
|
||||
MaxPublishDealsFee types.FIL
|
||||
MaxMarketBalanceAddFee types.FIL
|
||||
}
|
||||
|
||||
type MinerAddressConfig struct {
|
||||
// Addresses to send PreCommit messages from
|
||||
PreCommitControl []string
|
||||
// Addresses to send Commit messages from
|
||||
CommitControl []string
|
||||
TerminateControl []string
|
||||
DealPublishControl []string
|
||||
|
||||
// DisableOwnerFallback disables usage of the owner address for messages
|
||||
// sent automatically
|
||||
DisableOwnerFallback bool
|
||||
// DisableWorkerFallback disables usage of the worker address for messages
|
||||
// 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.
|
||||
DisableWorkerFallback bool
|
||||
}
|
||||
|
||||
// API contains configs for API endpoint
|
||||
type API struct {
|
||||
// Binding address for the Lotus API
|
||||
ListenAddress string
|
||||
RemoteListenAddress string
|
||||
Timeout Duration
|
||||
}
|
||||
|
||||
// Libp2p contains configs for libp2p
|
||||
type Libp2p struct {
|
||||
// Binding address for the libp2p host - 0 means random port.
|
||||
// Format: multiaddress; see https://multiformats.io/multiaddr/
|
||||
ListenAddresses []string
|
||||
// Addresses to explicitally announce to other peers. If not specified,
|
||||
// all interface addresses are announced
|
||||
// Format: multiaddress
|
||||
AnnounceAddresses []string
|
||||
// Addresses to not announce
|
||||
// Format: multiaddress
|
||||
NoAnnounceAddresses []string
|
||||
BootstrapPeers []string
|
||||
ProtectedPeers []string
|
||||
|
||||
ConnMgrLow uint
|
||||
ConnMgrHigh uint
|
||||
ConnMgrGrace Duration
|
||||
}
|
||||
|
||||
type Pubsub struct {
|
||||
// Run the node in bootstrap-node mode
|
||||
Bootstrapper bool
|
||||
// DirectPeers specifies peers with direct peering agreements. These peers are
|
||||
// connected outside of the mesh, with all (valid) message unconditionally
|
||||
// forwarded to them. The router will maintain open connections to these peers.
|
||||
// Note that the peering agreement should be reciprocal with direct peers
|
||||
// symmetrically configured at both ends.
|
||||
// Type: Array of multiaddress peerinfo strings, must include peerid (/p2p/12D3K...
|
||||
DirectPeers []string
|
||||
IPColocationWhitelist []string
|
||||
RemoteTracer string
|
||||
}
|
||||
|
||||
type Chainstore struct {
|
||||
EnableSplitstore bool
|
||||
Splitstore Splitstore
|
||||
}
|
||||
|
||||
type Splitstore struct {
|
||||
ColdStoreType string
|
||||
HotStoreType string
|
||||
MarkSetType string
|
||||
|
||||
HotStoreMessageRetention uint64
|
||||
}
|
||||
|
||||
// // Full Node
|
||||
|
||||
type Metrics struct {
|
||||
Nickname string
|
||||
HeadNotifs bool
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
UseIpfs bool
|
||||
IpfsOnlineMode bool
|
||||
IpfsMAddr string
|
||||
IpfsUseForRetrieval bool
|
||||
// The maximum number of simultaneous data transfers between the client
|
||||
// and storage providers
|
||||
SimultaneousTransfers uint64
|
||||
}
|
||||
|
||||
type Wallet struct {
|
||||
RemoteBackend string
|
||||
EnableLedger bool
|
||||
DisableLocal bool
|
||||
}
|
||||
|
||||
type FeeConfig struct {
|
||||
DefaultMaxFee types.FIL
|
||||
}
|
||||
+19
-17
@@ -10,8 +10,8 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
apitypes "github.com/filecoin-project/lotus/api/types"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
)
|
||||
@@ -21,8 +21,6 @@ var session = uuid.New()
|
||||
type CommonAPI struct {
|
||||
fx.In
|
||||
|
||||
NetAPI
|
||||
|
||||
APISecret *dtypes.APIAlg
|
||||
ShutdownChan dtypes.ShutdownChan
|
||||
}
|
||||
@@ -48,6 +46,24 @@ func (a *CommonAPI) AuthNew(ctx context.Context, perms []auth.Permission) ([]byt
|
||||
return jwt.Sign(&p, (*jwt.HMACSHA)(a.APISecret))
|
||||
}
|
||||
|
||||
func (a *CommonAPI) Discover(ctx context.Context) (apitypes.OpenRPCDocument, error) {
|
||||
return build.OpenRPCDiscoverJSON_Full(), nil
|
||||
}
|
||||
|
||||
func (a *CommonAPI) Version(context.Context) (api.APIVersion, error) {
|
||||
v, err := api.VersionForType(api.RunningNodeType)
|
||||
if err != nil {
|
||||
return api.APIVersion{}, err
|
||||
}
|
||||
|
||||
return api.APIVersion{
|
||||
Version: build.UserVersion(),
|
||||
APIVersion: v,
|
||||
|
||||
BlockDelay: build.BlockDelaySecs,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *CommonAPI) LogList(context.Context) ([]string, error) {
|
||||
return logging.GetSubsystems(), nil
|
||||
}
|
||||
@@ -68,17 +84,3 @@ func (a *CommonAPI) Session(ctx context.Context) (uuid.UUID, error) {
|
||||
func (a *CommonAPI) Closing(ctx context.Context) (<-chan struct{}, error) {
|
||||
return make(chan struct{}), nil // relies on jsonrpc closing
|
||||
}
|
||||
|
||||
func (a *CommonAPI) Version(context.Context) (api.APIVersion, error) {
|
||||
v, err := api.VersionForType(api.RunningNodeType)
|
||||
if err != nil {
|
||||
return api.APIVersion{}, err
|
||||
}
|
||||
|
||||
return api.APIVersion{
|
||||
Version: build.UserVersion(),
|
||||
APIVersion: v,
|
||||
|
||||
BlockDelay: build.BlockDelaySecs,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
apitypes "github.com/filecoin-project/lotus/api/types"
|
||||
"github.com/libp2p/go-libp2p-core/metrics"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
var (
|
||||
errNotImplemented = errors.New("not implemented")
|
||||
)
|
||||
|
||||
type MockNetAPI struct {
|
||||
fx.In
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetAgentVersion(ctx context.Context, p peer.ID) (string, error) {
|
||||
return "", errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetConnectedness(ctx context.Context, pid peer.ID) (conn network.Connectedness, err error) {
|
||||
err = errNotImplemented
|
||||
return
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetPubsubScores(context.Context) ([]api.PubsubScore, error) {
|
||||
return nil, errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetPeers(context.Context) ([]peer.AddrInfo, error) {
|
||||
return nil, errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetPeerInfo(_ context.Context, p peer.ID) (*api.ExtendedPeerInfo, error) {
|
||||
return nil, errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetConnect(ctx context.Context, p peer.AddrInfo) error {
|
||||
return errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetAddrsListen(context.Context) (ai peer.AddrInfo, err error) {
|
||||
err = errNotImplemented
|
||||
return
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetDisconnect(ctx context.Context, p peer.ID) error {
|
||||
return errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetFindPeer(ctx context.Context, p peer.ID) (ai peer.AddrInfo, err error) {
|
||||
err = errNotImplemented
|
||||
return
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetAutoNatStatus(ctx context.Context) (i api.NatInfo, err error) {
|
||||
err = errNotImplemented
|
||||
return
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetBandwidthStats(ctx context.Context) (s metrics.Stats, err error) {
|
||||
err = errNotImplemented
|
||||
return
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetBandwidthStatsByPeer(ctx context.Context) (map[string]metrics.Stats, error) {
|
||||
return nil, errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetBandwidthStatsByProtocol(ctx context.Context) (map[protocol.ID]metrics.Stats, error) {
|
||||
return nil, errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) Discover(ctx context.Context) (apitypes.OpenRPCDocument, error) {
|
||||
return nil, errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) ID(context.Context) (p peer.ID, err error) {
|
||||
err = errNotImplemented
|
||||
return
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetBlockAdd(ctx context.Context, acl api.NetBlockList) error {
|
||||
return errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetBlockRemove(ctx context.Context, acl api.NetBlockList) error {
|
||||
return errNotImplemented
|
||||
}
|
||||
|
||||
func (a *MockNetAPI) NetBlockList(ctx context.Context) (result api.NetBlockList, err error) {
|
||||
err = errNotImplemented
|
||||
return
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
metrics "github.com/libp2p/go-libp2p-core/metrics"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
apitypes "github.com/filecoin-project/lotus/api/types"
|
||||
)
|
||||
|
||||
type NetAPI interface {
|
||||
NetConnectedness(ctx context.Context, pid peer.ID) (network.Connectedness, error)
|
||||
NetPubsubScores(context.Context) ([]api.PubsubScore, error)
|
||||
NetPeers(context.Context) ([]peer.AddrInfo, error)
|
||||
NetPeerInfo(_ context.Context, p peer.ID) (*api.ExtendedPeerInfo, error)
|
||||
NetConnect(ctx context.Context, p peer.AddrInfo) error
|
||||
NetAddrsListen(context.Context) (peer.AddrInfo, error)
|
||||
NetDisconnect(ctx context.Context, p peer.ID) error
|
||||
NetFindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error)
|
||||
NetAutoNatStatus(ctx context.Context) (i api.NatInfo, err error)
|
||||
NetAgentVersion(ctx context.Context, p peer.ID) (string, error)
|
||||
NetBandwidthStats(ctx context.Context) (metrics.Stats, error)
|
||||
NetBandwidthStatsByPeer(ctx context.Context) (map[string]metrics.Stats, error)
|
||||
NetBandwidthStatsByProtocol(ctx context.Context) (map[protocol.ID]metrics.Stats, error)
|
||||
Discover(ctx context.Context) (apitypes.OpenRPCDocument, error)
|
||||
ID(context.Context) (peer.ID, error)
|
||||
NetBlockAdd(ctx context.Context, acl api.NetBlockList) error
|
||||
NetBlockRemove(ctx context.Context, acl api.NetBlockList) error
|
||||
NetBlockList(ctx context.Context) (api.NetBlockList, error)
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/impl/common"
|
||||
"github.com/filecoin-project/lotus/node/impl/full"
|
||||
"github.com/filecoin-project/lotus/node/impl/market"
|
||||
"github.com/filecoin-project/lotus/node/impl/net"
|
||||
"github.com/filecoin-project/lotus/node/impl/paych"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/modules/lp2p"
|
||||
@@ -23,6 +24,7 @@ var log = logging.Logger("node")
|
||||
|
||||
type FullNodeAPI struct {
|
||||
common.CommonAPI
|
||||
net.NetAPI
|
||||
full.ChainAPI
|
||||
client.API
|
||||
full.MpoolAPI
|
||||
|
||||
@@ -83,6 +83,9 @@ type ChainAPI struct {
|
||||
// expose externally. In the future, this will be segregated into two
|
||||
// blockstores.
|
||||
ExposedBlockstore dtypes.ExposedBlockstore
|
||||
|
||||
// BaseBlockstore is the underlying blockstore
|
||||
BaseBlockstore dtypes.BaseBlockstore
|
||||
}
|
||||
|
||||
func (m *ChainModule) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error) {
|
||||
@@ -644,3 +647,21 @@ func (a *ChainAPI) ChainExport(ctx context.Context, nroots abi.ChainEpoch, skipo
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *ChainAPI) ChainCheckBlockstore(ctx context.Context) error {
|
||||
checker, ok := a.BaseBlockstore.(interface{ Check() error })
|
||||
if !ok {
|
||||
return xerrors.Errorf("underlying blockstore does not support health checks")
|
||||
}
|
||||
|
||||
return checker.Check()
|
||||
}
|
||||
|
||||
func (a *ChainAPI) ChainBlockstoreInfo(ctx context.Context) (map[string]interface{}, error) {
|
||||
info, ok := a.BaseBlockstore.(interface{ Info() map[string]interface{} })
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("underlying blockstore does not provide info")
|
||||
}
|
||||
|
||||
return info.Info(), nil
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package common
|
||||
package net
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
var cLog = logging.Logger("conngater")
|
||||
|
||||
func (a *Libp2pNetAPI) NetBlockAdd(ctx context.Context, acl api.NetBlockList) error {
|
||||
func (a *NetAPI) NetBlockAdd(ctx context.Context, acl api.NetBlockList) error {
|
||||
for _, p := range acl.Peers {
|
||||
err := a.ConnGater.BlockPeer(p)
|
||||
if err != nil {
|
||||
@@ -89,7 +89,7 @@ func (a *Libp2pNetAPI) NetBlockAdd(ctx context.Context, acl api.NetBlockList) er
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetBlockRemove(ctx context.Context, acl api.NetBlockList) error {
|
||||
func (a *NetAPI) NetBlockRemove(ctx context.Context, acl api.NetBlockList) error {
|
||||
for _, p := range acl.Peers {
|
||||
err := a.ConnGater.UnblockPeer(p)
|
||||
if err != nil {
|
||||
@@ -124,7 +124,7 @@ func (a *Libp2pNetAPI) NetBlockRemove(ctx context.Context, acl api.NetBlockList)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetBlockList(ctx context.Context) (result api.NetBlockList, err error) {
|
||||
func (a *NetAPI) NetBlockList(ctx context.Context) (result api.NetBlockList, err error) {
|
||||
result.Peers = a.ConnGater.ListBlockedPeers()
|
||||
for _, ip := range a.ConnGater.ListBlockedAddrs() {
|
||||
result.IPAddrs = append(result.IPAddrs, ip.String())
|
||||
@@ -1,29 +1,28 @@
|
||||
package common
|
||||
package net
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"go.uber.org/fx"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
metrics "github.com/libp2p/go-libp2p-core/metrics"
|
||||
"github.com/libp2p/go-libp2p-core/metrics"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
swarm "github.com/libp2p/go-libp2p-swarm"
|
||||
basichost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||
"github.com/libp2p/go-libp2p/p2p/net/conngater"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
"go.uber.org/fx"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
apitypes "github.com/filecoin-project/lotus/api/types"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/modules/lp2p"
|
||||
)
|
||||
|
||||
type Libp2pNetAPI struct {
|
||||
type NetAPI struct {
|
||||
fx.In
|
||||
|
||||
RawHost lp2p.RawHost
|
||||
@@ -34,11 +33,15 @@ type Libp2pNetAPI struct {
|
||||
Sk *dtypes.ScoreKeeper
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetConnectedness(ctx context.Context, pid peer.ID) (network.Connectedness, error) {
|
||||
func (a *NetAPI) ID(context.Context) (peer.ID, error) {
|
||||
return a.Host.ID(), nil
|
||||
}
|
||||
|
||||
func (a *NetAPI) NetConnectedness(ctx context.Context, pid peer.ID) (network.Connectedness, error) {
|
||||
return a.Host.Network().Connectedness(pid), nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetPubsubScores(context.Context) ([]api.PubsubScore, error) {
|
||||
func (a *NetAPI) NetPubsubScores(context.Context) ([]api.PubsubScore, error) {
|
||||
scores := a.Sk.Get()
|
||||
out := make([]api.PubsubScore, len(scores))
|
||||
i := 0
|
||||
@@ -54,7 +57,7 @@ func (a *Libp2pNetAPI) NetPubsubScores(context.Context) ([]api.PubsubScore, erro
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetPeers(context.Context) ([]peer.AddrInfo, error) {
|
||||
func (a *NetAPI) NetPeers(context.Context) ([]peer.AddrInfo, error) {
|
||||
conns := a.Host.Network().Conns()
|
||||
out := make([]peer.AddrInfo, len(conns))
|
||||
|
||||
@@ -70,7 +73,7 @@ func (a *Libp2pNetAPI) NetPeers(context.Context) ([]peer.AddrInfo, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetPeerInfo(_ context.Context, p peer.ID) (*api.ExtendedPeerInfo, error) {
|
||||
func (a *NetAPI) NetPeerInfo(_ context.Context, p peer.ID) (*api.ExtendedPeerInfo, error) {
|
||||
info := &api.ExtendedPeerInfo{ID: p}
|
||||
|
||||
agent, err := a.Host.Peerstore().Get(p, "AgentVersion")
|
||||
@@ -101,7 +104,7 @@ func (a *Libp2pNetAPI) NetPeerInfo(_ context.Context, p peer.ID) (*api.ExtendedP
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetConnect(ctx context.Context, p peer.AddrInfo) error {
|
||||
func (a *NetAPI) NetConnect(ctx context.Context, p peer.AddrInfo) error {
|
||||
if swrm, ok := a.Host.Network().(*swarm.Swarm); ok {
|
||||
swrm.Backoff().Clear(p.ID)
|
||||
}
|
||||
@@ -109,22 +112,22 @@ func (a *Libp2pNetAPI) NetConnect(ctx context.Context, p peer.AddrInfo) error {
|
||||
return a.Host.Connect(ctx, p)
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetAddrsListen(context.Context) (peer.AddrInfo, error) {
|
||||
func (a *NetAPI) NetAddrsListen(context.Context) (peer.AddrInfo, error) {
|
||||
return peer.AddrInfo{
|
||||
ID: a.Host.ID(),
|
||||
Addrs: a.Host.Addrs(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetDisconnect(ctx context.Context, p peer.ID) error {
|
||||
func (a *NetAPI) NetDisconnect(ctx context.Context, p peer.ID) error {
|
||||
return a.Host.Network().ClosePeer(p)
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetFindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error) {
|
||||
func (a *NetAPI) NetFindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error) {
|
||||
return a.Router.FindPeer(ctx, p)
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetAutoNatStatus(ctx context.Context) (i api.NatInfo, err error) {
|
||||
func (a *NetAPI) NetAutoNatStatus(ctx context.Context) (i api.NatInfo, err error) {
|
||||
autonat := a.RawHost.(*basichost.BasicHost).GetAutoNat()
|
||||
|
||||
if autonat == nil {
|
||||
@@ -148,7 +151,7 @@ func (a *Libp2pNetAPI) NetAutoNatStatus(ctx context.Context) (i api.NatInfo, err
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetAgentVersion(ctx context.Context, p peer.ID) (string, error) {
|
||||
func (a *NetAPI) NetAgentVersion(ctx context.Context, p peer.ID) (string, error) {
|
||||
ag, err := a.Host.Peerstore().Get(p, "AgentVersion")
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -161,11 +164,11 @@ func (a *Libp2pNetAPI) NetAgentVersion(ctx context.Context, p peer.ID) (string,
|
||||
return ag.(string), nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetBandwidthStats(ctx context.Context) (metrics.Stats, error) {
|
||||
func (a *NetAPI) NetBandwidthStats(ctx context.Context) (metrics.Stats, error) {
|
||||
return a.Reporter.GetBandwidthTotals(), nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetBandwidthStatsByPeer(ctx context.Context) (map[string]metrics.Stats, error) {
|
||||
func (a *NetAPI) NetBandwidthStatsByPeer(ctx context.Context) (map[string]metrics.Stats, error) {
|
||||
out := make(map[string]metrics.Stats)
|
||||
for p, s := range a.Reporter.GetBandwidthByPeer() {
|
||||
out[p.String()] = s
|
||||
@@ -173,14 +176,8 @@ func (a *Libp2pNetAPI) NetBandwidthStatsByPeer(ctx context.Context) (map[string]
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) NetBandwidthStatsByProtocol(ctx context.Context) (map[protocol.ID]metrics.Stats, error) {
|
||||
func (a *NetAPI) NetBandwidthStatsByProtocol(ctx context.Context) (map[protocol.ID]metrics.Stats, error) {
|
||||
return a.Reporter.GetBandwidthByProtocol(), nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) Discover(ctx context.Context) (apitypes.OpenRPCDocument, error) {
|
||||
return build.OpenRPCDiscoverJSON_Full(), nil
|
||||
}
|
||||
|
||||
func (a *Libp2pNetAPI) ID(context.Context) (peer.ID, error) {
|
||||
return a.Host.ID(), nil
|
||||
}
|
||||
var _ api.Net = &NetAPI{}
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"go.uber.org/fx"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
@@ -38,7 +39,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/markets/storageadapter"
|
||||
"github.com/filecoin-project/lotus/miner"
|
||||
"github.com/filecoin-project/lotus/node/impl/common"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
@@ -46,7 +46,10 @@ import (
|
||||
)
|
||||
|
||||
type StorageMinerAPI struct {
|
||||
common.CommonAPI
|
||||
fx.In
|
||||
|
||||
api.Common
|
||||
api.Net
|
||||
|
||||
Full api.FullNode
|
||||
LocalStore *stores.Local
|
||||
|
||||
@@ -78,8 +78,9 @@ func SplitBlockstore(cfg *config.Chainstore) func(lc fx.Lifecycle, r repo.Locked
|
||||
}
|
||||
|
||||
cfg := &splitstore.Config{
|
||||
MarkSetType: cfg.Splitstore.MarkSetType,
|
||||
DiscardColdBlocks: cfg.Splitstore.ColdStoreType == "discard",
|
||||
MarkSetType: cfg.Splitstore.MarkSetType,
|
||||
DiscardColdBlocks: cfg.Splitstore.ColdStoreType == "discard",
|
||||
HotStoreMessageRetention: cfg.Splitstore.HotStoreMessageRetention,
|
||||
}
|
||||
ss, err := splitstore.Open(path, ds, hot, cold, cfg)
|
||||
if err != nil {
|
||||
@@ -95,6 +96,14 @@ func SplitBlockstore(cfg *config.Chainstore) func(lc fx.Lifecycle, r repo.Locked
|
||||
}
|
||||
}
|
||||
|
||||
func SplitBlockstoreGCReferenceProtector(_ fx.Lifecycle, s dtypes.SplitBlockstore) dtypes.GCReferenceProtector {
|
||||
return s.(dtypes.GCReferenceProtector)
|
||||
}
|
||||
|
||||
func NoopGCReferenceProtector(_ fx.Lifecycle) dtypes.GCReferenceProtector {
|
||||
return dtypes.NoopGCReferenceProtector{}
|
||||
}
|
||||
|
||||
func ExposedSplitBlockstore(_ fx.Lifecycle, s dtypes.SplitBlockstore) dtypes.ExposedBlockstore {
|
||||
return s.(*splitstore.SplitStore).Expose()
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func ChainBlockService(bs dtypes.ExposedBlockstore, rem dtypes.ChainBitswap) dty
|
||||
return blockservice.New(bs, rem)
|
||||
}
|
||||
|
||||
func MessagePool(lc fx.Lifecycle, mpp messagepool.Provider, ds dtypes.MetadataDS, nn dtypes.NetworkName, j journal.Journal) (*messagepool.MessagePool, error) {
|
||||
func MessagePool(lc fx.Lifecycle, mpp messagepool.Provider, ds dtypes.MetadataDS, nn dtypes.NetworkName, j journal.Journal, protector dtypes.GCReferenceProtector) (*messagepool.MessagePool, error) {
|
||||
mp, err := messagepool.New(mpp, ds, nn, j)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("constructing mpool: %w", err)
|
||||
@@ -68,6 +68,7 @@ func MessagePool(lc fx.Lifecycle, mpp messagepool.Provider, ds dtypes.MetadataDS
|
||||
return mp.Close()
|
||||
},
|
||||
})
|
||||
protector.AddProtector(mp.ForEachPendingMessage)
|
||||
return mp, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package dtypes
|
||||
|
||||
import (
|
||||
cid "github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
type GCReferenceProtector interface {
|
||||
AddProtector(func(func(cid.Cid) error) error)
|
||||
}
|
||||
|
||||
type NoopGCReferenceProtector struct{}
|
||||
|
||||
func (p NoopGCReferenceProtector) AddProtector(func(func(cid.Cid) error) error) {}
|
||||
@@ -327,6 +327,21 @@ func (fsr *fsLockedRepo) Blockstore(ctx context.Context, domain BlockstoreDomain
|
||||
return
|
||||
}
|
||||
|
||||
//
|
||||
// Tri-state environment variable LOTUS_CHAIN_BADGERSTORE_DISABLE_FSYNC
|
||||
// - unset == the default (currently fsync enabled)
|
||||
// - set with a false-y value == fsync enabled no matter what a future default is
|
||||
// - set with any other value == fsync is disabled ignored defaults (recommended for day-to-day use)
|
||||
//
|
||||
if nosyncBs, nosyncBsSet := os.LookupEnv("LOTUS_CHAIN_BADGERSTORE_DISABLE_FSYNC"); nosyncBsSet {
|
||||
nosyncBs = strings.ToLower(nosyncBs)
|
||||
if nosyncBs == "" || nosyncBs == "0" || nosyncBs == "false" || nosyncBs == "no" {
|
||||
opts.SyncWrites = true
|
||||
} else {
|
||||
opts.SyncWrites = false
|
||||
}
|
||||
}
|
||||
|
||||
bs, err := badgerbs.Open(opts)
|
||||
if err != nil {
|
||||
fsr.bsErr = err
|
||||
|
||||
Reference in New Issue
Block a user