From 79eb9635c2abb66c6987e13c0efeff67358c1220 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sat, 6 Apr 2024 07:59:18 +0000 Subject: [PATCH] Fix cpfp vsize rounding & goggles bugs --- backend/src/api/blocks.ts | 2 +- backend/src/api/common.ts | 3 +++ backend/src/api/transaction-utils.ts | 4 ++-- .../block-overview-tooltip.component.ts | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index a36f18200..97b5d2055 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -1151,7 +1151,7 @@ class Blocks { transactions: cpfpSummary.transactions.map(tx => { let flags: number = 0; try { - flags = tx.flags || Common.getTransactionFlags(tx); + flags = Common.getTransactionFlags(tx); } catch (e) { logger.warn('Failed to classify transaction: ' + (e instanceof Error ? e.message : e)); } diff --git a/backend/src/api/common.ts b/backend/src/api/common.ts index dffabce0a..cba39a511 100644 --- a/backend/src/api/common.ts +++ b/backend/src/api/common.ts @@ -419,12 +419,15 @@ export class Common { let flags = tx.flags ? BigInt(tx.flags) : 0n; // Update variable flags (CPFP, RBF) + flags &= ~TransactionFlags.cpfp_child; if (tx.ancestors?.length) { flags |= TransactionFlags.cpfp_child; } + flags &= ~TransactionFlags.cpfp_parent; if (tx.descendants?.length) { flags |= TransactionFlags.cpfp_parent; } + flags &= ~TransactionFlags.replacement; if (tx.replacement) { flags |= TransactionFlags.replacement; } diff --git a/backend/src/api/transaction-utils.ts b/backend/src/api/transaction-utils.ts index 9107f2ae7..b3077b935 100644 --- a/backend/src/api/transaction-utils.ts +++ b/backend/src/api/transaction-utils.ts @@ -103,7 +103,7 @@ class TransactionUtils { } const feePerVbytes = (transaction.fee || 0) / (transaction.weight / 4); const transactionExtended: TransactionExtended = Object.assign({ - vsize: Math.round(transaction.weight / 4), + vsize: transaction.weight / 4, feePerVsize: feePerVbytes, effectiveFeePerVsize: feePerVbytes, }, transaction); @@ -123,7 +123,7 @@ class TransactionUtils { const adjustedFeePerVsize = (transaction.fee || 0) / adjustedVsize; const transactionExtended: MempoolTransactionExtended = Object.assign(transaction, { order: this.txidToOrdering(transaction.txid), - vsize: Math.round(transaction.weight / 4), + vsize, adjustedVsize, sigops, feePerVsize: feePerVbytes, diff --git a/frontend/src/app/components/block-overview-tooltip/block-overview-tooltip.component.ts b/frontend/src/app/components/block-overview-tooltip/block-overview-tooltip.component.ts index d59bfa87f..16cba08c0 100644 --- a/frontend/src/app/components/block-overview-tooltip/block-overview-tooltip.component.ts +++ b/frontend/src/app/components/block-overview-tooltip/block-overview-tooltip.component.ts @@ -68,7 +68,7 @@ export class BlockOverviewTooltipComponent implements OnChanges { this.effectiveRate = this.tx.rate; const txFlags = BigInt(this.tx.flags) || 0n; this.acceleration = this.tx.acc || (txFlags & TransactionFlags.acceleration); - this.hasEffectiveRate = this.tx.acc || Math.abs((this.fee / this.vsize) - this.effectiveRate) > 0.05 + this.hasEffectiveRate = this.tx.acc || !(Math.abs((this.fee / this.vsize) - this.effectiveRate) <= 0.05 && Math.abs((this.fee / Math.ceil(this.vsize)) - this.effectiveRate) <= 0.05) || (txFlags && (txFlags & (TransactionFlags.cpfp_child | TransactionFlags.cpfp_parent)) > 0n); this.filters = this.tx.flags ? toFilters(txFlags).filter(f => f.tooltip) : []; this.activeFilters = {}