From 7b6d67ec1e3db6da0584e66dc0076f22ee1feac8 Mon Sep 17 00:00:00 2001 From: waynewyang Date: Wed, 23 Oct 2019 11:51:48 +0800 Subject: [PATCH] Check if fromaddress equal workaddress when CommitSector --- chain/actors/actor_miner.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/chain/actors/actor_miner.go b/chain/actors/actor_miner.go index de7e4d225..404051222 100644 --- a/chain/actors/actor_miner.go +++ b/chain/actors/actor_miner.go @@ -225,13 +225,17 @@ func (sma StorageMinerActor) CommitSector(act *types.Actor, vmctx types.VMContex return nil, err } + if vmctx.Message().From != mi.Worker { + return nil, aerrors.New(1, "not authorized to commit sector for miner") + } + // TODO: this needs to get normalized to either the ID address or the actor address maddr := vmctx.Message().To if ok, err := ValidatePoRep(maddr, mi.SectorSize, params); err != nil { return nil, err } else if !ok { - return nil, aerrors.New(1, "bad proof!") + return nil, aerrors.New(2, "bad proof!") } // make sure the miner isnt trying to submit a pre-existing sector @@ -240,7 +244,7 @@ func (sma StorageMinerActor) CommitSector(act *types.Actor, vmctx types.VMContex return nil, err } if !unique { - return nil, aerrors.New(2, "sector already committed!") + return nil, aerrors.New(3, "sector already committed!") } // Power of the miner after adding this sector @@ -248,7 +252,7 @@ func (sma StorageMinerActor) CommitSector(act *types.Actor, vmctx types.VMContex collateralRequired := CollateralForPower(futurePower) if act.Balance.LessThan(collateralRequired) { - return nil, aerrors.New(3, "not enough collateral") + return nil, aerrors.New(4, "not enough collateral") } // Note: There must exist a unique index in the miner's sector set for each