Basic CC Upgrade logic
This commit is contained in:
parent
dd6398dbcb
commit
e2691f3b3d
2
go.mod
2
go.mod
@ -10,7 +10,7 @@ require (
|
||||
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200218225740-47c639bab663 // indirect
|
||||
github.com/filecoin-project/go-statemachine v0.0.0-20200226041606-2074af6d51d9
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200625154333-98ef8e4ef246
|
||||
github.com/filecoin-project/specs-actors v0.7.0
|
||||
github.com/filecoin-project/specs-actors v0.7.1
|
||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea
|
||||
github.com/ipfs/go-cid v0.0.5
|
||||
github.com/ipfs/go-datastore v0.4.4
|
||||
|
2
go.sum
2
go.sum
@ -64,6 +64,8 @@ github.com/filecoin-project/specs-actors v0.6.0 h1:IepUsmDGY60QliENVTkBTAkwqGWw9
|
||||
github.com/filecoin-project/specs-actors v0.6.0/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY=
|
||||
github.com/filecoin-project/specs-actors v0.7.0 h1:tldjW8pFiJcMtyGPsXmPoFdbN/18mKW3BpEMlO4NJAc=
|
||||
github.com/filecoin-project/specs-actors v0.7.0/go.mod h1:+z0htZu/wLBDbOLcQTKKUEC2rkUTFzL2KJ/bRAVWkws=
|
||||
github.com/filecoin-project/specs-actors v0.7.1 h1:/zW++MN4gGIPvG+s0zmSI97k0Z/aaeiREjLC10gQbco=
|
||||
github.com/filecoin-project/specs-actors v0.7.1/go.mod h1:+z0htZu/wLBDbOLcQTKKUEC2rkUTFzL2KJ/bRAVWkws=
|
||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY=
|
||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
|
@ -3,6 +3,7 @@ package sealing
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/ipfs/go-datastore"
|
||||
@ -55,6 +56,9 @@ type Sealing struct {
|
||||
|
||||
unsealedInfos map[abi.SectorNumber]UnsealedSectorInfo
|
||||
pcp PreCommitPolicy
|
||||
|
||||
upgradeLk sync.Mutex
|
||||
toUpgrade map[abi.SectorNumber]struct{}
|
||||
}
|
||||
|
||||
type UnsealedSectorInfo struct {
|
||||
|
@ -169,6 +169,12 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
|
||||
DealIDs: sector.dealIDs(),
|
||||
}
|
||||
|
||||
replace := m.maybeUpgradableSector()
|
||||
if replace != nil {
|
||||
params.ReplaceCapacity = true
|
||||
params.ReplaceSector = *replace
|
||||
}
|
||||
|
||||
enc := new(bytes.Buffer)
|
||||
if err := params.MarshalCBOR(enc); err != nil {
|
||||
return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("could not serialize pre-commit sector parameters: %w", err)})
|
||||
|
1
types.go
1
types.go
@ -62,6 +62,7 @@ type SectorInfo struct {
|
||||
TicketValue abi.SealRandomness
|
||||
TicketEpoch abi.ChainEpoch
|
||||
PreCommit1Out storage.PreCommit1Out
|
||||
CCReplace *abi.SectorNumber
|
||||
|
||||
// PreCommit2
|
||||
CommD *cid.Cid
|
||||
|
57
upgrade_queue.go
Normal file
57
upgrade_queue.go
Normal file
@ -0,0 +1,57 @@
|
||||
package sealing
|
||||
|
||||
import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
)
|
||||
|
||||
func (m *Sealing) MarkForUpgrade(id abi.SectorNumber) error {
|
||||
m.upgradeLk.Lock()
|
||||
defer m.upgradeLk.Unlock()
|
||||
|
||||
_, found := m.toUpgrade[id]
|
||||
if found {
|
||||
return xerrors.Errorf("sector %d already marked for upgrade", id)
|
||||
}
|
||||
|
||||
si, err := m.GetSectorInfo(id)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("getting sector info: %w", err)
|
||||
}
|
||||
|
||||
if si.State != Proving {
|
||||
return xerrors.Errorf("can't mark sectors not in the 'Proving' state for upgrade")
|
||||
}
|
||||
|
||||
if len(si.Pieces) != 1 {
|
||||
return xerrors.Errorf("not a committed-capacity sector, expected 1 piece")
|
||||
}
|
||||
|
||||
if si.Pieces[0].DealInfo != nil {
|
||||
return xerrors.Errorf("not a committed-capacity sector, has deals")
|
||||
}
|
||||
|
||||
// TODO: more checks to match actor constraints
|
||||
|
||||
m.toUpgrade[id] = struct{}{}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Sealing) maybeUpgradableSector() *abi.SectorNumber {
|
||||
m.upgradeLk.Lock()
|
||||
defer m.upgradeLk.Unlock()
|
||||
for number := range m.toUpgrade {
|
||||
// TODO: checks to match actor constraints
|
||||
|
||||
// this one looks good
|
||||
/*if checks */{
|
||||
delete(m.toUpgrade, number)
|
||||
return &number
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user