Skip to content

Conversation

@shash256
Copy link
Collaborator

Implements the SDS spec update: vacp2p/rfc-index#130 and closes the issue #11.

Summary:

  • When Alice receives a message, the application can store the SDS_message_ID -> Waku_message_hash mapping
  • When Alice sends, her causal history includes retrieval hints via the provider callback
  • When Bob receives Alice's message and finds missing dependencies, he gets both message IDs and their retrieval hints
  • Bob's application can use the hints for efficient store queries

@shash256 shash256 self-assigned this Jul 25, 2025
@shash256 shash256 requested review from Ivansete-status, gabrielmer and jm-clius and removed request for gabrielmer July 25, 2025 07:12
@shash256 shash256 added the enhancement New feature or request label Jul 25, 2025
@shash256 shash256 linked an issue Jul 25, 2025 that may be closed by this pull request
13 tasks
@github-project-automation github-project-automation bot moved this to To triage in Reliability Jul 25, 2025
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 few minor comments, with a question about retrieval hints on checkDependencies being the only blocker to approving.


proc toCausalHistory*(messageIds: seq[SdsMessageID]): seq[HistoryEntry] =
## Converts a sequence of message IDs to HistoryEntry sequence
result = newSeq[HistoryEntry](messageIds.len)
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +178 to +180
if not rm.onRetrievalHint.isNil() and dep.retrievalHint.len == 0:
let hint = rm.onRetrievalHint(dep.messageId)
missingDeps.add(newHistoryEntry(dep.messageId, hint))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I get the point of this logic:

  1. We have received a message and are checking dependencies
  2. A dependency is missing (from library history cache) and has no retrieval hint.
  3. We somehow believe the app incorporating this library will have a retrieval hint for this dependency even if we didn't receive it from the remote? I guess this is very unlikely to happen if this is an actual missing dependency - for example, if the Waku message ID is the retrieval hint, this is only visible to an app if it has received the message or crafted it.

In other words, doesn't it make more sense to say a retrieval hint must always come from the remote party. If it's not there we simply do not have a retrieval hint?

Comment on lines +185 to +191
if not rm.onRetrievalHint.isNil():
for dep in deps:
if dep.retrievalHint.len == 0:
let hint = rm.onRetrievalHint(dep.messageId)
missingDeps.add(newHistoryEntry(dep.messageId, hint))
else:
missingDeps.add(dep)
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, I might be missing something obvious, but I'm not sure how an app could fill in the retrieval hint for received missing dependencies?

@jm-clius jm-clius requested review from adklempner and removed request for gabrielmer July 30, 2025 09:36
@jm-clius
Copy link
Contributor

@adklempner I would appreciate your eye on this - not necessarily reviewing Nim code, but a sanity check on the logic of the HistoryEntry and how that gets populated via callback.

@Ivansete-status feel free to nominate anyone from the nwaku team to help check Nim usage here (the detail of how SDS retrieval hints work is less important).

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.

LGTM re Nim PoV! Thanks!
Only need to avoid the use of result

)

if not isNil(hint) and hintLen > 0:
result = newSeq[byte](hintLen)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should always avoid the use of the implicit result

msg.causalHistory = causalHistory
# Handle both old and new causal history formats
var historyBuffers: seq[seq[byte]]
if pb.getRepeatedField(3, historyBuffers).isOk:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Super nitpick one. Verbs with parenthesis; nouns without

Suggested change
if pb.getRepeatedField(3, historyBuffers).isOk:
if pb.getRepeatedField(3, historyBuffers).isOk():

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

Update Causal History to Support Retrieval Hints

4 participants