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

Negative balance due to unprocessable transaction (already processed nonce) #3921

Closed
314159265359879 opened this issue Jun 23, 2023 · 7 comments · Fixed by #4022
Closed

Negative balance due to unprocessable transaction (already processed nonce) #3921

314159265359879 opened this issue Jun 23, 2023 · 7 comments · Fixed by #4022
Assignees
Labels
area:nonce bug Functionality broken bug-p2 Critical functionality broken for few users, with no clear workarounds effort:medium Expected to take 2-5 days of integration work

Comments

@314159265359879
Copy link
Contributor

RBF'ed transactions create a clone with the same nonce and a higher fee. The clone can remain pending in the wallet/API because we do not have a special state for it as suggested here: hirosystems/explorer#1038

image

image

This is different from negative balance due to incoming transactions and the fees which is described here: #3761

@314159265359879 314159265359879 added bug Functionality broken bug-p2 Critical functionality broken for few users, with no clear workarounds labels Jun 23, 2023
@github-project-automation github-project-automation bot moved this to Enhancements backlog in Hiro Wallet (DEPRECATED) Jun 23, 2023
@314159265359879
Copy link
Contributor Author

The workaround is: wait for the pending transaction to get dropped after 256 blocks (approx. 2 days) or use another wallet.

I am not sure if this problem always pops up or only when the new transaction isn't propagated through the network before the old one gets picked up by a miner or the other way around (the new one gets picked up without being propagated over the Stacks network to replace (RBF) all other instances with lower fee).

@markmhendrickson markmhendrickson moved this from Enhancements backlog to Triage in Hiro Wallet (DEPRECATED) Jun 26, 2023
@markmhendrickson markmhendrickson moved this from Triage to Assigned in Hiro Wallet (DEPRECATED) Jun 27, 2023
@alter-eggo alter-eggo added the effort:medium Expected to take 2-5 days of integration work label Jul 7, 2023
@alter-eggo alter-eggo moved this from Assigned to WIP in Hiro Wallet (DEPRECATED) Jul 7, 2023
@alter-eggo alter-eggo moved this from WIP to Assigned in Hiro Wallet (DEPRECATED) Jul 10, 2023
@alter-eggo alter-eggo moved this from Assigned to WIP in Hiro Wallet (DEPRECATED) Jul 13, 2023
alter-eggo added a commit that referenced this issue Jul 13, 2023
@alter-eggo alter-eggo moved this from WIP to Review in Hiro Wallet (DEPRECATED) Jul 13, 2023
@alter-eggo
Copy link
Contributor

alter-eggo commented Jul 14, 2023

hm, yeah, I managed to reproduce this problem and my pr actually doesn't solve this. wonder what can we do here 🤔
maybe don't subtract pending txs if current date - receipt_time < 'x' time? x === 1 hour maybe? 2 hours?
example of pending tx:

{
    "tx_id": "0x32611cde7277065fdb315114d023642cf95f0b2862d5707f611b2c9a2b84721f",
    "nonce": 1,
    "fee_rate": "544175",
    "sender_address": "ST3WSKSKGNFCDGJN9EXF6AC9NFF69XNNFXN2DQA7E",
    "sponsored": false,
    "post_condition_mode": "deny",
    "post_conditions": [],
    "anchor_mode": "any",
    "tx_status": "pending",
    "receipt_time": 1689261001,
    "receipt_time_iso": "2023-07-13T15:10:01.000Z",
    "tx_type": "token_transfer",
    "token_transfer": {
        "recipient_address": "ST5BQXGQJR6FQEEZMXT9TF20THFZ5ZE9NMQDAZZT",
        "amount": "2000000",
        "memo": "0x00000000000000000000000000000000000000000000000000000000000000000000"
    }
}

@alter-eggo
Copy link
Contributor

wdyt @314159265359879 @markmhx

@314159265359879
Copy link
Contributor Author

