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

Failure after quitting a stake pool from API #2009

Closed
disassembler opened this issue Aug 7, 2020 · 4 comments
Closed

Failure after quitting a stake pool from API #2009

disassembler opened this issue Aug 7, 2020 · 4 comments
Assignees

Comments

@disassembler
Copy link
Contributor

disassembler commented Aug 7, 2020

Context

I quit a stake pool with intention of getting my deposit back and now my wallet throws this error in the logs:

[cardano-wallet.wallet-engine:Error:43] [2020-08-07 07:32:45.73 UTC] 237779f4: Unexpected error following the chain: arithmetic underflow
Information -
Version
Platform
Installation

Steps to Reproduce

  1. ...

Expected behavior

Actual behavior


Resolution


QA

@Fell-x27
Copy link

Fell-x27 commented Aug 7, 2020

Got the same error today,:

[cardano-wallet.wallet-engine:Error:1114] [2020-08-07 18:20:38.15 UTC] 4ec9262c: Unexpected error following the chain: arithmetic underflow

The wallet can't sync and spamming node with:

[developM:cardano.node.LocalErrorPolicy:Error:62] [2020-08-07 18:20:41.11 UTC] [String "ErrorPolicyUnhandledApplicationException (MuxError MuxBearerClosed \"<socket: 82> closed when reading data, waiting on next header True\")",String "ErrorPolicyTrace",String "LocalAddress {getFilePath = \"\"}"]

So node even gets desync and can't work normally.

Trying understand why this wallet (4ec9262c) is causing it.

Just one of ~100 wallets. Others work fine.

@Fell-x27
Copy link

Fell-x27 commented Aug 7, 2020

Trying understand why this wallet (4ec9262c) is causing it.

Fortunately I discovered that it's a person I know :)
The wallet's owner is an enthusiast, who tried to undelegate his stake today :)

The full log section:

[cardano-wallet.wallet-engine:Error:32] [2020-08-07 19:38:16.50 UTC] 4ec9262c: Unexpected error following the chain: arithmetic underflow [cardano-wallet.network:Notice:32] [2020-08-07 19:38:16.50 UTC] Destroying cursor connection at ThreadId 443187 [cardano-wallet.network:Info:443198] [2020-08-07 19:38:16.50 UTC] conn::/home/fell-x27/git/cardano.socket Send MsgProposeVersions (fromList [(NodeToClientV_3,TInt 764824073)]) [cardano-wallet.network:Info:32] [2020-08-07 19:38:16.50 UTC] Looking for an intersection with the node's local chain with: 5f20df93<-[89d9b5a5-0#0], 59e67269<-[f0f37dc8-5189640#4525300], 9a994ebb<-[0dbdd996-5191640#4525400], a23f9f36<-[2279d25d-5193640#4525500], 836ba4cd<-[7875274b-5195640#4525600], 957d2694<-[f5059a2c-5197640#4525700], 4793c79a<-[45212633-5199640#4525800], 90fe6b97<-[a90f4275-5201640#4525900], cc622411<-[b8883845-5203640#4526000], cb96e67c<-[1169d62a-5205640#4526100], ba48b8a7<-[8f4ae904-5207640#4526200], 5e6618ac<-[951d7571-5209640#4526300], 3f502034<-[c78ad8fd-5211640#4526400], ed03f0ec<-[5e95bc1d-5213640#4526500], 228ed36a<-[d2dcd254-5215640#4526600], ad8731e0<-[23bb6109-5217640#4526700], 339bafe5<-[f515b7b7-5219640#4526800], 53a9307f<-[4fc27b21-5221820#4526900], 821c6d47<-[0a136cf6-5224000#4527000], 53b7edcf<-[9d2baad5-5226060#4527100], dcd4e071<-[2f2dfce6-5228060#4527200], 97edfa4c<-[a08275d4-5230060#4527300], 0589b52e<-[289a6937-5232060#4527400], af75bdd9<-[641672f5-5233960#4527495], 641672f5<-[ac757a39-5233980#4527496], ac757a39<-[20e9f14c-5234000#4527497], 20e9f14c<-[6a7fd41c-5234020#4527498], 6a7fd41c<-[cd73c1b9-5234040#4527499], cd73c1b9<-[204ecfdb-5234060#4527500], 204ecfdb<-[181233ad-5234080#4527501], 181233ad<-[0c90398e-5234100#4527502], 0c90398e<-[d416ec39-5234120#4527503], d416ec39<-[91eb913b-5234140#4527504], 91eb913b<-[b301dc32-5234160#4527505] [cardano-wallet.network:Info:443198] [2020-08-07 19:38:16.50 UTC] conn::/home/fell-x27/git/cardano.socket Recv MsgAcceptVersion NodeToClientV_3 (TInt 764824073) [cardano-wallet.network:Info:32] [2020-08-07 19:38:16.50 UTC] Intersection found: b301dc32 [cardano-wallet.wallet-engine:Info:32] [2020-08-07 19:38:16.50 UTC] 4ec9262c: Applying blocks [5234180 ... 5234180]

@KtorZ
Copy link
Member

KtorZ commented Aug 8, 2020

@Fell-x27 see #2010, if you feel like building from sources. Samuel confirmed it worked indeed. The issue lied in the calculation of the amount for the transaction Metadata, or more exactly, how we interpret the amount.

In the past, the transaction would always be "balanced" and there was an easy equation between inputs, outputs and fees with the nice property that outputs were necessarily smaller than inputs (and even strictly smaller for non null fees). Shelley introduces its set of implicit things, like the key deposit reclaim, which adds an implicit input to the transaction. So in some cases, it may happen that there's more on the output side than the inputs actually spent by the transaction. So it's literally creating money :)

So the wallet need to account for this extra dimension and, consider such transactions correctly.

@Fell-x27
Copy link

Fell-x27 commented Aug 8, 2020

Yep, I've found, built and tested it about 3hrs ago and can confirm it works. Thanks! My service is online again!
Hope that #2006 will be fixed soon for full happiness :)

@KtorZ KtorZ added this to Backlog in Adrestia via automation Aug 10, 2020
@KtorZ KtorZ moved this from Backlog to In Progress in Adrestia Aug 10, 2020
@KtorZ KtorZ moved this from In Progress to QA in Adrestia Aug 10, 2020
iohk-bors bot added a commit that referenced this issue Aug 10, 2020
2010: Yet another fix for reported withdrawals in transactions + underflow in case of key deposit reclaim r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#2009 + TODO


# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- 5757a55
  📍 **highlight reported failure in integration scenarios by adding more assertions**
  
- d5b4335
  📍 **report our withdrawals differently from external withdrawals.**
    We haven't been quite careful here when introducing the reward redemption and the transaction amount are looking weird again.
  This commit fixes several issues:

  1. It only counts withdrawals on the "spent" side of the balance if they are coming from OUR reward account. Indeed, in the case of external withdrawals, the money is coming from elsewhere and not from the wallet itself.

  2. Fix an underflow in the amount calculation in the case where we spent less than we receive. This can be the case when:
    a. We are redeeming from an external account and the reward brings more than the fee. From the redeeming wallet, it'll look like the wallet is receiving money.
    b. We are reclaiming a key deposit back, and it brings more money than what's actually spent.

  3. Discover transactions that are spending our withdrawals without belonging to our wallet. This happens when the reward is redeemed from another wallet. That transaction should still show up in the redeemed wallet, without which rewards would just "vanish" without any trace reported by the wallet.

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
@KtorZ KtorZ closed this as completed Aug 12, 2020
Adrestia automation moved this from QA to Closed Aug 12, 2020
@CharlesMorgan-IOHK CharlesMorgan-IOHK removed this from Closed in Adrestia Jun 21, 2023
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

No branches or pull requests

3 participants