From c4852e04c9c1960914667363dc5858127ec60eb5 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 30 Apr 2020 13:21:46 -0700 Subject: [PATCH] Use miner address in randomness mixing --- chain/sync.go | 7 ++++++- miner/miner.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/chain/sync.go b/chain/sync.go index 6ca56b5b0..fe241af47 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -742,12 +742,17 @@ func (syncer *Syncer) VerifyWinningPoStProof(ctx context.Context, h *types.Block return xerrors.Errorf("[TESTING] winning post was invalid") } + buf := new(bytes.Buffer) + if err := h.Miner.MarshalCBOR(buf); err != nil { + return xerrors.Errorf("failed to marshal miner address: %w", err) + } + rbase := prevBeacon if len(h.BeaconEntries) > 0 { rbase = h.BeaconEntries[len(h.BeaconEntries)-1] } - rand, err := store.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_WinningPoStChallengeSeed, h.Height-1, nil) + rand, err := store.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_WinningPoStChallengeSeed, h.Height-1, buf.Bytes()) if err != nil { return xerrors.Errorf("failed to get randomness for verifying winningPost proof: %w", err) } diff --git a/miner/miner.go b/miner/miner.go index 70c768fa4..96b33aaa4 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -361,7 +361,12 @@ func (m *Miner) mineOne(ctx context.Context, addr address.Address, base *MiningB return nil, nil } - rand, err := store.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_WinningPoStChallengeSeed, base.TipSet.Height()+base.NullRounds, nil) + buf := new(bytes.Buffer) + if err := m.addresses[0].MarshalCBOR(buf); err != nil { + return nil, xerrors.Errorf("failed to marshal miner address: %w", err) + } + + rand, err := store.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_WinningPoStChallengeSeed, base.TipSet.Height()+base.NullRounds, buf.Bytes()) if err != nil { return nil, xerrors.Errorf("failed to get randomness for winning post: %w", err) }