[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-exchange] branch master updated (9384234 -> 04055de)
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-exchange] branch master updated (9384234 -> 04055de) |
Date: |
Thu, 09 Aug 2018 22:30:47 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a change to branch master
in repository exchange.
from 9384234 use correct HTTP status code for commit failures
new 68848aa eliminate redundant hash call
new bce6a80 try with row locking to avoid rollbacks (in theory, to be
verified)
new 7ef4896 fix spacing
new 53e98c1 add option for optimistic signing on withdraw (pre DB
transaction)
new 04055de spaceing
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../.config/taler/account-2.json | 4 +-
src/benchmark/taler-exchange-benchmark.c | 4 +-
.../testing_api_cmd_fakebank_transfer.c | 2 +
.../taler-exchange-httpd_reserve_withdraw.c | 76 ++++++++++++++++++++--
src/exchangedb/plugin_exchangedb_postgres.c | 25 ++++---
5 files changed, 91 insertions(+), 20 deletions(-)
diff --git a/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json
b/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json
index 584b0df..eee026e 100644
--- a/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json
+++ b/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json
@@ -1,5 +1,5 @@
{
"url": "payto://x-taler-bank/localhost:8082/2",
- "salt":
"PYVTA2APWFGKR25915J4VRMW8RH9TKSFP0E0FEB9D2QATY2WHFYBFH4ERTP2PQNRY652RB53QHNWV0PZ4QGX0P3FHSJWNMXVSQTNFK0",
- "master_sig":
"92WX8HRWCP3NFAX4Y2VXQGX4M4T9M99Y08GP67TDBXXXG88JBCY6JQS75CMQGER9CSMBX39QDX00H6584MK11YSC95W9PQ2JNQZNJ30"
+ "salt":
"SNYXSSB37FTJ3CB5WS4FXMFJ0GDPD4HYZ2635A57G0CHBRFJW48CFN20R0Y7S1T7GHKCDHAVBCDCMB78YMZ8G09Y39DBW0101Q5HWYG",
+ "master_sig":
"P43SJJKQ8PSCX90WBJD3D82FZAR2NDYYS6QGW2VFDYDZJ4D7DSK0ZB4J47BFCZYYT96DVV4PZB3XCNYR28QS5794MQGH8DKNEFDW808"
}
\ No newline at end of file
diff --git a/src/benchmark/taler-exchange-benchmark.c
b/src/benchmark/taler-exchange-benchmark.c
index 34777bb..7e6fd20 100644
--- a/src/benchmark/taler-exchange-benchmark.c
+++ b/src/benchmark/taler-exchange-benchmark.c
@@ -68,7 +68,7 @@ enum BenchmarkError {
#define FIRST_INSTRUCTION -1
-#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
+#define CMD_TRANSFER_TO_EXCHANGE(label, amount) \
TALER_TESTING_cmd_fakebank_transfer (label, amount, \
exchange_bank_account.bank_base_url, \
USER_ACCOUNT_NUMBER, \
@@ -576,7 +576,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
waitpid (cpids[i],
&wstatus,
0);
- if ( (!WIFEXITED (wstatus)) ||
+ if ( (! WIFEXITED (wstatus)) ||
(0 != WEXITSTATUS (wstatus)) )
{
GNUNET_break (0);
diff --git a/src/exchange-lib/testing_api_cmd_fakebank_transfer.c
b/src/exchange-lib/testing_api_cmd_fakebank_transfer.c
index a24d24b..28449d5 100644
--- a/src/exchange-lib/testing_api_cmd_fakebank_transfer.c
+++ b/src/exchange-lib/testing_api_cmd_fakebank_transfer.c
@@ -370,6 +370,7 @@ fakebank_transfer_traits (void *cls,
index);
}
+
/**
* Create fakebank_transfer command, the subject line will be
* derived from a randomly created reserve priv. Note that that
@@ -430,6 +431,7 @@ TALER_TESTING_cmd_fakebank_transfer
return cmd;
}
+
/**
* Create "fakebank transfer" CMD, letting the caller specifying
* the subject line.
diff --git a/src/exchange/taler-exchange-httpd_reserve_withdraw.c
b/src/exchange/taler-exchange-httpd_reserve_withdraw.c
index 870fd43..2b127ce 100644
--- a/src/exchange/taler-exchange-httpd_reserve_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_reserve_withdraw.c
@@ -30,6 +30,14 @@
/**
+ * Perform RSA signature before checking with the database?
+ * Reduces time spent in transaction, but may cause us to
+ * waste CPU time if DB check fails.
+ */
+#define OPTIMISTIC_SIGN 1
+
+
+/**
* Send reserve status information to client with the
* message that we have insufficient funds for the
* requested /reserve/withdraw operation.
@@ -171,14 +179,16 @@ withdraw_transaction (void *cls,
int res;
enum GNUNET_DB_QueryStatus qs;
struct TALER_DenominationSignature denom_sig;
- struct GNUNET_HashCode h_blind;
- GNUNET_CRYPTO_hash (wc->blinded_msg,
- wc->blinded_msg_len,
- &h_blind);
+#if OPTIMISTIC_SIGN
+ /* store away optimistic signature to protect
+ it from being overwritten by get_withdraw_info */
+ denom_sig = wc->collectable.sig;
+ wc->collectable.sig.rsa_signature = NULL;
+#endif
qs = TEH_plugin->get_withdraw_info (TEH_plugin->cls,
session,
- &h_blind,
+ &wc->wsrd.h_coin_envelope,
&wc->collectable);
if (0 > qs)
{
@@ -186,12 +196,20 @@ withdraw_transaction (void *cls,
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_WITHDRAW_DB_FETCH_ERROR);
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return qs;
}
/* Don't sign again if we have already signed the coin */
if (1 == qs)
+ {
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
+ }
GNUNET_assert (0 == qs);
/* Check if balance is sufficient */
@@ -204,6 +222,9 @@ withdraw_transaction (void *cls,
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_WITHDRAW_DB_FETCH_ERROR);
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return qs;
}
if (NULL == rh)
@@ -211,6 +232,9 @@ withdraw_transaction (void *cls,
*mhd_ret = TEH_RESPONSE_reply_arg_unknown (connection,
TALER_EC_WITHDRAW_RESERVE_UNKNOWN,
"reserve_pub");
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -233,6 +257,9 @@ withdraw_transaction (void *cls,
{
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_WITHDRAW_AMOUNT_DEPOSITS_OVERFLOW);
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return GNUNET_DB_STATUS_HARD_ERROR;
}
res |= 1;
@@ -249,6 +276,9 @@ withdraw_transaction (void *cls,
{
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_WITHDRAW_AMOUNT_WITHDRAWALS_OVERFLOW);
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return GNUNET_DB_STATUS_HARD_ERROR;
}
res |= 2;
@@ -265,6 +295,9 @@ withdraw_transaction (void *cls,
{
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_WITHDRAW_AMOUNT_DEPOSITS_OVERFLOW);
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return GNUNET_DB_STATUS_HARD_ERROR;
}
res |= 1;
@@ -281,6 +314,9 @@ withdraw_transaction (void *cls,
{
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_WITHDRAW_AMOUNT_WITHDRAWALS_OVERFLOW);
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -294,6 +330,9 @@ withdraw_transaction (void *cls,
GNUNET_break (0);
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_WITHDRAW_RESERVE_WITHOUT_WIRE_TRANSFER);
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return GNUNET_DB_STATUS_HARD_ERROR;
}
if (0 == (res & 2))
@@ -312,6 +351,9 @@ withdraw_transaction (void *cls,
GNUNET_break (0); /* database inconsistent */
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_WITHDRAW_RESERVE_HISTORY_IMPOSSIBLE);
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -323,12 +365,16 @@ withdraw_transaction (void *cls,
rh);
TEH_plugin->free_reserve_history (TEH_plugin->cls,
rh);
+#if OPTIMISTIC_SIGN
+ GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
+#endif
return GNUNET_DB_STATUS_HARD_ERROR;
}
TEH_plugin->free_reserve_history (TEH_plugin->cls,
rh);
/* Balance is good, sign the coin! */
+#if !OPTIMISTIC_SIGN
denom_sig.rsa_signature
= GNUNET_CRYPTO_rsa_sign_blinded (wc->dki->denom_priv.rsa_private_key,
wc->blinded_msg,
@@ -341,6 +387,7 @@ withdraw_transaction (void *cls,
"Internal error");
return GNUNET_DB_STATUS_HARD_ERROR;
}
+#endif
TALER_amount_ntoh (&fee_withdraw,
&wc->dki->issue.properties.fee_withdraw);
wc->collectable.sig = denom_sig;
@@ -348,7 +395,7 @@ withdraw_transaction (void *cls,
wc->collectable.amount_with_fee = wc->amount_required;
wc->collectable.withdraw_fee = fee_withdraw;
wc->collectable.reserve_pub = wc->wsrd.reserve_pub;
- wc->collectable.h_coin_envelope = h_blind;
+ wc->collectable.h_coin_envelope = wc->wsrd.h_coin_envelope;
wc->collectable.reserve_sig = wc->signature;
qs = TEH_plugin->insert_withdraw_info (TEH_plugin->cls,
session,
@@ -486,6 +533,23 @@ TEH_RESERVE_handler_reserve_withdraw (struct
TEH_RequestHandler *rh,
"reserve_sig");
}
+#if OPTIMISTIC_SIGN
+ /* Sign before transaction! */
+ wc.collectable.sig.rsa_signature
+ = GNUNET_CRYPTO_rsa_sign_blinded (wc.dki->denom_priv.rsa_private_key,
+ wc.blinded_msg,
+ wc.blinded_msg_len);
+ if (NULL == wc.collectable.sig.rsa_signature)
+ {
+ GNUNET_break (0);
+ GNUNET_JSON_parse_free (spec);
+ TEH_KS_release (wc.key_state);
+ return TEH_RESPONSE_reply_internal_error (connection,
+
TALER_EC_WITHDRAW_SIGNATURE_FAILED,
+ "Internal error");
+ }
+#endif
+
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"run reserve withdraw",
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c
b/src/exchangedb/plugin_exchangedb_postgres.c
index 6aeeff6..b9c577b 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -682,7 +682,8 @@ postgres_prepare (PGconn *db_conn)
",execution_date"
",sender_account_details"
" FROM reserves_in"
- " WHERE reserve_pub=$1;",
+ " WHERE reserve_pub=$1"
+ " FOR UPDATE;",
1),
/* Used in #postgres_insert_withdraw_info() to store
the signature of a blinded coin with the blinded coin's
@@ -725,7 +726,8 @@ postgres_prepare (PGconn *db_conn)
" FROM reserves_out"
" JOIN denominations denom"
" USING (denom_pub_hash)"
- " WHERE h_blind_ev=$1;",
+ " WHERE h_blind_ev=$1"
+ " FOR UPDATE;",
1),
/* Used during #postgres_get_reserve_history() to
obtain all of the /reserve/withdraw operations that
@@ -747,7 +749,8 @@ postgres_prepare (PGconn *db_conn)
" FROM reserves_out"
" JOIN denominations denom"
" USING (denom_pub_hash)"
- " WHERE reserve_pub=$1;",
+ " WHERE reserve_pub=$1"
+ " FOR UPDATE",
1),
/* Used in #postgres_select_reserves_out_above_serial_id() */
GNUNET_PQ_make_prepare ("audit_get_reserves_out_incr",
@@ -1498,7 +1501,8 @@ postgres_prepare (PGconn *db_conn)
" USING (denom_pub_hash)"
" JOIN reserves_out ro"
" USING (h_blind_ev)"
- " WHERE ro.reserve_pub=$1;",
+ " WHERE ro.reserve_pub=$1"
+ " FOR UPDATE;",
1),
/* Used in #postgres_get_reserve_history() */
GNUNET_PQ_make_prepare ("close_by_reserve",
@@ -1513,7 +1517,8 @@ postgres_prepare (PGconn *db_conn)
",receiver_account"
",wtid"
" FROM reserves_close"
- " WHERE reserve_pub=$1;",
+ " WHERE reserve_pub=$1"
+ " FOR UPDATE",
1),
/* Used in #postgres_get_expired_reserves() */
GNUNET_PQ_make_prepare ("get_expired_reserves",
@@ -6706,7 +6711,7 @@ sum_kyc_events (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = {
TALER_PQ_result_spec_amount ("amount", &tmp),
- GNUNET_PQ_result_spec_end
+ GNUNET_PQ_result_spec_end
};
for (unsigned int i = 0; i < ntuples; i++)
@@ -6725,7 +6730,7 @@ sum_kyc_events (void *cls,
&tmp));
}
-
+
}
@@ -6780,16 +6785,16 @@ postgres_get_kyc_status (void *cls,
const char *payto_url,
TALER_EXCHANGEDB_KycStatusCallback ksc,
void *ksc_cls)
-{
+{
uint8_t status;
- uint64_t merchant_serial_id;
+ uint64_t merchant_serial_id;
enum GNUNET_DB_QueryStatus qs;
char *general_id;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (payto_url),
GNUNET_PQ_query_param_end
- };
+ };
struct GNUNET_PQ_ResultSpec rs[] = {
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-exchange] branch master updated (9384234 -> 04055de),
gnunet <=
- [GNUnet-SVN] [taler-exchange] 02/05: try with row locking to avoid rollbacks (in theory, to be verified), gnunet, 2018/08/09
- [GNUnet-SVN] [taler-exchange] 04/05: add option for optimistic signing on withdraw (pre DB transaction), gnunet, 2018/08/09
- [GNUnet-SVN] [taler-exchange] 03/05: fix spacing, gnunet, 2018/08/09
- [GNUnet-SVN] [taler-exchange] 01/05: eliminate redundant hash call, gnunet, 2018/08/09
- [GNUnet-SVN] [taler-exchange] 05/05: spaceing, gnunet, 2018/08/09