From 6acc6b8b94dde459d30df2e3fbf8be5a3c30f117 Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Tue, 11 Oct 2022 11:11:40 +0200 Subject: simplified database schema --- design-documents/028-deposit-policies.rst | 54 ++++++++++++++----------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/design-documents/028-deposit-policies.rst b/design-documents/028-deposit-policies.rst index be840353..0dd7c62d 100644 --- a/design-documents/028-deposit-policies.rst +++ b/design-documents/028-deposit-policies.rst @@ -57,7 +57,7 @@ TODO, explain: - Naming conventions for policy extensions - Deadlines and -handling - API-endpoints (``/extensions/policy_...``) -- Typical choreography of a deposit with policy and its fulfilment +- Typical choreography of a deposit with policy and its fulfillment Database-schema =============== @@ -87,60 +87,56 @@ TODO: Description label=<policy_details> margin=20 policy_details [ - label="id\l|hash_code (unique)\l|deadline\l|commitment (amount)\l|accumulated_total (amount)\l|fee (amount)\l|transferable (amount)\l|fulfilment_state\l" + label="id\l|hash_code (unique)\l|deadline\l|commitment (amount)\l|accumulated_total (amount)\l|fee (amount)\l|transferable (amount)\l|fulfillment_state\l" ] } - subgraph cluster_policy_fulfilments { - label=<policy_fulfilments> + subgraph cluster_policy_fulfillments { + label=<policy_fulfillments> margin=20 rank=min; - policy_fulfilments [ - label="id\l|proof\l|timestamp\l" - ] - } - - subgraph cluster_policy_details_fulfilments { - label=<policy_details_fulfilments> - margin=20 - policy_details_fulfilments [ - label="hash_code\l|fulfilment_id\l" + policy_fulfillments [ + label="id\l|proof\l|timestamp\l|policy_hash_codes (blob)\l" ] } deposits:ref->policy_details:id [ label="n:1"; fontname="monospace" ]; - policy_details:hash->policy_details_fulfilments:ref_details [ dir=back; label="1:1"; fontname="monospace" ]; - policy_details_fulfilments:ref_fulfilments->policy_fulfilments:id [ label="n:1"; fontname="monospace" ]; - + policy_details:hash->policy_fulfillments:codes [ label="quasi n:1"; fontname="monospace"; dir=back; style=dashed]; } -Policy Fulfilment States -======================== -The fulfilment of a policy can be in one of the following five states: +The entry ``policy_hash_codes`` in table ``policy_fulfillment`` is a binary blob +that consists of the concatenation of all ``hash_code``'s from the +``policy_details`` that are fulfilled by this proof. + + +Policy Fulfillment States +========================= + +The fulfillment of a policy can be in one of the following five states: Ready The policy is funded and ready. The exchange is waiting for a proof of - fulfilment to arrive before the deadline. + fulfillment to arrive before the deadline. Insufficient The policy lacks funding, that is ``accumulated_total`` < ``commitment``, but has otherwise been accepted. Funding can be - continued by calling ``/deposit`` with more coins and the same policy - details. + continued by calling ``/deposit`` or ``/batch-deposit`` with more coins + and the same policy details. Success The policy is provably fulfilled. The amounts for payout, fees and - refresh are transfered/can be claimed. Note that a policy fulfilment + refresh are transfered/can be claimed. Note that a policy fulfillment handler can change the values for the amounts for payout, fees and refresh. Timeout - The policy has timed out. The amount for payout, free and refresh are + The policy has timed out. The amounts for payout and refresh are transfered/can be claimed. Failure - The policy is in an failure state. Payouts, fees and refreshes are + The policy is in an failure state. Payouts and refreshes are blocked, timeouts are ignored. @@ -150,14 +146,14 @@ Invariants The following invariants need to be fulfilled and be checked by the auditor: -- The fulfilment state of a policy is **Insufficient** IF AND ONLY IF the +- The fulfillment state of a policy is **Insufficient** IF AND ONLY IF the amount in ``commitment`` is larger than the amount in ``accumulated_total``. - The sum of amounts in ``fee`` and ``transferable`` must be less or equal to the amount in ``accumulated_total``. -- If the fulfilment state of a policy is **Success**, there MUST exists an - entry in the ``policy_details_fulfilment`` table for the corresponding +- If the fulfillment state of a policy is **Success**, there MUST exists an + entry in the ``policy_details_fulfillment`` table for the corresponding ``hash_code``. -- cgit v1.2.3