Skip to content

fix(store): fix validation to allow store query by hash #2330

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adklempner
Copy link
Member

@adklempner adklempner commented Mar 29, 2025

Problem / Description

Validation logic in the our implementation of the Store RPC requests prevented queries based on message hashes from going through

Solution

  • Fixed the validation logic in StoreQueryRequest to properly handle message hash queries
  • explicit support for messageHashes in the query parameters
  • unit tests to verify the query functionality with message hashes

Notes


Checklist

  • Code changes are covered by unit tests.
  • Code changes are covered by e2e tests, if applicable.
  • Dogfooding has been performed, if feasible.
  • A test version has been published, if required.
  • All CI checks pass successfully.

@adklempner adklempner force-pushed the fix/hash-store-query branch 2 times, most recently from bb686dd to 453f4ef Compare May 15, 2025 00:44
Copy link

github-actions bot commented May 15, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 62.25 KB (+0.44% 🔺) 1.3 s (+0.44% 🔺) 8.4 s (+9.06% 🔺) 9.7 s
Waku Simple Light Node 115.06 KB (+0.2% 🔺) 2.4 s (+0.2% 🔺) 11.2 s (-19.25% 🔽) 13.5 s
ECIES encryption 23 KB (0%) 461 ms (0%) 4.4 s (-19.31% 🔽) 4.9 s
Symmetric encryption 22.44 KB (0%) 449 ms (0%) 5 s (+19.09% 🔺) 5.4 s
DNS discovery 50.83 KB (0%) 1.1 s (0%) 8.6 s (-11.03% 🔽) 9.6 s
Peer Exchange discovery 51.38 KB (0%) 1.1 s (0%) 8.1 s (+36.83% 🔺) 9.1 s
Local Peer Cache Discovery 44.7 KB (0%) 894 ms (0%) 7.9 s (+26.13% 🔺) 8.8 s
Privacy preserving protocols 52.94 KB (0%) 1.1 s (0%) 6.8 s (-17.52% 🔽) 7.8 s
Waku Filter 54.92 KB (0%) 1.1 s (0%) 7.5 s (-20.05% 🔽) 8.6 s
Waku LightPush 52.29 KB (0%) 1.1 s (0%) 11.6 s (+66.69% 🔺) 12.6 s
History retrieval protocols 52.74 KB (+0.24% 🔺) 1.1 s (+0.24% 🔺) 9.3 s (+33.75% 🔺) 10.4 s
Deterministic Message Hashing 7.33 KB (0%) 147 ms (0%) 3.6 s (+81.92% 🔺) 3.8 s

@adklempner adklempner force-pushed the fix/hash-store-query branch from 453f4ef to 645b543 Compare May 15, 2025 01:17
@adklempner adklempner marked this pull request as ready for review May 15, 2025 01:27
@adklempner adklempner requested a review from a team as a code owner May 15, 2025 01:27
@adklempner adklempner force-pushed the fix/hash-store-query branch from 645b543 to beb60c6 Compare May 15, 2025 01:45
@adklempner adklempner force-pushed the fix/hash-store-query branch from beb60c6 to fb54552 Compare May 15, 2025 22:18
@weboko weboko requested a review from Copilot May 19, 2025 22:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the validation logic in the Store RPC to allow queries by message hash and prevents conflicts with content filter criteria. Key changes include:

  • Adjusting the validation in the core and SDK store modules to handle message hash queries.
  • Updating tests to cover message hash query scenarios.
  • Adding a dependency for message hash functionality in the tests package.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/tests/tests/store/utils.ts Updated sendMessages to support optional timestamps.
packages/tests/tests/store/message_hash.spec.ts Added tests to verify message hash queries.
packages/tests/package.json Added dependency for "@waku/message-hash".
packages/sdk/src/store/store.ts Introduced queryByMessageHashes and adjusted regular query flow.
packages/core/src/lib/store/store.ts Modified content topic validation for message hash queries.
packages/core/src/lib/store/rpc.ts Adjusted validation to allow message hash queries without content filters.
Comments suppressed due to low confidence (1)

packages/core/src/lib/store/store.ts:49

  • Using toString() for comparing arrays may be brittle and order sensitive; consider using a more robust array equality check such as comparing sorted arrays.
queryOpts.contentTopics.toString() !== Array.from(decoders.keys()).toString()

});

it("can query messages by message hash", async function () {
// Send messages first
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's not have not needed comments :)

here and in other places/PRs too

AI sometimes adds it, but I think it doesn't bring value as we are literally getting:

// send messages
await sendMessages();

cc @waku-org/js-waku

}
}

// Note: The real issue might be that message hash lookup is not properly supported
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am missing the value of the test here. It would succeed even if no messages are found, right?

pubsubTopic: string
): Promise<void> {
pubsubTopic: string,
timestamp: boolean = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
timestamp: boolean = false
includeTimestamp: boolean = false

Copy link
Collaborator

@weboko weboko left a comment

Choose a reason for hiding this comment

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

left some comments, overall looks good!
did you validate is in SDS context?

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.

feat: make store fetch messages by hash
2 participants