From 6dce181314f6cdd620952a3e0be2ef3a3bf7c7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 10 Feb 2020 22:25:22 +0100 Subject: [PATCH] Update specs-actors --- chain/actors/actor_miner.go | 104 +---------------------------- chain/actors/actor_paych.go | 2 +- chain/actors/actor_storagepower.go | 20 +----- go.mod | 2 +- go.sum | 2 + 5 files changed, 10 insertions(+), 120 deletions(-) diff --git a/chain/actors/actor_miner.go b/chain/actors/actor_miner.go index 86250e1a4..92ef545e0 100644 --- a/chain/actors/actor_miner.go +++ b/chain/actors/actor_miner.go @@ -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 } diff --git a/chain/actors/actor_paych.go b/chain/actors/actor_paych.go index d7a07eee3..532843b95 100644 --- a/chain/actors/actor_paych.go +++ b/chain/actors/actor_paych.go @@ -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 } diff --git a/chain/actors/actor_storagepower.go b/chain/actors/actor_storagepower.go index 76a69dcd1..e4c3117e7 100644 --- a/chain/actors/actor_storagepower.go +++ b/chain/actors/actor_storagepower.go @@ -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 }) diff --git a/go.mod b/go.mod index 6f5bed0bf..d9a1b3dc8 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index efc500afc..e9dd32493 100644 --- a/go.sum +++ b/go.sum @@ -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=