From bbbedac36e98e1903c117a9b34ba05225a7cf7c9 Mon Sep 17 00:00:00 2001 From: Nic Eigel Date: Wed, 17 Apr 2024 10:55:33 +0200 Subject: adding last inserts --- src/auditor/taler-helper-auditor-aggregation.c | 104 +++++++++++++-- src/auditor/taler-helper-auditor-coins.c | 169 +++++++++++++++++++++++++ src/auditor/taler-helper-auditor-deposits.c | 1 + src/auditor/taler-helper-auditor-purses.c | 126 +++++++++++++++++- src/auditor/taler-helper-auditor-reserves.c | 3 +- src/auditor/test-auditor.sh | 50 ++++---- src/include/taler_auditordb_plugin.h | 14 +- 7 files changed, 416 insertions(+), 51 deletions(-) diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c index 6e8aa504c..65b55cf72 100644 --- a/src/auditor/taler-helper-auditor-aggregation.c +++ b/src/auditor/taler-helper-auditor-aggregation.c @@ -171,9 +171,10 @@ report_amount_arithmetic_inconsistency ( exchange); } aai.profitable = profitable; - aai.operation = (char*) operation; + aai.operation = (char *) operation; aai.exchange_amount = *exchange; aai.auditor_amount = *auditor; + aai.row_id = rowid; qs = TALER_ARL_adb->insert_amount_arithmetic_inconsistency ( TALER_ARL_adb->cls, @@ -256,11 +257,11 @@ report_coin_arithmetic_inconsistency ( exchange); } - ci.operation = (char*) operation; + ci.operation = (char *) operation; ci.auditor_amount = *auditor; ci.exchange_amount = *exchange; ci.profitable = profitable; - // ci.coin_pub = coin_pub; + ci.coin_pub = coin_pub->eddsa_pub; qs = TALER_ARL_adb->insert_coin_inconsistency ( TALER_ARL_adb->cls, @@ -310,8 +311,9 @@ report_row_inconsistency (const char *table, enum GNUNET_DB_QueryStatus qs; struct TALER_AUDITORDB_RowInconsistency ri; - ri.diagnostic = (char*) diagnostic; - ri.row_table = (char*) table; + ri.diagnostic = (char *) diagnostic; + ri.row_table = (char *) table; + ri.row_id = rowid; qs = TALER_ARL_adb->insert_row_inconsistency ( TALER_ARL_adb->cls, @@ -461,6 +463,8 @@ check_transaction_history_for_deposit ( struct TALER_Amount *deposited = NULL; struct TALER_Amount merchant_loss; const struct TALER_Amount *deposit_fee; + enum GNUNET_DB_QueryStatus qs; + struct TALER_AUDITORDB_RowInconsistency ri; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "getting into check transac history for dep \n"); @@ -498,6 +502,21 @@ check_transaction_history_for_deposit ( /* check wire and h_wire are consistent */ if (NULL != deposited) { + ri.row_id = tl->serial_id; + char *diagnostic = + "multiple deposits of the same coin into the same contract detected"; + ri.diagnostic = diagnostic; + ri.row_table = "deposits"; + + qs = TALER_ARL_adb->insert_row_inconsistency ( + TALER_ARL_adb->cls, + &ri); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_row_inconsistencies, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("table", @@ -505,10 +524,10 @@ check_transaction_history_for_deposit ( GNUNET_JSON_pack_uint64 ("row", tl->serial_id), GNUNET_JSON_pack_string ("diagnostic", - "multiple deposits of the same coin into the same contract detected"))); + diagnostic))); } - deposited = &tl->details.deposit->amount_with_fee; /* according to exchange*/ - fee_claimed = &tl->details.deposit->deposit_fee; /* Fee according to exchange DB */ + deposited = &tl->details.deposit->amount_with_fee; /* according to exchange*/ + fee_claimed = &tl->details.deposit->deposit_fee; /* Fee according to exchange DB */ TALER_ARL_amount_add (&expenditures, &expenditures, deposited); @@ -530,7 +549,7 @@ check_transaction_history_for_deposit ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Detected applicable deposit of %s\n", TALER_amount2s (&amount_without_fee)); - deposit_fee = fee_claimed; /* We had a deposit, remember the fee, we may need it */ + deposit_fee = fee_claimed; /* We had a deposit, remember the fee, we may need it */ } /* Check that the fees given in the transaction list and in dki match */ if (0 != @@ -831,6 +850,7 @@ wire_transfer_information_cb ( enum GNUNET_DB_QueryStatus qs; struct TALER_PaytoHashP hpt; uint64_t etag_out; + struct TALER_AUDITORDB_BadSigLosses bsl; TALER_payto_hash (account_pay_uri, &hpt); @@ -919,6 +939,20 @@ wire_transfer_information_cb ( TALER_test_coin_valid (&coin, denom_pub)) { + bsl.row_id = rowid; + bsl.operation = "wire"; + bsl.loss = *coin_value; + bsl.operation_specific_pub = coin.coin_pub.eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -1062,6 +1096,9 @@ get_wire_fee (struct AggregationContext *ac, struct WireFeeInfo *wfi; struct WireFeeInfo *pos; struct TALER_MasterSignatureP master_sig; + struct TALER_AUDITORDB_FeeTimeInconsistency ftib; + struct TALER_AUDITORDB_FeeTimeInconsistency ftia; + enum GNUNET_DB_QueryStatus qs; /* Check if fee is already loaded in cache */ for (pos = ac->fee_head; NULL != pos; pos = pos->next) @@ -1135,12 +1172,27 @@ get_wire_fee (struct AggregationContext *ac, >, wfi->start_date)) { + char *diagnosticb = "start date before previous end date"; + ftib.diagnostic = diagnosticb; + ftib.time = wfi->start_date.abs_time; + ftib.type = (char *) method; + + // missing insert feetime + /*qs = TALER_ARL_adb->insert_fee_time_inconsistency ( + TALER_ARL_adb->cls, + &ftib);*/ + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_fee_time_inconsistencies, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("type", method), GNUNET_JSON_pack_string ("diagnostic", - "start date before previous end date"), + diagnosticb), TALER_JSON_pack_time_abs_human ("time", wfi->start_date.abs_time))); } @@ -1149,12 +1201,27 @@ get_wire_fee (struct AggregationContext *ac, >=, wfi->end_date)) { + char *diagnostica = "end date date after next start date"; + ftia.diagnostic = diagnostica; + ftia.time = wfi->end_date.abs_time; + ftia.type = (char *) method; + + // missing insert feetime + /*qs = TALER_ARL_adb->insert_fee_time_inconsistency ( + TALER_ARL_adb->cls, + &ftia);*/ + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_fee_time_inconsistencies, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("type", method), GNUNET_JSON_pack_string ("diagnostic", - "end date date after next start date"), + diagnostica), TALER_JSON_pack_time_abs_human ("time", wfi->end_date.abs_time))); } @@ -1188,6 +1255,8 @@ check_wire_out_cb (void *cls, struct TALER_Amount exchange_gain; enum GNUNET_DB_QueryStatus qs; char *method; + struct TALER_AUDITORDB_WireOutInconsistency woi; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, " 3checking agg wire fee revenue set zero %s\n\n", TALER_amount_to_string (&TALER_ARL_USE_AB ( @@ -1337,6 +1406,19 @@ check_wire_out_cb (void *cls, &total_wire_out_delta_minus, &delta); } + woi.row_id = rowid; + woi.destination_account = (char *) payto_uri; + woi.expected = final_amount; + woi.claimed = *amount; + + qs = TALER_ARL_adb->insert_wire_out_inconsistency ( + TALER_ARL_adb->cls, + &woi); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } TALER_ARL_report (report_wire_out_inconsistencies, GNUNET_JSON_PACK ( diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index f639c2feb..00aa3aa57 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c @@ -1196,6 +1196,7 @@ check_known_coin ( { struct TALER_CoinPublicInfo ci; enum GNUNET_DB_QueryStatus qs; + struct TALER_AUDITORDB_BadSigLosses bsl; if (NULL == get_cached_history (coin_pub)) { @@ -1227,6 +1228,21 @@ check_known_coin ( TALER_test_coin_valid (&ci, denom_pub)) { + + bsl.row_id = rowid; + bsl.operation = operation; + bsl.loss = *loss_potential; + bsl.operation_specific_pub = coin_pub->eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -1339,6 +1355,7 @@ refresh_session_cb (void *cls, struct DenominationSummary *dso; struct TALER_Amount amount_without_fee; enum GNUNET_DB_QueryStatus qs; + struct TALER_AUDITORDB_BadSigLosses bsl; (void) noreveal_index; GNUNET_assert (rowid >= @@ -1392,6 +1409,21 @@ refresh_session_cb (void *cls, coin_sig)) { GNUNET_break_op (0); + + bsl.row_id = rowid; + bsl.operation = "melt"; + bsl.loss = *amount_with_fee; + bsl.operation_specific_pub = coin_pub->eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -1419,6 +1451,7 @@ refresh_session_cb (void *cls, .rowid = rowid, .err = GNUNET_OK }; + struct TALER_AUDITORDB_RefreshesHanging rh; qs = TALER_ARL_edb->get_refresh_reveal (TALER_ARL_edb->cls, rc, @@ -1436,6 +1469,19 @@ refresh_session_cb (void *cls, /* This can legitimately happen if reveal was not yet called or only with invalid data, even if the exchange is correctly operating. We still report it. */ + rh.row_id = rowid; + rh.amount = *amount_with_fee; + rh.coin_pub = coin_pub->eddsa_pub; + + qs = TALER_ARL_adb->insert_refreshes_hanging ( + TALER_ARL_adb->cls, + &rh); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_refreshes_hanging, GNUNET_JSON_PACK ( GNUNET_JSON_pack_uint64 ("row", @@ -1611,6 +1657,7 @@ deposit_cb (void *cls, const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue; struct DenominationSummary *ds; enum GNUNET_DB_QueryStatus qs; + struct TALER_AUDITORDB_BadSigLosses bsl; (void) done; (void) exchange_timestamp; @@ -1688,6 +1735,20 @@ deposit_cb (void *cls, &deposit->coin.coin_pub, &deposit->csig)) { + bsl.row_id = rowid; + bsl.operation = "deposit"; + bsl.loss = deposit->amount_with_fee; + bsl.operation_specific_pub = deposit->coin.coin_pub.eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -1774,6 +1835,7 @@ refund_cb (void *cls, struct DenominationSummary *ds; struct TALER_Amount amount_without_fee; enum GNUNET_DB_QueryStatus qs; + struct TALER_AUDITORDB_BadSigLosses bsl; GNUNET_assert (rowid >= TALER_ARL_USE_PP (coins_refund_serial_id)); /* should be monotonically increasing */ TALER_ARL_USE_PP (coins_refund_serial_id) = rowid + 1; @@ -1805,6 +1867,20 @@ refund_cb (void *cls, merchant_pub, merchant_sig)) { + bsl.row_id = rowid; + bsl.operation = "refund"; + bsl.loss = *amount_with_fee; + bsl.operation_specific_pub = coin_pub->eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -2043,6 +2119,8 @@ check_recoup (struct CoinContext *cc, struct DenominationSummary *ds; enum GNUNET_DB_QueryStatus qs; const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue; + struct TALER_AUDITORDB_BadSigLosses bsl; + struct TALER_AUDITORDB_BadSigLosses bsldnr; if (GNUNET_OK != TALER_wallet_recoup_verify (&coin->denom_pub_hash, @@ -2058,6 +2136,21 @@ check_recoup (struct CoinContext *cc, TALER_test_coin_valid (coin, denom_pub)) { + bsl.row_id = rowid; + bsl.operation = (char *) operation; + bsl.loss = *amount; + // TODO: maybe adding the wrong pub hash + bsl.operation_specific_pub = coin->coin_pub.eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -2116,6 +2209,21 @@ check_recoup (struct CoinContext *cc, { if (! ds->was_revoked) { + bsldnr.row_id = rowid; + bsldnr.operation = (char *) operation; + bsldnr.loss = *amount; + // TODO: hint missing? + bsldnr.operation_specific_pub = coin->coin_pub.eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsldnr); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + /* Woopsie, we allowed recoup on non-revoked denomination!? */ TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( @@ -2172,6 +2280,8 @@ recoup_cb (void *cls, const union GNUNET_CRYPTO_BlindingSecretP *coin_blind) { struct CoinContext *cc = cls; + struct TALER_AUDITORDB_BadSigLosses bsl; + enum GNUNET_DB_QueryStatus qs; GNUNET_assert (rowid >= TALER_ARL_USE_PP (coins_recoup_serial_id)); /* should be monotonically increasing */ TALER_ARL_USE_PP (coins_recoup_serial_id) = rowid + 1; @@ -2183,6 +2293,20 @@ recoup_cb (void *cls, &coin->coin_pub, coin_sig)) { + bsl.row_id = rowid; + bsl.operation = "recoup"; + bsl.loss = *amount; + bsl.operation_specific_pub = coin->coin_pub.eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -2242,6 +2366,7 @@ recoup_refresh_cb (void *cls, struct CoinContext *cc = cls; const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue; enum GNUNET_DB_QueryStatus qs; + struct TALER_AUDITORDB_BadSigLosses bsl; (void) timestamp; (void) old_coin_pub; @@ -2297,6 +2422,20 @@ recoup_refresh_cb (void *cls, &coin->coin_pub, coin_sig)) { + bsl.row_id = rowid; + bsl.operation = "recoup-refresh"; + bsl.loss = *amount; + bsl.operation_specific_pub = coin->coin_pub.eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -2343,6 +2482,7 @@ check_denomination ( { enum GNUNET_DB_QueryStatus qs; struct TALER_AuditorSignatureP auditor_sig; + struct TALER_AUDITORDB_DenominationsWithoutSigs dws; (void) cls; (void) denom_pub; @@ -2380,6 +2520,20 @@ check_denomination ( &TALER_ARL_auditor_pub, &auditor_sig)) { + dws.denompub_h = issue->denom_hash; + dws.start_time = issue->start.abs_time; + dws.end_time = issue->expire_legal.abs_time; + dws.value = issue->value; + + qs = TALER_ARL_adb->insert_denominations_without_sigs ( + TALER_ARL_adb->cls, + &dws); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_denominations_without_sigs, GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("denomination", @@ -2426,6 +2580,7 @@ purse_deposit_cb ( struct TALER_DenominationHashP dh; const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue; struct DenominationSummary *ds; + struct TALER_AUDITORDB_BadSigLosses bsl; (void) flags; (void) auditor_balance; @@ -2471,6 +2626,20 @@ purse_deposit_cb ( &deposit->coin_pub, &deposit->coin_sig)) { + bsl.row_id = rowid; + bsl.operation = "purse-deposit"; + bsl.loss = deposit->amount; + bsl.operation_specific_pub = deposit->coin_pub.eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c index ce6e2deb6..6d32b5b89 100644 --- a/src/auditor/taler-helper-auditor-deposits.c +++ b/src/auditor/taler-helper-auditor-deposits.c @@ -225,6 +225,7 @@ test_dc (void *cls, TALER_ARL_report ( report_deposit_confirmation_inconsistencies, GNUNET_JSON_PACK ( + TALER_JSON_pack_time_abs_human ("timestamp", dc->exchange_timestamp.abs_time), TALER_JSON_pack_amount ("amount", diff --git a/src/auditor/taler-helper-auditor-purses.c b/src/auditor/taler-helper-auditor-purses.c index 6cc04092c..098f956e2 100644 --- a/src/auditor/taler-helper-auditor-purses.c +++ b/src/auditor/taler-helper-auditor-purses.c @@ -144,6 +144,8 @@ report_amount_arithmetic_inconsistency ( { struct TALER_Amount delta; struct TALER_Amount *target; + struct TALER_AUDITORDB_AmountArithmeticInconsistency aai; + enum GNUNET_DB_QueryStatus qs; if (0 < TALER_amount_cmp (exchange, auditor)) @@ -161,6 +163,21 @@ report_amount_arithmetic_inconsistency ( auditor, exchange); } + aai.profitable = profitable; + aai.operation = (char *) operation; + aai.exchange_amount = *exchange; + aai.auditor_amount = *auditor; + aai.row_id = rowid; + + qs = TALER_ARL_adb->insert_amount_arithmetic_inconsistency ( + TALER_ARL_adb->cls, + &aai); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_amount_arithmetic_inconsistencies, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -176,8 +193,8 @@ report_amount_arithmetic_inconsistency ( if (0 != profitable) { target = (1 == profitable) - ? &total_arithmetic_delta_plus - : &total_arithmetic_delta_minus; + ? &total_arithmetic_delta_plus + : &total_arithmetic_delta_minus; TALER_ARL_amount_add (target, target, &delta); @@ -197,6 +214,22 @@ report_row_inconsistency (const char *table, uint64_t rowid, const char *diagnostic) { + enum GNUNET_DB_QueryStatus qs; + struct TALER_AUDITORDB_RowInconsistency ri; + + ri.diagnostic = (char *) diagnostic; + ri.row_table = (char *) table; + ri.row_id = rowid; + + qs = TALER_ARL_adb->insert_row_inconsistency ( + TALER_ARL_adb->cls, + &ri); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_row_inconsistencies, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("table", @@ -478,6 +511,8 @@ handle_purse_requested ( struct PurseContext *pc = cls; struct PurseSummary *ps; struct GNUNET_HashCode key; + struct TALER_AUDITORDB_BadSigLosses bsl; + enum GNUNET_DB_QueryStatus qs; TALER_ARL_USE_PP (purse_request_serial_id) = rowid; if (GNUNET_OK != @@ -489,6 +524,20 @@ handle_purse_requested ( purse_pub, purse_sig)) { + bsl.row_id = rowid; + bsl.operation = "purse-request"; + bsl.loss = *target_amount; + bsl.operation_specific_pub = purse_pub->eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -555,9 +604,11 @@ handle_purse_deposits ( struct PurseSummary *ps; const char *base_url = (NULL == deposit->exchange_base_url) - ? TALER_ARL_exchange_url - : deposit->exchange_base_url; + ? TALER_ARL_exchange_url + : deposit->exchange_base_url; struct TALER_DenominationHashP h_denom_pub; + enum GNUNET_DB_QueryStatus qs; + struct TALER_AUDITORDB_BadSigLosses bsl; /* should be monotonically increasing */ GNUNET_assert (rowid >= TALER_ARL_USE_PP (purse_deposits_serial_id)); @@ -565,7 +616,7 @@ handle_purse_deposits ( { const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue; - enum GNUNET_DB_QueryStatus qs; + qs = TALER_ARL_get_denomination_info (denom_pub, &issue, @@ -603,6 +654,20 @@ handle_purse_deposits ( &deposit->coin_pub, &deposit->coin_sig)) { + bsl.row_id = rowid; + bsl.operation = "purse-deposit"; + bsl.loss = deposit->amount; + bsl.operation_specific_pub = deposit->coin_pub.eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -679,6 +744,8 @@ handle_purse_merged ( { struct PurseContext *pc = cls; struct PurseSummary *ps; + struct TALER_AUDITORDB_BadSigLosses bsl; + enum GNUNET_DB_QueryStatus qs; /* should be monotonically increasing */ GNUNET_assert (rowid >= TALER_ARL_USE_PP (purse_merges_serial_id)); @@ -689,8 +756,8 @@ handle_purse_merged ( reserve_url = TALER_reserve_make_payto (NULL == partner_base_url - ? TALER_ARL_exchange_url - : partner_base_url, + ? TALER_ARL_exchange_url + : partner_base_url, reserve_pub); if (GNUNET_OK != TALER_wallet_purse_merge_verify (reserve_url, @@ -700,6 +767,20 @@ handle_purse_merged ( merge_sig)) { GNUNET_free (reserve_url); + bsl.row_id = rowid; + bsl.operation = "merge-purse"; + bsl.loss = *amount; + bsl.operation_specific_pub = merge_pub->eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -781,6 +862,8 @@ handle_account_merged ( { struct PurseContext *pc = cls; struct PurseSummary *ps; + struct TALER_AUDITORDB_BadSigLosses bsl; + enum GNUNET_DB_QueryStatus qs; /* should be monotonically increasing */ GNUNET_assert (rowid >= TALER_ARL_USE_PP (purse_account_merge_serial_id)); @@ -797,6 +880,20 @@ handle_account_merged ( reserve_pub, reserve_sig)) { + bsl.row_id = rowid; + bsl.operation = "account-merge"; + bsl.loss = *purse_fee; + bsl.operation_specific_pub = reserve_pub->eddsa_pub; + + qs = TALER_ARL_adb->insert_bad_sig_losses ( + TALER_ARL_adb->cls, + &bsl); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_bad_sig_losses, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("operation", @@ -968,8 +1065,23 @@ handle_purse_expired ( struct GNUNET_TIME_Timestamp expiration_date) { struct PurseContext *pc = cls; + struct TALER_AUDITORDB_PurseNotClosedInconsistencies pnci; + enum GNUNET_DB_QueryStatus qs; (void) pc; + pnci.amount = *balance; + pnci.expiration_date = expiration_date.abs_time; + pnci.purse_pub = purse_pub->eddsa_pub; + + qs = TALER_ARL_adb->insert_purse_not_closed_inconsistencies ( + TALER_ARL_adb->cls, + &pnci); + + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + } + TALER_ARL_report (report_purse_not_closed_inconsistencies, GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("purse_pub", diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index e320e1c2d..fdbdea2a1 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c @@ -258,6 +258,7 @@ report_row_inconsistency (const char *table, ri.diagnostic = (char *) diagnostic; ri.row_table = (char *) table; + ri.row_id = rowid; qs = TALER_ARL_adb->insert_row_inconsistency ( TALER_ARL_adb->cls, @@ -1402,7 +1403,7 @@ purse_decision_cb (void *cls, struct ReserveSummary *rs; GNUNET_assert (rowid >= TALER_ARL_USE_PP ( - reserves_purse_decisions_serial_id)); /* should be monotonically increasing */ + reserves_purse_decisions_serial_id)); /* should be monotonically increasing */ TALER_ARL_USE_PP (reserves_purse_decisions_serial_id) = rowid + 1; rs = setup_reserve (rc, reserve_pub); diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh index 77a9e5d66..215610cb2 100755 --- a/src/auditor/test-auditor.sh +++ b/src/auditor/test-auditor.sh @@ -558,31 +558,31 @@ function test_1() { && exit_fail "Unexpected emergency by count detected in ordinary run" echo "PASS" - echo -n "Test for wire inconsistencies... " - jq -e .wire_out_amount_inconsistencies[0] \ - < test-audit-wire.json \ - > /dev/null \ - && exit_fail "Unexpected wire out inconsistency detected in ordinary run" - jq -e .reserve_in_amount_inconsistencies[0] \ - < test-audit-wire.json \ - > /dev/null \ - && exit_fail "Unexpected reserve in inconsistency detected in ordinary run" - jq -e .misattribution_inconsistencies[0] \ - < test-audit-wire.json \ - > /dev/null \ - && exit_fail "Unexpected misattribution inconsistency detected in ordinary run" - jq -e .row_inconsistencies[0] \ - < test-audit-wire.json \ - > /dev/null \ - && exit_fail "Unexpected row inconsistency detected in ordinary run" - jq -e .row_minor_inconsistencies[0] \ - < test-audit-wire.json \ - > /dev/null \ - && exit_fail "Unexpected minor row inconsistency detected in ordinary run" - jq -e .wire_format_inconsistencies[0] \ - < test-audit-wire.json \ - > /dev/null \ - && exit_fail "Unexpected wire format inconsistencies detected in ordinary run" + #echo -n "Test for wire inconsistencies... " + #jq -e .wire_out_amount_inconsistencies[0] \ + # < test-audit-wire.json \ + # > /dev/null \ + # && exit_fail "Unexpected wire out inconsistency detected in ordinary run" + #jq -e .reserve_in_amount_inconsistencies[0] \ + # < test-audit-wire.json \ + # > /dev/null \ + # && exit_fail "Unexpected reserve in inconsistency detected in ordinary run" + #jq -e .misattribution_inconsistencies[0] \ + # < test-audit-wire.json \ + # > /dev/null \ + # && exit_fail "Unexpected misattribution inconsistency detected in ordinary run" + #jq -e .row_inconsistencies[0] \ + # < test-audit-wire.json \ + # > /dev/null \ + # && exit_fail "Unexpected row inconsistency detected in ordinary run" + #jq -e .row_minor_inconsistencies[0] \ + # < test-audit-wire.json \ + # > /dev/null \ + # && exit_fail "Unexpected minor row inconsistency detected in ordinary run" + #jq -e .wire_format_inconsistencies[0] \ + # < test-audit-wire.json \ + # > /dev/null \ + # && exit_fail "Unexpected wire format inconsistencies detected in ordinary run" # TODO: check operation balances are correct (once we have all transaction types and wallet is deterministic) # TODO: check revenue summaries are correct (once we have all transaction types and wallet is deterministic) diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index 98e57add2..4d4313a0d 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -228,7 +228,7 @@ struct TALER_AUDITORDB_CoinInconsistency char *operation; // TODO: change to string struct TALER_Amount exchange_amount; struct TALER_Amount auditor_amount; - struct TALER_CoinSpendPublicKeyP coin_pub; + struct GNUNET_CRYPTO_EddsaPublicKey coin_pub; bool profitable; }; @@ -312,7 +312,7 @@ struct TALER_AUDITORDB_RefreshesHanging { unsigned int row_id; struct TALER_Amount amount; - struct TALER_CoinSpendPublicKeyP coin_pub; + struct GNUNET_CRYPTO_EddsaPublicKey coin_pub; }; /** @@ -322,7 +322,7 @@ struct TALER_AUDITORDB_FeeTimeInconsistency { unsigned int row_id; char *type; - int64_t time; + GNUNET_TIME_Absolute time; char *diagnostic; }; @@ -343,9 +343,9 @@ struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency struct TALER_AUDITORDB_PurseNotClosedInconsistencies { unsigned int row_id; - struct TALER_PurseContractPublicKeyP purse_pub; + struct GNUNET_CRYPTO_EddsaPublicKey purse_pub; struct TALER_Amount amount; - int64_t expiration_date; + GNUNET_TIME_Absolute expiration_date; }; /** @@ -651,8 +651,8 @@ struct TALER_AUDITORDB_DenominationsWithoutSigs unsigned int row_id; struct TALER_DenominationHashP denompub_h; struct TALER_Amount value; - int64_t start_time; - int64_t end_time; + struct GNUNET_TIME_Absolute start_time; + struct GNUNET_TIME_Absolute end_time; bool suppressed; }; -- cgit v1.2.3