Skip to content

Commit

Permalink
Change miner.Sectors AMT bitwidth to 5. Move constants to state files. (
Browse files Browse the repository at this point in the history
  • Loading branch information
anorth authored and bibibong committed Feb 19, 2021
1 parent 0a8a57b commit 0b306c3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 18 deletions.
7 changes: 4 additions & 3 deletions actors/builtin/market/index_multimap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"

"github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/filecoin-project/specs-actors/v2/actors/util/adt"
)

Expand Down Expand Up @@ -70,12 +71,12 @@ func (mm *IndexMultimap) Put(epoch abi.ChainEpoch, providerIndexes map[address.A
}
var arr *adt.Array
if found {
arr, err = adt.AsArray(mm.store, cid.Cid(arrRoot), ProviderDataIndexesAmtBitwidth)
arr, err = adt.AsArray(mm.store, cid.Cid(arrRoot), builtin.DefaultHamtBitwidth)
if err != nil {
return err
}
} else {
arr, err = adt.MakeEmptyArray(mm.store, ProviderDataIndexesAmtBitwidth)
arr, err = adt.MakeEmptyArray(mm.store, builtin.DefaultHamtBitwidth)
if err != nil {
return err
}
Expand Down Expand Up @@ -144,7 +145,7 @@ func (mm *IndexMultimap) ForEach(epoch abi.ChainEpoch, fn func(provder address.A
return err
}

arr, err := adt.AsArray(mm.store, cid.Cid(arrRoot), ProviderDataIndexesAmtBitwidth)
arr, err := adt.AsArray(mm.store, cid.Cid(arrRoot), builtin.DefaultHamtBitwidth)
if err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions actors/builtin/market/market_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type BalanceLockingReason int
ProviderCollateral
) */

// Bitwidth of AMTs determined empirically from mutation patterns and projections of mainnet data.
const ProposalsAmtBitwidth = 5
const StatesAmtBitwidth = 6

type State struct {
Proposals cid.Cid // AMT[DealID]DealProposal
States cid.Cid // AMT[DealID]DealState
Expand Down
10 changes: 0 additions & 10 deletions actors/builtin/market/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ const DealMaxLabelSize = 256

const DefaultInitialQuota = 100

// Bitwidth of proposals AMT determined empirically from mutation patterns and
// projections of mainnet data.
const ProposalsAmtBitwidth = 5

// Bitwidth of states AMT determined empirically from mutation patterns and
// projections of mainnet data.
const StatesAmtBitwidth = 6

const ProviderDataIndexesAmtBitwidth = 5

/*
// Bounds (inclusive) on deal duration
func DealDurationBounds(_ abi.PaddedPieceSize) (min abi.ChainEpoch, max abi.ChainEpoch) {
Expand Down
3 changes: 2 additions & 1 deletion actors/builtin/miner/deadline_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ type Deadline struct {
FaultyPower PowerPair
}

const DeadlinePartitionsAmtBitwidth = 3
// Bitwidth of AMTs determined empirically from mutation patterns and projections of mainnet data.
const DeadlinePartitionsAmtBitwidth = 3 // Usually a small array
const DeadlineExpirationAmtBitwidth = 5

//
Expand Down
3 changes: 2 additions & 1 deletion actors/builtin/miner/miner_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ type State struct {
Pieces cid.Cid // Map, HAMT[PieceCID]SectorNumber
}

// Bitwidth of AMTs determined empirically from mutation patterns and projections of mainnet data.
const PrecommitExpiryAmtBitwidth = 6
const SectorsAmtBitwidth = 6
const SectorsAmtBitwidth = 5

type MinerInfo struct {
// Account that owns this miner.
Expand Down
4 changes: 1 addition & 3 deletions actors/builtin/miner/partition_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ type Partition struct {
RecoveringPower PowerPair
}

// Bitwidth of partition expiration AMT determined empirically from mutation
// patterns and projections of mainnet data.
// Bitwidth of AMTs determined empirically from mutation patterns and projections of mainnet data.
const PartitionExpirationAmtBitwidth = 4

const PartitionEarlyTerminationArrayAmtBitwidth = 3

// Value type for a pair of raw and QA power.
Expand Down

0 comments on commit 0b306c3

Please sign in to comment.