Skip to content

Conversation

@danjm
Copy link
Contributor

@danjm danjm commented Feb 1, 2024

Description

Solves this problem:

For people on slow networks, the amount of time it takes from "Dapp button click" -> "Popup notification window appears" might be a problem. When blockaid is toggled off, and the network is throttled to slow via the chrome dev tools, I see a ~3 second worse case for this time, but when blockaid is toggled on, I see a 12 second (or even a bit longer) worst case scenario for this time.

The risk here is that users unexpectedly see a longer delay then usual, and so think they need to click the button again, and then get shown multiple confirmation requests and confirm all of them, leading to fund loss.

This can happen on either slow internet connections, or if an infura request is taking longer than usual (which could effect people regardless of internet connection). Yesterday when I first saw this issue, I wasn't slowing down my connection, but it still took ~20 seconds to open. Probably a somewhat rare case (because as I mentioned I didn't notice any problems again until I intentionally throttled the network requests), but even if it only affected 10% of users only once a month, that would be enough to get plenty of "why did metamask just take 20 seconds to open a confirmation window?!?" complaints.

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • 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".

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.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2024

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.

@danjm danjm force-pushed the ppom-async-poc branch 3 times, most recently from 382c36c to 30df005 Compare February 2, 2024 05:53
@danjm danjm marked this pull request as ready for review February 2, 2024 06:07
@danjm danjm requested a review from a team as a code owner February 2, 2024 06:07
}
}
} catch (error: any) {
sentry?.captureException(error);
Copy link
Contributor

@jpuri jpuri Feb 2, 2024

Choose a reason for hiding this comment

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

Not important in this PR, but later we can refactor out validation from here as middleware is not needed for async validation - validation can now be done in controllers.

providerRequestsCount?: Record<string, number>;
securityAlertId?: string;
};

Copy link
Contributor

Choose a reason for hiding this comment

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

This files does not seems to be present in 11.9 branch.

if (!foundConfirmation) {
await new Promise((resolve) => setTimeout(resolve, 100));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If we move validation from middleware I think we can avoid above logic for search confirmation.

digiwand
digiwand previously approved these changes Feb 5, 2024
Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

🙌🏼

Works as expected and displays the LoadingIndicator while validation is in progress. Left a couple of non-blocking comments


addSignatureSecurityAlertResponse(securityAlertResponse) {
const currentState = this.store.getState();
const { signatureSecurityAlertResponses } = currentState; //
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const { signatureSecurityAlertResponses } = currentState; //
const { signatureSecurityAlertResponses } = currentState;

Comment on lines 94 to 95
reason: 'loading',
result_type: 'validation_in_progress',
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] we could define these as local values in shared/constants/security-provider.ts

'eth_signTypedData_v1',
'eth_signTypedData_v3',
'eth_signTypedData_v4',
'personal_sign',
Copy link
Contributor

Choose a reason for hiding this comment

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

we spoke with the Blockaid team about removing validation for 'personal_sign' types. We can do this here or another PR

Suggested change
'personal_sign',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let's do this in a separate PR

jpuri
jpuri previously approved these changes Feb 6, 2024
Copy link
Contributor

@jpuri jpuri left a comment

Choose a reason for hiding this comment

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

LGTM

@seaona
Copy link
Member

seaona commented Feb 6, 2024

QA findings

1. Error when initiating Send from inside the Wallet

Note: this issue is not happening on develop.

Whenever initiating a send from inside the wallet, I see the error TypeError: Cannot read properties of undefined (reading 'securityAlertId') when I land into the lasy Confirmation screen and the validation stays loading indefinetly

reading-security-alerts.mp4

2. e2e failures: Spinner stays loading indefinitely in failed validation case

Whenever we are in the case where the validation will fail, we now see the spinner loading indefinitely instead of displaying the Validation Failed warning

This is what's happening with the e2e failures: we simulated a failed validation by using this mock

  await mockServer
    .forPost()
    .withJsonBodyIncluding({
      method: 'debug_traceCall',
      params: [{ accessList: [], data: '0x00000000' }],
    })
    .thenCallback(() => {
      return {
        statusCode: 500,
      };
    });
}

and we can see on the screenshot that thet Failed Validation warning never appeared. Instead, the spinner stayed there

validation-failed.mp4

@seaona seaona added the DO-NOT-MERGE Pull requests that should not be merged label Feb 6, 2024
@danjm danjm dismissed stale reviews from jpuri and digiwand via 52ff091 February 6, 2024 13:57
@seaona seaona removed the DO-NOT-MERGE Pull requests that should not be merged label Feb 6, 2024
jpuri
jpuri previously approved these changes Feb 6, 2024
digiwand
digiwand previously approved these changes Feb 6, 2024
jpuri
jpuri previously approved these changes Feb 6, 2024
@danjm danjm merged commit 0364739 into develop Feb 6, 2024
@danjm danjm deleted the ppom-async-poc branch February 6, 2024 16:26
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2024
@metamaskbot metamaskbot added the release-11.11.0 Issue or pull request that will be included in release 11.11.0 label Feb 6, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [a9f4524]
Page Load Metrics (751 ± 29 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint83165109209
domContentLoaded9321763
load6869407516129
domInteractive9321763
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 2.46 KiB (0.07%)
  • ui: 418 Bytes (0.01%)
  • common: 262 Bytes (0.01%)

@metamaskbot metamaskbot added release-11.9.0 Issue or pull request that will be included in release 11.9.0 and removed release-11.11.0 Issue or pull request that will be included in release 11.11.0 labels Feb 6, 2024
@metamaskbot
Copy link
Collaborator

Missing release label release-11.9.0 on PR. Adding release label release-11.9.0 on PR and removing other release labels(release-11.11.0), as PR was cherry-picked in branch 11.9.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-11.9.0 Issue or pull request that will be included in release 11.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants