This repository has been archived by the owner on Jun 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
/
sector.go
130 lines (118 loc) · 4.7 KB
/
sector.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package builtin
import (
stabi "github.com/filecoin-project/go-state-types/abi"
"golang.org/x/xerrors"
)
// Policy values associated with a seal proof type.
type SealProofPolicy struct {
SectorMaxLifetime stabi.ChainEpoch
}
// For V1 Stacked DRG sectors, the max is 540 days since Network Version 11
// according to https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0014.md
const EpochsIn540Days = stabi.ChainEpoch(540 * EpochsInDay)
// For V1_1 Stacked DRG sectors, the max is 5 years
const EpochsInFiveYears = stabi.ChainEpoch(5 * EpochsInYear)
// 540-day maximum life time setting for V1 since network version 11
var SealProofPoliciesV11 = map[stabi.RegisteredSealProof]*SealProofPolicy{
stabi.RegisteredSealProof_StackedDrg2KiBV1: {
SectorMaxLifetime: EpochsIn540Days,
},
stabi.RegisteredSealProof_StackedDrg8MiBV1: {
SectorMaxLifetime: EpochsIn540Days,
},
stabi.RegisteredSealProof_StackedDrg512MiBV1: {
SectorMaxLifetime: EpochsIn540Days,
},
stabi.RegisteredSealProof_StackedDrg32GiBV1: {
SectorMaxLifetime: EpochsIn540Days,
},
stabi.RegisteredSealProof_StackedDrg64GiBV1: {
SectorMaxLifetime: EpochsIn540Days,
},
stabi.RegisteredSealProof_StackedDrg2KiBV1_1: {
SectorMaxLifetime: EpochsInFiveYears,
},
stabi.RegisteredSealProof_StackedDrg8MiBV1_1: {
SectorMaxLifetime: EpochsInFiveYears,
},
stabi.RegisteredSealProof_StackedDrg512MiBV1_1: {
SectorMaxLifetime: EpochsInFiveYears,
},
stabi.RegisteredSealProof_StackedDrg32GiBV1_1: {
SectorMaxLifetime: EpochsInFiveYears,
},
stabi.RegisteredSealProof_StackedDrg64GiBV1_1: {
SectorMaxLifetime: EpochsInFiveYears,
},
}
// Returns the partition size, in sectors, associated with a seal proof type.
// The partition size is the number of sectors proved in a single PoSt proof.
func SealProofWindowPoStPartitionSectors(p stabi.RegisteredSealProof) (uint64, error) {
wPoStProofType, err := p.RegisteredWindowPoStProof()
if err != nil {
return 0, err
}
return PoStProofWindowPoStPartitionSectors(wPoStProofType)
}
// SectorMaximumLifetime is the maximum duration a sector sealed with this proof may exist between activation and expiration
func SealProofSectorMaximumLifetime(p stabi.RegisteredSealProof) (stabi.ChainEpoch, error) {
info, ok := SealProofPoliciesV11[p]
if !ok {
return 0, xerrors.Errorf("unsupported proof type: %v", p)
}
return info.SectorMaxLifetime, nil
}
// The minimum power of an individual miner to meet the threshold for leader election (in bytes).
// Motivation:
// - Limits sybil generation
// - Improves consensus fault detection
// - Guarantees a minimum fee for consensus faults
// - Ensures that a specific soundness for the power table
// Note: We may be able to reduce this in the future, addressing consensus faults with more complicated penalties,
// sybil generation with crypto-economic mechanism, and PoSt soundness by increasing the challenges for small miners.
func ConsensusMinerMinPower(p stabi.RegisteredPoStProof) (stabi.StoragePower, error) {
info, ok := PoStProofPolicies[p]
if !ok {
return stabi.NewStoragePower(0), xerrors.Errorf("unsupported proof type: %v", p)
}
return info.ConsensusMinerMinPower, nil
}
// Policy values associated with a PoSt proof type.
type PoStProofPolicy struct {
WindowPoStPartitionSectors uint64
ConsensusMinerMinPower stabi.StoragePower
}
// Partition sizes must match those used by the proofs library.
// See https://github.com/filecoin-project/rust-fil-proofs/blob/master/filecoin-proofs/src/constants.rs#L85
var PoStProofPolicies = map[stabi.RegisteredPoStProof]*PoStProofPolicy{
stabi.RegisteredPoStProof_StackedDrgWindow2KiBV1: {
WindowPoStPartitionSectors: 2,
ConsensusMinerMinPower: stabi.NewStoragePower(10 << 40),
},
stabi.RegisteredPoStProof_StackedDrgWindow8MiBV1: {
WindowPoStPartitionSectors: 2,
ConsensusMinerMinPower: stabi.NewStoragePower(10 << 40),
},
stabi.RegisteredPoStProof_StackedDrgWindow512MiBV1: {
WindowPoStPartitionSectors: 2,
ConsensusMinerMinPower: stabi.NewStoragePower(10 << 40),
},
stabi.RegisteredPoStProof_StackedDrgWindow32GiBV1: {
WindowPoStPartitionSectors: 2349,
ConsensusMinerMinPower: stabi.NewStoragePower(10 << 40),
},
stabi.RegisteredPoStProof_StackedDrgWindow64GiBV1: {
WindowPoStPartitionSectors: 2300,
ConsensusMinerMinPower: stabi.NewStoragePower(10 << 40),
},
// Winning PoSt proof types omitted.
}
// Returns the partition size, in sectors, associated with a Window PoSt proof type.
// The partition size is the number of sectors proved in a single PoSt proof.
func PoStProofWindowPoStPartitionSectors(p stabi.RegisteredPoStProof) (uint64, error) {
info, ok := PoStProofPolicies[p]
if !ok {
return 0, xerrors.Errorf("unsupported proof type: %v", p)
}
return info.WindowPoStPartitionSectors, nil
}