From bf97de5472b703abe3c554c6d388196f9f76290e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 18 Nov 2022 13:50:45 +0100 Subject: [PATCH 1/5] add postgres to list of dependencies --- debian/taler-exchange.taler-exchange-aggregator.service | 1 + debian/taler-exchange.taler-exchange-closer.service | 1 + debian/taler-exchange.taler-exchange-expire.service | 1 + debian/taler-exchange.taler-exchange-transfer.service | 2 +- debian/taler-exchange.taler-exchange-wirewatch.service | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/debian/taler-exchange.taler-exchange-aggregator.service b/debian/taler-exchange.taler-exchange-aggregator.service index aa4f32e38..28bd4a3ab 100644 --- a/debian/taler-exchange.taler-exchange-aggregator.service +++ b/debian/taler-exchange.taler-exchange-aggregator.service @@ -1,6 +1,7 @@ [Unit] Description=GNU Taler payment system exchange aggregator service PartOf=taler-exchange.target +After=postgres.service [Service] User=taler-exchange-aggregator diff --git a/debian/taler-exchange.taler-exchange-closer.service b/debian/taler-exchange.taler-exchange-closer.service index d3a654cc7..df21c724d 100644 --- a/debian/taler-exchange.taler-exchange-closer.service +++ b/debian/taler-exchange.taler-exchange-closer.service @@ -1,6 +1,7 @@ [Unit] Description=GNU Taler payment system exchange closer service PartOf=taler-exchange.target +After=network.target postgres.service [Service] User=taler-exchange-closer diff --git a/debian/taler-exchange.taler-exchange-expire.service b/debian/taler-exchange.taler-exchange-expire.service index e4432f231..0ef1b1e99 100644 --- a/debian/taler-exchange.taler-exchange-expire.service +++ b/debian/taler-exchange.taler-exchange-expire.service @@ -1,6 +1,7 @@ [Unit] Description=GNU Taler payment system exchange expire service PartOf=taler-exchange.target +After=postgres.service [Service] User=taler-exchange-expire diff --git a/debian/taler-exchange.taler-exchange-transfer.service b/debian/taler-exchange.taler-exchange-transfer.service index c7187b30e..3464bdace 100644 --- a/debian/taler-exchange.taler-exchange-transfer.service +++ b/debian/taler-exchange.taler-exchange-transfer.service @@ -1,6 +1,6 @@ [Unit] Description=Taler Exchange Transfer Service -After=network.target +After=network.target postgres.service PartOf=taler-exchange.target [Service] diff --git a/debian/taler-exchange.taler-exchange-wirewatch.service b/debian/taler-exchange.taler-exchange-wirewatch.service index e49472143..c68dcfdc1 100644 --- a/debian/taler-exchange.taler-exchange-wirewatch.service +++ b/debian/taler-exchange.taler-exchange-wirewatch.service @@ -1,6 +1,6 @@ [Unit] Description=GNU Taler payment system exchange wirewatch service -After=network.target +After=network.target postgres.service PartOf=taler-exchange.target [Service] From 8250d830b6facc3cd51ba9cecf109566ec346013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Sun, 20 Nov 2022 12:36:54 +0100 Subject: [PATCH 2/5] Call TEH_keys_update_state on extension config change Fixes #7266 Also better API: - TEH_keys_get_state and - TEH_keys_get_state_for_management_only --- .../taler-exchange-httpd_extensions.c | 5 +++++ src/exchange/taler-exchange-httpd_keys.c | 20 ++++++++++++++----- src/exchange/taler-exchange-httpd_keys.h | 12 +++-------- ...aler-exchange-httpd_management_post_keys.c | 3 +-- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/exchange/taler-exchange-httpd_extensions.c b/src/exchange/taler-exchange-httpd_extensions.c index 30d1c5ac9..c89a00411 100644 --- a/src/exchange/taler-exchange-httpd_extensions.c +++ b/src/exchange/taler-exchange-httpd_extensions.c @@ -20,6 +20,7 @@ #include "platform.h" #include #include "taler_dbevents.h" +#include "taler-exchange-httpd_keys.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_extensions.h" #include "taler_json_lib.h" @@ -156,6 +157,10 @@ extension_update_event_cb (void *cls, TALER_age_mask_to_string (&conf->mask)); } + + // Finally, call TEH_keys_update_states in order to refresh the cached + // values. + TEH_keys_update_states (); } diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c index edfe50e58..b37c68d95 100644 --- a/src/exchange/taler-exchange-httpd_keys.c +++ b/src/exchange/taler-exchange-httpd_keys.c @@ -2623,8 +2623,8 @@ TEH_keys_update_states () } -struct TEH_KeyStateHandle * -TEH_keys_get_state2 (bool management_only) +static struct TEH_KeyStateHandle * +keys_get_state (bool management_only) { struct TEH_KeyStateHandle *old_ksh; struct TEH_KeyStateHandle *ksh; @@ -2659,20 +2659,29 @@ TEH_keys_get_state2 (bool management_only) } +struct TEH_KeyStateHandle * +TEH_keys_get_state_for_management_only (void) +{ + return keys_get_state (true); +} + + struct TEH_KeyStateHandle * TEH_keys_get_state (void) { struct TEH_KeyStateHandle *ksh; - ksh = TEH_keys_get_state2 (false); + ksh = keys_get_state (false); if (NULL == ksh) return NULL; + if (ksh->management_only) { if (GNUNET_OK != finish_keys_response (ksh)) return NULL; } + return ksh; } @@ -2715,6 +2724,7 @@ TEH_keys_denomination_by_hash ( NULL); return NULL; } + return TEH_keys_denomination_by_hash2 (ksh, h_denom_pub, conn, @@ -3410,7 +3420,7 @@ TEH_keys_get_timing (const struct TALER_ExchangePublicKeyP *exchange_pub, struct HelperSignkey *hsk; struct GNUNET_PeerIdentity pid; - ksh = TEH_keys_get_state2 (true); + ksh = TEH_keys_get_state_for_management_only (); if (NULL == ksh) { GNUNET_break (0); @@ -3580,7 +3590,7 @@ TEH_keys_management_get_keys_handler (const struct TEH_RequestHandler *rh, json_t *reply; (void) rh; - ksh = TEH_keys_get_state2 (true); + ksh = TEH_keys_get_state_for_management_only (); if (NULL == ksh) { return TALER_MHD_reply_with_error (connection, diff --git a/src/exchange/taler-exchange-httpd_keys.h b/src/exchange/taler-exchange-httpd_keys.h index 7e8c1e995..8758afb71 100644 --- a/src/exchange/taler-exchange-httpd_keys.h +++ b/src/exchange/taler-exchange-httpd_keys.h @@ -168,18 +168,12 @@ TEH_check_invariants (void); struct TEH_KeyStateHandle * TEH_keys_get_state (void); - /** - * Obtain the key state. Should ONLY be used - * directly if @a management_only is true. Otherwise use #TEH_keys_get_state(). - * - * @param management_only if we should NOT run finish_keys_response() - * because we only need the state for the /management/keys API - * @return NULL on error + * Obtain the key state if we should NOT run finish_keys_response() because we + * only need the state for the /management/keys API */ struct TEH_KeyStateHandle * -TEH_keys_get_state2 (bool management_only); - +TEH_keys_get_state_for_management_only (void); /** * Something changed in the database. Rebuild all key states. This function diff --git a/src/exchange/taler-exchange-httpd_management_post_keys.c b/src/exchange/taler-exchange-httpd_management_post_keys.c index 7d9853e9b..df351ad5f 100644 --- a/src/exchange/taler-exchange-httpd_management_post_keys.c +++ b/src/exchange/taler-exchange-httpd_management_post_keys.c @@ -376,8 +376,7 @@ TEH_handler_management_post_keys ( } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received /management/keys\n"); - akc.ksh = TEH_keys_get_state2 (true); /* may start its own transaction, thus - must be done here, before we run ours! */ + akc.ksh = TEH_keys_get_state_for_management_only (); /* may start its own transaction, thus must be done here, before we run ours! */ if (NULL == akc.ksh) { GNUNET_break_op (0); From 496a13f35eb3b352eb2bcf8cf84938ce0683e9c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Sun, 20 Nov 2022 16:34:29 +0100 Subject: [PATCH 3/5] retry test after 2s sleep; workaround for #7445 --- src/auditor/test-auditor.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh index 2fc97283b..60cc00bd2 100755 --- a/src/auditor/test-auditor.sh +++ b/src/auditor/test-auditor.sh @@ -240,7 +240,13 @@ function audit_only () { echo -n "." $VALGRIND taler-helper-auditor-reserves -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-reserves-inc.json 2> ${MY_TMP_DIR}/test-audit-reserves-inc.log || exit_fail "incremental reserves audit failed" echo -n "." - $VALGRIND taler-helper-auditor-wire -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire.json 2> ${MY_TMP_DIR}/test-wire-audit.log || exit_fail "wire audit failed" + rm -f ${MY_TMP_DIR}/test-wire-audit.log + thaw() { + $VALGRIND taler-helper-auditor-wire -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire.json 2>> ${MY_TMP_DIR}/test-wire-audit.log + } + thaw || ( echo -e " FIRST CALL TO taler-helper-auditor-wire FAILED,\nRETRY AFTER TWO SECONDS..." | tee -a ${MY_TMP_DIR}/test-wire-audit.log + sleep 2 + thaw || exit_fail "wire audit failed" ) echo -n "." $VALGRIND taler-helper-auditor-wire -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire-inc.json 2> ${MY_TMP_DIR}/test-wire-audit-inc.log || exit_fail "wire audit inc failed" echo -n "." From e033f82dc0d54a533af5989094345aa56137050e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 20 Nov 2022 21:53:32 +0100 Subject: [PATCH 4/5] -implement missing testing checks --- src/testing/testing_api_cmd_common.c | 39 +++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/testing/testing_api_cmd_common.c b/src/testing/testing_api_cmd_common.c index bb0eb3f04..91138f361 100644 --- a/src/testing/testing_api_cmd_common.c +++ b/src/testing/testing_api_cmd_common.c @@ -90,8 +90,7 @@ TALER_TESTING_history_entry_cmp ( (GNUNET_TIME_timestamp_cmp ( h1->details.history_details.request_timestamp, ==, - h2->details.history_details. - request_timestamp)) && + h2->details.history_details.request_timestamp)) && (0 == GNUNET_memcmp (&h1->details.history_details.reserve_sig, &h2->details.history_details.reserve_sig)) ) @@ -131,10 +130,42 @@ TALER_TESTING_history_entry_cmp ( return 0; return 1; case TALER_EXCHANGE_RTT_OPEN: - // FIXME: verify response... + if ( (0 == + TALER_amount_cmp (&h1->amount, + &h2->amount)) && + (GNUNET_TIME_timestamp_cmp ( + h1->details.open_request.request_timestamp, + ==, + h2->details.open_request.request_timestamp)) && + (GNUNET_TIME_timestamp_cmp ( + h1->details.open_request.reserve_expiration, + ==, + h2->details.open_request.reserve_expiration)) && + (h1->details.open_request.purse_limit == + h2->details.open_request.purse_limit) && + (0 == + TALER_amount_cmp (&h1->details.open_request.reserve_payment, + &h2->details.open_request.reserve_payment)) && + (0 == + GNUNET_memcmp (&h1->details.open_request.reserve_sig, + &h2->details.open_request.reserve_sig)) ) + return 0; return 1; case TALER_EXCHANGE_RTT_CLOSE: - // FIXME: verify response... + if ( (0 == + TALER_amount_cmp (&h1->amount, + &h2->amount)) && + (GNUNET_TIME_timestamp_cmp ( + h1->details.close_request.request_timestamp, + ==, + h2->details.close_request.request_timestamp)) && + (0 == + GNUNET_memcmp (&h1->details.close_request.target_account_h_payto, + &h2->details.close_request.target_account_h_payto)) && + (0 == + GNUNET_memcmp (&h1->details.close_request.reserve_sig, + &h2->details.close_request.reserve_sig)) ) + return 0; return 1; } GNUNET_assert (0); From e82cbd05b6b2c52f4053f3347ac01b0d0ed905af Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 21 Nov 2022 00:53:03 +0100 Subject: [PATCH 5/5] -fix NPE --- src/auditor/taler-helper-auditor-wire.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/auditor/taler-helper-auditor-wire.c b/src/auditor/taler-helper-auditor-wire.c index 852c219cf..e1b57392b 100644 --- a/src/auditor/taler-helper-auditor-wire.c +++ b/src/auditor/taler-helper-auditor-wire.c @@ -1775,13 +1775,16 @@ conclude_account (struct WireAccount *wa) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Reconciling CREDIT processing of account `%s'\n", wa->ai->section_name); - GNUNET_CONTAINER_multihashmap_iterate (in_map, - &complain_in_not_found, - wa); - /* clean up before 2nd phase */ - GNUNET_CONTAINER_multihashmap_iterate (in_map, - &free_rii, - NULL); + if (NULL != in_map) + { + GNUNET_CONTAINER_multihashmap_iterate (in_map, + &complain_in_not_found, + wa); + /* clean up before 2nd phase */ + GNUNET_CONTAINER_multihashmap_iterate (in_map, + &free_rii, + NULL); + } process_credits (wa->next); }