From db6bd890d9b6a7a89672b44f2a725fd77efed175 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 9 Sep 2020 20:06:23 -0700 Subject: [PATCH] condition randomness changes on fork height Signed-off-by: Jakub Sztandera --- chain/gen/gen.go | 4 +++- chain/sync.go | 4 +++- miner/miner.go | 7 +++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/chain/gen/gen.go b/chain/gen/gen.go index f2cd985f3..d661411fe 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -358,7 +358,9 @@ func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m add return nil, nil, nil, xerrors.Errorf("failed to cbor marshal address: %w", err) } - buf.Write(pts.MinTicket().VRFProof) + if round > build.UpgradeSmokeHeight { + buf.Write(pts.MinTicket().VRFProof) + } ticketRand, err := store.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_TicketProduction, round-build.TicketRandomnessLookback, buf.Bytes()) if err != nil { diff --git a/chain/sync.go b/chain/sync.go index 67e925ae8..9864600dd 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -891,7 +891,9 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er return xerrors.Errorf("failed to marshal miner address to cbor: %w", err) } - buf.Write(baseTs.MinTicket().VRFProof) + if h.Height > build.UpgradeSmokeHeight { + buf.Write(baseTs.MinTicket().VRFProof) + } beaconBase := *prevBeacon if len(h.BeaconEntries) != 0 { diff --git a/miner/miner.go b/miner/miner.go index b08b9c38a..1b0f0c766 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -447,9 +447,12 @@ func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, bas return nil, xerrors.Errorf("failed to marshal address to cbor: %w", err) } - buf.Write(base.TipSet.MinTicket().VRFProof) + round := base.TipSet.Height() + base.NullRounds + 1 + if round > build.UpgradeSmokeHeight { + buf.Write(base.TipSet.MinTicket().VRFProof) + } - input, err := store.DrawRandomness(brand.Data, crypto.DomainSeparationTag_TicketProduction, base.TipSet.Height()+base.NullRounds+1-build.TicketRandomnessLookback, buf.Bytes()) + input, err := store.DrawRandomness(brand.Data, crypto.DomainSeparationTag_TicketProduction, round-build.TicketRandomnessLookback, buf.Bytes()) if err != nil { return nil, err }