Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions builtin/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ var MethodsPaych = struct {
4,
}

// ext::miner::SECTOR_CONTENT_CHANGED
var MethodSectorContentChanged = MustGenerateFRCMethodNum("SectorContentChanged")

var MethodsMarket = struct {
Constructor abi.MethodNum
AddBalance abi.MethodNum
Expand All @@ -125,6 +128,8 @@ var MethodsMarket = struct {
GetDealProviderCollateralExported abi.MethodNum
GetDealVerifiedExported abi.MethodNum
GetDealActivationExported abi.MethodNum
GetDealSectorExported abi.MethodNum
SectorContentChangedExported abi.MethodNum
}{
MethodConstructor,
2,
Expand All @@ -149,6 +154,8 @@ var MethodsMarket = struct {
MustGenerateFRCMethodNum("GetDealProviderCollateral"),
MustGenerateFRCMethodNum("GetDealVerified"),
MustGenerateFRCMethodNum("GetDealActivation"),
MustGenerateFRCMethodNum("GetDealSector"),
MethodSectorContentChanged,
}

var MethodsPower = struct {
Expand Down Expand Up @@ -191,7 +198,7 @@ var MethodsMiner = struct {
ChangePeerID abi.MethodNum
ChangePeerIDExported abi.MethodNum
SubmitWindowedPoSt abi.MethodNum
PreCommitSector abi.MethodNum
PreCommitSector abi.MethodNum // deprecated av13
ProveCommitSector abi.MethodNum
ExtendSectorExpiration abi.MethodNum
TerminateSectors abi.MethodNum
Expand All @@ -215,11 +222,11 @@ var MethodsMiner = struct {
ChangeOwnerAddress abi.MethodNum
ChangeOwnerAddressExported abi.MethodNum
DisputeWindowedPoSt abi.MethodNum
PreCommitSectorBatch abi.MethodNum
PreCommitSectorBatch abi.MethodNum // deprecated av13
ProveCommitAggregate abi.MethodNum
ProveReplicaUpdates abi.MethodNum
PreCommitSectorBatch2 abi.MethodNum
ProveReplicaUpdates2 abi.MethodNum
ProveReplicaUpdates2 abi.MethodNum // deprecated av13
ChangeBeneficiary abi.MethodNum
ChangeBeneficiaryExported abi.MethodNum
GetBeneficiary abi.MethodNum
Expand All @@ -231,6 +238,9 @@ var MethodsMiner = struct {
GetVestingFundsExported abi.MethodNum
GetPeerIDExported abi.MethodNum
GetMultiaddrsExported abi.MethodNum
// MovePartitionsExported abi.MethodNum
ProveCommitSectors3 abi.MethodNum
ProveReplicaUpdates3 abi.MethodNum
}{
MethodConstructor,
2,
Expand Down Expand Up @@ -279,6 +289,9 @@ var MethodsMiner = struct {
MustGenerateFRCMethodNum("GetVestingFunds"),
MustGenerateFRCMethodNum("GetPeerID"),
MustGenerateFRCMethodNum("GetMultiaddrs"),
// MovePartitions: 33,
34,
35,
}

var MethodsVerifiedRegistry = struct {
Expand Down
12 changes: 12 additions & 0 deletions builtin/v13/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func main() {
// actor state
market.State{},
market.DealState{},
market.SectorDealIDs{},
// method params and returns
market.WithdrawBalanceParams{},
market.PublishStorageDealsParams{},
Expand Down Expand Up @@ -192,6 +193,17 @@ func main() {
miner.GetOwnerReturn{},
miner.GetPeerIDReturn{},
miner.GetMultiAddrsReturn{},
miner.ProveCommitSectors3Params{},
miner.SectorActivationManifest{},
miner.PieceActivationManifest{},
miner.VerifiedAllocationKey{},
miner.DataActivationNotification{},
miner.BatchReturn{},
miner.FailCode{},
miner.ProveReplicaUpdates3Params{},
miner.SectorUpdateManifest{},
miner.SectorChanges{},
miner.PieceChange{},
// other types
miner.FaultDeclaration{},
miner.RecoveryDeclaration{},
Expand Down
125 changes: 109 additions & 16 deletions builtin/v13/market/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions builtin/v13/market/deal.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
addr "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/builtin/v13/verifreg"
acrypto "github.com/filecoin-project/go-state-types/crypto"
)

Expand All @@ -27,10 +26,10 @@ var PieceCIDPrefix = cid.Prefix{
}

type DealState struct {
SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector
LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated
SlashEpoch abi.ChainEpoch // -1 if deal never slashed
VerifiedClaim verifreg.AllocationId
SectorNumber abi.SectorNumber // 0 if not yet included in proven sector (0 is also a valid sector number)
SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector
LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated
SlashEpoch abi.ChainEpoch // -1 if deal never slashed
}

// The DealLabel is a kinded union of string or byte slice.
Expand Down Expand Up @@ -111,7 +110,7 @@ func (label *DealLabel) MarshalCBOR(w io.Writer) error {
_, err := io.WriteString(w, string(""))
return err
}
if len(label.bs) > cbg.ByteArrayMaxLen {
if uint64(len(label.bs)) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("label is too long to marshal (%d), max allowed (%d)", len(label.bs), cbg.ByteArrayMaxLen)
}

Expand Down
4 changes: 0 additions & 4 deletions builtin/v13/market/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ func CheckStateInvariants(st *State, store adt.Store, balance abi.TokenAmount, c

dealStateCount++

if dealState.VerifiedClaim != verifreg.NoAllocationID {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dropped, since deal states no longer record verified claims. New invariants will be added in a future PR.

claimIdToDealId[verifreg.ClaimId(dealState.VerifiedClaim)] = abi.DealID(dealID)
}

return nil
})
acc.RequireNoError(err, "error iterating deal states")
Expand Down
14 changes: 14 additions & 0 deletions builtin/v13/market/market_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const EpochUndefined = abi.ChainEpoch(-1)
// Bitwidth of AMTs determined empirically from mutation patterns and projections of mainnet data.
const ProposalsAmtBitwidth = 5
const StatesAmtBitwidth = 6
const ProviderSectorsHamtBitwidth = 5

type State struct {
// Proposals are deals that have been proposed and not yet cleaned up after expiry or termination.
Expand Down Expand Up @@ -55,6 +56,14 @@ type State struct {

// Verified registry allocation IDs for deals that are not yet activated.
PendingDealAllocationIds cid.Cid // HAMT[DealID]AllocationID

/// Maps providers to their sector IDs to deal IDs.
/// This supports finding affected deals when a sector is terminated early
/// or has data replaced.
/// Grouping by provider limits the cost of operations in the expected use case
/// of multiple sectors all belonging to the same provider.
/// HAMT[ActorID]HAMT[SectorNumber]SectorDealIDs
ProviderSectors cid.Cid
}

func ConstructState(store adt.Store) (*State, error) {
Expand Down Expand Up @@ -83,6 +92,10 @@ func ConstructState(store adt.Store) (*State, error) {
if err != nil {
return nil, xerrors.Errorf("failed to create empty map: %w", err)
}
emptyProviderSectorsMap, err := adt.StoreEmptyMap(store, ProviderSectorsHamtBitwidth)
if err != nil {
return nil, xerrors.Errorf("failed to create empty map: %w", err)
}

return &State{
Proposals: emptyProposalsArrayCid,
Expand All @@ -94,6 +107,7 @@ func ConstructState(store adt.Store) (*State, error) {
DealOpsByEpoch: emptyDealOpsHamtCid,
LastCron: abi.ChainEpoch(-1),
PendingDealAllocationIds: emptyPendingDealAllocationMapCid,
ProviderSectors: emptyProviderSectorsMap,

TotalClientLockedCollateral: abi.NewTokenAmount(0),
TotalProviderLockedCollateral: abi.NewTokenAmount(0),
Expand Down
6 changes: 6 additions & 0 deletions builtin/v13/market/market_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/filecoin-project/go-state-types/builtin/v13/verifreg"
)

type SectorDealIDs []abi.DealID

type WithdrawBalanceParams struct {
ProviderOrClientAddress addr.Address
Amount abi.TokenAmount
Expand Down Expand Up @@ -132,3 +134,7 @@ type GetDealActivationReturn struct {
// Epoch at which the deal was terminated abnormally, or -1.
Terminated abi.ChainEpoch
}

type GetDealSectorParams = DealQueryParams

type GetDealSectorReturn = abi.SectorNumber
Loading