gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: perf and logging improvements


From: gnunet
Subject: [taler-wallet-core] branch master updated: perf and logging improvements
Date: Fri, 06 Aug 2021 16:27:23 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 05e52d4e perf and logging improvements
05e52d4e is described below

commit 05e52d4e116222728d9bcba3bcbf9e441bb4e4ed
Author: Florian Dold <florian@dold.me>
AuthorDate: Fri Aug 6 16:27:18 2021 +0200

    perf and logging improvements
---
 packages/taler-wallet-cli/src/lint.ts              |  5 +-
 packages/taler-wallet-core/src/headless/helpers.ts |  1 +
 .../taler-wallet-core/src/operations/exchanges.ts  | 12 +++-
 .../taler-wallet-core/src/operations/withdraw.ts   | 82 ++++++++++++----------
 4 files changed, 59 insertions(+), 41 deletions(-)

diff --git a/packages/taler-wallet-cli/src/lint.ts 
b/packages/taler-wallet-cli/src/lint.ts
index f8886595..4b963387 100644
--- a/packages/taler-wallet-cli/src/lint.ts
+++ b/packages/taler-wallet-cli/src/lint.ts
@@ -149,10 +149,11 @@ function checkBasicConf(context: LintContext): BasicConf {
   }
 
   const roundUnit = cfg.getAmount("taler", "currency_round_unit");
