View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0012279 | Taler | exchange | public | 2026-11-21 10:28 | 2026-11-21 22:52 |
| Reporter | bot-oec [agent] | ||||
| Implementer | Christian Grothoff | ||||
| Estimated effort (hours) | 1 | ||||
| Priority | low | Severity | major | ||
| Status | implementing | ||||
| Target Version | 1.10 | ||||
| Summary | 0012279: An open request for more purses can shorten the reserve's expiration, down to now; the garbage collection date follows the old expiration | ||||
| Description | Opening a reserve should extend its expiration and purse quota as paid for, and no reserve should be closed earlier than the idle expiration after a credit. `do_reserve_open.sql`, in the branch for a purse limit above the reserve's quota, sets the new expiration to `now + years`, where `years` counts from now to the *desired* expiration, and writes it back unconditionally. A reserve that already runs longer, asking for more purses with a desired expiration before its current one, pays and gets an earlier expiration, down to now. The HTTP handler bounds the desired expiration only from above. The same update sets the garbage collection date to the *old* expiration plus the legal retention time: an opening for longer than that retention leaves a reserve with a zero balance to be collected, with its quota, before the period it paid for ends. **Steps to reproduce:** 1. A reserve running to 2096 asks for one purse with the desired expiration "now" (2020): it pays EUR:1, and its expiration should stay in 2096; it becomes 13 September 2020. 2. A reserve expiring now is opened for ten years (legal retention 7 years in the test configuration): its garbage collection date should not precede its expiration; it does. The database test `src/exchangedb/test_reserves_open_requests.c` (new checks `purses-keep-expiration` for step 1, `gc-after-expiration` for step 2) does this; it fails on master at both checks (expects the expiration kept and the collection date after it, gets 13 September 2020 and a collection date before the expiration). The test will be on branch `dev/oec/formalization-findings` on git.taler.net; a note here will name the commit. **Proposed fix:** never lower the expiration in that branch (`GREATEST` with the current one), and date the collection from the new expiration, never earlier than before. With it both checks pass, and the opening, auditor reserve-open, P2P and KYC tests still pass. How many years an extra purse costs for a reserve already paid beyond now is left as it is. **Found by:** the formalization of the Taler protocols; the rule violated is (E0) in `spec/p2p.md`: opening extends the reserve's expiration and purse quota as paid for; and W9 in `spec/withdraw.md`: no reserve is closed earlier than the idle expiration after a credit. | ||||
| Tags | No tags attached. | ||||
| Test: branch `dev/oec/formalization-findings` of exchange.git (git.taler.net), commit 7000488e17fb "exchangedb: reserve open requests keep the expiration (0012279)", on master 7b658d8da. Two checks in test_reserves_open_requests: purses-keep-expiration (an open request for more purses does not shorten the reserve's expiration) and gc-after-expiration (the collection date is not before the expiration). Both fail on master. | |
| Proposed patch (exchange master ba48fdeac; with it the two checks of test_reserves_open_requests from dev/oec/formalization-findings pass, and the exchangedb suite, test_exchange_api_p2p_{rsa,cs} and test_kyc_api still pass). When more purses are bought, the expiration is never lowered below the one the reserve has, and the collection date follows the new expiration, never earlier than before. How many years an extra purse costs for a reserve already paid beyond now is left as it is: diff --git a/src/exchangedb/do_reserve_open.sql b/src/exchangedb/do_reserve_open.sql index 0c5e8362e..1344c136d 100644 --- a/src/exchangedb/do_reserve_open.sql +++ b/src/exchangedb/do_reserve_open.sql @@ -103,7 +103,11 @@ END IF; IF (reserve.purses_allowed < in_min_purse_limit) THEN my_years = (31535999999999 + my_desired_expiration - in_now) / 31536000000000; - my_expiration_date = in_now + 31536000000000 * my_years; + -- Never shorten the expiration the reserve already has (0012279: + -- opening extends it): asking for purses with a desired expiration + -- before the current one set it to that earlier time. + my_expiration_date = GREATEST (my_expiration_date, + in_now + 31536000000000 * my_years); -- in_min_purse_limit is an INT4 that comes straight from the client's -- "purse_limit", so this sum has to be evaluated in INT8: in INT4 it -- overflows before the division. @@ -236,7 +240,9 @@ END IF; UPDATE reserves SET current_balance=my_balance - ,gc_date=reserve.expiration_date + in_reserve_gc_delay + -- after the expiration just granted, not the one the reserve had, and + -- never earlier than before + ,gc_date=GREATEST (gc_date, my_expiration_date + in_reserve_gc_delay) ,expiration_date=my_expiration_date ,purses_allowed=my_purses_allowed WHERE | |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-11-21 10:28 | bot-oec | New Issue | |
| 2026-11-21 10:28 | bot-oec | Implementer | => oec |
| 2026-11-21 10:28 | bot-oec | Reviewer | => Christian Grothoff |
| 2026-11-21 10:28 | bot-oec | Release signed by | => Christian Grothoff |
| 2026-11-21 10:28 | bot-oec | Deployed by | => Christian Grothoff |
| 2026-11-21 10:28 | bot-oec | Verifier | => oec |
| 2026-11-21 10:28 | bot-oec | Communicator | => CM_7 |
| 2026-11-21 10:47 | bot-oec | Note Added: 0030679 | |
| 2026-11-21 16:16 | oec | Implementer | oec => |
| 2026-11-21 22:21 | Christian Grothoff | Locked by | => Christian Grothoff |
| 2026-11-21 22:21 | Christian Grothoff | Status | new => planning |
| 2026-11-21 22:22 | Christian Grothoff | Implementer | => Christian Grothoff |
| 2026-11-21 22:22 | Christian Grothoff | Reviewer | Christian Grothoff => oec |
| 2026-11-21 22:22 | Christian Grothoff | Priority | normal => low |
| 2026-11-21 22:22 | Christian Grothoff | Target Version | => 1.10 |
| 2026-11-21 22:22 | Christian Grothoff | Status | planning => implementing |
| 2026-11-21 22:23 | Christian Grothoff | Locked by | Christian Grothoff => |
| 2026-11-21 22:26 | Christian Grothoff | Estimated effort (hours) | => 1 |
| 2026-11-21 22:42 | Christian Grothoff | View Status | private => public |
| 2026-11-21 22:52 | bot-oec | Note Added: 0030714 |