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

client: fix connection persistence bug #1938

Merged
merged 5 commits into from
Dec 10, 2024
Merged

client: fix connection persistence bug #1938

merged 5 commits into from
Dec 10, 2024

Conversation

TalDerei
Copy link
Contributor

@TalDerei TalDerei commented Dec 10, 2024

references penumbra-zone/dex-explorer#154

this is a subtle wallet connection bug. Initially, I thought the culprit was related to mobx's observer HOC, where the connection state wasn't properly being observed. Upon digging deeper, I narrowed in on the client connection implementation, specifically this no-op comment. If the connection is set, indicating an active connection, the nullish coalescing operator prevents initializing a new connection. Debugging the connection state revealed that this no-op behavior becomes problematic in a specific (yet common) case: the connection is set, but the underlying connection is broken. This could be from either the connection timing out, provider detaching, etc. and the no-op behavior prevents the frontend from re-establishing connection, even when the extension is logged in.

Screenshot 2024-12-09 at 10 04 23 PM

Problematically, the same error is encountered when the user manually denies the connection. If this error isn't explicitly caught and propagated back to the caller, then a a denied connection would immediately trigger an attempt to re-establish the connection. For other types of errors, the connect method was modified to clean up the existing connection resources and attempts to establish a new connection to the attached provider.

We should sanity check the security implications of this remediation given that the last audit caught some connection related vulnerabilities.


Screen.Recording.2024-12-09.at.10.51.50.PM.mov

@TalDerei TalDerei self-assigned this Dec 10, 2024
Copy link

changeset-bot bot commented Dec 10, 2024

🦋 Changeset detected

Latest commit: d558919

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@penumbra-zone/client Minor
minifront Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@TalDerei TalDerei marked this pull request as draft December 10, 2024 06:48
@TalDerei TalDerei marked this pull request as ready for review December 10, 2024 08:26
Comment on lines +205 to +206
// Clean up dangling connection resources and attempt to establish reconnection
this.destroyConnection();
Copy link
Contributor Author

@TalDerei TalDerei Dec 10, 2024

Choose a reason for hiding this comment

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

Is this sufficient for ensuring no dangling connection resources persist?

Copy link
Contributor

@VanishMax VanishMax 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 good to me. Should we create a new issue for the disconnect from wallet persisting the connection after page reload, which you showed on the video?

@TalDerei
Copy link
Contributor Author

TalDerei commented Dec 10, 2024

This looks good to me. Should we create a new issue for the disconnect from wallet persisting the connection after page reload, which you showed on the video?

sure, it's a separate bug on the dex explorer side. If you directly disconnect from the dex explorer, it behaves properly and prompts a wallet reconnection. But if you first lock the wallet, disconnect from the dex explorer, and refresh, the connection persists as you pointed out.

@TalDerei TalDerei merged commit 0cadc3c into main Dec 10, 2024
6 checks passed
@TalDerei TalDerei deleted the connection-status branch December 10, 2024 20:22
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.

2 participants