Merge remote-tracking branch 'origin/master' into feat/post-worker
This commit is contained in:
@@ -33,6 +33,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||
"github.com/filecoin-project/lotus/journal"
|
||||
"github.com/filecoin-project/lotus/journal/alerting"
|
||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||
"github.com/filecoin-project/lotus/lib/peermgr"
|
||||
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
||||
@@ -249,6 +250,9 @@ func Base() Option {
|
||||
|
||||
// Config sets up constructors based on the provided Config
|
||||
func ConfigCommon(cfg *config.Common, enableLibp2pNode bool) Option {
|
||||
// setup logging early
|
||||
lotuslog.SetLevelsFromConfig(cfg.Logging.SubsystemLevels)
|
||||
|
||||
return Options(
|
||||
func(s *Settings) error { s.Config = true; return nil },
|
||||
Override(new(dtypes.APIEndpoint), func() (dtypes.APIEndpoint, error) {
|
||||
|
||||
@@ -47,6 +47,11 @@ func defCommon() Common {
|
||||
ListenAddress: "/ip4/127.0.0.1/tcp/1234/http",
|
||||
Timeout: Duration(30 * time.Second),
|
||||
},
|
||||
Logging: Logging{
|
||||
SubsystemLevels: map[string]string{
|
||||
"example-subsystem": "INFO",
|
||||
},
|
||||
},
|
||||
Libp2p: Libp2p{
|
||||
ListenAddresses: []string{
|
||||
"/ip4/0.0.0.0/tcp/0",
|
||||
|
||||
@@ -32,6 +32,24 @@ func TestDefaultFullNodeRoundtrip(t *testing.T) {
|
||||
require.True(t, reflect.DeepEqual(c, c2))
|
||||
}
|
||||
|
||||
func TestDefaultFullNodeCommentRoundtrip(t *testing.T) {
|
||||
c := DefaultFullNode()
|
||||
|
||||
var s string
|
||||
{
|
||||
c, err := ConfigComment(DefaultFullNode())
|
||||
require.NoError(t, err)
|
||||
s = string(c)
|
||||
}
|
||||
|
||||
c2, err := FromReader(strings.NewReader(s), DefaultFullNode())
|
||||
require.NoError(t, err)
|
||||
|
||||
fmt.Println(s)
|
||||
|
||||
require.True(t, reflect.DeepEqual(c, c2))
|
||||
}
|
||||
|
||||
func TestDefaultMinerRoundtrip(t *testing.T) {
|
||||
c := DefaultStorageMiner()
|
||||
|
||||
|
||||
@@ -127,6 +127,12 @@ of automatically performing on-chain operations.`,
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Logging",
|
||||
Type: "Logging",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Libp2p",
|
||||
Type: "Libp2p",
|
||||
@@ -484,6 +490,14 @@ count towards this limit.`,
|
||||
closed by the connection manager.`,
|
||||
},
|
||||
},
|
||||
"Logging": []DocField{
|
||||
{
|
||||
Name: "SubsystemLevels",
|
||||
Type: "map[string]string",
|
||||
|
||||
Comment: `SubsystemLevels specify per-subsystem log levels`,
|
||||
},
|
||||
},
|
||||
"MinerAddressConfig": []DocField{
|
||||
{
|
||||
Name: "PreCommitControl",
|
||||
|
||||
@@ -16,7 +16,7 @@ func findDoc(root interface{}, section, name string) *DocField {
|
||||
return findDocSect("Common", section, name)
|
||||
}
|
||||
|
||||
func findDocSect(root string, section, name string) *DocField {
|
||||
func findDocSect(root, section, name string) *DocField {
|
||||
path := strings.Split(section, ".")
|
||||
|
||||
docSection := Doc[root]
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ func ConfigUpdate(cfgCur, cfgDef interface{}, comment bool) ([]byte, error) {
|
||||
}
|
||||
|
||||
if comment {
|
||||
// create a map of default lines so we can comment those out later
|
||||
// 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 {
|
||||
|
||||
+11
-4
@@ -13,10 +13,11 @@ import (
|
||||
|
||||
// Common is common config between full node and miner
|
||||
type Common struct {
|
||||
API API
|
||||
Backup Backup
|
||||
Libp2p Libp2p
|
||||
Pubsub Pubsub
|
||||
API API
|
||||
Backup Backup
|
||||
Logging Logging
|
||||
Libp2p Libp2p
|
||||
Pubsub Pubsub
|
||||
}
|
||||
|
||||
// FullNode is a full node config
|
||||
@@ -39,6 +40,12 @@ type Backup struct {
|
||||
DisableMetadataLog bool
|
||||
}
|
||||
|
||||
// Logging is the logging system config
|
||||
type Logging struct {
|
||||
// SubsystemLevels specify per-subsystem log levels
|
||||
SubsystemLevels map[string]string
|
||||
}
|
||||
|
||||
// StorageMiner is a miner config
|
||||
type StorageMiner struct {
|
||||
Common
|
||||
|
||||
@@ -47,7 +47,6 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
cborutil "github.com/filecoin-project/go-cbor-util"
|
||||
"github.com/filecoin-project/go-commp-utils/ffiwrapper"
|
||||
"github.com/filecoin-project/go-commp-utils/writer"
|
||||
datatransfer "github.com/filecoin-project/go-data-transfer"
|
||||
|
||||
@@ -1263,28 +1262,12 @@ func (a *API) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Addre
|
||||
}
|
||||
|
||||
func (a *API) ClientCalcCommP(ctx context.Context, inpath string) (*api.CommPRet, error) {
|
||||
|
||||
// Hard-code the sector type to 32GiBV1_1, because:
|
||||
// - ffiwrapper.GeneratePieceCIDFromFile requires a RegisteredSealProof
|
||||
// - commP itself is sector-size independent, with rather low probability of that changing
|
||||
// ( note how the final rust call is identical for every RegSP type )
|
||||
// https://github.com/filecoin-project/rust-filecoin-proofs-api/blob/v5.0.0/src/seal.rs#L1040-L1050
|
||||
//
|
||||
// IF/WHEN this changes in the future we will have to be able to calculate
|
||||
// "old style" commP, and thus will need to introduce a version switch or similar
|
||||
arbitraryProofType := abi.RegisteredSealProof_StackedDrg64GiBV1_1
|
||||
|
||||
rdr, err := os.Open(inpath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rdr.Close() //nolint:errcheck
|
||||
|
||||
stat, err := rdr.Stat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// check that the data is a car file; if it's not, retrieval won't work
|
||||
_, err = car.ReadHeader(bufio.NewReader(rdr))
|
||||
if err != nil {
|
||||
@@ -1295,16 +1278,20 @@ func (a *API) ClientCalcCommP(ctx context.Context, inpath string) (*api.CommPRet
|
||||
return nil, xerrors.Errorf("seek to start: %w", err)
|
||||
}
|
||||
|
||||
pieceReader, pieceSize := padreader.New(rdr, uint64(stat.Size()))
|
||||
commP, err := ffiwrapper.GeneratePieceCIDFromFile(arbitraryProofType, pieceReader, pieceSize)
|
||||
w := &writer.Writer{}
|
||||
_, err = io.CopyBuffer(w, rdr, make([]byte, writer.CommPBuf))
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("copy into commp writer: %w", err)
|
||||
}
|
||||
|
||||
commp, err := w.Sum()
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("computing commP failed: %w", err)
|
||||
}
|
||||
|
||||
return &api.CommPRet{
|
||||
Root: commP,
|
||||
Size: pieceSize,
|
||||
Root: commp.PieceCID,
|
||||
Size: commp.PieceSize.Unpadded(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -676,18 +676,18 @@ func (tc *transferConverter) convertTransfer(channelID datatransfer.ChannelID, h
|
||||
}
|
||||
var channelIDPtr *datatransfer.ChannelID
|
||||
if !hasChannelID {
|
||||
diagnostics = append(diagnostics, fmt.Sprintf("No data transfer channel id for GraphSync request ID %d", requestID))
|
||||
diagnostics = append(diagnostics, fmt.Sprintf("No data transfer channel id for GraphSync request ID %s", requestID))
|
||||
} else {
|
||||
channelIDPtr = &channelID
|
||||
if isCurrentChannelRequest && !hasState {
|
||||
diagnostics = append(diagnostics, fmt.Sprintf("No current request state for data transfer channel id %s", channelID))
|
||||
} else if !isCurrentChannelRequest && hasState {
|
||||
diagnostics = append(diagnostics, fmt.Sprintf("Graphsync request %d is a previous request on data transfer channel id %s that was restarted, but it is still running", requestID, channelID))
|
||||
diagnostics = append(diagnostics, fmt.Sprintf("Graphsync request %s is a previous request on data transfer channel id %s that was restarted, but it is still running", requestID, channelID))
|
||||
}
|
||||
}
|
||||
diagnostics = append(diagnostics, tc.gsDiagnostics[requestID]...)
|
||||
transfer := &api.GraphSyncDataTransfer{
|
||||
RequestID: requestID,
|
||||
RequestID: &requestID,
|
||||
RequestState: stateString,
|
||||
IsCurrentChannelRequest: isCurrentChannelRequest,
|
||||
ChannelID: channelIDPtr,
|
||||
@@ -717,7 +717,7 @@ func (tc *transferConverter) collectRemainingTransfers() {
|
||||
channelID := channelID
|
||||
cs := api.NewDataTransferChannel(channelState.SelfPeer(), channelState)
|
||||
transfer := &api.GraphSyncDataTransfer{
|
||||
RequestID: graphsync.RequestID(-1),
|
||||
RequestID: nil,
|
||||
RequestState: "graphsync state unknown",
|
||||
IsCurrentChannelRequest: false,
|
||||
ChannelID: &channelID,
|
||||
|
||||
Reference in New Issue
Block a user