Persistent message store#814
Conversation
|
@philon- is attempting to deploy a commit to the Meshtastic Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces persistent storage for the message store and enhances node PKI validation. It implements client-side persistence for messages and adds improved validation logic for node database operations to prevent PKI conflicts and ensure proper data integrity.
Key Changes:
- Message store refactored to support persistence with device-scoped storage
- Node PKI validation system implemented to detect key conflicts and prevent impersonation
- Fallback mechanism added for packet timestamps when zero or negative
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
packages/web/src/pages/Messages.tsx |
Updates to use new message store API with device-scoped access |
packages/web/src/core/subscriptions.ts |
Simplifies node handling by delegating PKI validation to nodeDB |
packages/web/src/core/stores/utils/useNewNodeNum.ts |
New utility for coordinating node number updates across stores |
packages/web/src/core/stores/nodeDBStore/types.ts |
Adds new error type for duplicate PKI detection |
packages/web/src/core/stores/nodeDBStore/nodeValidation.ts |
New validation logic for incoming nodes with PKI conflict detection |
packages/web/src/core/stores/nodeDBStore/nodeDBStore.test.ts |
Comprehensive tests for validation and merge behavior |
packages/web/src/core/stores/nodeDBStore/index.ts |
Integrates validation, adds timestamp fallback, and improves merge logic |
packages/web/src/core/stores/messageStore/messageStore.test.ts |
Updates tests for new persistent store structure |
packages/web/src/core/stores/messageStore/index.ts |
Complete refactor to support persistence and device-scoped instances |
packages/web/src/core/stores/index.ts |
Exports new hooks and utilities for the refactored stores |
packages/web/src/core/services/dev-overrides.ts |
Enables message persistence feature flag in development |
| Various component files | Updates to use new message store API patterns |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Implement node validation and improve merging logic - Added `validateIncomingNode` function to validate new nodes against existing nodes, checking for public key conflicts and ensuring proper handling of node updates. - Updated `nodeDBFactory` to utilize the new validation function when adding nodes. - Enhanced `getNodes` method to optionally include the current node in the results. - Removed the `mergeNodeInfo` utility as its functionality is now integrated into the validation and merging process. - Updated tests to cover new validation logic and ensure correct behavior during node addition and merging. - Cleaned up unused utility functions related to key comparison.
1eb6177 to
2910c96
Compare
ce4b37b to
988c045
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@philon- Any chance you could rebase main onto this branch to bring it up to date? And run |
Description
This PR introduces persistent storage for the message store and some enhancements to node PKI validation and nodeDB merging logic
Related Issues
Changes Made
Persistent Message Store: Adds persistence to the message store, ensuring messages and node information survive page reloads and browser restarts.
Node PKI Validation & Merging:
validateIncomingNodeto check new nodes for public key conflicts and correct update handling. This flow is taken from Meshtastic-Android NodeInfo upsertnodeDBFactoryto use new validation during node addition.There is also a minor fix to fall back to client's Date.now() when a packet is received with a time field less or equal to 0. This is consistent with how the Meshtastic-Apple client handles new packets.
Testing Done
Added/updated tests to cover new validation logic and merging behavior that ensures proper behavior on node addition, PKI mismatch.
Added/updated messageStore tests to also check persistence flow
Added/updated users of messageStore to reflect new structure
Screenshots (if applicable)
Checklist
CONTRIBUTING_I18N_DEVELOPER_GUIDE.md for more details)