status-im / status-go

The Status module that consumes go-ethereum
https://status.im
Mozilla Public License 2.0
727 stars 246 forks source link

Fetch messages from store nodes on a scheduled basis #5283

Closed vitvly closed 3 months ago

vitvly commented 4 months ago

Problem

We need to fetch messages periodically from store nodes.

Currently this is done by https://github.com/status-im/status-go/blob/dfdc1652a2e28c41059b8bc187c78b92c325d253/protocol/messenger.go#L928 which is periodically invoked from Messenger.watchConnectionChange(): https://github.com/status-im/status-go/blob/dfdc1652a2e28c41059b8bc187c78b92c325d253/protocol/messenger.go#L1447

But this won't fetch anything in case there was no connection state change. Moreover, this is not a pure polling mechanism, as same role is fulfilled by the code below, that utilizes waku2's ConnStatusSubscriptions.

UPDATE: clear now, the polling mechanism is only there for deprecated wakuv1. Additionally, wakuv1 also supports mailserver cycle events, that are processed when peers are updated.

So, we need a proper polling mechanism for store node messages.

Proposed solution

  1. Write a code that will do the following every N minutes:
    • check if we're current in the process of fetching. If so, do nothing.
    • otherwise, and if last fetch time was earlier than N minutes, start fetching.
      1. Provide a user-configurable setting for N.
      2. Chore: drop waku1 code from Messenger.watchConnectionChange().

cc @churik @cammellos

vitvly commented 3 months ago

Respective PR (https://github.com/status-im/status-go/pull/5292) closed, some refactorings extracted into https://github.com/status-im/status-go/pull/5420.