Check if fromaddress equal workaddress when CommitSector

This commit is contained in:
waynewyang 2019-10-23 11:51:48 +08:00
parent 007edf7830
commit 7b6d67ec1e

View File

@ -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