Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIP-0045: DataCap migration #84

Closed
wants to merge 2 commits into from
Closed
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
47 changes: 47 additions & 0 deletions builtin/v8/miner/deadline_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,57 @@ const DeadlineExpirationAmtBitwidth = 5
// only exceed the partition AMT's height at ~0.75EiB of storage.
const DeadlineOptimisticPoStSubmissionsAmtBitwidth = 2

//
// Deadline (singular)
//

func ConstructDeadline(store adt.Store) (*Deadline, error) {
emptyPartitionsArrayCid, err := adt.StoreEmptyArray(store, DeadlinePartitionsAmtBitwidth)
if err != nil {
return nil, xerrors.Errorf("failed to construct empty partitions array: %w", err)
}
emptyDeadlineExpirationArrayCid, err := adt.StoreEmptyArray(store, DeadlineExpirationAmtBitwidth)
if err != nil {
return nil, xerrors.Errorf("failed to construct empty deadline expiration array: %w", err)
}

emptySectorsSnapshotArrayCid, err := adt.StoreEmptyArray(store, SectorsAmtBitwidth)
if err != nil {
return nil, xerrors.Errorf("failed to construct empty sectors snapshot array: %w", err)
}

emptyPoStSubmissionsArrayCid, err := adt.StoreEmptyArray(store, DeadlineOptimisticPoStSubmissionsAmtBitwidth)
if err != nil {
return nil, xerrors.Errorf("failed to construct empty proofs array: %w", err)
}

return &Deadline{
Partitions: emptyPartitionsArrayCid,
ExpirationsEpochs: emptyDeadlineExpirationArrayCid,
EarlyTerminations: bitfield.New(),
LiveSectors: 0,
TotalSectors: 0,
FaultyPower: NewPowerPairZero(),
PartitionsPoSted: bitfield.New(),
OptimisticPoStSubmissions: emptyPoStSubmissionsArrayCid,
PartitionsSnapshot: emptyPartitionsArrayCid,
SectorsSnapshot: emptySectorsSnapshotArrayCid,
OptimisticPoStSubmissionsSnapshot: emptyPoStSubmissionsArrayCid,
}, nil
}

//
// Deadlines (plural)
//

func ConstructDeadlines(emptyDeadlineCid cid.Cid) *Deadlines {
d := new(Deadlines)
for i := range d.Due {
d.Due[i] = emptyDeadlineCid
}
return d
}

func (d *Deadlines) LoadDeadline(store adt.Store, dlIdx uint64) (*Deadline, error) {
if dlIdx >= uint64(len(d.Due)) {
return nil, xc.ErrIllegalArgument.Wrapf("invalid deadline %d", dlIdx)
Expand Down
3 changes: 0 additions & 3 deletions builtin/v9/datacap/datacap_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import (
"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"
"github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
)

var DatacapGranularity = builtin.TokenPrecision

type State struct {
Governor address.Address
Token TokenState
Expand Down
4 changes: 4 additions & 0 deletions builtin/v9/datacap/datacap_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ package datacap
import (
"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"
)

var InfiniteAllowance = big.Mul(big.MustFromString("1000000000000000000000"), builtin.TokenPrecision)

type MintParams struct {
To address.Address
Amount abi.TokenAmount
Expand Down
2 changes: 1 addition & 1 deletion builtin/v9/market/market_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type State struct {
TotalClientStorageFee abi.TokenAmount

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

func ConstructState(store adt.Store) (*State, error) {
Expand Down
Loading