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

Fix unconfirmed txs being weird #415

Merged
merged 9 commits into from
Oct 7, 2024

Conversation

Duddino
Copy link
Member

@Duddino Duddino commented Oct 3, 2024

Abstract

Unconfirmed txs were incorrectly sorted at the beginning of the array txs, which lead to incorrect behavior.

Testing

  • Import a wallet with uncofirmed txs and assert that it works

Copy link

netlify bot commented Oct 3, 2024

Deploy Preview for cheery-moxie-4f1121 ready!

Name Link
🔨 Latest commit 9c2d843
🔍 Latest deploy log https://app.netlify.com/sites/cheery-moxie-4f1121/deploys/670248033ae0b30008924f3d
😎 Deploy Preview https://deploy-preview-415--cheery-moxie-4f1121.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JSKitty
Copy link
Member

JSKitty commented Oct 4, 2024

Could we move the TX sorting to pre-DB-write rather than at DB read?
If implemented correctly we won't need to sort the TXDB at all, we should have it chronologically correct with unconfirmed Txs placed accordingly before commitment.

A downside being we would need to bump the DB version so we can keep sorting logic for existing clients with chronologically-incorrect TXDB, but imo, it's worth the small perf improvement.

@@ -327,6 +327,9 @@ export class Database {
const store = this.#db
.transaction('txs', 'readonly')
.objectStore('txs');
// Put unconfirmed txs (blockHeight -1) as last
Copy link
Member

Choose a reason for hiding this comment

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

Why are unconfirmed txs stored in the DB in the first place?

@panleone
Copy link
Member

panleone commented Oct 4, 2024

Could we move the TX sorting to pre-DB-write rather than at DB read? If implemented correctly we won't need to sort the TXDB at all, we should have it chronologically correct with unconfirmed Txs placed accordingly before commitment.

A downside being we would need to bump the DB version so we can keep sorting logic for existing clients with chronologically-incorrect TXDB, but imo, it's worth the small perf improvement.

in my opinion for this PR is better just to solve the bug

@panleone panleone added the Bug This is either a bugfix (PR) or a bug (issue). label Oct 4, 2024
Copy link
Member

@JSKitty JSKitty left a comment

Choose a reason for hiding this comment

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

Some 'Pending' transactions (i.e: Shield Pending) act as if they're fully confirmed after restarting MPW directly after a Tx.

I'm assuming it's loading them from the DB as if they're confirmed, leads the balance to show as spendable when it is not, so Txs can fail temporarily.

Is this out of scope? Or should this PR handle such a case? Either way it is not optimal functionality.

@Duddino
Copy link
Member Author

Duddino commented Oct 4, 2024

Some 'Pending' transactions (i.e: Shield Pending) act as if they're fully confirmed after restarting MPW directly after a Tx.

I'm assuming it's loading them from the DB as if they're confirmed, leads the balance to show as spendable when it is not, so Txs can fail temporarily.

Is this out of scope? Or should this PR handle such a case? Either way it is not optimal functionality.

I think that's fixed now

Copy link
Member

@JSKitty JSKitty left a comment

Choose a reason for hiding this comment

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

At this line my wallet is hitting error "cursor is null", I may have accidentally introduced that in #413, should we change this to while (cursor) { ... instead?

Copy link
Member

@JSKitty JSKitty left a comment

Choose a reason for hiding this comment

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

tACK 9c2d843

Spammed various Shield Txs, refreshed the app, Txs were gone until synced via network - functionally sound.

Ideally in the future to prevent that 'disappearance' we integrate true mempool support via our RPC nodes, but that's a separate and larger project.

@Duddino Duddino merged commit dd8b02d into PIVX-Labs:master Oct 7, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is either a bugfix (PR) or a bug (issue).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants