From 56976f02299861413fee0b5623784cdd0f6fea95 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 4 Oct 2024 21:08:21 +0000 Subject: [PATCH] Delay static manifest until our head is within the target period (#696) Unfortunately, due to https://github.com/filecoin-project/lotus/issues/12557, time in our lotus tests is basically broken. So we start by relying on time but also check the head so we don't switch too early. This doesn't matter in practice, but I'd really like to be able to test this in CI, fully integrated. --- manifest/fusing_provider.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/manifest/fusing_provider.go b/manifest/fusing_provider.go index b2212dd4..104fe837 100644 --- a/manifest/fusing_provider.go +++ b/manifest/fusing_provider.go @@ -90,10 +90,30 @@ func (m *FusingManifestProvider) Start(ctx context.Context) error { for m.runningCtx.Err() == nil { select { case <-timer.C: + // Make sure we're actually at the target epoch. This shouldn't be + // an issue unless our clocks are really funky, the network is + // behind, or we're in a lotus integration test + // (https://github.com/filecoin-project/lotus/issues/12557). + head, err := m.ec.GetHead(m.runningCtx) + switch { + case err != nil: + log.Errorw("failed to get head in fusing manifest provider", "error", err) + fallthrough + case head.Epoch() < switchEpoch: + log.Infow("delaying fusing manifest switch-over because head is behind the target epoch", + "head", head.Epoch(), + "target epoch", switchEpoch, + "bootstrap epoch", m.static.BootstrapEpoch, + ) + timer.Reset(m.static.EC.Period) + continue + } + log.Infow( "fusing to the static manifest, stopping the dynamic manifest provider", "network", m.static.NetworkName, "bootstrap epoch", m.static.BootstrapEpoch, + "current epoch", head.Epoch(), ) m.updateManifest(m.static) // Log any errors and move on. We don't bubble it because we don't