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: sync storage manager #2561

Merged
merged 10 commits into from
Apr 4, 2024
Merged

Conversation

chaitanyaprem
Copy link
Contributor

@chaitanyaprem chaitanyaprem commented Mar 28, 2024

Description

Introducing storage manager .

Changes

Implementing sync protocol flow in Sync session as per waku-org/research#80 (comment) can be taken up in a separate PR.
cc @SionoiS , I don't think i had time to start on this. Maybe you can take it up from here after merging this PR.

@chaitanyaprem chaitanyaprem requested a review from SionoiS March 28, 2024 11:36
@chaitanyaprem chaitanyaprem changed the base branch from master to feat--nwaku-sync March 28, 2024 11:37
@chaitanyaprem chaitanyaprem changed the title feart: sync storage manager feat: sync storage manager Mar 28, 2024
Copy link
Contributor

@SionoiS SionoiS left a comment

Choose a reason for hiding this comment

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

General direction looks good but I hate strings...

See my other style comments.

waku/waku_sync/storage.nim Outdated Show resolved Hide resolved
waku/waku_sync/storage.nim Outdated Show resolved Hide resolved
waku/waku_sync/storage.nim Outdated Show resolved Hide resolved
waku/waku_sync/storage.nim Outdated Show resolved Hide resolved
waku/waku_sync/storage.nim Outdated Show resolved Hide resolved
@chaitanyaprem chaitanyaprem marked this pull request as ready for review April 2, 2024 05:07
@chaitanyaprem chaitanyaprem requested a review from SionoiS April 2, 2024 05:07
Copy link

github-actions bot commented Apr 3, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2561-rln-v2-true

Built from 568c3af

Copy link
Contributor

@SionoiS SionoiS left a comment

Choose a reason for hiding this comment

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

good direction!

Comment on lines +49 to +51
#TODO: Do we need to check if this message has already been ingessed?
# because what if messages is received via gossip and sync as well?
# Might 2 entries to be inserted into storage which is inefficient.
Copy link
Contributor

Choose a reason for hiding this comment

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

The system should be idempotent, so i would say yes. Is the negentropy storage insert func not idempotent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Negentropy doesn't seem to be, because I wrote a small test to verify and it shows as a diff. Hence this needs to be handled separately at higher layer.


proc sync*(
self: WakuSync
): Future[Result[(seq[WakuMessageHash], RemotePeerInfo), string]] {.async, gcsafe.} =
let peer: RemotePeerInfo = self.peerManager.selectPeer(WakuSyncCodec).valueOr:
return err("No suitable peer found for sync")

let conn: Connection = (await self.peerManager.dialPeer(peer, WakuSyncCodec)).valueOr:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it not more concise this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is concise but leading to a bug where the handler gets invoked twice. i referred the issue in the pr description.

self.periodicSyncFut = self.periodicSync()

proc stopWait*(self: WakuSync) {.async.} =
await self.periodicSyncFut.cancelAndWait()

proc storageSize*(self: WakuSync): int =
return self.storage.size()
#[ TODO:Fetch from storageManager??
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it would make sense to me.

Comment on lines +13 to +15
type SyncSessionType* = enum
CLIENT = 1
SERVER = 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we expect more session type in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so

Comment on lines +31 to +35
Session State Machine
1. negotiate sync params
2. start negentropy sync
3. find out local needhashes
4. If client, share peer's needhashes to peer
Copy link
Contributor

Choose a reason for hiding this comment

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

Love state machine!

self: SyncSession, conn: Connection, storageMgr: WakuSyncStorageManager
) {.async, gcsafe.} =
#TODO: Find matching storage based on sync range and continue??
#TODO: Return error rather than closing stream abruptly?
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding standard error code and desc. to the payload would be the way I think

@SionoiS SionoiS merged commit 6bc1bbf into feat--nwaku-sync Apr 4, 2024
20 of 21 checks passed
@SionoiS SionoiS deleted the feat/sync-storage-manager branch April 4, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants