Skip to content

Commit

Permalink
Merge pull request #7642 from LedgerHQ/bugfix/LIVE-13694-bis
Browse files Browse the repository at this point in the history
[LIVE-13694][LLD] Fix app install hanging on Windows due to performance monitoring related stuff
  • Loading branch information
ofreyssinet-ledger authored Aug 22, 2024
2 parents ed20002 + cc3199d commit fea9bae
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 149 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-rats-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/live-common": patch
---

Sentry: disable capture of "performance spans", which were not actually in use, but still causing a stop of the internal process on LLD Windows
4 changes: 0 additions & 4 deletions apps/ledger-live-desktop/src/sentry/internal.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import * as Sentry from "@sentry/node";
import { Primitive } from "@sentry/types";
import { connectLogsToSentry } from "@ledgerhq/live-common/performance";
import { init, setShouldSendCallback } from "./install";
// @ts-expect-error The right type would be typeof SentryMainModule from "@sentry/electron/main"…
// …but we should avoid importing the whole module here
const available = init(Sentry, {
integrations: [Sentry.httpIntegration()],
});
if (available) {
connectLogsToSentry(Sentry);
}
export default (shouldSendCallback: () => boolean, userId: string) => {
if (!available) return;
setShouldSendCallback(shouldSendCallback);
Expand Down
24 changes: 8 additions & 16 deletions libs/coin-modules/coin-bitcoin/src/bridge/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
makeSync,
} from "@ledgerhq/coin-framework/bridge/jsHelpers";
import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
import { StartSpan, makeGetAccountShape, postSync } from "../synchronisation";
import { makeGetAccountShape, postSync } from "../synchronisation";
import { assignFromAccountRaw, assignToAccountRaw } from "../serialization";
import { BitcoinAccount, Transaction, TransactionStatus } from "../types";
import { getTransactionStatus } from "../getTransactionStatus";
Expand All @@ -21,10 +21,10 @@ import { broadcast } from "../broadcast";
import { perCoinLogic } from "../logic";
import resolver from "../hw-getAddress";

