From 59b166b8337741307f205a56393bd4f27fe10ea0 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 26 Apr 2024 15:02:48 +1000 Subject: [PATCH 1/2] fix(events): check for sync-in-progress --- chain/events/filter/event.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chain/events/filter/event.go b/chain/events/filter/event.go index 1669d840eec..09513f9a63b 100644 --- a/chain/events/filter/event.go +++ b/chain/events/filter/event.go @@ -378,6 +378,10 @@ func (m *EventFilterManager) Install(ctx context.Context, minHeight, maxHeight a currentHeight := m.currentHeight m.mu.Unlock() + if currentHeight == 0 { + return nil, xerrors.Errorf("sync in progress, cannot install event filter") + } + if m.EventIndex == nil && minHeight != -1 && minHeight < currentHeight { return nil, xerrors.Errorf("historic event index disabled") } From 74c926ca97b7abec575cf83c9ca04dd0942a40de Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 26 Apr 2024 17:39:19 +1000 Subject: [PATCH 2/2] fix(events): get currentHeight from chainstore if we don't have it --- chain/events/filter/event.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chain/events/filter/event.go b/chain/events/filter/event.go index 09513f9a63b..0accc551ab4 100644 --- a/chain/events/filter/event.go +++ b/chain/events/filter/event.go @@ -375,13 +375,13 @@ func (m *EventFilterManager) Revert(ctx context.Context, from, to *types.TipSet) func (m *EventFilterManager) Install(ctx context.Context, minHeight, maxHeight abi.ChainEpoch, tipsetCid cid.Cid, addresses []address.Address, keysWithCodec map[string][]types.ActorEventBlock, excludeReverted bool) (EventFilter, error) { m.mu.Lock() + if m.currentHeight == 0 { + // sync in progress, we haven't had an Apply + m.currentHeight = m.ChainStore.GetHeaviestTipSet().Height() + } currentHeight := m.currentHeight m.mu.Unlock() - if currentHeight == 0 { - return nil, xerrors.Errorf("sync in progress, cannot install event filter") - } - if m.EventIndex == nil && minHeight != -1 && minHeight < currentHeight { return nil, xerrors.Errorf("historic event index disabled") }