-  if (!roundUnit.isDefined) {
+  const ru = roundUnit.required();
+  if (ru.currency.toLowerCase() != mainCurrency.toLowerCase()) {
     context.numErr++;
     console.log(
-      "error: configuration incomplete, section TALER option 
CURRENCY_ROUND_UNIT missing",
+      "error: [TALER]/CURRENCY_ROUND_UNIT: currency does not match main 
currency",
     );
   }
   return { mainCurrency };
diff --git a/packages/taler-wallet-core/src/headless/helpers.ts 
b/packages/taler-wallet-core/src/headless/helpers.ts
index cb788e2b..f29dfd69 100644
--- a/packages/taler-wallet-core/src/headless/helpers.ts
+++ b/packages/taler-wallet-core/src/headless/helpers.ts
@@ -118,6 +118,7 @@ export async function getDefaultNodeWallet(
     }
 
     myBackend.afterCommitCallback = async () => {
+      logger.trace("committing database");
       // Allow caller to stop persisting the wallet.
       if (args.persistentStoragePath === undefined) {
         return;
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts 
b/packages/taler-wallet-core/src/operations/exchanges.ts
index 86a51867..64821a7b 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -341,7 +341,6 @@ async function downloadKeysInfo(
   );
 
   logger.info("received /keys response");
-  logger.trace(j2s(exchangeKeysJson));
 
   if (exchangeKeysJson.denoms.length === 0) {
     const opErr = makeErrorDetails(
@@ -442,18 +441,23 @@ async function updateExchangeFromUrlImpl(
 
   const keysInfo = await downloadKeysInfo(baseUrl, ws.http, timeout);
 
+  logger.info("updating exchange /wire info");
   const wireInfoDownload = await downloadExchangeWithWireInfo(
     baseUrl,
     ws.http,
     timeout,
   );
 
+  logger.info("validating exchange /wire info");
+
   const wireInfo = await validateWireInfo(
     wireInfoDownload,
     keysInfo.masterPublicKey,
     ws.cryptoApi,
   );
 
+  logger.info("finished validating exchange /wire info");
+
   const tosDownload = await downloadExchangeWithTermsOfService(
     baseUrl,
     ws.http,
@@ -462,6 +466,8 @@ async function updateExchangeFromUrlImpl(
 
   let recoupGroupId: string | undefined = undefined;
 
+  logger.trace("updating exchange info in database");
+
   const updated = await ws.db
     .mktx((x) => ({
       exchanges: x.exchanges,
@@ -512,6 +518,7 @@ async function updateExchangeFromUrlImpl(
       await tx.exchanges.put(r);
       await tx.exchangeDetails.put(details);
 
+      logger.trace("updating denominations in database");
       for (const currentDenom of keysInfo.currentDenominations) {
         const oldDenom = await tx.denominations.get([
           baseUrl,
@@ -523,6 +530,7 @@ async function updateExchangeFromUrlImpl(
           await tx.denominations.put(currentDenom);
         }
       }
+      logger.trace("done updating denominations in database");
 
       // Handle recoup
       const recoupDenomList = keysInfo.recoup;
@@ -579,6 +587,8 @@ async function updateExchangeFromUrlImpl(
     throw Error("something went wrong with updating the exchange");
   }
 
+  logger.trace("done updating exchange info in database");
+
   return {
     exchange: updated.exchange,
     exchangeDetails: updated.exchangeDetails,
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index 55f39b6b..99d8d7d3 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -675,6 +675,9 @@ export async function updateWithdrawalDenoms(
   ws: InternalWalletState,
   exchangeBaseUrl: string,
 ): Promise<void> {
+  logger.trace(
+    `updating denominations used for withdrawal for ${exchangeBaseUrl}`,
+  );
   const exchangeDetails = await ws.db
     .mktx((x) => ({
       exchanges: x.exchanges,
@@ -689,53 +692,56 @@ export async function updateWithdrawalDenoms(
   }
   // First do a pass where the validity of candidate denominations
   // is checked and the result is stored in the database.
+  logger.trace("getting candidate denominations");
   const denominations = await getCandidateWithdrawalDenoms(ws, 
exchangeBaseUrl);
-  for (const denom of denominations) {
-    if (denom.status === DenominationStatus.Unverified) {
-      const valid = await ws.cryptoApi.isValidDenom(
-        denom,
-        exchangeDetails.masterPublicKey,
-      );
-      if (!valid) {
-        logger.warn(
-          `Signature check for denomination h=${denom.denomPubHash} failed`,
+  logger.trace(`got ${denominations.length} candidate denominations`);
+  const batchSize = 500;
+  let current = 0;
+
+  while (current < denominations.length) {
+    const updatedDenominations: DenominationRecord[] = [];
+    // Do a batch of batchSize
+    for (let batchIdx = 0; batchIdx < batchSize; batchIdx++) {
+      current++;
+      if (current >= denominations.length) {
+        break;
+      }
+      const denom = denominations[current];
+      if (denom.status === DenominationStatus.Unverified) {
+        logger.trace(
+          `Validation denomination (${current + 1}/${
+            denominations.length
+          }) signature of ${denom.denomPubHash}`,
         );
-        denom.status = DenominationStatus.VerifiedBad;
-      } else {
-        denom.status = DenominationStatus.VerifiedGood;
+        const valid = await ws.cryptoApi.isValidDenom(
+          denom,
+          exchangeDetails.masterPublicKey,
+        );
+        logger.trace(`Done validating ${denom.denomPubHash}`);
+        if (!valid) {
+          logger.warn(
+            `Signature check for denomination h=${denom.denomPubHash} failed`,
+          );
+          denom.status = DenominationStatus.VerifiedBad;
+        } else {
+          denom.status = DenominationStatus.VerifiedGood;
+        }
+        updatedDenominations.push(denom);
       }
+    }
+    if (updatedDenominations.length > 0) {
+      logger.trace("writing denomination batch to db");
       await ws.db
         .mktx((x) => ({ denominations: x.denominations }))
         .runReadWrite(async (tx) => {
-          await tx.denominations.put(denom);
+          for (let i = 0; i < updatedDenominations.length; i++) {
+            const denom = updatedDenominations[i];
+            await tx.denominations.put(denom);
+          }
         });
+      logger.trace("done with DB write");
     }
   }
-  // FIXME:  This debug info should either be made conditional on some flag
-  // or put into some wallet-core API.
-  const nextDenominations = await getCandidateWithdrawalDenoms(
-    ws,
-    exchangeBaseUrl,
-  );
-  logger.trace(
-    `updated withdrawable denominations for "${exchangeBaseUrl}, 
n=${nextDenominations.length}"`,
-  );
-  const now = getTimestampNow();
-  for (const denom of nextDenominations) {
-    const startDelay = getDurationRemaining(denom.stampStart, now);
-    const lastPossibleWithdraw = timestampSubtractDuraction(
-      denom.stampExpireWithdraw,
-      { d_ms: 50 * 1000 },
-    );
-    const remaining = getDurationRemaining(lastPossibleWithdraw, now);
-    logger.trace(
-      `Denom ${denom.denomPubHash} ${denom.status} revoked ${
-        denom.isRevoked
-      } offered ${denom.isOffered} remaining ${
-        (remaining.d_ms as number) / 1000
-      }sec withdrawDelay ${(startDelay.d_ms as number) / 1000}sec`,
-    );
-  }
 }
 
 async function incrementWithdrawalRetry(

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]