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

Restrict the size of the permissions metadata store #8596

Merged
merged 13 commits into from
May 26, 2020

Conversation

rekmarks
Copy link
Member

@rekmarks rekmarks commented May 14, 2020

Closes #8569

This PR bounds the size of the permissions metadata store to the number of domains with permissions.

  • Metadata is never deleted for domains with permissions
    • This should be fine in the short to medium term
    • This may be untenable in the long term, but we need to make some fundamental improvements to our JSON RPC implementation before we can address it in version 8.x
  • When rehydrating the store on boot, we delete the metadata of all domains without permissions, if any
  • At runtime, we keep track of newly added metadata origins via the _pendingSiteMetadata set
    • If adding a new origin would ever grow this set beyond 100 in size, we delete the oldest entry in it, and if that oldest origin has no permissions, we also delete its metadata from the store
  • We do not delete metadata when permissions are removed, to prevent a degraded user experience
    • We still delete the metadata of such domains on boot, but not otherwise
    • This will be addressed when we can request permissions on demand in 8.x

Comment on lines +515 to +519
/**
* Removes all known domains and their related permissions.
*/
clearPermissions () {
this.permissions.clearDomains()
this.notifyAllDomains({
method: NOTIFICATION_NAMES.accountsChanged,
result: [],
})
}
Copy link
Member Author

@rekmarks rekmarks May 14, 2020

Choose a reason for hiding this comment

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

This function was moved, because its placement didn't make any sense. It hasn't been changed.

This is the only formatting change in this PR.

@Gudahtt
Copy link
Member

Gudahtt commented May 15, 2020

Do we ever want to trim metadata for sites with permissions? 🤔 I don't see the harm in keeping that. We use it in the UI anyway - we'd have to remove the permission too to avoid weird UI bugs.

@rekmarks rekmarks marked this pull request as ready for review May 15, 2020 18:12
@rekmarks rekmarks requested a review from a team as a code owner May 15, 2020 18:12
@metamaskbot
Copy link
Collaborator

Builds ready [e2e75ea]
Page Load Metrics (626 ± 74 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint3297502110
domContentLoaded33689762415574
load34189862615474
domInteractive33589762415574

@metamaskbot
Copy link
Collaborator

Builds ready [8b4df94]
Page Load Metrics (584 ± 68 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint307638115
domContentLoaded33989658214167
load34189858414168
domInteractive33989558214167

@rekmarks rekmarks changed the title Trim permissions domain metadata Restrict the size of the permissions metadata store May 15, 2020
app/scripts/controllers/permissions/index.js Outdated Show resolved Hide resolved
app/scripts/controllers/permissions/index.js Outdated Show resolved Hide resolved
app/scripts/controllers/permissions/index.js Outdated Show resolved Hide resolved
@rekmarks rekmarks force-pushed the trim-domain-metadata branch 2 times, most recently from d655755 to a8a3865 Compare May 19, 2020 16:18
@rekmarks rekmarks force-pushed the trim-domain-metadata branch from 047feba to bec3dab Compare May 19, 2020 19:47
@metamaskbot
Copy link
Collaborator

Builds ready [bec3dab]
Page Load Metrics (644 ± 31 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint319042157
domContentLoaded4107706426531
load4117716446531
domInteractive4107706426531

@metamaskbot
Copy link
Collaborator

Builds ready [bb8e211]
Page Load Metrics (600 ± 51 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint319138136
domContentLoaded34570259810651
load34670460010651
domInteractive34570259810651

@rekmarks rekmarks requested a review from Gudahtt May 20, 2020 21:30
@metamaskbot
Copy link
Collaborator

Builds ready [e96a18e]
Page Load Metrics (666 ± 34 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint318340115
domContentLoaded3947336657234
load3967346667234
domInteractive3947326647234

Copy link
Contributor

@whymarrh whymarrh left a comment

Choose a reason for hiding this comment

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

  • If there are 100 or more domains in the metadata store, we attempt to remove a domain without permissions before adding a new one
    • This only fails if there is no domain metadata for a domain without permissions

What is supposed to happen in this failure case?

app/scripts/controllers/permissions/index.js Outdated Show resolved Hide resolved
app/scripts/controllers/permissions/index.js Outdated Show resolved Hide resolved
app/scripts/controllers/permissions/index.js Outdated Show resolved Hide resolved
app/scripts/controllers/permissions/index.js Outdated Show resolved Hide resolved
@rekmarks
Copy link
Member Author

@whymarrh all inline comments addressed in d3c7d89.

Regarding your question:

What is supposed to happen in this failure case?

The PR description was outdated; there is no failure case. The bullet point you referred to has been updated to read:

  • At runtime, we keep track of newly added metadata origins via the _pendingSiteMetadata set
    • If adding a new origin would ever grow this set beyond 100 in size, we delete the oldest entry in it, and if that oldest origin has no permissions, we also delete its metadata from the store

@rekmarks
Copy link
Member Author

rekmarks commented May 26, 2020

@Gudahtt I didn't see your review until after responding to @whymarrh, will comment on your requested changes in turn.

@rekmarks rekmarks requested review from whymarrh and Gudahtt May 26, 2020 17:50
@metamaskbot
Copy link
Collaborator

Builds ready [c3b7128]
Page Load Metrics (885 ± 72 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint37133662813
domContentLoaded459116588315072
load460116988515172
domInteractive459116588215072

Gudahtt
Gudahtt previously approved these changes May 26, 2020
Copy link
Member

@Gudahtt Gudahtt 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
Contributor

@whymarrh whymarrh left a comment

Choose a reason for hiding this comment

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

:shipit:

@metamaskbot
Copy link
Collaborator

Builds ready [87d1bf3]
Page Load Metrics (676 ± 52 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint318745178
domContentLoaded36284867410952
load36485067610952
domInteractive36284767410952

@rekmarks rekmarks merged commit e0b31aa into develop May 26, 2020
@rekmarks rekmarks deleted the trim-domain-metadata branch May 26, 2020 21:06
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.

Site metadata has unbounded growth
4 participants