function buildCurrencyBridge(signerContext: SignerContext, perfLogger: PerfLogger) {
function buildCurrencyBridge(signerContext: SignerContext) {
const getAddress = resolver(signerContext);
const scanAccounts = makeScanAccounts<BitcoinAccount>({
getAccountShape: makeGetAccountShape(signerContext, perfLogger.startSpan),
getAccountShape: makeGetAccountShape(signerContext),
getAddressFn: getAddressWrapper(getAddress),
});

Expand All @@ -35,9 +35,9 @@ function buildCurrencyBridge(signerContext: SignerContext, perfLogger: PerfLogge
};
}

function buildAccountBridge(signerContext: SignerContext, perfLogger: PerfLogger) {
function buildAccountBridge(signerContext: SignerContext) {
const sync = makeSync<Transaction, BitcoinAccount, TransactionStatus>({
getAccountShape: makeGetAccountShape(signerContext, perfLogger.startSpan),
getAccountShape: makeGetAccountShape(signerContext),
postSync,
});

Expand Down Expand Up @@ -79,19 +79,11 @@ function buildAccountBridge(signerContext: SignerContext, perfLogger: PerfLogger
};
}

export type PerfLogger = {
startSpan: StartSpan;
};

export function createBridges(
signerContext: SignerContext,
perfLogger: PerfLogger,
coinConfig: CoinConfig,
) {
export function createBridges(signerContext: SignerContext, coinConfig: CoinConfig) {
setCoinConfig(coinConfig);

return {
currencyBridge: buildCurrencyBridge(signerContext, perfLogger),
accountBridge: buildAccountBridge(signerContext, perfLogger),
currencyBridge: buildCurrencyBridge(signerContext),
accountBridge: buildAccountBridge(signerContext),
};
}
31 changes: 1 addition & 30 deletions libs/coin-modules/coin-bitcoin/src/synchronisation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,8 @@ const deduplicateOperations = (operations: (Operation | undefined)[]): Operation
return out;
};

// For performance monitoring
export type StartSpan = (
op: string,
description?: string,
rest?: {
tags?: any;
data?: any;
},
) => {
finish: () => void;
};
export function makeGetAccountShape(
signerContext: SignerContext,
startSpan: StartSpan,
): GetAccountShape<BitcoinAccount> {
export function makeGetAccountShape(signerContext: SignerContext): GetAccountShape<BitcoinAccount> {
return async info => {
let span;
const { currency, index, derivationPath, derivationMode, initialAccount, deviceId } = info;
// In case we get a full derivation path, extract the seed identification part
// 44'/0'/0'/0/0 --> 44'/0'
Expand Down Expand Up @@ -115,7 +100,6 @@ export function makeGetAccountShape(
const walletNetwork = toWalletNetwork(currency.id);
const walletDerivationMode = toWalletDerivationMode(derivationMode);

span = startSpan("sync", "generateAccount");
const walletAccount =
initialAccount?.bitcoinResources?.walletAccount ||
(await wallet.generateAccount(
Expand All @@ -129,7 +113,6 @@ export function makeGetAccountShape(
},
currency,
));
span.finish();

const oldOperations = initialAccount?.operations || [];
const currentBlock = await walletAccount.xpub.explorer.getCurrentBlock();
Expand All @@ -138,39 +121,27 @@ export function makeGetAccountShape(
await wallet.syncAccount(walletAccount, blockHeight);

const balance = await wallet.getAccountBalance(walletAccount);
span = startSpan("sync", "getAccountTransactions");
const { txs: transactions } = await wallet.getAccountTransactions(walletAccount);
span.finish();

span = startSpan("sync", "getXpubAddresses");
const accountAddresses: Set<string> = new Set<string>();
const accountAddressesWithInfo = await walletAccount.xpub.getXpubAddresses();
accountAddressesWithInfo.forEach(a => accountAddresses.add(a.address));
span.finish();

span = startSpan("sync", "getUniquesAddresses");
const changeAddresses: Set<string> = new Set<string>();
const changeAddressesWithInfo = await walletAccount.xpub.storage.getUniquesAddresses({
account: 1,
});
changeAddressesWithInfo.forEach(a => changeAddresses.add(a.address));
span.finish();

span = startSpan("sync", "mapTxToOperations");
const newOperations = transactions
?.map(tx => mapTxToOperations(tx, currency.id, accountId, accountAddresses, changeAddresses))
.flat();
span.finish();

span = startSpan("sync", "unify operations");
const newUniqueOperations = deduplicateOperations(newOperations);
const operations = mergeOps(oldOperations, newUniqueOperations);
span.finish();

span = startSpan("sync", "gather utxos");
const rawUtxos = await wallet.getAccountUnspentUtxos(walletAccount);
const utxos = rawUtxos.map(utxo => fromWalletUtxo(utxo, changeAddresses));
span.finish();

return {
id: accountId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9438,18 +9438,18 @@ exports[`bitcoin_cash currency bridge scanAccounts bitcoin_cash seed 1 1`] = `
"xpub": "xpub6BuPWhjLqutPV8SF4RMrrn8c3t7uBZbz4CBbThpbg9GYjqRMncra9mjgSfWSK7uMDz37hhzJ8wvkbDDQQJt6VgwLoszvmPiSBtLA1bPLLSn",
},
{
"balance": "99774",
"balance": "100774",
"bitcoinResources": {},
"currencyId": "bitcoin_cash",
"derivationMode": "",
"freshAddress": "bitcoincash:qrpv5gkjr7t734nc9j5dmaln02rhzntl2cv0u822y5",
"freshAddressPath": "44'/145'/0'/0/23",
"id": "js:2:bitcoin_cash:xpub6D7pqJa4V3SFSigcsRaFL2mpfG7469osrMkk4ieR2uk8y1v3nuQUD8W8v36PLWQtVRSggSQM7jLpGNKH7sqCaoPSJEp9wZCVkRnMWoiUUXa:",
"index": 0,
"operationsCount": 66,
"operationsCount": 67,
"pendingOperations": [],
"seedIdentifier": "04884ed3fe628a8487f782f97f38e7a9f014e624f1ea679951cf3a67445ea33fb334f4cc19e6c421b3ef9943d526cd4fbfebacebe8a62cc45db79a33d3ab04bd47",
"spendableBalance": "99774",
"spendableBalance": "100774",
"swapHistory": [],
"syncHash": undefined,
"used": true,
Expand Down Expand Up @@ -11312,6 +11312,24 @@ exports[`bitcoin_cash currency bridge scanAccounts bitcoin_cash seed 1 2`] = `
"type": "IN",
"value": "599434",
},
{
"accountId": "js:2:bitcoin_cash:xpub6D7pqJa4V3SFSigcsRaFL2mpfG7469osrMkk4ieR2uk8y1v3nuQUD8W8v36PLWQtVRSggSQM7jLpGNKH7sqCaoPSJEp9wZCVkRnMWoiUUXa:",
"blockHash": "0000000000000000003d037b815760feb7df62117b3882d2f53d1af949d0ed7f",
"blockHeight": 855031,
"extra": {},
"fee": "277",
"hasFailed": false,
"hash": "d69e7f7a220a998d29b13fdec9b9a157c92d89997c6f0d7302014165566689f8",
"id": "js:2:bitcoin_cash:xpub6D7pqJa4V3SFSigcsRaFL2mpfG7469osrMkk4ieR2uk8y1v3nuQUD8W8v36PLWQtVRSggSQM7jLpGNKH7sqCaoPSJEp9wZCVkRnMWoiUUXa:-d69e7f7a220a998d29b13fdec9b9a157c92d89997c6f0d7302014165566689f8-IN",
"recipients": [
"qp28czls5tlvfpmxhpeyt7fx9wfnhpl2a5pzga4cwa",
],
"senders": [
"qp62arrql0hvg5mu8f8mp3cnmn8pp2tfmcr5q6ndql",
],
"type": "IN",
"value": "1000",
},
{
"accountId": "js:2:bitcoin_cash:xpub6D7pqJa4V3SFSigcsRaFL2mpfG7469osrMkk4ieR2uk8y1v3nuQUD8W8v36PLWQtVRSggSQM7jLpGNKH7sqCaoPSJEp9wZCVkRnMWoiUUXa:",
"blockHash": "00000000000000000201065d6543396afc932549b02510721592dccaff7cbdbc",
Expand Down Expand Up @@ -19375,18 +19393,18 @@ exports[`litecoin currency bridge scanAccounts litecoin seed 1 1`] = `
"xpub": "Ltub2ZDyeYFtDj5kL5kYEcBGiDwhXQtZNefG3k4XvAtoMfD5cHxa93WMr6zLGnLb11LCgUXpxWTZRVPv2Roh2vdxesTpgFYayeNNVJb7wmCfD3x",
},
{
"balance": "461844",
"balance": "483964",
"bitcoinResources": {},
"currencyId": "litecoin",
"derivationMode": "segwit",
"freshAddress": "MBR9ZEDS2ufrM3QJCnnvLAUEcob9wFRPKe",
"freshAddressPath": "49'/2'/0'/0/25",
"id": "js:2:litecoin:Ltub2ZoEDG8AmPfD8oGoFEvfsKWjeyiXh6TiKYjgLnoVxfeECfQteY6sDF1AuH1iW6ekue2PSwdbbvG2NpFPzLqcgNgteHZPNo6zGthjcAmwxT3:segwit",
"index": 0,
"operationsCount": 51,
"operationsCount": 53,
"pendingOperations": [],
"seedIdentifier": "04921553e9c4ff6ef39e98f2e8a7719d76e6ecdc67cbb65dcdfd4d04b7e0386524daf087032c6a2ab4280d343d8f4d086e1ef78d9acc1e2464282feb75abf624aa",
"spendableBalance": "461844",
"spendableBalance": "483964",
"swapHistory": [],
"syncHash": undefined,
"used": true,
Expand Down Expand Up @@ -19854,6 +19872,24 @@ exports[`litecoin currency bridge scanAccounts litecoin seed 1 2`] = `
"type": "OUT",
"value": "21800",
},
{
"accountId": "js:2:litecoin:Ltub2ZoEDG8AmPfD8oGoFEvfsKWjeyiXh6TiKYjgLnoVxfeECfQteY6sDF1AuH1iW6ekue2PSwdbbvG2NpFPzLqcgNgteHZPNo6zGthjcAmwxT3:segwit",
"blockHash": "398564d222e0075bfce3ec282cba68911f30002b2977e7a35fd248e2c49ee01f",
"blockHeight": 2721804,
"extra": {},
"fee": "327",
"hasFailed": false,
"hash": "19a733d3cd66111de0bd8297a07a247ba786c9571b00d0b611c4359e9f2cf0d1",
"id": "js:2:litecoin:Ltub2ZoEDG8AmPfD8oGoFEvfsKWjeyiXh6TiKYjgLnoVxfeECfQteY6sDF1AuH1iW6ekue2PSwdbbvG2NpFPzLqcgNgteHZPNo6zGthjcAmwxT3:segwit-19a733d3cd66111de0bd8297a07a247ba786c9571b00d0b611c4359e9f2cf0d1-IN",
"recipients": [
"MGWgRF4qLAHtYhEe6VcQNeQRxVhPd3evHc",
],
"senders": [
"MGV7YgucxkwsTmB167poMS7yX5tY68FAt2",
],
"type": "IN",
"value": "12000",
},
{
"accountId": "js:2:litecoin:Ltub2ZoEDG8AmPfD8oGoFEvfsKWjeyiXh6TiKYjgLnoVxfeECfQteY6sDF1AuH1iW6ekue2PSwdbbvG2NpFPzLqcgNgteHZPNo6zGthjcAmwxT3:segwit",
"blockHash": "44d1cdfe6831b62152d83ded24aac350878e628b0f65b6a2cac773481916722d",
Expand Down Expand Up @@ -20538,6 +20574,24 @@ exports[`litecoin currency bridge scanAccounts litecoin seed 1 2`] = `
"type": "OUT",
"value": "1015860",
},
{
"accountId": "js:2:litecoin:Ltub2ZoEDG8AmPfD8oGoFEvfsKWjeyiXh6TiKYjgLnoVxfeECfQteY6sDF1AuH1iW6ekue2PSwdbbvG2NpFPzLqcgNgteHZPNo6zGthjcAmwxT3:segwit",
"blockHash": "af5e73eb01066e4fdd9bd7b42d7b88b5e4774ed45cb569a4f60e774918ad631e",
"blockHeight": 2721801,
"extra": {},
"fee": "327",
"hasFailed": false,
"hash": "d856eb791a03d93bd19d8153a0997358e6c396152d5c72ba162b70c8baac5616",
"id": "js:2:litecoin:Ltub2ZoEDG8AmPfD8oGoFEvfsKWjeyiXh6TiKYjgLnoVxfeECfQteY6sDF1AuH1iW6ekue2PSwdbbvG2NpFPzLqcgNgteHZPNo6zGthjcAmwxT3:segwit-d856eb791a03d93bd19d8153a0997358e6c396152d5c72ba162b70c8baac5616-IN",
"recipients": [
"MGWgRF4qLAHtYhEe6VcQNeQRxVhPd3evHc",
],
"senders": [
"MGhyc5uFXviT4SZRJLk6oYCJV5zENaGVZB",
],
"type": "IN",
"value": "10120",
},
{
"accountId": "js:2:litecoin:Ltub2ZoEDG8AmPfD8oGoFEvfsKWjeyiXh6TiKYjgLnoVxfeECfQteY6sDF1AuH1iW6ekue2PSwdbbvG2NpFPzLqcgNgteHZPNo6zGthjcAmwxT3:segwit",
"blockHash": "d1ee2556cf97c5126be0576ac1f1fc1b6e80f4588f7e18e9a5afc11d801030f1",
Expand Down
6 changes: 0 additions & 6 deletions libs/ledger-live-common/src/families/bitcoin/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { signMessage } from "@ledgerhq/coin-bitcoin/hw-signMessage";
import { BitcoinAccount, Transaction, TransactionStatus } from "@ledgerhq/coin-bitcoin/types";
import { GetAddressOptions, Resolver } from "../../hw/getAddress/types";
import { withDevice } from "../../hw/deviceAccess";
import { startSpan } from "../../performance";
import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
import { getCurrencyConfiguration } from "../../config";
import { BitcoinConfigInfo } from "@ledgerhq/coin-bitcoin/lib/config";
Expand All @@ -36,13 +35,8 @@ const getCurrencyConfig = (currency: CryptoCurrency) => {
return { info: getCurrencyConfiguration<BitcoinConfigInfo>(currency) };
};

const perfLogger = {
startSpan,
};

const bridge: Bridge<Transaction, BitcoinAccount, TransactionStatus> = createBridges(
signerContext,
perfLogger,
getCurrencyConfig,
);

Expand Down
26 changes: 0 additions & 26 deletions libs/ledger-live-common/src/performance.test.ts

This file was deleted.

61 changes: 0 additions & 61 deletions libs/ledger-live-common/src/performance.ts

This file was deleted.

0 comments on commit fea9bae

Please sign in to comment.