From b7fab5f937001f125801f4579cfa25bb25a072bb Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 9 Mar 2021 22:03:05 -0800 Subject: [PATCH] fix: wait a bit before starting to compute window post proofs Due to a (now consensus critical) bug in randomness selection, "beacon" randomness depends on whether the epoch in which the beacon occurred was a null block. Unfortunately, this means: 1. If a challenge lands on a non-null round but that non-null round gets re-orged to a null round, the randomness will change to the beacon in the first preceding non-null block. 2. If a challenge lands on a null round but that null round gets re-orged to a non-null round, the randomness will change to the beacon in the new non-null round. The correct solution is to change the way the beacon is selected: 1. Wait until a non-null round. 2. The block in this round will contain all beacons from the null rounds, select the beacon from the target epoch. Unfortunately, this requires a mandatory network upgrade. Instead, this patch just waits a bit before beginning to compute window post after passing the challenge round to wait-out any reorgs. --- storage/wdpost_changehandler.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/wdpost_changehandler.go b/storage/wdpost_changehandler.go index 285995757..188d7e93a 100644 --- a/storage/wdpost_changehandler.go +++ b/storage/wdpost_changehandler.go @@ -13,7 +13,10 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -const SubmitConfidence = 4 +const ( + SubmitConfidence = 4 + ChallengeConfidence = 10 +) type CompleteGeneratePoSTCb func(posts []miner.SubmitWindowedPoStParams, err error) type CompleteSubmitPoSTCb func(err error) @@ -230,7 +233,7 @@ func (p *proveHandler) processHeadChange(ctx context.Context, newTS *types.TipSe } // Check if the chain is above the Challenge height for the post window - if newTS.Height() < di.Challenge { + if newTS.Height() < di.Challenge+ChallengeConfidence { return }