Merge branch 'release/v1.18.0' into asr/merge-release-into-master
This commit is contained in:
@@ -52,7 +52,7 @@ import (
|
||||
"github.com/filecoin-project/go-padreader"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
|
||||
markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
@@ -228,12 +228,12 @@ func (a *API) dealStarter(ctx context.Context, params *api.StartDealParams, isSt
|
||||
// stateless flow from here to the end
|
||||
//
|
||||
|
||||
label, err := market8.NewLabelFromString(params.Data.Root.Encode(multibase.MustNewEncoder('u')))
|
||||
label, err := markettypes.NewLabelFromString(params.Data.Root.Encode(multibase.MustNewEncoder('u')))
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to encode label: %w", err)
|
||||
}
|
||||
|
||||
dealProposal := &market8.DealProposal{
|
||||
dealProposal := &markettypes.DealProposal{
|
||||
PieceCID: *params.Data.PieceCid,
|
||||
PieceSize: params.Data.PieceSize.Padded(),
|
||||
Client: walletKey,
|
||||
@@ -265,7 +265,7 @@ func (a *API) dealStarter(ctx context.Context, params *api.StartDealParams, isSt
|
||||
return nil, xerrors.Errorf("failed to sign proposal : %w", err)
|
||||
}
|
||||
|
||||
dealProposalSigned := &market8.ClientDealProposal{
|
||||
dealProposalSigned := &markettypes.ClientDealProposal{
|
||||
Proposal: *dealProposal,
|
||||
ClientSignature: *dealProposalSig,
|
||||
}
|
||||
|
||||
+174
-11
@@ -19,6 +19,7 @@ import (
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
"github.com/filecoin-project/go-state-types/crypto"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
@@ -30,6 +31,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/datacap"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/multisig"
|
||||
@@ -769,6 +771,135 @@ func (m *StateModule) StateMarketStorageDeal(ctx context.Context, dealId abi.Dea
|
||||
return stmgr.GetStorageDeal(ctx, m.StateManager, dealId, ts)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateGetAllocationForPendingDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
st, err := a.StateManager.GetMarketState(ctx, ts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
allocationId, err := st.GetAllocationIdForPendingDeal(dealId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if allocationId == verifregtypes.NoAllocationID {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
dealState, err := a.StateMarketStorageDeal(ctx, dealId, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return a.StateGetAllocation(ctx, dealState.Proposal.Client, allocationId, tsk)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateGetAllocation(ctx context.Context, clientAddr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error) {
|
||||
idAddr, err := a.StateLookupID(ctx, clientAddr, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
st, err := a.StateManager.GetVerifregState(ctx, ts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
allocation, found, err := st.GetAllocation(idAddr, allocationId)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("getting allocation: %w", err)
|
||||
}
|
||||
if !found {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return allocation, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateGetAllocations(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) {
|
||||
idAddr, err := a.StateLookupID(ctx, clientAddr, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
st, err := a.StateManager.GetVerifregState(ctx, ts)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading verifreg state: %w", err)
|
||||
}
|
||||
|
||||
allocations, err := st.GetAllocations(idAddr)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("getting allocations: %w", err)
|
||||
}
|
||||
|
||||
return allocations, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateGetClaim(ctx context.Context, providerAddr address.Address, claimId verifregtypes.ClaimId, tsk types.TipSetKey) (*verifregtypes.Claim, error) {
|
||||
idAddr, err := a.StateLookupID(ctx, providerAddr, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
st, err := a.StateManager.GetVerifregState(ctx, ts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
claim, found, err := st.GetClaim(idAddr, claimId)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("getting claim: %w", err)
|
||||
}
|
||||
if !found {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return claim, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) {
|
||||
idAddr, err := a.StateLookupID(ctx, providerAddr, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
st, err := a.StateManager.GetVerifregState(ctx, ts)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading verifreg state: %w", err)
|
||||
}
|
||||
|
||||
claims, err := st.GetClaims(idAddr)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("getting claims: %w", err)
|
||||
}
|
||||
|
||||
return claims, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateComputeDataCID(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) {
|
||||
nv, err := a.StateNetworkVersion(ctx, tsk)
|
||||
if err != nil {
|
||||
@@ -962,7 +1093,7 @@ func (a *StateAPI) StateListMessages(ctx context.Context, match *api.MessageMatc
|
||||
_, err := a.StateLookupID(ctx, match.To, tsk)
|
||||
|
||||
// if the recipient doesn't exist at the start point, we're not gonna find any matches
|
||||
if xerrors.Is(err, types.ErrActorNotFound) {
|
||||
if xerrors.Is(err, &api.ErrActorNotFound{}) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -973,7 +1104,7 @@ func (a *StateAPI) StateListMessages(ctx context.Context, match *api.MessageMatc
|
||||
_, err := a.StateLookupID(ctx, match.From, tsk)
|
||||
|
||||
// if the sender doesn't exist at the start point, we're not gonna find any matches
|
||||
if xerrors.Is(err, types.ErrActorNotFound) {
|
||||
if xerrors.Is(err, &api.ErrActorNotFound{}) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -1399,26 +1530,56 @@ func (a *StateAPI) StateVerifierStatus(ctx context.Context, addr address.Address
|
||||
// Returns zero if there is no entry in the data cap table for the
|
||||
// address.
|
||||
func (m *StateModule) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) {
|
||||
act, err := m.StateGetActor(ctx, verifreg.Address, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
aid, err := m.StateLookupID(ctx, addr, tsk)
|
||||
if err != nil {
|
||||
log.Warnf("lookup failure %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vrs, err := verifreg.Load(m.StateManager.ChainStore().ActorStore(ctx), act)
|
||||
nv, err := m.StateNetworkVersion(ctx, tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to load verified registry state: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
verified, dcap, err := vrs.VerifiedClientDataCap(aid)
|
||||
av, err := actorstypes.VersionForNetwork(nv)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("looking up verified client: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var dcap abi.StoragePower
|
||||
var verified bool
|
||||
if av <= 8 {
|
||||
act, err := m.StateGetActor(ctx, verifreg.Address, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vrs, err := verifreg.Load(m.StateManager.ChainStore().ActorStore(ctx), act)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to load verified registry state: %w", err)
|
||||
}
|
||||
|
||||
verified, dcap, err = vrs.VerifiedClientDataCap(aid)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("looking up verified client: %w", err)
|
||||
}
|
||||
} else {
|
||||
act, err := m.StateGetActor(ctx, datacap.Address, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dcs, err := datacap.Load(m.StateManager.ChainStore().ActorStore(ctx), act)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to load datacap actor state: %w", err)
|
||||
}
|
||||
|
||||
verified, dcap, err = dcs.VerifiedClientDataCap(aid)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("looking up verified client: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if !verified {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -1636,6 +1797,8 @@ func (a *StateAPI) StateGetNetworkParams(ctx context.Context) (*api.NetworkParam
|
||||
UpgradeHyperdriveHeight: build.UpgradeHyperdriveHeight,
|
||||
UpgradeChocolateHeight: build.UpgradeChocolateHeight,
|
||||
UpgradeOhSnapHeight: build.UpgradeOhSnapHeight,
|
||||
UpgradeSkyrHeight: build.UpgradeSkyrHeight,
|
||||
UpgradeSharkHeight: build.UpgradeSharkHeight,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user