-
Notifications
You must be signed in to change notification settings - Fork 144
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/track txs locally #1726
Feat/track txs locally #1726
Conversation
🦋 Changeset detectedLatest commit: 54c2577 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/blockstack/stacks-wallet-web/3VQrqWSHhanbv1vP6rCnZwegK6wk |
I like the feedback this provides when it moves into pending quickly, but I'm curious how users will respond if they have backed up |
Just realized that makes absolutely no sense bc the explorer won't have any awareness of this ...so we just do nothing in the explorer? |
Yes -- part of the reason that some transactions are pending for so long is due to not having a 100% accurate nonce all the time. This hopefully will help that somewhat. Additionally, this is more about fixing an issue where sometimes transactions don't even show up, let alone show up for 24 hours. So i'd ask which is better: no transaction, or a long pending transaction (which currently happens anyways).
Yeah this is completely local and there would be no way to do this. This is meant for the local state of a users wallet, nothing more.
This is an open question and has its own set of complexities, unrelated to this feature. |
src/store/accounts/nonce.ts
Outdated
if (latestLocallySumbmittedNonce) { | ||
// if we have a locally submitted nonce, and it's higher than the api nonce, use that | ||
if (latestLocallySumbmittedNonce.toNumber() > apiNonce) | ||
return latestLocallySumbmittedNonce.toNumber(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aulneau If this is the last locally submitted nonce, shouldn't this be latestLocallySubmittedNonce + 1 ?
src/store/accounts/nonce.ts
Outdated
// We try to use the api nonce first since it will be the most accurate value | ||
if (typeof apiNonce === 'number') return apiNonce; | ||
if (typeof apiNonce === 'number') { | ||
if (latestLocallySumbmittedNonce) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the api might still return a value but an incorrect value (because the prod api has not picked up the latest tx). So it won't use the local nonce calculation. This won't solve this issue https://github.com/hirosystems/devops/issues/797 but it will solve 'api down' issues and the wallet can correctly build new tx. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should definitely include some logic to remove submitted txs when they appear in a block, otherwise it'll grow indefinitely (with all the caching of contracts going on, we may even hit the 5MB limit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a more thorough look. Works alright. Appreciate it being kept simple for now (no Suspense, leaving TxList compnent as is etc).
Think we should have a separate visual style (grey) with a tool tip maybe explaining what submitted means.
Local txs should probably have its own folder, rather than being in account activity.
I guess we'd need to think through how we swap between nonce calculation logic, purely the presence of local txs?
@@ -27,16 +32,44 @@ function EmptyActivity() { | |||
); | |||
} | |||
|
|||
const LocalTxListItem = ({ txid }: { txid: string }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to its own component.
Yep it was my goal to have it be as minimal as possible, while adding the new feature.
Yeah, thinking about it more, "queued" seems to make more sense to me vs "submitted"
Yeah, see this line https://github.com/blockstack/stacks-wallet-web/pull/1726/files#diff-2ac8b8a230a77c0902125ef70aa464b65f2868d7d0e9a75c63aaf62e45ea018eR40, this will be the last tx, and only if the tx does not exist in the mempool response. the logic is simple, if the last local tx nonce is greater than the api nonce, use the local tx nonce. Might need some work or adjustment. |
Looking good to me from a UX perspective, though perhaps it'd be more consistent to show it under "Today" but instead of "Pending" label it "Submitted" with a different color, perhaps a (mid-tone) grey as @kyranjamie suggests? |
Okay, to summarize my changes per comments given:
To test this yourself, it's best to use the throttle functionality in the chrome network dev tools panel See the video: Kapture.2021-09-22.at.08.32.08.mp4 |
@aulneau Looking good in first round of testing.Will test around few other tokens and between the networks |
Test passed.Moving the ticket to QA Done |
4c74900
to
54c2577
Compare
With the issues being reported via discord and all the extensive feedback in #1723, I wanted to create a proof of concept of how we could better track local transactions from this #1712 topic.
I've tested this and I feel as though it's a good combination between relying on what currently exists, with adding the minimal to be able to leverage locally persisted transactions.
Here is a video to show how it works. Very open to better suggestions around how to display them, what to label them (if we need any).
Kapture.2021-09-19.at.16.42.26.mp4
cc/ @aulneau @kyranjamie @fbwoolf