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: waku store sync 2.0 common types & codec #3213

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

Conversation

SionoiS
Copy link
Contributor

@SionoiS SionoiS commented Dec 17, 2024

Description

First PR for the new Waku Store Sync 2.0

Include types and encode/decode of payloads and also tests.

Specification
Research issue

Changes

  • Common types
  • Codec
  • Tests

Followed by #3215

Issue

Copy link

github-actions bot commented Dec 17, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:3213

Built from 7460edc

@SionoiS SionoiS changed the title feat: store sync 2.0 common types & codec feat: waku store sync 2.0 common types & codec Dec 17, 2024
Copy link
Contributor

@gabrielmer gabrielmer left a comment

Choose a reason for hiding this comment

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

Amazinggg, thanks so much! 😍

Honestly, I think I should understand more about range based reconciliation in order to follow what's going on here.

Any article or resource you recommend to read and use as a reference? I probably have some homework to do 😬

waku/waku_store_sync/codec.nim Outdated Show resolved Hide resolved
waku/waku_store_sync/codec.nim Outdated Show resolved Hide resolved
@SionoiS
Copy link
Contributor Author

SionoiS commented Jan 6, 2025

Amazinggg, thanks so much! 😍

Honestly, I think I should understand more about range based reconciliation in order to follow what's going on here.

Any article or resource you recommend to read and use as a reference? I probably have some homework to do 😬

The goto should be my research issue. waku-org/research#102 and wip spec https://github.com/waku-org/specs/blob/feat--waku-sync-2/standards/core/sync.md

Although a lot of details are implementation specific which is not mentioned anywhere 🤔 maybe more code comment are needed.

@SionoiS SionoiS requested a review from jm-clius January 7, 2025 15:59
Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the (significant!) effort, also in the follow-up PRs! 🚀 I've requested some changes, mostly related to helping reviewers understand the code/protocol a bit better. For example, there are some magic numbers that I still can't quite figure out, some codec types don't quite match the spec or need some context, etc.

For this PR, I'd be happy to approve if the code is made clearer (with comments, reduced magic numbers, etc.). However, I think it will be easier for this (and follow-up) PRs to expand the wire protocol specification itself and get an agreed-upon design as spec first so that reviewers wouldn't have to infer how the protocol works only from code.

waku/waku_store_sync/common.nim Outdated Show resolved Hide resolved
Comment on lines 31 to 34
SyncPayload* = object
ranges*: seq[(Slice[ID], RangeType)]
fingerprints*: seq[Fingerprint]
itemSets*: seq[ItemSet]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we really need a proper wire protocol specification to both understand (and review) what SyncPayload does, when and how it's exchanged and interpreted, procedural flow, etc. We can then review the implementation as an accurate reflection of the agreed upon design/specification. For example, are Waku Sync nodes simply exchanging SyncPayload as handshake messages? Is there no negotiation about what shards (or time range) to sync? If not, do we assume that this Sync protocol will eventually be coupled with a negotiation protocol that will first establish the set of shards and time range (and later content topics) the nodes will sync? If not, I can imagine two Sync nodes storing completely different shards routinely happily reconciling their 100% divergent "sets", even if the two sets have nothing to do with each other. metadata protocol can also not be relied upon, as (i) this will create a strong dependency between the two protocols (ii) Sync nodes store sets may not match all shards they subscribe to/advertise in metadata protocol.

Copy link
Contributor Author

@SionoiS SionoiS Jan 8, 2025

Choose a reason for hiding this comment

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

At this stage, the impl. is 100% equivalent to the previous one in features. There's no negotiation. We can start discussing limited shard support in my research issue if you want.

waku/waku_store_sync/codec.nim Outdated Show resolved Hide resolved
waku/waku_store_sync/codec.nim Outdated Show resolved Hide resolved

return idx

proc deltaDecode*(T: type SyncPayload, buffer: seq[byte]): T =
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can reference the spec here in the comments.

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 it's a good idea to add links in the code. Link always end up broken anyway.

Maybe a section at the top explaining that there's a spec?

waku/waku_store_sync/codec.nim Outdated Show resolved Hide resolved
Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

Thanks for it! A few comments so far :)

waku/waku_store_sync/codec.nim Outdated Show resolved Hide resolved
waku/waku_store_sync/codec.nim Outdated Show resolved Hide resolved
waku/waku_store_sync/common.nim Outdated Show resolved Hide resolved
waku/waku_store_sync/common.nim Outdated Show resolved Hide resolved
waku/waku_store_sync/common.nim Outdated Show resolved Hide resolved
waku/waku_store_sync/common.nim Outdated Show resolved Hide resolved
tests/waku_store_sync/sync_utils.nim Outdated Show resolved Hide resolved
waku/waku_store_sync/common.nim Outdated Show resolved Hide resolved
waku/waku_store_sync/common.nim Outdated Show resolved Hide resolved
time*: Timestamp
hash*: WakuMessageHash

ItemSet* = object
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think every type, and its procs, should be contained in a separate file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Come on, the file is not even 100 lines.

@SionoiS SionoiS requested a review from jm-clius January 16, 2025 15:05
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.

4 participants