From ed8569eb9981978bbc8267388bde359cd9071424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 23 Feb 2020 21:00:47 +0100 Subject: [PATCH] More unified randomness handling --- sealing.go | 3 ++- states.go | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sealing.go b/sealing.go index 029c053f0..ce30be446 100644 --- a/sealing.go +++ b/sealing.go @@ -15,6 +15,7 @@ import ( "github.com/filecoin-project/go-sectorbuilder" "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/builtin/miner" + "github.com/filecoin-project/specs-actors/actors/crypto" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/events" @@ -46,7 +47,7 @@ type sealingApi interface { // TODO: trim down ChainHead(context.Context) (*types.TipSet, error) ChainNotify(context.Context) (<-chan []*store.HeadChange, error) - ChainGetRandomness(context.Context, types.TipSetKey, int64) ([]byte, error) + ChainGetRandomness(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, *types.TipSet) (*types.TipSet, error) ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error) ChainReadObj(context.Context, cid.Cid) ([]byte, error) diff --git a/states.go b/states.go index 1622011a3..2408ad09c 100644 --- a/states.go +++ b/states.go @@ -2,6 +2,7 @@ package sealing import ( "context" + "github.com/filecoin-project/specs-actors/actors/crypto" commcid "github.com/filecoin-project/go-fil-commcid" "github.com/filecoin-project/go-sectorbuilder/fs" @@ -146,11 +147,11 @@ func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) er } log.Info("precommit message landed on chain: ", sector.SectorID) - randHeight := mw.TipSet.Height() + build.InteractivePoRepDelay - 1 // -1 because of how the messages are applied + randHeight := mw.TipSet.Height() + miner.PreCommitChallengeDelay - 1 // -1 because of how the messages are applied log.Infof("precommit for sector %d made it on chain, will start proof computation at height %d", sector.SectorID, randHeight) err = m.events.ChainAt(func(ectx context.Context, ts *types.TipSet, curH abi.ChainEpoch) error { - rand, err := m.api.ChainGetRandomness(ectx, ts.Key(), int64(randHeight)) + rand, err := m.api.ChainGetRandomness(ectx, ts.Key(), crypto.DomainSeparationTag_InteractiveSealChallengeSeed, randHeight, nil) if err != nil { err = xerrors.Errorf("failed to get randomness for computing seal proof: %w", err) @@ -168,7 +169,7 @@ func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) er log.Warn("revert in interactive commit sector step") // TODO: need to cancel running process and restart... return nil - }, build.InteractivePoRepConfidence, mw.TipSet.Height()+build.InteractivePoRepDelay) + }, build.InteractivePoRepConfidence, mw.TipSet.Height()+miner.PreCommitChallengeDelay) if err != nil { log.Warn("waitForPreCommitMessage ChainAt errored: ", err) }