Interesting idea I think it will work in most cases but could set us up for disaster in times of congestion. Using the time it has been pending, anything more than two hours is good indication of an unprocessable/troublesome transaction, if there is no congestion on the network. It could be problematic if there is congestion though... it would lead to more unprocessable/double spend transaction as it gives "false positives" in such a case.

I think the following would be safer:
Is it possible to ignore transaction based on last executed transaction nonce for the address if the pending transaction nonce is equal or lower because then we can be certain it will not get mined.

@alter-eggo alter-eggo moved this from Review to WIP in Hiro Wallet (DEPRECATED) Jul 14, 2023
@alter-eggo
Copy link
Contributor

this will lead to that we will fetch all txs and all pending txs for all accounts in case user, e.g. opens select acc modal. I feel like we need some cheaper solution, or it's ok? @kyranjamie @markmhx

@314159265359879
Copy link
Contributor Author

Ow I see, I didn't realize that.
Isn't "last executed tx nonce" something you can fetch without fetching all (confirmed) transactions?
(for example what if you derive, last executed tx nonce from this API [get account info](https://stacks-node-api.mainnet.stacks.co/v2/accounts/SP497E7RX3233ATBS2AB9G4WTHB63X5PBSP5VGAQ) it would be nonce minus 1)

Then you just need all the pending transactions (an account can have 25 max I believe, and an account having that many pending is quite rare).

Probably best if @kyranjamie comments on this.

@kyranjamie
Copy link
Collaborator

kyranjamie commented Jul 17, 2023

Spoke with @alter-eggo about this. Suggestion was to not subtract pending txs if nonce value exists in array of mined transactions

@alter-eggo alter-eggo moved this from WIP to Ready to release in Hiro Wallet (DEPRECATED) Jul 18, 2023
blockstack-devops pushed a commit that referenced this issue Jul 18, 2023
## [4.36.0](v4.35.0...v4.36.0) (2023-07-18)

### Features

* change arrow icon in send flow ([2b4a2a9](2b4a2a9))
* change caret color in seed phrase input ([8fc248c](8fc248c))

### Bug Fixes

* add module type ([227ea75](227ea75))
* choose acc total balance, closes [#3989](#3989) ([6e4bedf](6e4bedf))
* disable sentry in service worker ([d5e8f26](d5e8f26))
* entire activity item is clickable ([167429b](167429b))
* exceed amount in rbf, closes [#3921](#3921) ([0d8e72f](0d8e72f))
* form restore ([c48fc22](c48fc22))
* go to RequestDiagnostics after fresh installation to avoid flash redirect, fixes [#2330](#2330) ([bef7e08](bef7e08))
* port disconnecting ([da3a2f5](da3a2f5))
* prevent secret key showing before blurred ([6929ada](6929ada))
* refactor JSX namespace to React.JSX ([4a07bcb](4a07bcb))
* retore form state, chromium ([be3204d](be3204d))
* secret key input, closes [#3954](#3954) ([5f000ba](5f000ba))
* stacks nfts loading key not unique, closes [#3789](#3789) ([dad5d6e](dad5d6e))
* upgrade packages ([74f6d25](74f6d25))
* use routes over state for home tabs, closes [#3518](#3518) ([cb2f317](cb2f317))
* use windows friendly syntax so that yarn dev will launch on windows machines ([56b6778](56b6778))

### Internal

* keychain ([c5d4761](c5d4761))
* migrate to manifest version 3 ([03dbb1e](03dbb1e))
* mv3 fix ([0f54a1f](0f54a1f))
* restore gaia functionality ([bf136dc](bf136dc))
* sending max fees, closes [#3871](#3871) ([90c1c31](90c1c31))
* stacks keychain logic ([846132b](846132b))
* upgrade packages ([d3978f0](d3978f0))
* upgrade packages, p1 ([cb7da02](cb7da02))
* upgrade packages, p2 ([51b7da0](51b7da0))
kyranjamie pushed a commit that referenced this issue Jul 18, 2023
## [4.36.0](v4.35.0...v4.36.0) (2023-07-18)

### Features

* change arrow icon in send flow ([2b4a2a9](2b4a2a9))
* change caret color in seed phrase input ([8fc248c](8fc248c))

### Bug Fixes

* add module type ([227ea75](227ea75))
* choose acc total balance, closes [#3989](#3989) ([6e4bedf](6e4bedf))
* disable sentry in service worker ([d5e8f26](d5e8f26))
* entire activity item is clickable ([167429b](167429b))
* exceed amount in rbf, closes [#3921](#3921) ([0d8e72f](0d8e72f))
* form restore ([c48fc22](c48fc22))
* go to RequestDiagnostics after fresh installation to avoid flash redirect, fixes [#2330](#2330) ([bef7e08](bef7e08))
* port disconnecting ([da3a2f5](da3a2f5))
* prevent secret key showing before blurred ([6929ada](6929ada))
* refactor JSX namespace to React.JSX ([4a07bcb](4a07bcb))
* retore form state, chromium ([be3204d](be3204d))
* secret key input, closes [#3954](#3954) ([5f000ba](5f000ba))
* stacks nfts loading key not unique, closes [#3789](#3789) ([dad5d6e](dad5d6e))
* upgrade packages ([74f6d25](74f6d25))
* use routes over state for home tabs, closes [#3518](#3518) ([cb2f317](cb2f317))
* use windows friendly syntax so that yarn dev will launch on windows machines ([56b6778](56b6778))

### Internal

* keychain ([c5d4761](c5d4761))
* migrate to manifest version 3 ([03dbb1e](03dbb1e))
* mv3 fix ([0f54a1f](0f54a1f))
* restore gaia functionality ([bf136dc](bf136dc))
* sending max fees, closes [#3871](#3871) ([90c1c31](90c1c31))
* stacks keychain logic ([846132b](846132b))
* upgrade packages ([d3978f0](d3978f0))
* upgrade packages, p1 ([cb7da02](cb7da02))
* upgrade packages, p2 ([51b7da0](51b7da0))
blockstack-devops pushed a commit that referenced this issue Jul 25, 2023
## [6.0.0](v5.0.0...v6.0.0) (2023-07-25)

### ⚠ BREAKING CHANGES

* this change is sufficient enough to warrant a major
bump

### Features

* added bitcoin contract request page ([83cf049](83cf049))
* added use-bitcoin-contract hook and additional functions and configs ([626ef0b](626ef0b))
* extended rpcmethods with bitcoin contract related case, added routes and success/failure pages ([f0ff7af](f0ff7af))
* manifest v3 release trigger ([80615ca](80615ca))

### Bug Fixes

* added back dlc-wasm-wallet package ([ba27aaf](ba27aaf))
* added working package.json ([e8067d0](e8067d0))
* cross install tracking ([3bc59ac](3bc59ac))
* fixed frozen lockfile ([536aeec](536aeec))
* made requested css and const changes ([8846e0e](8846e0e))
* modified bitcoin contract request ui (width, size, weight) ([36d7c80](36d7c80))
* modified yarn lock file ([52b1d14](52b1d14))
* multi extension loading ([03465c0](03465c0))
* only show errors when field not in focus, closes [#3766](#3766) ([abffd71](abffd71))
* ran prettier formatting ([16ca959](16ca959))
* ran prettier formatting ([515b1e5](515b1e5))
* remove warning banner ([b3427bf](b3427bf))
* type errors ([a2598a9](a2598a9))
* unprocessable pending txs balance subtraction, closes [#3921](#3921) ([2d284db](2d284db))

### Internal

* **release:** 4.36.0 ([8184b75](8184b75)), closes [#3989](#3989) [#3921](#3921) [#2330](#2330) [#3954](#3954) [#3789](#3789) [#3518](#3518) [#3871](#3871)
* **release:** 5.0.0 ([0e73a1e](0e73a1e))
@fbwoolf fbwoolf moved this from Ready to release to Released in Hiro Wallet (DEPRECATED) Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:nonce bug Functionality broken bug-p2 Critical functionality broken for few users, with no clear workarounds effort:medium Expected to take 2-5 days of integration work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants