Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: storenode cycle #1223

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

feat: storenode cycle #1223

wants to merge 3 commits into from

Conversation

richard-ramos
Copy link
Member

@richard-ramos richard-ramos commented Sep 19, 2024

This PR contains the storenode cycle code from status-go.
I tried to simplify it a bit but most of the heavy refactoring should be done on a separate PR since this one is already complex enough.

@plopezlpz, @kaichaosun @igor-sirotin @chaitanyaprem:
I'm still working on the unit tests, but so far, while testing status-im/status-go#5857 with Desktop, it looks promising. Reviews are appreciated!

s.Lock()
defer s.Unlock()

for _, subs := range s.subscriptions {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be sub.

waku/v2/api/history/emitters.go Outdated Show resolved Hide resolved
m.host = h
m.failedRequests = make(map[peer.ID]uint)
m.peers = make(map[peer.ID]peerStatus)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we connect the store node first with some strategy before actually verify the status?

} else {
m.peers[m.activeStorenode] = peerStatus{
status: disconnected,
canConnectAfter: time.Now().Add(backoffDuration),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another strategy is have a blacklist of unreachable store nodes, and periodically check if the node should be kept in the list.

m.logger.Info("Automatically switching storenode")

if m.activeStorenode != "" {
m.disconnectActiveStorenode(graylistBackoff)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering why this is needed and the intention of this graylistBackoff?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Looking at the existing code in status-go, i believe it is so we dont connect again to this storenode for 3 minutes.

waku/v2/api/history/cycle.go Show resolved Hide resolved
waku/v2/api/history/cycle.go Outdated Show resolved Hide resolved
waku/v2/api/history/cycle.go Show resolved Hide resolved
}

func (m *StorenodeCycle) verifyStorenodeStatus(ctx context.Context) {
ticker := time.NewTicker(1 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a constant.

waku/v2/api/history/cycle.go Show resolved Hide resolved
@richard-ramos richard-ramos marked this pull request as ready for review September 30, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants