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: messageHash attribute added in SQLite + testcase #2142

Merged
merged 2 commits into from
Oct 24, 2023

Conversation

ABresting
Copy link
Contributor

Description

messageHash attributed added to SQLite, which aims to remove the id attribute in upcoming PRs. An associated test case also added.

migration scripts will be changed after the deletion of id attribute in upcoming PRs.

Changes

  • messageHash attribute added
  • added test case to test the messageHash attribute

Issue

#2112

@github-actions
Copy link

This PR may contain changes to database schema of one of the drivers.

If you are introducing any changes to the schema, make sure the upgrade from the latest release to this change passes without any errors/issues.

Please make sure the label release-notes is added to make sure upgrade instructions properly highlight this change.

@ABresting ABresting changed the title feat: messageHash attaribute added in SQLite + testcase feat: messageHash attribute added in SQLite + testcase Oct 19, 2023
@ABresting ABresting added the release-notes Issue/PR needs to be evaluated for inclusion in release notes highlights or upgrade instructions label Oct 19, 2023
@github-actions
Copy link

github-actions bot commented Oct 19, 2023

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2142

Built from 2efab14

Copy link
Member

@richard-ramos richard-ramos left a comment

Choose a reason for hiding this comment

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

LGTM

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 the PR! It is getting a look shape. However, I have the impression that we need to properly implement the computeDeterministicMessageHash proc, as I mentioned in a comment.

tests/waku_archive/test_driver_sqlite_query.nim Outdated Show resolved Hide resolved
Comment on lines 68 to +69
@(digest.data), # id
@(digest.data), # messageHash
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe there is something that I'm missing but messageHash looks the same as id.

I think we need to create a new computeDeterministicMessageHash proc in waku_archive.nim where we create the following attribute: https://rfc.vac.dev/spec/14/#deterministic-message-hashing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, as per the initial approach, we aim to remove the id attribute and replace it with messageHash, as not only nomenclature is better but the way digest/hash is computed it makes sense.

the computation logic behind messageHash follows the RFC. The digest logic is implemented in the previous PR for the same base issue #2112

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are absolutely right that we have it implemented. I got confused because we have another computeDigest definition, which is different. We need to revisit it and check if we can only use one.

proc computeDigest*(msg: WakuMessage): MessageDigest =

@Ivansete-status
Copy link
Collaborator

@jm-clius - something that I realized while reviewing this PR is that the messageHash won't be unique and therefore we need to also consider the storedAt attribute as part of the PK, as @ABresting is properly applying now.
wdyt?

@ABresting
Copy link
Contributor Author

@jm-clius - something that I realized while reviewing this PR is that the messageHash won't be unique and therefore we need to also consider the storedAt attribute as part of the PK, as @ABresting is properly applying now. wdyt?

Well, the problem with storedAt is that it is very local since the storedAt time is the local node time, i.e. for every node this time attribute can be different. The aim of messageHash is to make sure we have a unique message identifier across the decentralized network which then be used in the new sync protocol for efficient synchronization.

Co-authored-by: Ivan FB <128452529+Ivansete-status@users.noreply.github.com>
@ABresting ABresting merged commit 9cd8c73 into master Oct 24, 2023
9 of 10 checks passed
@ABresting ABresting deleted the add-new-message-hash-column branch October 24, 2023 10:19
ABresting added a commit that referenced this pull request Oct 24, 2023
ABresting added a commit that referenced this pull request Oct 24, 2023
ABresting added a commit that referenced this pull request Oct 24, 2023
omahs pushed a commit to omahs/nwaku that referenced this pull request Nov 21, 2023
* feat: messageHash attaribute added in SQLite + testcase

* Update tests/waku_archive/test_driver_sqlite_query.nim

Co-authored-by: Ivan FB <128452529+Ivansete-status@users.noreply.github.com>

---------

Co-authored-by: Ivan FB <128452529+Ivansete-status@users.noreply.github.com>
omahs pushed a commit to omahs/nwaku that referenced this pull request Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes Issue/PR needs to be evaluated for inclusion in release notes highlights or upgrade instructions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants