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 metrics for provider calls coming from ppom on mobile #7419

Merged
merged 2 commits into from
Oct 20, 2023

Conversation

segun
Copy link
Contributor

@segun segun commented Oct 9, 2023

Description

We need to add metrics to help measure and estimate the usage and cost of Infura by ppom.

This fix uses the providerRequestsCount object returned as part of the securityAlertResponse of transaction object and gets only the keys that matches the below specified requests.

Proposal

Add new properties to Transactions and Signature events where which property will count the number of rpc requests made by ppom to evaluate that specific transaction or signature.

  • ppom_eth_call_count - counts the number of eth_call rpc requests made by ppom to evaluate that transaction or signature
  • ppom_eth_createAccessList_count - counts the number of eth_call rpc requests made by ppom to evaluate that transaction or signature
  • ppom_eth_getStorageAt_count - counts the number of eth_call rpc requests made by ppom to evaluate that transaction or signature
  • ppom_eth_getCode_count - counts the number of eth_call rpc requests made by ppom to evaluate that transaction or signature
  • ppom_eth_getTrasanctionCount_count - counts the number of eth_call rpc requests made by ppom to evaluate that transaction or signature
  • ppom_eth_getBalance_count - counts the number of eth_call rpc requests made by ppom to evaluate that transaction or signature
  • ppom_trace_call_count - counts the number of eth_call rpc requests made by ppom to evaluate that transaction or signature

References

Related issues

_Fixes #1357

Testing

  1. Start extension with blockaid enabled
  2. Go to test-dapp and initiate a blockaid transaction
  3. When blockaid banner is shown, check that the above keys (or some of it at least) are part of the metrics transaction or signature events

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained:
    • What problem this PR is solving.
    • How this problem was solved.
    • How reviewers can test my changes.
  • I’ve indicated what issue this PR is linked to: Fixes #???
  • I’ve included tests if applicable.
  • I’ve documented any added code.
  • I’ve applied the right labels on the PR (see labeling guidelines).
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/855ec13d-b519-46d5-b3d6-f0067fe9fd57

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.

@segun segun added needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) team-confirmations-secure-ux DEPRECATED: please use "team-confirmations" label instead team-confirmations-secure-ux-PR PR from the confirmations team labels Oct 9, 2023
@segun segun requested a review from a team as a code owner October 9, 2023 10:05
@segun segun self-assigned this Oct 9, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

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.

@segun segun changed the title Add metrics for provider calls coming from ppom on extension feat: Add metrics for provider calls coming from ppom on extension Oct 9, 2023
@segun segun changed the title feat: Add metrics for provider calls coming from ppom on extension feat: Add metrics for provider calls coming from ppom on mobile Oct 9, 2023
@codecov-commenter
Copy link

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (24b4b7e) 34.61% compared to head (b1fd5be) 34.64%.
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7419      +/-   ##
==========================================
+ Coverage   34.61%   34.64%   +0.02%     
==========================================
  Files        1017     1017              
  Lines       27162    27168       +6     
  Branches     2211     2212       +1     
==========================================
+ Hits         9402     9411       +9     
+ Misses      17273    17267       -6     
- Partials      487      490       +3     
Files Coverage Δ
app/core/Analytics/MetaMetrics.events.ts 100.00% <ø> (ø)
app/util/blockaid/index.ts 77.77% <83.33%> (+44.44%) ⬆️
...ents/Views/Settings/ExperimentalSettings/index.tsx 79.16% <0.00%> (-7.20%) ⬇️
app/core/Analytics/Analytics.js 5.19% <0.00%> (-0.07%) ⬇️

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@segun segun force-pushed the olu/blockaid-metrics-rpc-calls branch from b1fd5be to 85aa789 Compare October 11, 2023 13:50
@bschorchit bschorchit removed the team-confirmations-secure-ux DEPRECATED: please use "team-confirmations" label instead label Oct 11, 2023
@segun segun force-pushed the olu/blockaid-metrics-rpc-calls branch from 85aa789 to 346d8d8 Compare October 12, 2023 10:58
Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com>

lint fixes

Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com>

use preferences controller

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

Remove array props

Use CSV instead of list

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

use the list without spreading.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

use strings to store security providers key

lint fix.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

Add metrics for blockaid provider calls count.

track all methods
tests for blockaid utils

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
@segun segun force-pushed the olu/blockaid-metrics-rpc-calls branch from 346d8d8 to ef3efb7 Compare October 13, 2023 09:33
@sonarcloud
Copy link

sonarcloud bot commented Oct 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@jpuri
Copy link
Contributor

jpuri commented Oct 19, 2023

I think we would need to test this in mobile after PR: https://github.com/MetaMask/metamask-mobile/pulls/jpuri is merged.

@segun segun merged commit 865efd8 into main Oct 20, 2023
25 checks passed
@segun segun deleted the olu/blockaid-metrics-rpc-calls branch October 20, 2023 12:38
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Oct 20, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 2023
@metamaskbot metamaskbot added the release-7.11.0 Issue or pull request that will be included in release 7.11.0 label Oct 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-metrics release-7.11.0 Issue or pull request that will be included in release 7.11.0 team-confirmations-secure-ux-PR PR from the confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants