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

Remote Settings: store full changesets instead of just records #6517

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

leplatrem
Copy link
Contributor

@leplatrem leplatrem commented Dec 5, 2024

In order to prepare the work of signature verification, where we want to be able to assess data integrity/authenticity, we need to store collection metadata and timestamps.

Also, this PR fixes an issue where the timestamp was wrong in certain cases (empty collections, tombstones, etc.)

It is an internal change that does not require a CHANGELOG entry.

  • Refactoring
  • Storing
  • Retrieving
  • Storage DB migration

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

Branch builds: add [firefox-android: branch-name] to the PR title.

@@ -51,6 +51,7 @@ impl Storage {
CREATE TABLE IF NOT EXISTS collection_metadata (
collection_url TEXT PRIMARY KEY,
last_modified INTEGER,
metadata BLOB NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather storing each field metadata separately rather than serializing it into a single field. I don't feel very strongly about this one, though, feel free to push back on it.

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 also hesitated there.

The reason behind my choice is that eventually we will potentially look at other metadata fields, like attachment to know whether there's a bundle to pull, or flags to know whether a collection is required to have records during startup.
But, we can perfectly decide to put this aside, and add the additional columns only when we implement these features.

It depends a bit how confident we are in database migration for the future

Copy link
Contributor

Choose a reason for hiding this comment

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

Database migrations should be pretty easy. I was tempted to add one in #6526, but I decided to leave it out. If you want, I can try to write up a PR that adds a trivial migration so you can see how they work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would definitely help yes please 🙏 Maybe a candidate would be the fetched column

Copy link
Contributor

Choose a reason for hiding this comment

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

I got a bit distracted last week, but it's finally up: #6537.

Copy link
Contributor

@bendk bendk left a comment

Choose a reason for hiding this comment

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

Looks like the right direction to me, thanks for working on this one.

components/remote_settings/src/storage.rs Show resolved Hide resolved
@leplatrem leplatrem force-pushed the remote-settings-store-metadata branch 2 times, most recently from cbeee6b to 68c8951 Compare December 18, 2024 16:17
@leplatrem leplatrem marked this pull request as ready for review December 18, 2024 16:18
@leplatrem leplatrem force-pushed the remote-settings-store-metadata branch 3 times, most recently from dca1f28 to f8ead0e Compare December 19, 2024 21:34
@leplatrem leplatrem requested a review from bendk December 19, 2024 21:40
@leplatrem leplatrem force-pushed the remote-settings-store-metadata branch from f8ead0e to 89d95d2 Compare December 19, 2024 21:55
Copy link
Member

@gruberb gruberb left a comment

Choose a reason for hiding this comment

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

Just some comments, looks good!

components/remote_settings/src/client.rs Outdated Show resolved Hide resolved
components/remote_settings/src/storage.rs Show resolved Hide resolved
Copy link
Contributor

@bendk bendk left a comment

Choose a reason for hiding this comment

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

This looks great to me. The one remaining issue is the database migration. I'll try to put up a PR one soon so that you can use it to base your work off.

components/remote_settings/src/storage.rs Outdated Show resolved Hide resolved
Ok(())
}
#[test]
fn test_storage_get_collection_content() -> Result<()> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
fn test_storage_get_collection_content() -> Result<()> {
fn test_storage_get_collection_metadata() -> Result<()> {

@@ -105,6 +111,36 @@ impl Storage {
result
}

/// Get cached content for this collection
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
/// Get cached content for this collection
/// Get cached metadata for this collection

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.

3 participants