Update specs-actors

This commit is contained in:
Łukasz Magiera 2020-02-10 22:25:22 +01:00
parent c0ed0dda8e
commit 6dce181314
5 changed files with 10 additions and 120 deletions

View File

@ -233,14 +233,6 @@ func (sma StorageMinerActor) PreCommitSector(act *types.Actor, vmctx types.VMCon
return nil, aerrors.New(3, "sector already committed!")
}
// Power of the miner after adding this sector
futurePower := types.BigAdd(self.Power, types.NewInt(uint64(mi.SectorSize)))
collateralRequired := CollateralForPower(futurePower)
// TODO: grab from market?
if act.Balance.LessThan(collateralRequired) {
return nil, aerrors.New(4, "not enough collateral")
}
self.PreCommittedSectors[uintToStringKey(uint64(params.SectorNumber))] = &PreCommittedSector{
Info: *params,
@ -519,10 +511,10 @@ func (sma StorageMinerActor) GetPower(act *types.Actor, vmctx types.VMContext, p
}
if self.SlashedAt != 0 {
return types.NewInt(0).Bytes(), nil
return nil, nil
}
return self.Power.Bytes(), nil
return nil, nil
}
func SectorIsUnique2(ctx context.Context, s cbor.IpldStore, sroot cid.Cid, sid uint64) (bool, ActorError) {
@ -683,17 +675,9 @@ func (sma StorageMinerActor) UpdatePeerID(act *types.Actor, vmctx types.VMContex
}
func (sma StorageMinerActor) GetSectorSize(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
_, self, err := loadState(vmctx)
if err != nil {
return nil, err
}
mi, err := loadMinerInfo(vmctx, self)
if err != nil {
return nil, err
}
return types.NewInt(uint64(mi.SectorSize)).Bytes(), nil
return nil, nil
}
func (sma StorageMinerActor) IsSlashed(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
@ -726,13 +710,6 @@ func (sma StorageMinerActor) CheckMiner(act *types.Actor, vmctx types.VMContext,
return nil, nil
}
if params.NetworkPower.Equals(self.Power) {
// Don't break the network when there's only one miner left
log.Warnf("can't slash miner %s for missed PoSt, no power would be left in the network", vmctx.Message().To)
return nil, nil
}
// Slash for being late
self.SlashedAt = uint64(vmctx.BlockHeight())
@ -809,9 +786,6 @@ func (sma StorageMinerActor) SlashConsensusFault(act *types.Actor, vmctx types.V
}
slashedCollateral := params.SlashedCollateral
if slashedCollateral.LessThan(act.Balance) {
slashedCollateral = act.Balance
}
// Some of the slashed collateral should be paid to the slasher
// GROWTH_RATE determines how fast the slasher share of slashed collateral will increase as block elapses
@ -924,80 +898,8 @@ func (sma StorageMinerActor) SubmitElectionPoSt(act *types.Actor, vmctx types.VM
}
func onSuccessfulPoSt2(self *StorageMinerActorState, vmctx types.VMContext, activeFaults uint64) aerrors.ActorError {
ctx := vmctx.Context()
var mi MinerInfo
if err := vmctx.Storage().Get(self.Info, &mi); err != nil {
return err
}
pss, nerr := amt2.LoadAMT(ctx, vmctx.Ipld(), self.ProvingSet)
if nerr != nil {
return aerrors.HandleExternalError(nerr, "failed to load proving set")
}
ss, nerr := amt2.LoadAMT(ctx, vmctx.Ipld(), self.Sectors)
if nerr != nil {
return aerrors.HandleExternalError(nerr, "failed to load sector set")
}
faults, nerr := self.FaultSet.All(2 * ss.Count)
if nerr != nil {
return aerrors.Absorb(nerr, 1, "invalid bitfield (fatal?)")
}
self.FaultSet = types.NewBitField()
oldPower := self.Power
newPower := types.BigMul(types.NewInt(pss.Count-activeFaults), types.NewInt(uint64(mi.SectorSize)))
// If below the minimum size requirement, miners have zero power
if newPower.LessThan(types.NewInt(build.MinimumMinerPower)) {
newPower = types.NewInt(0)
}
self.Power = newPower
delta := types.BigSub(self.Power, oldPower)
if self.SlashedAt != 0 {
self.SlashedAt = 0
delta = self.Power
}
prevSlashingDeadline := self.ElectionPeriodStart + build.SlashablePowerDelay
if !self.Active && newPower.GreaterThan(types.NewInt(0)) {
self.Active = true
prevSlashingDeadline = 0
}
if !(oldPower.IsZero() && newPower.IsZero()) {
enc, err := SerializeParams(&UpdateStorageParams{
Delta: delta,
NextSlashDeadline: uint64(vmctx.BlockHeight()) + build.SlashablePowerDelay,
PreviousSlashDeadline: uint64(prevSlashingDeadline),
})
if err != nil {
return err
}
_, err = vmctx.Send(StoragePowerAddress, SPAMethods.UpdateStorage, types.NewInt(0), enc)
if err != nil {
return aerrors.Wrap(err, "updating storage failed")
}
self.ElectionPeriodStart = vmctx.BlockHeight()
}
var ncid cid.Cid
var err aerrors.ActorError
ncid, err = RemoveFromSectorSet2(ctx, vmctx.Ipld(), self.Sectors, faults)
if err != nil {
return err
}
self.Sectors = ncid
self.ProvingSet = ncid
return nil
}

View File

@ -298,5 +298,5 @@ func (pca PaymentChannelActor) GetToSend(act *types.Actor, vmctx types.VMContext
return nil, err
}
return self.ToSend.Bytes(), nil
return nil, nil
}

View File

@ -437,7 +437,7 @@ func (spa StoragePowerActor) GetTotalStorage(act *types.Actor, vmctx types.VMCon
return nil, err
}
return self.TotalStorage.Bytes(), nil
return nil, nil
}
type PowerLookupParams struct {
@ -450,12 +450,8 @@ func (spa StoragePowerActor) PowerLookup(act *types.Actor, vmctx types.VMContext
return nil, aerrors.Wrap(err, "getting head")
}
pow, err := powerLookup(context.TODO(), vmctx, &self, params.Miner)
if err != nil {
return nil, err
}
return pow.Bytes(), nil
return nil, nil
}
func powerLookup(ctx context.Context, vmctx types.VMContext, self *StoragePowerState, miner address.Address) (types.BigInt, ActorError) {
@ -523,12 +519,7 @@ func (spa StoragePowerActor) PledgeCollateralForSize(act *types.Actor, vmctx typ
return nil, err
}
totalCollateral, err := pledgeCollateralForSize(vmctx, param.Size, self.TotalStorage, self.MinerCount)
if err != nil {
return nil, err
}
return totalCollateral.Bytes(), nil
return nil, nil
}
func pledgeCollateralForSize(vmctx types.VMContext, size, totalStorage types.BigInt, minerCount uint64) (types.BigInt, aerrors.ActorError) {
@ -682,11 +673,6 @@ func checkProofSubmissionsAtH(vmctx types.VMContext, self *StoragePowerState, he
return xerrors.Errorf("unmarshaling CheckMiner response (%x): %w", ret, err)
}
if power.GreaterThan(types.NewInt(0)) {
log.Warnf("slashing miner %s for missed PoSt (%s B, H: %d, Bucket: %d)", maddr, power, height, bucketID)
self.TotalStorage = types.BigSub(self.TotalStorage, power)
}
return nil
})

2
go.mod
View File

@ -22,7 +22,7 @@ require (
github.com/filecoin-project/go-paramfetch v0.0.1
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200203173614-42d67726bb62
github.com/filecoin-project/go-statestore v0.1.0
github.com/filecoin-project/specs-actors v0.0.0-20200207231150-6c4532d56ffd
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/gorilla/mux v1.7.3

2
go.sum
View File

@ -135,6 +135,8 @@ github.com/filecoin-project/specs-actors v0.0.0-20200207015621-48d5262d247f h1:3
github.com/filecoin-project/specs-actors v0.0.0-20200207015621-48d5262d247f/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
github.com/filecoin-project/specs-actors v0.0.0-20200207231150-6c4532d56ffd h1:jR9qzUElb3J6UxDgDA1tlZ0AnL35dMZz7/bN/2z8Agk=
github.com/filecoin-project/specs-actors v0.0.0-20200207231150-6c4532d56ffd/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf h1:fbxBG12yrxilPFV1EG2lYqpUyAlRZWkvtqjk2svSeXY=
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 h1:EzDjxMg43q1tA2c0MV3tNbaontnHLplHyFF6M5KiVP0=