View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006170 | Taler | exchange | public | 2020-04-08 16:14 | 2021-09-02 18:14 |
Reporter | fefe | Assigned To | Christian Grothoff | ||
Priority | normal | Severity | minor | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | 0.7.0 | ||||
Target Version | 0.7.1 | Fixed in Version | 0.7.1 | ||
Summary | 0006170: confusing code in verify_reserve_balance | ||||
Description | 1026 /* Check our reserve summary balance calculation shows that 1027 the reserve balance is acceptable (i.e. non-negative) */ 1028 GNUNET_assert (GNUNET_OK == 1029 TALER_amount_add (&balance, 1030 &rs->total_in, 1031 &rs->a_balance)); This does balance = rs->total_in + rs->a_balance. While I have an idea what total_in means, what is a_balance? Maybe rename it to balance_at_prev_audit or so? 1032 if (GNUNET_SYSERR == 1033 TALER_amount_subtract (&nbalance, 1034 &balance, 1035 &rs->total_out)) 1036 { Practically all other TALER_amount_subtract are in an assert that wants to make sure they did not return GNUNET_SYSERR. Why is this one different? And if the return was a SYSERR, why are we reacting not by logging an error but by doing some calculations? In fact the code looks like this is the expected code path. I'm confused by this. Please explain (and add comments in the code). | ||||
Tags | No tags attached. | ||||
|
Apparently subtract returns SYSERR of a-b would be negative. However it also returns SYSERR of the normalization failed. Maybe we meant the first case and forgot about the second one? |
|
TALER_amount_subtract also returns SYSERR if the currency was invalid. |
|
The intended case was "if result was negative". I actually forgot that we have the other two possibilities ;-). I'll try to clean up the code (later, still busy with 0006164). |
|
There is another instance of the pattern further down in the function: 1208 if (GNUNET_SYSERR == 1209 TALER_amount_subtract (&r, 1210 &total_escrow_balance, 1211 &rs->total_out)) 1212 { 1213 /* We could not reduce our total balance, i.e. exchange allowed IN TOTAL (!) 1214 to be withdrawn more than it was IN TOTAL ever given (exchange balance 1215 went negative!). Woopsie. Calculate how badly it went and log. */ This time there is a proper comment explaining what is happening. Recommendation: Add another return value for "value would become negative" instead of reusing SYSERR. |
|
Yes, at least. The TALER_amount_subtract() API's use of SYSERR for 'negative result' is one that actually has bitten me before... |
|
"a" in "a_balance" was supposed to be for "auditor_". But happy to rename as suggested, that is even clearer: 50bc862a..1554cc31 |
|
1554cc31..84a40be0 introduces new return types for amount addition and subtraction, plus modifies the auditor to clearly distinguish between the different cases where applicable. |
|
Fix committed to master branch. |
exchange: master 84a40be0 2020-04-09 01:52 Details Diff |
fix 0006170 and rest of 0006164 |
Affected Issues 0006170 |
|
mod - src/auditor/report-lib.c | Diff File | ||
mod - src/auditor/report-lib.h | Diff File | ||
mod - src/auditor/taler-helper-auditor-aggregation.c | Diff File | ||
mod - src/auditor/taler-helper-auditor-coins.c | Diff File | ||
mod - src/auditor/taler-helper-auditor-deposits.c | Diff File | ||
mod - src/auditor/taler-helper-auditor-reserves.c | Diff File | ||
mod - src/auditor/taler-helper-auditor-wire.c | Diff File | ||
mod - src/benchmark/taler-exchange-benchmark.c | Diff File | ||
mod - src/exchange/taler-exchange-aggregator.c | Diff File | ||
mod - src/exchange/taler-exchange-httpd_deposit.c | Diff File | ||
mod - src/exchange/taler-exchange-httpd_deposits_get.c | Diff File | ||
mod - src/exchange/taler-exchange-httpd_melt.c | Diff File | ||
mod - src/exchange/taler-exchange-httpd_recoup.c | Diff File | ||
mod - src/exchange/taler-exchange-httpd_refreshes_reveal.c | Diff File | ||
mod - src/exchange/taler-exchange-httpd_responses.c | Diff File | ||
mod - src/exchange/taler-exchange-httpd_transfers_get.c | Diff File | ||
mod - src/exchange/taler-exchange-httpd_withdraw.c | Diff File | ||
mod - src/exchangedb/exchangedb_transactions.c | Diff File | ||
mod - src/exchangedb/plugin_exchangedb_postgres.c | Diff File | ||
mod - src/exchangedb/test_exchangedb.c | Diff File | ||
mod - src/include/taler_amount_lib.h | Diff File | ||
mod - src/lib/exchange_api_common.c | Diff File | ||
mod - src/lib/exchange_api_deposit.c | Diff File | ||
mod - src/lib/exchange_api_melt.c | Diff File | ||
mod - src/lib/exchange_api_refresh_common.c | Diff File | ||
mod - src/lib/exchange_api_transfers_get.c | Diff File | ||
mod - src/lib/exchange_api_withdraw.c | Diff File | ||
mod - src/testing/testing_api_cmd_exec_closer.c | Diff File | ||
mod - src/testing/testing_api_cmd_refresh.c | Diff File | ||
mod - src/testing/testing_api_cmd_withdraw.c | Diff File | ||
mod - src/util/amount.c | Diff File | ||
mod - src/util/test_amount.c | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-04-08 16:14 | fefe | New Issue | |
2020-04-08 16:14 | fefe | Status | new => assigned |
2020-04-08 16:14 | fefe | Assigned To | => Christian Grothoff |
2020-04-08 16:16 | fefe | Note Added: 0015583 | |
2020-04-08 16:17 | fefe | Note Added: 0015584 | |
2020-04-08 17:00 | Christian Grothoff | Note Added: 0015585 | |
2020-04-08 17:05 | fefe | Note Added: 0015586 | |
2020-04-08 17:43 | Christian Grothoff | Note Added: 0015587 | |
2020-04-08 18:27 | Christian Grothoff | Note Added: 0015590 | |
2020-04-08 18:28 | Christian Grothoff | Note Edited: 0015590 | |
2020-04-08 23:57 | Christian Grothoff | Note Added: 0015597 | |
2020-04-08 23:57 | Christian Grothoff | Status | assigned => resolved |
2020-04-08 23:57 | Christian Grothoff | Resolution | open => fixed |
2020-04-08 23:57 | Christian Grothoff | Fixed in Version | => 0.7.1 |
2020-04-08 23:58 | Christian Grothoff | Target Version | => 0.7.1 |
2021-08-24 16:23 | Christian Grothoff | Status | resolved => closed |
2021-09-02 18:13 | Christian Grothoff | Changeset attached | => Taler-exchange master 84a40be0 |
2021-09-02 18:14 | Christian Grothoff | Note Added: 0018266 |