resolved conflicts
This commit is contained in:
commit
ff2772a58c
@ -547,7 +547,7 @@ func (st *StateTree) Version() types.StateTreeVersion {
|
|||||||
return st.version
|
return st.version
|
||||||
}
|
}
|
||||||
|
|
||||||
func Diff(oldTree, newTree *StateTree) (map[string]types.Actor, error) {
|
func Diff(ctx context.Context, oldTree, newTree *StateTree) (map[string]types.Actor, error) {
|
||||||
out := map[string]types.Actor{}
|
out := map[string]types.Actor{}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -555,33 +555,38 @@ func Diff(oldTree, newTree *StateTree) (map[string]types.Actor, error) {
|
|||||||
buf = bytes.NewReader(nil)
|
buf = bytes.NewReader(nil)
|
||||||
)
|
)
|
||||||
if err := newTree.root.ForEach(&ncval, func(k string) error {
|
if err := newTree.root.ForEach(&ncval, func(k string) error {
|
||||||
var act types.Actor
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return ctx.Err()
|
||||||
|
default:
|
||||||
|
var act types.Actor
|
||||||
|
|
||||||
addr, err := address.NewFromBytes([]byte(k))
|
addr, err := address.NewFromBytes([]byte(k))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("address in state tree was not valid: %w", err)
|
return xerrors.Errorf("address in state tree was not valid: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
found, err := oldTree.root.Get(abi.AddrKey(addr), &ocval)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if found && bytes.Equal(ocval.Raw, ncval.Raw) {
|
||||||
|
return nil // not changed
|
||||||
|
}
|
||||||
|
|
||||||
|
buf.Reset(ncval.Raw)
|
||||||
|
err = act.UnmarshalCBOR(buf)
|
||||||
|
buf.Reset(nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
out[addr.String()] = act
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := oldTree.root.Get(abi.AddrKey(addr), &ocval)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if found && bytes.Equal(ocval.Raw, ncval.Raw) {
|
|
||||||
return nil // not changed
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.Reset(ncval.Raw)
|
|
||||||
err = act.UnmarshalCBOR(buf)
|
|
||||||
buf.Reset(nil)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
out[addr.String()] = act
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1030,9 @@ var ChainExportCmd = &cli.Command{
|
|||||||
ArgsUsage: "[outputPath]",
|
ArgsUsage: "[outputPath]",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "tipset",
|
Name: "tipset",
|
||||||
|
Usage: "specify tipset to start the export from",
|
||||||
|
Value: "@head",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.Int64Flag{
|
||||||
Name: "recent-stateroots",
|
Name: "recent-stateroots",
|
||||||
|
@ -2140,7 +2140,7 @@ USAGE:
|
|||||||
lotus chain export [command options] [outputPath]
|
lotus chain export [command options] [outputPath]
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
--tipset value
|
--tipset value specify tipset to start the export from (default: "@head")
|
||||||
--recent-stateroots value specify the number of recent state roots to include in the export (default: 0)
|
--recent-stateroots value specify the number of recent state roots to include in the export (default: 0)
|
||||||
--skip-old-msgs (default: false)
|
--skip-old-msgs (default: false)
|
||||||
--help, -h show help (default: false)
|
--help, -h show help (default: false)
|
||||||
|
2
extern/storage-sealing/checks.go
vendored
2
extern/storage-sealing/checks.go
vendored
@ -62,7 +62,7 @@ func checkPieces(ctx context.Context, maddr address.Address, si SectorInfo, api
|
|||||||
}
|
}
|
||||||
|
|
||||||
if proposal.PieceCID != p.Piece.PieceCID {
|
if proposal.PieceCID != p.Piece.PieceCID {
|
||||||
return &ErrInvalidDeals{xerrors.Errorf("piece %d (of %d) of sector %d refers deal %d with wrong PieceCID: %x != %x", i, len(si.Pieces), si.SectorNumber, p.DealInfo.DealID, p.Piece.PieceCID, proposal.PieceCID)}
|
return &ErrInvalidDeals{xerrors.Errorf("piece %d (of %d) of sector %d refers deal %d with wrong PieceCID: %s != %s", i, len(si.Pieces), si.SectorNumber, p.DealInfo.DealID, p.Piece.PieceCID, proposal.PieceCID)}
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Piece.Size != proposal.PieceSize {
|
if p.Piece.Size != proposal.PieceSize {
|
||||||
|
4
extern/storage-sealing/states_failed.go
vendored
4
extern/storage-sealing/states_failed.go
vendored
@ -142,7 +142,7 @@ func (m *Sealing) handlePreCommitFailed(ctx statemachine.Context, sector SectorI
|
|||||||
}
|
}
|
||||||
|
|
||||||
if pci.Info.SealedCID != *sector.CommR {
|
if pci.Info.SealedCID != *sector.CommR {
|
||||||
log.Warnf("sector %d is precommitted on chain, with different CommR: %x != %x", sector.SectorNumber, pci.Info.SealedCID, sector.CommR)
|
log.Warnf("sector %d is precommitted on chain, with different CommR: %s != %s", sector.SectorNumber, pci.Info.SealedCID, sector.CommR)
|
||||||
return nil // TODO: remove when the actor allows re-precommit
|
return nil // TODO: remove when the actor allows re-precommit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +354,7 @@ func (m *Sealing) handleRecoverDealIDs(ctx statemachine.Context, sector SectorIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
if proposal.PieceCID != p.Piece.PieceCID {
|
if proposal.PieceCID != p.Piece.PieceCID {
|
||||||
log.Warnf("piece %d (of %d) of sector %d refers deal %d with wrong PieceCID: %x != %x", i, len(sector.Pieces), sector.SectorNumber, p.DealInfo.DealID, p.Piece.PieceCID, proposal.PieceCID)
|
log.Warnf("piece %d (of %d) of sector %d refers deal %d with wrong PieceCID: %s != %s", i, len(sector.Pieces), sector.SectorNumber, p.DealInfo.DealID, p.Piece.PieceCID, proposal.PieceCID)
|
||||||
toFix = append(toFix, i)
|
toFix = append(toFix, i)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
2
extern/storage-sealing/states_sealing.go
vendored
2
extern/storage-sealing/states_sealing.go
vendored
@ -524,7 +524,7 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo)
|
|||||||
|
|
||||||
log.Info("scheduling seal proof computation...")
|
log.Info("scheduling seal proof computation...")
|
||||||
|
|
||||||
log.Infof("KOMIT %d %x(%d); %x(%d); %v; r:%x; d:%x", sector.SectorNumber, sector.TicketValue, sector.TicketEpoch, sector.SeedValue, sector.SeedEpoch, sector.pieceInfos(), sector.CommR, sector.CommD)
|
log.Infof("KOMIT %d %x(%d); %x(%d); %v; r:%s; d:%s", sector.SectorNumber, sector.TicketValue, sector.TicketEpoch, sector.SeedValue, sector.SeedEpoch, sector.pieceInfos(), sector.CommR, sector.CommD)
|
||||||
|
|
||||||
if sector.CommD == nil || sector.CommR == nil {
|
if sector.CommD == nil || sector.CommR == nil {
|
||||||
return ctx.Send(SectorCommitFailed{xerrors.Errorf("sector had nil commR or commD")})
|
return ctx.Send(SectorCommitFailed{xerrors.Errorf("sector had nil commR or commD")})
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api/v1api"
|
"github.com/filecoin-project/lotus/api/v1api"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||||
|
"github.com/hashicorp/go-multierror"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@ -139,10 +140,14 @@ func (rpn *retrievalProviderNode) GetRetrievalPricingInput(ctx context.Context,
|
|||||||
}
|
}
|
||||||
tsk := head.Key()
|
tsk := head.Key()
|
||||||
|
|
||||||
|
var mErr error
|
||||||
|
|
||||||
for _, dealID := range storageDeals {
|
for _, dealID := range storageDeals {
|
||||||
ds, err := rpn.full.StateMarketStorageDeal(ctx, dealID, tsk)
|
ds, err := rpn.full.StateMarketStorageDeal(ctx, dealID, tsk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp, xerrors.Errorf("failed to look up deal %d on chain: err=%w", dealID, err)
|
log.Warnf("failed to look up deal %d on chain: err=%w", dealID, err)
|
||||||
|
mErr = multierror.Append(mErr, err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
if ds.Proposal.VerifiedDeal {
|
if ds.Proposal.VerifiedDeal {
|
||||||
resp.VerifiedDeal = true
|
resp.VerifiedDeal = true
|
||||||
@ -162,7 +167,11 @@ func (rpn *retrievalProviderNode) GetRetrievalPricingInput(ctx context.Context,
|
|||||||
// Note: The piece size can never actually be zero. We only use it to here
|
// Note: The piece size can never actually be zero. We only use it to here
|
||||||
// to assert that we didn't find a matching piece.
|
// to assert that we didn't find a matching piece.
|
||||||
if resp.PieceSize == 0 {
|
if resp.PieceSize == 0 {
|
||||||
return resp, xerrors.New("failed to find matching piece")
|
if mErr == nil {
|
||||||
|
return resp, xerrors.New("failed to find matching piece")
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, xerrors.Errorf("failed to fetch storage deal state: %w", mErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
@ -66,6 +66,31 @@ func TestGetPricingInput(t *testing.T) {
|
|||||||
expectedErrorStr: "failed to find matching piece",
|
expectedErrorStr: "failed to find matching piece",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"error when fails to fetch deal state": {
|
||||||
|
fFnc: func(n *mocks.MockFullNode) {
|
||||||
|
out1 := &api.MarketDeal{
|
||||||
|
Proposal: market.DealProposal{
|
||||||
|
PieceCID: pcid,
|
||||||
|
PieceSize: paddedSize,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
out2 := &api.MarketDeal{
|
||||||
|
Proposal: market.DealProposal{
|
||||||
|
PieceCID: testnet.GenerateCids(1)[0],
|
||||||
|
VerifiedDeal: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
n.EXPECT().ChainHead(gomock.Any()).Return(tsk, nil).Times(1)
|
||||||
|
gomock.InOrder(
|
||||||
|
n.EXPECT().StateMarketStorageDeal(gomock.Any(), deals[0], key).Return(out1, xerrors.New("error 1")),
|
||||||
|
n.EXPECT().StateMarketStorageDeal(gomock.Any(), deals[1], key).Return(out2, xerrors.New("error 2")),
|
||||||
|
)
|
||||||
|
|
||||||
|
},
|
||||||
|
expectedErrorStr: "failed to fetch storage deal state",
|
||||||
|
},
|
||||||
|
|
||||||
"verified is true even if one deal is verified and we get the correct piecesize": {
|
"verified is true even if one deal is verified and we get the correct piecesize": {
|
||||||
fFnc: func(n *mocks.MockFullNode) {
|
fFnc: func(n *mocks.MockFullNode) {
|
||||||
out1 := &api.MarketDeal{
|
out1 := &api.MarketDeal{
|
||||||
@ -92,6 +117,32 @@ func TestGetPricingInput(t *testing.T) {
|
|||||||
expectedVerified: true,
|
expectedVerified: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"success even if one deal state fetch errors out but the other deal is verified and has the required piececid": {
|
||||||
|
fFnc: func(n *mocks.MockFullNode) {
|
||||||
|
out1 := &api.MarketDeal{
|
||||||
|
Proposal: market.DealProposal{
|
||||||
|
PieceCID: testnet.GenerateCids(1)[0],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
out2 := &api.MarketDeal{
|
||||||
|
Proposal: market.DealProposal{
|
||||||
|
PieceCID: pcid,
|
||||||
|
PieceSize: paddedSize,
|
||||||
|
VerifiedDeal: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
n.EXPECT().ChainHead(gomock.Any()).Return(tsk, nil).Times(1)
|
||||||
|
gomock.InOrder(
|
||||||
|
n.EXPECT().StateMarketStorageDeal(gomock.Any(), deals[0], key).Return(out1, xerrors.New("some error")),
|
||||||
|
n.EXPECT().StateMarketStorageDeal(gomock.Any(), deals[1], key).Return(out2, nil),
|
||||||
|
)
|
||||||
|
|
||||||
|
},
|
||||||
|
expectedPieceSize: unpaddedSize,
|
||||||
|
expectedVerified: true,
|
||||||
|
},
|
||||||
|
|
||||||
"verified is false if both deals are unverified and we get the correct piece size": {
|
"verified is false if both deals are unverified and we get the correct piece size": {
|
||||||
fFnc: func(n *mocks.MockFullNode) {
|
fFnc: func(n *mocks.MockFullNode) {
|
||||||
out1 := &api.MarketDeal{
|
out1 := &api.MarketDeal{
|
||||||
|
@ -705,7 +705,7 @@ func (a *StateAPI) StateChangedActors(ctx context.Context, old cid.Cid, new cid.
|
|||||||
return nil, xerrors.Errorf("failed to load new state tree: %w", err)
|
return nil, xerrors.Errorf("failed to load new state tree: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return state.Diff(oldTree, newTree)
|
return state.Diff(ctx, oldTree, newTree)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *StateAPI) StateMinerSectorCount(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MinerSectors, error) {
|
func (a *StateAPI) StateMinerSectorCount(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MinerSectors, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user