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: Add anonymized signature metrics #27298

Merged
merged 14 commits into from
Sep 23, 2024
Merged

feat: Add anonymized signature metrics #27298

merged 14 commits into from
Sep 23, 2024

Conversation

pnarayanaswamy
Copy link
Contributor

@pnarayanaswamy pnarayanaswamy commented Sep 20, 2024

Description

Adds logic to send Signature Requested Anon, Signature Approved Anon and Signature Rejected Anon events when the signature is of type signTypedData_v4 with additional anonymous properties.
Updates the e2e to check the correct Anon events are sent with the additional properties
Added additional unit tests to increase sonar coverage
Exclude the test folder from sonar checks

Open in GitHub Codespaces

Related issues

Fixes: 3009

Manual testing steps

  1. Go to test dapp

  2. Under the Permit section, click on Sign

  3. This should trigger the Signature Anon events with:

    eip712_verifyingContract == 0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC
    eip712_domain_version == 1
    eip712_domain_name == MyToken
    
  4. Go to test dapp

  5. Under the SignTypedData_v4 section, click on Sign

  6. This should trigger the Signature Anon events with:

    eip712_verifyingContract == 0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC
    eip712_domain_version == 1
    eip712_domain_name == Ether Mail
    

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions bot added the team-confirmations Push issues to confirmations team label Sep 20, 2024
@pnarayanaswamy pnarayanaswamy changed the title Feat sig anon metrics feat: Add anonymized signature metrics Sep 20, 2024
@pnarayanaswamy pnarayanaswamy marked this pull request as ready for review September 20, 2024 06:57
@pnarayanaswamy pnarayanaswamy requested a review from a team as a code owner September 20, 2024 06:57
@metamaskbot
Copy link
Collaborator

Builds ready [801a531]
Page Load Metrics (1754 ± 45 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint36920001687314151
domContentLoaded1595197617269144
load1598198817549445
domInteractive137239189
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 772 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 152 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [b2139e1]
Page Load Metrics (1765 ± 94 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint23623301696387186
domContentLoaded15392187173318689
load15482277176519694
domInteractive228235168
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 772 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 152 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [256f2a4]
Page Load Metrics (1835 ± 172 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint155930031835355170
domContentLoaded152429541808342164
load155630011835357172
domInteractive15110392211
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 772 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 152 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [ace801e]
Page Load Metrics (1733 ± 74 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint23022611664361173
domContentLoaded15332249170915273
load15442258173315474
domInteractive15183443417
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 772 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 152 Bytes (0.00%)

properties: { ...DEFAULT_EVENT_PROPERTIES },
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

[non-blocking] we could DRY these up by looping the tests together

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -222,8 +224,7 @@ export default function createRPCMethodTrackingMiddleware({
) {
const { origin, method, params } = req;

const rateLimitType =
RATE_LIMIT_MAP[method] ?? RATE_LIMIT_TYPES.RANDOM_SAMPLE;
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we remove the RATE_LIMIT_TYPES.RANDOM_SAMPLE fallback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the switch has a default condition that falls back to the RANDOM_SAMPLE anyhow, so this is redundant

Comment on lines +349 to +358
const parsedMessageData = parseTypedDataMessage(data);
sensitiveEventProperties = {};

eventProperties.eip712_primary_type = parsedMessageData.primaryType;
sensitiveEventProperties.eip712_verifyingContract =
parsedMessageData.domain.verifyingContract;
sensitiveEventProperties.eip712_domain_version =
parsedMessageData.domain.version;
sensitiveEventProperties.eip712_domain_name =
parsedMessageData.domain.name;
Copy link
Contributor

Choose a reason for hiding this comment

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

could do something like this. Would need to update primaryType again if this suggestion is accepted

Suggested change
const parsedMessageData = parseTypedDataMessage(data);
sensitiveEventProperties = {};
eventProperties.eip712_primary_type = parsedMessageData.primaryType;
sensitiveEventProperties.eip712_verifyingContract =
parsedMessageData.domain.verifyingContract;
sensitiveEventProperties.eip712_domain_version =
parsedMessageData.domain.version;
sensitiveEventProperties.eip712_domain_name =
parsedMessageData.domain.name;
const { domain, primaryType } = parseTypedDataMessage(data);
sensitiveEventProperties = {
eip712_verifyingContract: domain.verifyingContract,
eip712_domain_version: domain.version,
eip712_domain_name: domain.name,
};
eventProperties.eip712_primary_type = primaryType;

@metamaskbot
Copy link
Collaborator

Builds ready [cdec7d9]
Page Load Metrics (1644 ± 47 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint30718931532404194
domContentLoaded1470180316269043
load1474181716449747
domInteractive12123392512
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 752 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 152 Bytes (0.00%)

Copy link

sonarcloud bot commented Sep 23, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [1a84558]
Page Load Metrics (1703 ± 70 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14252203170514268
domContentLoaded14152079167912359
load14232223170314670
domInteractive157936178
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 752 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 152 Bytes (0.00%)

@digiwand digiwand merged commit f17891a into develop Sep 23, 2024
77 checks passed
@digiwand digiwand deleted the feat-sig-anon-metrics branch September 23, 2024 15:01
@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Sep 23, 2024
@@ -3,7 +3,7 @@ sonar.organization=consensys

# Source
sonar.sources=app,development,offscreen,shared,test,types,ui
sonar.exclusions=**/*.test.**,**/*.spec.**,app/images
sonar.exclusions=**/*.test.**,**/*.spec.**,app/images,test/**
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏼

@metamaskbot metamaskbot added release-12.5.0 Issue or pull request that will be included in release 12.5.0 and removed release-12.6.0 Issue or pull request that will be included in release 12.6.0 labels Sep 29, 2024
@metamaskbot
Copy link
Collaborator

Missing release label release-12.5.0 on PR. Adding release label release-12.5.0 on PR and removing other release labels(release-12.6.0), as PR was added to branch 12.5.0 when release was cut.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.5.0 Issue or pull request that will be included in release 12.5.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants