View Issue Details

IDProjectCategoryView StatusLast Update
0006124Talerexchangepublic2020-03-31 16:04
ReporterFlorian DoldAssigned ToChristian Grothoff 
PrioritynormalSeveritymajorReproducibilityhave not tried
Status closedResolutionno change required 
Product Version0.6 
Target Version0.6Fixed in Version0.6 
Summary0006124: exchange computes reserve balance incorrectly in presence of refunds
DescriptionSee the wallet error message below. The "errorResponse" is the verbatim response from the exchange.

The reserve's "balance" is reported as "INTKUDOS:0.96", but the *last* history event on the reserve is a "INTKUDOS:5" recoup.
Additional InformationOperation failed: {
  "type": "protocol",
  "message": "received error response (status 409)",
  "details": {
    "httpStatusCode": 409,
    "errorResponse": {
      "hint": "insufficient funds",
      "code": 1100,
      "balance": "INTKUDOS:0.96",
      "history": [
        {
          "type": "DEPOSIT",
          "timestamp": {
            "t_ms": 1584019684000
          },
          "sender_account_url": "payto://x-taler-bank/bank.int.taler.net/x",
          "wire_reference": "0000000000004",
          "amount": "INTKUDOS:10"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "22DH1BHP9JA0DFQEWABYPR11K706BXZXG4FDYMQBQRY0G9210Z5JP6D8ERQ9C6DD1BR2EVB50QN9Y44D43CDPGSCVWBWFN158KSN820",
          "h_coin_envelope": "4F33GKMV5NPJABQR763D6V8G51KBWYZF4WFRMW58MKCQT4N47GKKWKCBBGC7ZK3E8Y2EQH6ZG7231CTY8PSVVQJ28KHA2JP2M944TYG",
          "h_denom_pub": "9XM3ZFQYY7RGAH66EZBBYEH1ZMT7SZ0FDRATBTVHSHZEJCPXGHYHBPTZCCNFNS3T5DKZKN18C8XTMJ49NSB2GTX46CV9PFWYRF1G1CR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:2.01"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "6SQKTB97XH255DQKCZM4F76WWKEAP1RPWYRFAGD95J8SAW4X5Q8ZZBK01FFD5E92771K3SEG1X800EB2X8CPJ84KH83D69P2RN01W1G",
          "h_coin_envelope": "S0JD1BBMVEFCBX71R6FPRB5TC5Y7F18KY44ZHFB5Z67J809R65SZ0JDHZYJ2D560YGVQ5KGAMVQ351Z1ZRKBM1K5J97J0AG3R2F3WCR",
          "h_denom_pub": "8XN0W75BPGHFTASG43A0PJWRNSJDDMJ54VEBAW8DPQHYKVEC1NNY8A1TMBNADGHS14BP9VTBYPN9B855BCHXQTYTXEJ1G0Z6YMPT5AR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:0.11"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "91956T5RHNHXXE9PRN613ZBNY0F0V6PVQWW93BAGQD952G7X5EW61SDCTA5FCX1341X6N47D29V3QPC5FCAXER2KZJGBRWN4GBM7T18",
          "h_coin_envelope": "305R2Q1TWX5XXHYM45MP2BK0QNXQ2713YT274Q8X60Y8HMPT2QA7QN1H5Z804N76FNXXEG9B0KD0DSWBKZVRFNAZVGS1M4XEVSQQMZ0",
          "h_denom_pub": "9XM3ZFQYY7RGAH66EZBBYEH1ZMT7SZ0FDRATBTVHSHZEJCPXGHYHBPTZCCNFNS3T5DKZKN18C8XTMJ49NSB2GTX46CV9PFWYRF1G1CR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:2.01"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "HDMQT2F6K4JXBHBB2517A1P60XXAFYCV6J6ZQ7PKDJ25JKQS94ZQP0S803JCCSC49B9KGS5TPXW45A4930YHETX83J8ZETT6M6F380R",
          "h_coin_envelope": "BZZ2FDSYSY5W18JSEGK2S2QQ14MC1M2TG647GMB0CTTF2K0RVRARF50JN1NBV4XHZJJF7B7J145H3RZWGZQJF41YFPRMA29GRY1MVN8",
          "h_denom_pub": "8XN0W75BPGHFTASG43A0PJWRNSJDDMJ54VEBAW8DPQHYKVEC1NNY8A1TMBNADGHS14BP9VTBYPN9B855BCHXQTYTXEJ1G0Z6YMPT5AR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:0.11"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "MYM2EZ76HYC872FZJ6D46MC4JKJ2GPWANKAY7ZPB6NRJYNFG90PQFFRWG806Q6R99TJANJ6ATSCRA6H1WNQ4GHC2MTJAPT1GMX82230",
          "h_coin_envelope": "279F68ZKY2WC575AB0TFKZ121Y0D7YXGEZM78Y527VWPBAMAZQMTABYR27NVF70KQ856H22BHVMVZVZCPBHCVF27YW9FKRX6RH1ZXP0",
          "h_denom_pub": "8XN0W75BPGHFTASG43A0PJWRNSJDDMJ54VEBAW8DPQHYKVEC1NNY8A1TMBNADGHS14BP9VTBYPN9B855BCHXQTYTXEJ1G0Z6YMPT5AR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:0.11"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "2DK9T4DSMF7AD5HPTRE50RTSQNCKJQB2VP9DX8HXFPCJTQYP48KJRKA8TXD88TY3SKZ65B2DVBGQJKC9DM6PFS8C1JSF8XCWGKDN628",
          "h_coin_envelope": "GQ3072E5ZD89C0ZD8RTC2YAZF34R33YZTWS3Q6M41XDWD7SSJVCE7KQFYFBABB80KAWYXWT5V8N29TNRKP1JC710ZTFAYB23TVQQFV0",
          "h_denom_pub": "8XN0W75BPGHFTASG43A0PJWRNSJDDMJ54VEBAW8DPQHYKVEC1NNY8A1TMBNADGHS14BP9VTBYPN9B855BCHXQTYTXEJ1G0Z6YMPT5AR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:0.11"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "K0M6WWYFTKMC8D8AY2BAF938W172G26N45GQYEFY72VMBYX6K7K3CMBV5KDM9XACBV1YB2FVZPPN7VDHKSAZF0VVHG2REFD5CQDB43R",
          "h_coin_envelope": "SBJSRNG7VYMRRA8WBAV0WNA0JDTMD21T38T9YR867DN0W4HHKP7Y88G0FYZY1RNHNNW5FWTKBBRK2RPYCWWT1P051R6EZAG5BJJVB48",
          "h_denom_pub": "8XN0W75BPGHFTASG43A0PJWRNSJDDMJ54VEBAW8DPQHYKVEC1NNY8A1TMBNADGHS14BP9VTBYPN9B855BCHXQTYTXEJ1G0Z6YMPT5AR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:0.11"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "0GZ9J45VPYG6W8VRSGFTJZD1WFANAT68RCZ7J02TH3CSWRZQPSMPPJ4M5HXTR04TMSTVH0RAH03JEN5HQQ6GXSEMRZDNBB74617EM10",
          "h_coin_envelope": "W7G01VD14DXZRK36D9CK7JFFZC8EKMHAP0MHRMC63YRNRFFQEBE63HK2NACNAT87T8396QVZHVXF7SCBSAKY9P6GCZHBMCVNVJ94ZZG",
          "h_denom_pub": "8XN0W75BPGHFTASG43A0PJWRNSJDDMJ54VEBAW8DPQHYKVEC1NNY8A1TMBNADGHS14BP9VTBYPN9B855BCHXQTYTXEJ1G0Z6YMPT5AR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:0.11"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "P2B3H9K59Z80H4WSFSSBRM44VFGDPMDAQWMJKD79MSBXV1BJN84HA8Q25B80VZ9ZXV9J044MGA2C16DCKX75D1NRV7K06TWNZXP083G",
          "h_coin_envelope": "TVZ9HHSKHK1T3SPA33CVC7EDGCT1NWPBZK65WHZJP1A1AAKASX6MW1CQVV4AQA6SCV838D69WN499YA4MRZNA44P5BSBH2Q53E3KBBG",
          "h_denom_pub": "8XN0W75BPGHFTASG43A0PJWRNSJDDMJ54VEBAW8DPQHYKVEC1NNY8A1TMBNADGHS14BP9VTBYPN9B855BCHXQTYTXEJ1G0Z6YMPT5AR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:0.11"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "TN0Z5CB4CHRC48BZ5QD4MYCFG7A3Q7398BH71FGFKK9N8P3QVTE9E6QJ1GJJDMH42T91DSF095B6WPNVG1E31NYHVRY1DDTVVY90Y2G",
          "h_coin_envelope": "X63F5HSKJ61RCE7KM55D1KXG3SR1CEZ0K34E30K7501M7F7TJXZ41WJG7WAGYGHA4FQS8CF3G4XKSDFQTFFGSR9CYE5N1HWZPS9P5H0",
          "h_denom_pub": "8XN0W75BPGHFTASG43A0PJWRNSJDDMJ54VEBAW8DPQHYKVEC1NNY8A1TMBNADGHS14BP9VTBYPN9B855BCHXQTYTXEJ1G0Z6YMPT5AR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:0.11"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "W89KHG0T50S9PT9YB7FMDF87HNSS8F187TD4EBNHVGPQT2T2Q46KQ3Z2GBG75035Q1WD2MZYMWH11RX4A91Z9XM953CX15RT9FJPG10",
          "h_coin_envelope": "T4NHGE7MHK78GQ219XW0FEGFJM7K871QQ8H4EN0P1YHFGQH0XAKS6FC6VWJX6RFK6CK8Z46ZKBGAJ2N1G6FMS8J509J6RVATTVGJ5S0",
          "h_denom_pub": "9XM3ZFQYY7RGAH66EZBBYEH1ZMT7SZ0FDRATBTVHSHZEJCPXGHYHBPTZCCNFNS3T5DKZKN18C8XTMJ49NSB2GTX46CV9PFWYRF1G1CR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:2.01"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "T58YMXQNTBDB2W9JQXDJBCGP65T1B7MEXYPE2W8HE1G6J7MRYP1WJWRFFV9XT2QCS58YCV89HRK5PP31QYEGXMHAHTSYEE07YDTYJ00",
          "h_coin_envelope": "N0HXCQ0FEG4EXGWZT22SQTA3VV39ZVVQEMK235XYH79DWSA37QHPB7PY6RYRM03XZGW2563712YDJDTPYB8347C32WGWTH0MH9YH10R",
          "h_denom_pub": "9XM3ZFQYY7RGAH66EZBBYEH1ZMT7SZ0FDRATBTVHSHZEJCPXGHYHBPTZCCNFNS3T5DKZKN18C8XTMJ49NSB2GTX46CV9PFWYRF1G1CR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:2.01"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "YMZZJHFTR4J9J3QXSF2CN1SFGD51S7AXNBHXT660NEZ8XV8DS9PTE5FNVV9D5M1PNZ04TJDW590C9P4KD4YAK4D33Y3K9681FZWY610",
          "h_coin_envelope": "1SVDMF7Z290BKCNE32SRGRH7F0V53XKJ5B5X3EVSW8NCTR66P1V61P7XYE46NEC0WX2ED74NRK7FB6EVGEKBP557VJY4PZEKMY3T438",
          "h_denom_pub": "8XN0W75BPGHFTASG43A0PJWRNSJDDMJ54VEBAW8DPQHYKVEC1NNY8A1TMBNADGHS14BP9VTBYPN9B855BCHXQTYTXEJ1G0Z6YMPT5AR",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:0.11"
        },
        {
          "type": "WITHDRAW",
          "reserve_sig": "47DRX4N1K9677W75B7C3WPVPZ64BZT4F3QWTA8JSB9TDYNKK1QFFPYEDJVMMQ95HKZTX9Y93B3A4RVKA4P3WDDC6RWDST2V1EEJ8C1G",
          "h_coin_envelope": "MD0WFDTQ6P1E98Z4V89X0N1MMQE8R3VN2R6Q7F8PGGAZYK1VR24GES6ZMJJCK34GGW4G31AXN8SF1XM5PYXGVMD4FHD8M3CXTV3JWRR",
          "h_denom_pub": "7A641SRFG3BJHBJ52MWSZSH8E7XYASK432MAC445H6AAJZMTP5CPMK79SS3RD4VN6B4K8YM6VF8CTDNKBGVMMEVME2QHQ1CHYP4WESG",
          "withdraw_fee": "INTKUDOS:0.01",
          "amount": "INTKUDOS:5.01"
        },
        {
          "type": "RECOUP",
          "exchange_pub": "RGXDWT4E5FKKT1HAPG3616D2AZCMR15PFV0C8HV3EZYDMCJ2ZFH0",
          "exchange_sig": "2Q6R2AP9EMFC3Z8H1KKNEMDEZWKZA3K757R214G51S74N20FWHK25GAJXTXGDJ1ZCJY5GRS0KE745MGFK7CNB4HD8F6Q39MGVGC0T28",
          "timestamp": {
            "t_ms": 1584019765000
          },
          "amount": "INTKUDOS:5",
          "coin_pub": "TT5NGFCFGTRTD93HA39EKXHT9C1CKYVF5P0R4YSMSXPYEWZVV5ZG"
        }
      ]
    }
  }
}
TagsNo tags attached.

Activities

Christian Grothoff

2020-03-14 20:28

manager   ~0015455

Indeed. I did now:

1) expanded the exchangedb test case to test the reserve summary balance update there -- works.

2) manually reviewed and reviewed again the logic that generates the inconsistent response. Also cleaned up the code a tiny bit. Still: nothing.

3) added an additional internal sanity check to check that the balance we compute over the reserve history is consistent with the balance we have cached in the database.

Re-running the test suite now.

Anyway, I did NOT yet check whether we have an adequate "full" test for this in the test suite. But (2) is _very_ frustrating, as me manually reading the code (taler-exchange-httpd_responses.c) really suggests that the response you quote seems _impossible_ :-(((.

Christian Grothoff

2020-03-15 11:53

manager   ~0015456

Actually, this IS tested, but moreover, the exchange CAN do math. Just you cannot ;-). I did check:

$ expr 1000 - 201 - 11 - 201 - 11 - 11 - 11 - 11 - 11 - 11 - 11 - 201 - 201 - 11 - 501 + 500
96

So indeed the exchange is CORRECT here. Note that the events returned by the history are for technical reasons NOT sorted by date, but by event type (SELECT FROM table ...). Hence all recoups come last, even if the happened "earlier" in terms of history.

Issue History

Date Modified Username Field Change
2020-03-12 14:44 Florian Dold New Issue
2020-03-12 14:44 Florian Dold Status new => assigned
2020-03-12 14:44 Florian Dold Assigned To => Christian Grothoff
2020-03-14 20:28 Christian Grothoff Note Added: 0015455
2020-03-15 11:53 Christian Grothoff Note Added: 0015456
2020-03-15 11:53 Christian Grothoff Status assigned => resolved
2020-03-15 11:53 Christian Grothoff Resolution open => no change required
2020-03-15 11:53 Christian Grothoff Fixed in Version => 0.7.1
2020-03-15 11:54 Christian Grothoff Product Version => 0.6
2020-03-15 11:54 Christian Grothoff Fixed in Version 0.7.1 => 0.6
2020-03-15 11:54 Christian Grothoff Target Version => 0.6
2020-03-31 16:04 Christian Grothoff Status resolved => closed