Most tests passing

This commit is contained in:
Łukasz Magiera 2020-09-17 17:30:15 +02:00
parent e632643801
commit 6eda53565f
24 changed files with 159 additions and 84 deletions

View File

@ -326,7 +326,9 @@ type FullNode interface {
// StateMinerInfo returns info about the indicated miner // StateMinerInfo returns info about the indicated miner
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error)
// StateMinerDeadlines returns all the proving deadlines for the given miner // StateMinerDeadlines returns all the proving deadlines for the given miner
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]*miner.Deadline, error) StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]Deadline, error)
// StateMinerPartitions returns all partitions in the specified deadline
StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]Partition, error)
// StateMinerFaults returns a bitfield indicating the faulty sectors of the given miner // StateMinerFaults returns a bitfield indicating the faulty sectors of the given miner
StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
// StateAllMinerFaults returns all non-expired Faults that occur within lookback epochs of the given tipset // StateAllMinerFaults returns all non-expired Faults that occur within lookback epochs of the given tipset
@ -383,7 +385,7 @@ type FullNode interface {
// StateVerifiedClientStatus returns the data cap for the given address. // StateVerifiedClientStatus returns the data cap for the given address.
// Returns nil if there is no entry in the data cap table for the // Returns nil if there is no entry in the data cap table for the
// address. // address.
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (abi.StoragePower, error) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
// StateDealProviderCollateralBounds returns the min and max collateral a storage provider // StateDealProviderCollateralBounds returns the min and max collateral a storage provider
// can issue. It takes the deal size and verified status as parameters. // can issue. It takes the deal size and verified status as parameters.
StateDealProviderCollateralBounds(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (DealCollateralBounds, error) StateDealProviderCollateralBounds(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (DealCollateralBounds, error)
@ -816,6 +818,18 @@ const (
MsigCancel MsigCancel
) )
type Deadline struct {
PostSubmissions bitfield.BitField
}
type Partition struct {
AllSectors bitfield.BitField
FaultySectors bitfield.BitField
RecoveringSectors bitfield.BitField
LiveSectors bitfield.BitField
ActiveSectors bitfield.BitField
}
type Fault struct { type Fault struct {
Miner address.Address Miner address.Address
Epoch abi.ChainEpoch Epoch abi.ChainEpoch

View File

@ -55,7 +55,7 @@ func TestReturnTypes(t *testing.T) {
seen := map[reflect.Type]struct{}{} seen := map[reflect.Type]struct{}{}
todo := []reflect.Type{m.Type.Out(0)} todo := []reflect.Type{m.Type.Out(0)}
for len(todo) > 0 { for len(todo) > 0 {
typ := todo[len(todo) - 1] typ := todo[len(todo)-1]
todo = todo[:len(todo)-1] todo = todo[:len(todo)-1]
if _, ok := seen[typ]; ok { if _, ok := seen[typ]; ok {

View File

@ -167,7 +167,8 @@ type FullNodeStruct struct {
StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) `perm:"read"` StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) `perm:"read"`
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"` StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) `perm:"read"` StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) `perm:"read"`
StateMinerDeadlines func(context.Context, address.Address, types.TipSetKey) ([]*miner.Deadline, error) `perm:"read"` StateMinerDeadlines func(context.Context, address.Address, types.TipSetKey) ([]api.Deadline, error) `perm:"read"`
StateMinerPartitions func(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]api.Partition, error) `perm:"read"`
StateMinerFaults func(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) `perm:"read"` StateMinerFaults func(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) `perm:"read"`
StateAllMinerFaults func(context.Context, abi.ChainEpoch, types.TipSetKey) ([]*api.Fault, error) `perm:"read"` StateAllMinerFaults func(context.Context, abi.ChainEpoch, types.TipSetKey) ([]*api.Fault, error) `perm:"read"`
StateMinerRecoveries func(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) `perm:"read"` StateMinerRecoveries func(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) `perm:"read"`
@ -197,7 +198,7 @@ type FullNodeStruct struct {
StateMinerSectorCount func(context.Context, address.Address, types.TipSetKey) (api.MinerSectors, error) `perm:"read"` StateMinerSectorCount func(context.Context, address.Address, types.TipSetKey) (api.MinerSectors, error) `perm:"read"`
StateListMessages func(ctx context.Context, match *types.Message, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error) `perm:"read"` StateListMessages func(ctx context.Context, match *types.Message, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error) `perm:"read"`
StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*api.ComputeStateOutput, error) `perm:"read"` StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*api.ComputeStateOutput, error) `perm:"read"`
StateVerifiedClientStatus func(context.Context, address.Address, types.TipSetKey) (abi.StoragePower, error) `perm:"read"` StateVerifiedClientStatus func(context.Context, address.Address, types.TipSetKey) (*abi.StoragePower, error) `perm:"read"`
StateDealProviderCollateralBounds func(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (api.DealCollateralBounds, error) `perm:"read"` StateDealProviderCollateralBounds func(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (api.DealCollateralBounds, error) `perm:"read"`
StateCirculatingSupply func(context.Context, types.TipSetKey) (api.CirculatingSupply, error) `perm:"read"` StateCirculatingSupply func(context.Context, types.TipSetKey) (api.CirculatingSupply, error) `perm:"read"`
StateNetworkVersion func(context.Context, types.TipSetKey) (stnetwork.Version, error) `perm:"read"` StateNetworkVersion func(context.Context, types.TipSetKey) (stnetwork.Version, error) `perm:"read"`
@ -752,10 +753,14 @@ func (c *FullNodeStruct) StateMinerInfo(ctx context.Context, actor address.Addre
return c.Internal.StateMinerInfo(ctx, actor, tsk) return c.Internal.StateMinerInfo(ctx, actor, tsk)
} }
func (c *FullNodeStruct) StateMinerDeadlines(ctx context.Context, actor address.Address, tsk types.TipSetKey) ([]*miner.Deadline, error) { func (c *FullNodeStruct) StateMinerDeadlines(ctx context.Context, actor address.Address, tsk types.TipSetKey) ([]api.Deadline, error) {
return c.Internal.StateMinerDeadlines(ctx, actor, tsk) return c.Internal.StateMinerDeadlines(ctx, actor, tsk)
} }
func (c *FullNodeStruct) StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]api.Partition, error) {
return c.Internal.StateMinerPartitions(ctx, m, dlIdx, tsk)
}
func (c *FullNodeStruct) StateMinerFaults(ctx context.Context, actor address.Address, tsk types.TipSetKey) (bitfield.BitField, error) { func (c *FullNodeStruct) StateMinerFaults(ctx context.Context, actor address.Address, tsk types.TipSetKey) (bitfield.BitField, error) {
return c.Internal.StateMinerFaults(ctx, actor, tsk) return c.Internal.StateMinerFaults(ctx, actor, tsk)
} }
@ -868,7 +873,7 @@ func (c *FullNodeStruct) StateCompute(ctx context.Context, height abi.ChainEpoch
return c.Internal.StateCompute(ctx, height, msgs, tsk) return c.Internal.StateCompute(ctx, height, msgs, tsk)
} }
func (c *FullNodeStruct) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (abi.StoragePower, error) { func (c *FullNodeStruct) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) {
return c.Internal.StateVerifiedClientStatus(ctx, addr, tsk) return c.Internal.StateVerifiedClientStatus(ctx, addr, tsk)
} }

View File

@ -200,7 +200,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
require.NoError(t, err) require.NoError(t, err)
require.Greater(t, len(parts), 0) require.Greater(t, len(parts), 0)
secs, err := parts[0].AllSectors() secs := parts[0].AllSectors
require.NoError(t, err) require.NoError(t, err)
n, err := secs.Count() n, err := secs.Count()
require.NoError(t, err) require.NoError(t, err)
@ -224,7 +224,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
require.NoError(t, err) require.NoError(t, err)
require.Greater(t, len(parts), 0) require.Greater(t, len(parts), 0)
secs, err := parts[0].AllSectors() secs := parts[0].AllSectors
require.NoError(t, err) require.NoError(t, err)
n, err := secs.Count() n, err := secs.Count()
require.NoError(t, err) require.NoError(t, err)

View File

@ -17,7 +17,7 @@ const (
// Converts a network version into a specs-actors version. // Converts a network version into a specs-actors version.
func VersionForNetwork(version network.Version) Version { func VersionForNetwork(version network.Version) Version {
switch version { switch version {
case network.Version0, network.Version1: case network.Version0, network.Version1, network.Version2:
return Version0 return Version0
default: default:
panic(fmt.Sprintf("unsupported network version %d", version)) panic(fmt.Sprintf("unsupported network version %d", version))

View File

@ -57,6 +57,7 @@ type State interface {
type Deadline interface { type Deadline interface {
LoadPartition(idx uint64) (Partition, error) LoadPartition(idx uint64) (Partition, error)
ForEachPartition(cb func(idx uint64, part Partition) error) error ForEachPartition(cb func(idx uint64, part Partition) error) error
PostSubmissions() (bitfield.BitField, error)
} }
type Partition interface { type Partition interface {

View File

@ -266,6 +266,10 @@ func (d *v0Deadline) ForEachPartition(cb func(uint64, Partition) error) error {
}) })
} }
func (d *v0Deadline) PostSubmissions() (bitfield.BitField, error) {
return d.Deadline.PostSubmissions, nil
}
func (p *v0Partition) AllSectors() (bitfield.BitField, error) { func (p *v0Partition) AllSectors() (bitfield.BitField, error) {
return p.Partition.Sectors, nil return p.Partition.Sectors, nil
} }

View File

@ -28,7 +28,7 @@ func Load(store adt.Store, act *types.Actor) (st State, err error) {
} }
type State interface { type State interface {
cbor.Marshaler cbor.Er
RewardSmoothed() (builtin.FilterEstimate, error) RewardSmoothed() (builtin.FilterEstimate, error)
EffectiveBaselinePower() (abi.StoragePower, error) EffectiveBaselinePower() (abi.StoragePower, error)

View File

@ -12,11 +12,10 @@ import (
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/adt"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
"github.com/filecoin-project/lotus/chain/actors/builtin/market" "github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/actors/builtin/paych" "github.com/filecoin-project/lotus/chain/actors/builtin/paych"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
v0adt "github.com/filecoin-project/specs-actors/actors/util/adt"
cbor "github.com/ipfs/go-ipld-cbor" cbor "github.com/ipfs/go-ipld-cbor"
typegen "github.com/whyrusleeping/cbor-gen" typegen "github.com/whyrusleeping/cbor-gen"
@ -299,12 +298,12 @@ type DiffMinerActorStateFunc func(ctx context.Context, oldState miner.State, new
func (sp *StatePredicates) OnInitActorChange(diffInitActorState DiffInitActorStateFunc) DiffTipSetKeyFunc { func (sp *StatePredicates) OnInitActorChange(diffInitActorState DiffInitActorStateFunc) DiffTipSetKeyFunc {
return sp.OnActorStateChanged(builtin.InitActorAddr, func(ctx context.Context, oldActorState, newActorState *types.Actor) (changed bool, user UserData, err error) { return sp.OnActorStateChanged(builtin.InitActorAddr, func(ctx context.Context, oldActorState, newActorState *types.Actor) (changed bool, user UserData, err error) {
var oldState init_.State oldState, err := init_.Load(adt.WrapStore(ctx, sp.cst), oldActorState)
if err := sp.cst.Get(ctx, oldActorState.Head, &oldState); err != nil { if err != nil {
return false, nil, err return false, nil, err
} }
var newState init_.State newState, err := init_.Load(adt.WrapStore(ctx, sp.cst), newActorState)
if err := sp.cst.Get(ctx, newActorState.Head, &newState); err != nil { if err != nil {
return false, nil, err return false, nil, err
} }
return diffInitActorState(ctx, &oldState, &newState) return diffInitActorState(ctx, &oldState, &newState)
@ -314,12 +313,12 @@ func (sp *StatePredicates) OnInitActorChange(diffInitActorState DiffInitActorSta
func (sp *StatePredicates) OnMinerActorChange(minerAddr address.Address, diffMinerActorState DiffMinerActorStateFunc) DiffTipSetKeyFunc { func (sp *StatePredicates) OnMinerActorChange(minerAddr address.Address, diffMinerActorState DiffMinerActorStateFunc) DiffTipSetKeyFunc {
return sp.OnActorStateChanged(minerAddr, func(ctx context.Context, oldActorState, newActorState *types.Actor) (changed bool, user UserData, err error) { return sp.OnActorStateChanged(minerAddr, func(ctx context.Context, oldActorState, newActorState *types.Actor) (changed bool, user UserData, err error) {
var oldState miner.State oldState, err := miner.Load(adt.WrapStore(ctx, sp.cst), oldActorState)
if err := sp.cst.Get(ctx, oldActorState.Head, &oldState); err != nil { if err != nil {
return false, nil, err return false, nil, err
} }
var newState miner.State newState, err := miner.Load(adt.WrapStore(ctx, sp.cst), newActorState)
if err := sp.cst.Get(ctx, newActorState.Head, &newState); err != nil { if err != nil {
return false, nil, err return false, nil, err
} }
return diffMinerActorState(ctx, oldState, newState) return diffMinerActorState(ctx, oldState, newState)
@ -620,7 +619,7 @@ func (i *InitActorAddressChanges) Remove(key string, val *typegen.Deferred) erro
func (sp *StatePredicates) OnAddressMapChange() DiffInitActorStateFunc { func (sp *StatePredicates) OnAddressMapChange() DiffInitActorStateFunc {
return func(ctx context.Context, oldState, newState *init_.State) (changed bool, user UserData, err error) { return func(ctx context.Context, oldState, newState *init_.State) (changed bool, user UserData, err error) {
ctxStore := &contextStore{ /*ctxStore := &contextStore{
ctx: ctx, ctx: ctx,
cst: sp.cst, cst: sp.cst,
} }
@ -653,6 +652,9 @@ func (sp *StatePredicates) OnAddressMapChange() DiffInitActorStateFunc {
return false, nil, nil return false, nil, nil
} }
return true, addressChanges, nil return true, addressChanges, nil*/
panic("TODO")
return false, nil, nil
} }
} }

View File

@ -1216,6 +1216,9 @@ func makeZipfPremiumDistribution(rng *rand.Rand) func() uint64 {
} }
func TestCompetitiveMessageSelectionExp(t *testing.T) { func TestCompetitiveMessageSelectionExp(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
}
var capacityBoost, rewardBoost, tqReward float64 var capacityBoost, rewardBoost, tqReward float64
seeds := []int64{1947, 1976, 2020, 2100, 10000, 143324, 432432, 131, 32, 45} seeds := []int64{1947, 1976, 2020, 2100, 10000, 143324, 432432, 131, 32, 45}
for _, seed := range seeds { for _, seed := range seeds {

View File

@ -5,17 +5,20 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/filecoin-project/specs-actors/actors/builtin"
address "github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor" cbor "github.com/ipfs/go-ipld-cbor"
address "github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/lotus/build"
builtin2 "github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
) )
func BenchmarkStateTreeSet(b *testing.B) { func BenchmarkStateTreeSet(b *testing.B) {
cst := cbor.NewMemCborStore() cst := cbor.NewMemCborStore()
st, err := NewStateTree(cst) st, err := NewStateTree(cst, builtin2.VersionForNetwork(build.NewestNetworkVersion))
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
} }
@ -42,7 +45,7 @@ func BenchmarkStateTreeSet(b *testing.B) {
func BenchmarkStateTreeSetFlush(b *testing.B) { func BenchmarkStateTreeSetFlush(b *testing.B) {
cst := cbor.NewMemCborStore() cst := cbor.NewMemCborStore()
st, err := NewStateTree(cst) st, err := NewStateTree(cst, builtin2.VersionForNetwork(build.NewestNetworkVersion))
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
} }
@ -72,7 +75,7 @@ func BenchmarkStateTreeSetFlush(b *testing.B) {
func BenchmarkStateTree10kGetActor(b *testing.B) { func BenchmarkStateTree10kGetActor(b *testing.B) {
cst := cbor.NewMemCborStore() cst := cbor.NewMemCborStore()
st, err := NewStateTree(cst) st, err := NewStateTree(cst, builtin2.VersionForNetwork(build.NewestNetworkVersion))
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
} }
@ -114,7 +117,7 @@ func BenchmarkStateTree10kGetActor(b *testing.B) {
func TestSetCache(t *testing.T) { func TestSetCache(t *testing.T) {
cst := cbor.NewMemCborStore() cst := cbor.NewMemCborStore()
st, err := NewStateTree(cst) st, err := NewStateTree(cst, builtin2.VersionForNetwork(build.NewestNetworkVersion))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -151,7 +154,7 @@ func TestSetCache(t *testing.T) {
func TestSnapshots(t *testing.T) { func TestSnapshots(t *testing.T) {
ctx := context.Background() ctx := context.Background()
cst := cbor.NewMemCborStore() cst := cbor.NewMemCborStore()
st, err := NewStateTree(cst) st, err := NewStateTree(cst, builtin2.VersionForNetwork(build.NewestNetworkVersion))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -234,7 +237,7 @@ func assertNotHas(t *testing.T, st *StateTree, addr address.Address) {
func TestStateTreeConsistency(t *testing.T) { func TestStateTreeConsistency(t *testing.T) {
cst := cbor.NewMemCborStore() cst := cbor.NewMemCborStore()
st, err := NewStateTree(cst) st, err := NewStateTree(cst, builtin2.VersionForNetwork(build.NewestNetworkVersion))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -1024,9 +1024,9 @@ func GetFilMined(ctx context.Context, st *state.StateTree) (abi.TokenAmount, err
return big.Zero(), xerrors.Errorf("failed to load reward actor state: %w", err) return big.Zero(), xerrors.Errorf("failed to load reward actor state: %w", err)
} }
var rst reward.State rst, err := reward.Load(adt.WrapStore(ctx, st.Store), ractor)
if err := st.Store.Get(ctx, ractor.Head, &rst); err != nil { if err != nil {
return big.Zero(), xerrors.Errorf("failed to load reward state: %w", err) return big.Zero(), err
} }
return rst.TotalStoragePowerReward() return rst.TotalStoragePowerReward()

View File

@ -247,8 +247,18 @@ func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *S
out := make([]proof.SectorInfo, len(ids)) out := make([]proof.SectorInfo, len(ids))
for i, n := range ids { for i, n := range ids {
sb, err := provingSectors.Slice(n, 1)
if err != nil {
return nil, err
}
sid, err := sb.First()
if err != nil {
return nil, err
}
var sinfo miner.SectorOnChainInfo var sinfo miner.SectorOnChainInfo
found, err := sectors.Get(n, &sinfo) found, err := sectors.Get(sid, &sinfo)
if err != nil { if err != nil {
return nil, xerrors.Errorf("loading sector info: %w", err) return nil, xerrors.Errorf("loading sector info: %w", err)

View File

@ -417,7 +417,7 @@ var clientDealCmd = &cli.Command{
return err return err
} }
isVerified := dcap != types.EmptyInt isVerified := dcap != nil
// If the user has explicitly set the --verified-deal flag // If the user has explicitly set the --verified-deal flag
if cctx.IsSet("verified-deal") { if cctx.IsSet("verified-deal") {

View File

@ -300,8 +300,8 @@ func (p *Processor) updateMarketActorDealProposals(ctx context.Context, marketTi
} }
for _, modified := range changes.Modified { for _, modified := range changes.Modified {
if modified.From.SlashEpoch() != modified.To.SlashEpoch() { if modified.From.SlashEpoch != modified.To.SlashEpoch {
if _, err := stmt.Exec(modified.To.SlashEpoch(), modified.ID); err != nil { if _, err := stmt.Exec(modified.To.SlashEpoch, modified.ID); err != nil {
return err return err
} }
} }

View File

@ -417,24 +417,24 @@ func (r *refunder) ProcessTipset(ctx context.Context, tipset *types.TipSet, refu
// We use the parent tipset key because precommit information is removed when ProveCommitSector is executed // We use the parent tipset key because precommit information is removed when ProveCommitSector is executed
precommitChainInfo, err := r.api.StateSectorPreCommitInfo(ctx, m.To, sn, tipset.Parents()) precommitChainInfo, err := r.api.StateSectorPreCommitInfo(ctx, m.To, sn, tipset.Parents())
if err != nil { if err != nil {
log.Warnw("failed to get precommit info for sector", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To, "sector_number", proveCommitSector.SectorNumber) log.Warnw("failed to get precommit info for sector", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To, "sector_number", sn)
continue continue
} }
precommitTipset, err := r.api.ChainGetTipSetByHeight(ctx, precommitChainInfo.PreCommitEpoch, tipset.Key()) precommitTipset, err := r.api.ChainGetTipSetByHeight(ctx, precommitChainInfo.PreCommitEpoch, tipset.Key())
if err != nil { if err != nil {
log.Warnf("failed to lookup precommit epoch", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To, "sector_number", proveCommitSector.SectorNumber) log.Warnf("failed to lookup precommit epoch", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To, "sector_number", sn)
continue continue
} }
collateral, err := r.api.StateMinerInitialPledgeCollateral(ctx, m.To, precommitChainInfo.Info, precommitTipset.Key()) collateral, err := r.api.StateMinerInitialPledgeCollateral(ctx, m.To, precommitChainInfo.Info, precommitTipset.Key())
if err != nil { if err != nil {
log.Warnw("failed to get initial pledge collateral", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To, "sector_number", proveCommitSector.SectorNumber) log.Warnw("failed to get initial pledge collateral", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To, "sector_number", sn)
} }
collateral = big.Sub(collateral, precommitChainInfo.PreCommitDeposit) collateral = big.Sub(collateral, precommitChainInfo.PreCommitDeposit)
if collateral.LessThan(big.Zero()) { if collateral.LessThan(big.Zero()) {
log.Debugw("skipping zero pledge collateral difference", "method", messageMethod, "cid", msg.Cid, "miner", m.To, "sector_number", proveCommitSector.SectorNumber) log.Debugw("skipping zero pledge collateral difference", "method", messageMethod, "cid", msg.Cid, "miner", m.To, "sector_number", sn)
continue continue
} }

View File

@ -1,7 +1,6 @@
package main package main
import ( import (
"bytes"
"fmt" "fmt"
"os" "os"
"text/tabwriter" "text/tabwriter"
@ -73,12 +72,12 @@ var provingFaultsCmd = &cli.Command{
tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0) tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
_, _ = fmt.Fprintln(tw, "deadline\tpartition\tsectors") _, _ = fmt.Fprintln(tw, "deadline\tpartition\tsectors")
err = mas.ForEachDeadline(func(dlIdx uint64, dl miner.Deadline) error { err = mas.ForEachDeadline(func(dlIdx uint64, dl miner.Deadline) error {
dl.ForEachPartition(func(partIdx uint64, part miner.Partition) error { return dl.ForEachPartition(func(partIdx uint64, part miner.Partition) error {
faults, err := part.FaultySectors() faults, err := part.FaultySectors()
if err != nil { if err != nil {
return err return err
} }
faults.ForEach(func(num uint64) error { return faults.ForEach(func(num uint64) error {
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d\n", dlIdx, partIdx, num) _, _ = fmt.Fprintf(tw, "%d\t%d\t%d\n", dlIdx, partIdx, num)
return nil return nil
}) })
@ -173,6 +172,8 @@ var provingInfoCmd = &cli.Command{
} else { } else {
recovering += count recovering += count
} }
return nil
}) })
}); err != nil { }); err != nil {
return xerrors.Errorf("walking miner deadlines and partitions: %w", err) return xerrors.Errorf("walking miner deadlines and partitions: %w", err)
@ -250,22 +251,6 @@ var provingDeadlinesCmd = &cli.Command{
return xerrors.Errorf("getting deadlines: %w", err) return xerrors.Errorf("getting deadlines: %w", err)
} }
var mas miner.State
{
mact, err := api.StateGetActor(ctx, maddr, types.EmptyTSK)
if err != nil {
return err
}
miner.Load
rmas, err := api.ChainReadObj(ctx, mact.Head)
if err != nil {
return err
}
if err := mas.UnmarshalCBOR(bytes.NewReader(rmas)); err != nil {
return err
}
}
fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr)) fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr))
tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0) tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)

View File

@ -132,7 +132,7 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, preroot cid.Cid, epoch
BaseFee: BaseFee, BaseFee: BaseFee,
} }
lvm, err := vm.NewVM(vmOpts) lvm, err := vm.NewVM(context.TODO(), vmOpts)
if err != nil { if err != nil {
return nil, cid.Undef, err return nil, cid.Undef, err
} }

View File

@ -2,6 +2,8 @@ package sealing_test
import ( import (
"context" "context"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/build"
"testing" "testing"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
@ -18,6 +20,10 @@ type fakeChain struct {
h abi.ChainEpoch h abi.ChainEpoch
} }
func (f *fakeChain) StateNetworkVersion(ctx context.Context, tok sealing.TipSetToken) (network.Version, error) {
return build.NewestNetworkVersion, nil
}
func (f *fakeChain) ChainHead(ctx context.Context) (sealing.TipSetToken, abi.ChainEpoch, error) { func (f *fakeChain) ChainHead(ctx context.Context) (sealing.TipSetToken, abi.ChainEpoch, error) {
return []byte{1, 2, 3}, f.h, nil return []byte{1, 2, 3}, f.h, nil
} }

View File

@ -24,8 +24,8 @@ import (
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/crypto"
statemachine "github.com/filecoin-project/go-statemachine" statemachine "github.com/filecoin-project/go-statemachine"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/market" "github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage" sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
) )

View File

@ -108,7 +108,9 @@ func (n *ProviderNodeAdapter) OnDealComplete(ctx context.Context, deal storagema
curTime := time.Now() curTime := time.Now()
for time.Since(curTime) < addPieceRetryTimeout { for time.Since(curTime) < addPieceRetryTimeout {
if !xerrors.Is(err, sealing.ErrTooManySectorsSealing) { if !xerrors.Is(err, sealing.ErrTooManySectorsSealing) {
log.Errorf("failed to addPiece for deal %d, err: %w", deal.DealID, err) if err != nil {
log.Errorf("failed to addPiece for deal %d, err: %w", deal.DealID, err)
}
break break
} }
select { select {
@ -367,7 +369,7 @@ func (n *ProviderNodeAdapter) GetDataCap(ctx context.Context, addr address.Addre
} }
sp, err := n.StateVerifiedClientStatus(ctx, addr, tsk) sp, err := n.StateVerifiedClientStatus(ctx, addr, tsk)
return &sp, err return sp, err
} }
func (n *ProviderNodeAdapter) OnDealExpiredOrSlashed(ctx context.Context, dealID abi.DealID, onDealExpired storagemarket.DealExpiredCallback, onDealSlashed storagemarket.DealSlashedCallback) error { func (n *ProviderNodeAdapter) OnDealExpiredOrSlashed(ctx context.Context, dealID abi.DealID, onDealExpired storagemarket.DealExpiredCallback, onDealSlashed storagemarket.DealSlashedCallback) error {

View File

@ -112,7 +112,7 @@ func (a *StateAPI) StateMinerInfo(ctx context.Context, actor address.Address, ts
return mas.Info() return mas.Info()
} }
func (a *StateAPI) StateMinerDeadlines(ctx context.Context, m address.Address, tsk types.TipSetKey) ([]*miner.Deadline, error) { func (a *StateAPI) StateMinerDeadlines(ctx context.Context, m address.Address, tsk types.TipSetKey) ([]api.Deadline, error) {
act, err := a.StateManager.LoadActorTsk(ctx, m, tsk) act, err := a.StateManager.LoadActorTsk(ctx, m, tsk)
if err != nil { if err != nil {
return nil, xerrors.Errorf("failed to load miner actor: %w", err) return nil, xerrors.Errorf("failed to load miner actor: %w", err)
@ -128,9 +128,16 @@ func (a *StateAPI) StateMinerDeadlines(ctx context.Context, m address.Address, t
return nil, xerrors.Errorf("getting deadline count: %w", err) return nil, xerrors.Errorf("getting deadline count: %w", err)
} }
out := make([]*miner.Deadline, deadlines) out := make([]api.Deadline, deadlines)
if err := mas.ForEachDeadline(func(i uint64, dl miner.Deadline) error { if err := mas.ForEachDeadline(func(i uint64, dl miner.Deadline) error {
out[i] = &dl ps, err := dl.PostSubmissions()
if err != nil {
return err
}
out[i] = api.Deadline{
PostSubmissions: ps,
}
return nil return nil
}); err != nil { }); err != nil {
return nil, err return nil, err
@ -138,7 +145,7 @@ func (a *StateAPI) StateMinerDeadlines(ctx context.Context, m address.Address, t
return out, nil return out, nil
} }
func (a *StateAPI) StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]*miner.Partition, error) { func (a *StateAPI) StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]api.Partition, error) {
act, err := a.StateManager.LoadActorTsk(ctx, m, tsk) act, err := a.StateManager.LoadActorTsk(ctx, m, tsk)
if err != nil { if err != nil {
return nil, xerrors.Errorf("failed to load miner actor: %w", err) return nil, xerrors.Errorf("failed to load miner actor: %w", err)
@ -154,10 +161,40 @@ func (a *StateAPI) StateMinerPartitions(ctx context.Context, m address.Address,
return nil, xerrors.Errorf("failed to load the deadline: %w", err) return nil, xerrors.Errorf("failed to load the deadline: %w", err)
} }
var out []*miner.Partition var out []api.Partition
err = dl.ForEachPartition(func(_ uint64, part miner.Partition) error { err = dl.ForEachPartition(func(_ uint64, part miner.Partition) error {
p := part allSectors, err := part.AllSectors()
out = append(out, &p) if err != nil {
return xerrors.Errorf("getting AllSectors: %w", err)
}
faultySectors, err := part.FaultySectors()
if err != nil {
return xerrors.Errorf("getting FaultySectors: %w", err)
}
recoveringSectors, err := part.RecoveringSectors()
if err != nil {
return xerrors.Errorf("getting RecoveringSectors: %w", err)
}
liveSectors, err := part.LiveSectors()
if err != nil {
return xerrors.Errorf("getting LiveSectors: %w", err)
}
activeSectors, err := part.ActiveSectors()
if err != nil {
return xerrors.Errorf("getting ActiveSectors: %w", err)
}
out = append(out, api.Partition{
AllSectors: allSectors,
FaultySectors: faultySectors,
RecoveringSectors: recoveringSectors,
LiveSectors: liveSectors,
ActiveSectors: activeSectors,
})
return nil return nil
}) })
@ -1037,29 +1074,32 @@ func (a *StateAPI) StateMinerAvailableBalance(ctx context.Context, maddr address
// StateVerifiedClientStatus returns the data cap for the given address. // StateVerifiedClientStatus returns the data cap for the given address.
// Returns zero if there is no entry in the data cap table for the // Returns zero if there is no entry in the data cap table for the
// address. // address.
func (a *StateAPI) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (abi.StoragePower, error) { func (a *StateAPI) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) {
act, err := a.StateGetActor(ctx, builtin.VerifiedRegistryActorAddr, tsk) act, err := a.StateGetActor(ctx, builtin.VerifiedRegistryActorAddr, tsk)
if err != nil { if err != nil {
return types.EmptyInt, err return nil, err
} }
aid, err := a.StateLookupID(ctx, addr, tsk) aid, err := a.StateLookupID(ctx, addr, tsk)
if err != nil { if err != nil {
log.Warnf("lookup failure %v", err) log.Warnf("lookup failure %v", err)
return types.EmptyInt, err return nil, err
} }
vrs, err := verifreg.Load(a.StateManager.ChainStore().Store(ctx), act) vrs, err := verifreg.Load(a.StateManager.ChainStore().Store(ctx), act)
if err != nil { if err != nil {
return types.EmptyInt, xerrors.Errorf("failed to load verified registry state: %w", err) return nil, xerrors.Errorf("failed to load verified registry state: %w", err)
} }
_, dcap, err := vrs.VerifiedClientDataCap(aid) verified, dcap, err := vrs.VerifiedClientDataCap(aid)
if err != nil { if err != nil {
return types.EmptyInt, xerrors.Errorf("looking up verified client: %w", err) return nil, xerrors.Errorf("looking up verified client: %w", err)
}
if !verified {
return nil, nil
} }
return dcap, nil return &dcap, nil
} }
var dealProviderCollateralNum = types.NewInt(110) var dealProviderCollateralNum = types.NewInt(110)

View File

@ -84,7 +84,7 @@ func (s SealingAPIAdapter) StateMinerWorkerAddress(ctx context.Context, maddr ad
return mi.Worker, nil return mi.Worker, nil
} }
func (s SealingAPIAdapter) StateMinerDeadlines(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) ([]*miner.Deadline, error) { func (s SealingAPIAdapter) StateMinerDeadlines(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) ([]api.Deadline, error) {
tsk, err := types.TipSetKeyFromBytes(tok) tsk, err := types.TipSetKeyFromBytes(tok)
if err != nil { if err != nil {
return nil, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err) return nil, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
@ -190,7 +190,7 @@ func (s SealingAPIAdapter) StateSectorPreCommitInfo(ctx context.Context, maddr a
if err != nil { if err != nil {
return nil, err return nil, err
} }
if pci != nil { if pci == nil {
set, err := state.IsAllocated(sectorNumber) set, err := state.IsAllocated(sectorNumber)
if err != nil { if err != nil {
return nil, xerrors.Errorf("checking if sector is allocated: %w", err) return nil, xerrors.Errorf("checking if sector is allocated: %w", err)

View File

@ -76,7 +76,7 @@ type storageMinerApi interface {
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error)
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error)
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]*miner.Deadline, error) StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]api.Deadline, error)
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)