abstract over deal collateral

This commit is contained in:
Steven Allen
2020-09-30 13:30:24 -07:00
parent 35e606d397
commit 8dcbd525da
2 changed files with 28 additions and 12 deletions
+10 -12
View File
@@ -5,10 +5,8 @@ import (
"context"
"strconv"
lotusbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
@@ -883,10 +881,10 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr
} else {
// NB: not exactly accurate, but should always lead us to *over* estimate, not under
duration := pci.Expiration - ts.Height()
sectorWeight = lotusbuiltin.QAPowerForWeight(ssize, duration, w, vw)
sectorWeight = builtin.QAPowerForWeight(ssize, duration, w, vw)
}
var powerSmoothed lotusbuiltin.FilterEstimate
var powerSmoothed builtin.FilterEstimate
if act, err := state.GetActor(power.Address); err != nil {
return types.EmptyInt, xerrors.Errorf("loading power actor: %w", err)
} else if s, err := power.Load(store, act); err != nil {
@@ -944,11 +942,11 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr
} else {
// NB: not exactly accurate, but should always lead us to *over* estimate, not under
duration := pci.Expiration - ts.Height()
sectorWeight = lotusbuiltin.QAPowerForWeight(ssize, duration, w, vw)
sectorWeight = builtin.QAPowerForWeight(ssize, duration, w, vw)
}
var (
powerSmoothed lotusbuiltin.FilterEstimate
powerSmoothed builtin.FilterEstimate
pledgeCollateral abi.TokenAmount
)
if act, err := state.GetActor(power.Address); err != nil {
@@ -1025,7 +1023,7 @@ func (a *StateAPI) StateMinerAvailableBalance(ctx context.Context, maddr address
// Returns zero if there is no entry in the data cap table for the
// address.
func (a *StateAPI) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) {
act, err := a.StateGetActor(ctx, builtin0.VerifiedRegistryActorAddr, tsk)
act, err := a.StateGetActor(ctx, verifreg.Address, tsk)
if err != nil {
return nil, err
}
@@ -1063,12 +1061,12 @@ func (a *StateAPI) StateDealProviderCollateralBounds(ctx context.Context, size a
return api.DealCollateralBounds{}, xerrors.Errorf("loading tipset %s: %w", tsk, err)
}
pact, err := a.StateGetActor(ctx, builtin0.StoragePowerActorAddr, tsk)
pact, err := a.StateGetActor(ctx, power.Address, tsk)
if err != nil {
return api.DealCollateralBounds{}, xerrors.Errorf("failed to load power actor: %w", err)
}
ract, err := a.StateGetActor(ctx, builtin0.RewardActorAddr, tsk)
ract, err := a.StateGetActor(ctx, reward.Address, tsk)
if err != nil {
return api.DealCollateralBounds{}, xerrors.Errorf("failed to load reward actor: %w", err)
}
@@ -1098,7 +1096,7 @@ func (a *StateAPI) StateDealProviderCollateralBounds(ctx context.Context, size a
return api.DealCollateralBounds{}, xerrors.Errorf("getting reward baseline power: %w", err)
}
min, max := market0.DealProviderCollateralBounds(size,
min, max := policy.DealProviderCollateralBounds(size,
verified,
powClaim.RawBytePower,
powClaim.QualityAdjPower,