miner: Use correct randomness for sealing
This commit is contained in:
parent
ecc38d1bd8
commit
b941b29fe5
2
go.mod
2
go.mod
@ -26,7 +26,7 @@ require (
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200417225459-e75536581a08
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200420172552-09dec8ff055a
|
||||
github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200417194744-f2744cf09977
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200420183220-1515cffb5d13
|
||||
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/gorilla/mux v1.7.4
|
||||
|
2
go.sum
2
go.sum
@ -188,6 +188,8 @@ github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102 h1:
|
||||
github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102/go.mod h1:xJ1/xl9+8zZeSSSFmDC3Wr6uusCTxyYPI0VeNVSFmPE=
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200417194744-f2744cf09977 h1:PDTyqPZEGUztRfoletRpmc2116mZFhvNQcjeF7gCue0=
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200417194744-f2744cf09977/go.mod h1:mJtW2Y2qIbZErBoc1MmgVKMFiNHWZ2qqeH6Hl3fHFWU=
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200420183220-1515cffb5d13 h1:Zv0ovLy4nOgMk9bCKOp+Wo6NMSSeuNgPNk0N3aLf5Wg=
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200420183220-1515cffb5d13/go.mod h1:mJtW2Y2qIbZErBoc1MmgVKMFiNHWZ2qqeH6Hl3fHFWU=
|
||||
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=
|
||||
|
@ -1,6 +1,7 @@
|
||||
package modules
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"net/http"
|
||||
"reflect"
|
||||
@ -282,7 +283,17 @@ func SetupBlockProducer(lc fx.Lifecycle, ds dtypes.MetadataDS, api lapi.FullNode
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func SealTicketGen(fapi lapi.FullNode) sealing.TicketFn {
|
||||
func SealTicketGen(fapi lapi.FullNode, ds dtypes.MetadataDS) (sealing.TicketFn, error) {
|
||||
minerAddr, err := minerAddrFromDS(ds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
entropy := new(bytes.Buffer)
|
||||
if err := minerAddr.MarshalCBOR(entropy); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return func(ctx context.Context, tok sealing.TipSetToken) (abi.SealRandomness, abi.ChainEpoch, error) {
|
||||
tsk, err := types.TipSetKeyFromBytes(tok)
|
||||
if err != nil {
|
||||
@ -294,13 +305,13 @@ func SealTicketGen(fapi lapi.FullNode) sealing.TicketFn {
|
||||
return nil, 0, xerrors.Errorf("getting TipSet for key failed: %w", err)
|
||||
}
|
||||
|
||||
r, err := fapi.ChainGetRandomness(ctx, ts.Key(), crypto.DomainSeparationTag_SealRandomness, ts.Height()-build.SealRandomnessLookback, nil)
|
||||
r, err := fapi.ChainGetRandomness(ctx, ts.Key(), crypto.DomainSeparationTag_SealRandomness, ts.Height()-build.SealRandomnessLookback, entropy.Bytes())
|
||||
if err != nil {
|
||||
return nil, 0, xerrors.Errorf("getting randomness for SealTicket failed: %w", err)
|
||||
}
|
||||
|
||||
return abi.SealRandomness(r), ts.Height() - build.SealRandomnessLookback, nil
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewProviderRequestValidator(deals dtypes.ProviderDealStore) *requestvalidation.ProviderRequestValidator {
|
||||
|
Loading…
Reference in New Issue
Block a user