diff --git a/build/params_shared.go b/build/params_shared.go index 0357bf03a..fd9dbf65d 100644 --- a/build/params_shared.go +++ b/build/params_shared.go @@ -56,6 +56,9 @@ const SealRandomnessLookback = Finality // Epochs const SealRandomnessLookbackLimit = SealRandomnessLookback + 2000 +// Maximum lookback that randomness can be sourced from for a seal proof submission +const MaxSealLookback = SealRandomnessLookbackLimit + 2000 + // ///// // Mining diff --git a/chain/actors/actor_miner.go b/chain/actors/actor_miner.go index e5e8b3b1e..c6bb7ae6d 100644 --- a/chain/actors/actor_miner.go +++ b/chain/actors/actor_miner.go @@ -321,6 +321,14 @@ func (sma StorageMinerActor) ProveCommitSector(act *types.Actor, vmctx types.VMC // TODO: ensure normalization to ID address maddr := vmctx.Message().To + if vmctx.BlockHeight()-us.Info.SealEpoch > build.MaxSealLookback { + return nil, aerrors.Newf(5, "source randomness for sector SealEpoch too far in past (epoch %d)", us.Info.SealEpoch) + } + + if vmctx.BlockHeight()-us.ReceivedEpoch > build.MaxSealLookback { + return nil, aerrors.Newf(6, "source randomness for sector ReceivedEpoch too far in past (epoch %d)", us.ReceivedEpoch) + } + ticket, err := vmctx.GetRandomness(us.Info.SealEpoch - build.SealRandomnessLookback) if err != nil { return nil, aerrors.Wrap(err, "failed to get ticket randomness")