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

replace SimpleQaPower with flags #212

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
9 changes: 8 additions & 1 deletion builtin/v12/migration/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,20 @@ func migrateSectorInfo(sectorInfo miner11.SectorOnChainInfo) *miner12.SectorOnCh
// PowerBaseEpoch := Activation (in all cases)
// Activation := Activation (for non-upgraded sectors and sectors upgraded through old CC path)
// Activation := OldActivation - ReplacedSectorAge (for sectors updated through SnapDeals)
//
// SimpleQAPower field got replaced by flags field. We set the flag SIMPLE_QA_POWER if the sector had the field set to true.

powerBaseEpoch := sectorInfo.Activation
activationEpoch := sectorInfo.Activation
if sectorInfo.SectorKeyCID != nil {
activationEpoch = sectorInfo.Activation - sectorInfo.ReplacedSectorAge
}

flags := miner12.SectorOnChainInfoFlags(0)
if sectorInfo.SimpleQAPower {
flags = flags | miner12.SIMPLE_QA_POWER
}

return &miner12.SectorOnChainInfo{
SectorNumber: sectorInfo.SectorNumber,
SealProof: sectorInfo.SealProof,
Expand All @@ -402,6 +409,6 @@ func migrateSectorInfo(sectorInfo miner11.SectorOnChainInfo) *miner12.SectorOnCh
PowerBaseEpoch: powerBaseEpoch,
ReplacedDayReward: sectorInfo.ReplacedDayReward,
SectorKeyCID: sectorInfo.SectorKeyCID,
SimpleQAPower: sectorInfo.SimpleQAPower,
Flags: flags,
}
}
33 changes: 16 additions & 17 deletions builtin/v12/miner/cbor_gen.go

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

29 changes: 18 additions & 11 deletions builtin/v12/miner/miner_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,30 @@ type SectorPreCommitOnChainInfo struct {
PreCommitEpoch abi.ChainEpoch
}

type SectorOnChainInfoFlags uint64

const (
SIMPLE_QA_POWER SectorOnChainInfoFlags = 1 << iota // QA power mechanism introduced in FIP-0045
)


// Information stored on-chain for a proven sector.
type SectorOnChainInfo struct {
SectorNumber abi.SectorNumber
SealProof abi.RegisteredSealProof // The seal proof type implies the PoSt proof/s
SealedCID cid.Cid // CommR
DealIDs []abi.DealID
Activation abi.ChainEpoch // Epoch during which the sector proof was accepted
Expiration abi.ChainEpoch // Epoch during which the sector expires
DealWeight abi.DealWeight // Integral of active deals over sector lifetime
VerifiedDealWeight abi.DealWeight // Integral of active verified deals over sector lifetime
InitialPledge abi.TokenAmount // Pledge collected to commit this sector
ExpectedDayReward abi.TokenAmount // Expected one day projection of reward for sector computed at activation time
ExpectedStoragePledge abi.TokenAmount // Expected twenty day projection of reward for sector computed at activation time
PowerBaseEpoch abi.ChainEpoch // Epoch at which this sector's power was most recently updated
ReplacedDayReward abi.TokenAmount // Day reward of this sector before its power was most recently updated
SectorKeyCID *cid.Cid // The original SealedSectorCID, only gets set on the first ReplicaUpdate
SimpleQAPower bool // Flag for QA power mechanism introduced in FIP-0045
Activation abi.ChainEpoch // Epoch during which the sector proof was accepted
Expiration abi.ChainEpoch // Epoch during which the sector expires
DealWeight abi.DealWeight // Integral of active deals over sector lifetime
VerifiedDealWeight abi.DealWeight // Integral of active verified deals over sector lifetime
InitialPledge abi.TokenAmount // Pledge collected to commit this sector
ExpectedDayReward abi.TokenAmount // Expected one day projection of reward for sector computed at activation time
ExpectedStoragePledge abi.TokenAmount // Expected twenty day projection of reward for sector computed at activation time
PowerBaseEpoch abi.ChainEpoch // Epoch at which this sector's power was most recently updated
ReplacedDayReward abi.TokenAmount // Day reward of this sector before its power was most recently updated
SectorKeyCID *cid.Cid // The original SealedSectorCID, only gets set on the first ReplicaUpdate
Flags SectorOnChainInfoFlags // Additional flags
}

func (st *State) GetInfo(store adt.Store) (*MinerInfo, error) {
Expand Down