From fa76fa66624b5b4cd57275aad67f159acf046b70 Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Tue, 11 Oct 2022 11:44:41 +0200 Subject: simplified DB-schema for policy_details and _fulfilments --- design-documents/028-deposit-policies.rst | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/design-documents/028-deposit-policies.rst b/design-documents/028-deposit-policies.rst index 38423d72..bbf0edc4 100644 --- a/design-documents/028-deposit-policies.rst +++ b/design-documents/028-deposit-policies.rst @@ -79,7 +79,7 @@ TODO: Description label=<deposits> margin=20 deposits [ - label="...|policy_details_id\l|...|timestamp\l|..." + label="...|policy_details_id (null)\l|...|timestamp\l|..." ] } @@ -87,7 +87,7 @@ 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|fulfillment_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|fullfilment_id (null)\l" ] } @@ -101,7 +101,7 @@ TODO: Description } deposits:ref->policy_details:id [ label="n:1"; fontname="monospace" ]; - policy_details:hash->policy_fulfillments:codes [ label="quasi m:1"; fontname="monospace"; dir=back; style=dashed]; + policy_details:fid->policy_fulfillments:id [label="n:1"; fontname="monosapce" ]; } @@ -147,15 +147,20 @@ Invariants The following invariants need to be fulfilled and be checked by the auditor: - The fulfillment state of a policy is **Insufficient** IF AND ONLY IF the - amount in ``commitment`` is larger than the amount in ``accumulated_total``. + amount in ``policy_details.commitment`` is larger than the amount in + ``policy_details.accumulated_total``. -- The sum of amounts in ``fee`` and ``transferable`` must be less or equal to - the amount in ``accumulated_total``. +- The sum of amounts in ``policy_details.fee`` and + ``policy_details.transferable`` must be less or equal to the amount in + ``policy_details.accumulated_total``. -- 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``. +- Each hash code encoded in ``policy_fulfillments.policy_hash_codes`` MUST + refer to an existing ``policy_details.hash_code`` AND its ``.fulfillment_id`` + MUST point to the same ``policy_fulfillments.id``. +- Conversely: If a ``policy_details.fulfilment_id`` points to an entry in + ``policy_fulfillment``, the ``policy_details.hash_code`` MUST be present in + that entry's ``.policy_hash_codes``. -- cgit v1.2.3