From fbf27560b3eca06504994cca534799f27dd9f561 Mon Sep 17 00:00:00 2001
From: Mononaut
Date: Sat, 10 Aug 2024 13:53:49 +0000
Subject: [PATCH 1/5] optimize processNewBlocks
---
backend/src/api/mempool-blocks.ts | 92 +++++++++++++++++++++----------
1 file changed, 62 insertions(+), 30 deletions(-)
diff --git a/backend/src/api/mempool-blocks.ts b/backend/src/api/mempool-blocks.ts
index 5d9dcf8f4..6e547e653 100644
--- a/backend/src/api/mempool-blocks.ts
+++ b/backend/src/api/mempool-blocks.ts
@@ -369,7 +369,7 @@ class MempoolBlocks {
const lastBlockIndex = blocks.length - 1;
let hasBlockStack = blocks.length >= 8;
let stackWeight;
- let feeStatsCalculator: OnlineFeeStatsCalculator | void;
+ let feeStatsCalculator: OnlineFeeStatsCalculator | null = null;
if (hasBlockStack) {
if (blockWeights && blockWeights[7] !== null) {
stackWeight = blockWeights[7];
@@ -380,28 +380,36 @@ class MempoolBlocks {
feeStatsCalculator = new OnlineFeeStatsCalculator(stackWeight, 0.5, [10, 20, 30, 40, 50, 60, 70, 80, 90]);
}
+ const ancestors: Ancestor[] = [];
+ const descendants: Ancestor[] = [];
+ let ancestor: MempoolTransactionExtended
for (const cluster of clusters) {
for (const memberTxid of cluster) {
const mempoolTx = mempool[memberTxid];
if (mempoolTx) {
- const ancestors: Ancestor[] = [];
- const descendants: Ancestor[] = [];
+ // ugly micro-optimization to avoid allocating new arrays
+ ancestors.length = 0;
+ descendants.length = 0;
let matched = false;
cluster.forEach(txid => {
+ ancestor = mempool[txid];
if (txid === memberTxid) {
matched = true;
} else {
- if (!mempool[txid]) {
+ if (!ancestor) {
console.log('txid missing from mempool! ', txid, candidates?.txs[txid]);
+ return;
}
const relative = {
txid: txid,
- fee: mempool[txid].fee,
- weight: (mempool[txid].adjustedVsize * 4),
+ fee: ancestor.fee,
+ weight: (ancestor.adjustedVsize * 4),
};
if (matched) {
descendants.push(relative);
- mempoolTx.lastBoosted = Math.max(mempoolTx.lastBoosted || 0, mempool[txid].firstSeen || 0);
+ if (!mempoolTx.lastBoosted || (ancestor.firstSeen && ancestor.firstSeen > mempoolTx.lastBoosted)) {
+ mempoolTx.lastBoosted = ancestor.firstSeen;
+ }
} else {
ancestors.push(relative);
}
@@ -410,7 +418,20 @@ class MempoolBlocks {
if (mempoolTx.ancestors?.length !== ancestors.length || mempoolTx.descendants?.length !== descendants.length) {
mempoolTx.cpfpDirty = true;
}
- Object.assign(mempoolTx, {ancestors, descendants, bestDescendant: null, cpfpChecked: true});
+ // ugly micro-optimization to avoid allocating new arrays or objects
+ if (mempoolTx.ancestors) {
+ mempoolTx.ancestors.length = 0;
+ } else {
+ mempoolTx.ancestors = [];
+ }
+ if (mempoolTx.descendants) {
+ mempoolTx.descendants.length = 0;
+ } else {
+ mempoolTx.descendants = [];
+ }
+ mempoolTx.ancestors.push(...ancestors);
+ mempoolTx.descendants.push(...descendants);
+ mempoolTx.cpfpChecked = true;
}
}
}
@@ -420,7 +441,10 @@ class MempoolBlocks {
const sizeLimit = (config.MEMPOOL.BLOCK_WEIGHT_UNITS / 4) * 1.2;
// update this thread's mempool with the results
let mempoolTx: MempoolTransactionExtended;
- const mempoolBlocks: MempoolBlockWithTransactions[] = blocks.map((block, blockIndex) => {
+ let acceleration: Acceleration;
+ const mempoolBlocks: MempoolBlockWithTransactions[] = [];
+ for (let blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
+ const block = blocks[blockIndex];
let totalSize = 0;
let totalVsize = 0;
let totalWeight = 0;
@@ -436,7 +460,8 @@ class MempoolBlocks {
}
}
- for (const txid of block) {
+ for (let i = 0; i < block.length; i++) {
+ const txid = block[i];
if (txid) {
mempoolTx = mempool[txid];
// save position in projected blocks
@@ -445,30 +470,37 @@ class MempoolBlocks {
vsize: totalVsize + (mempoolTx.vsize / 2),
};
- const acceleration = accelerations[txid];
- if (isAcceleratedBy[txid] || (acceleration && (!accelerationPool || acceleration.pools.includes(accelerationPool)))) {
- if (!mempoolTx.acceleration) {
- mempoolTx.cpfpDirty = true;
- }
- mempoolTx.acceleration = true;
- mempoolTx.acceleratedBy = isAcceleratedBy[txid] || acceleration?.pools;
- mempoolTx.acceleratedAt = acceleration?.added;
- mempoolTx.feeDelta = acceleration?.feeDelta;
- for (const ancestor of mempoolTx.ancestors || []) {
- if (!mempool[ancestor.txid].acceleration) {
- mempool[ancestor.txid].cpfpDirty = true;
+ if (txid in accelerations) {
+ acceleration = accelerations[txid];
+ if (isAcceleratedBy[txid] || (acceleration && (!accelerationPool || acceleration.pools.includes(accelerationPool)))) {
+ if (!mempoolTx.acceleration) {
+ mempoolTx.cpfpDirty = true;
+ }
+ mempoolTx.acceleration = true;
+ mempoolTx.acceleratedBy = isAcceleratedBy[txid] || acceleration?.pools;
+ mempoolTx.acceleratedAt = acceleration?.added;
+ mempoolTx.feeDelta = acceleration?.feeDelta;
+ for (const ancestor of mempoolTx.ancestors || []) {
+ if (!mempool[ancestor.txid].acceleration) {
+ mempool[ancestor.txid].cpfpDirty = true;
+ }
+ mempool[ancestor.txid].acceleration = true;
+ mempool[ancestor.txid].acceleratedBy = mempoolTx.acceleratedBy;
+ mempool[ancestor.txid].acceleratedAt = mempoolTx.acceleratedAt;
+ mempool[ancestor.txid].feeDelta = mempoolTx.feeDelta;
+ isAcceleratedBy[ancestor.txid] = mempoolTx.acceleratedBy;
+ }
+ } else {
+ if (mempoolTx.acceleration) {
+ mempoolTx.cpfpDirty = true;
+ delete mempoolTx.acceleration;
}
- mempool[ancestor.txid].acceleration = true;
- mempool[ancestor.txid].acceleratedBy = mempoolTx.acceleratedBy;
- mempool[ancestor.txid].acceleratedAt = mempoolTx.acceleratedAt;
- mempool[ancestor.txid].feeDelta = mempoolTx.feeDelta;
- isAcceleratedBy[ancestor.txid] = mempoolTx.acceleratedBy;
}
} else {
if (mempoolTx.acceleration) {
mempoolTx.cpfpDirty = true;
+ delete mempoolTx.acceleration;
}
- delete mempoolTx.acceleration;
}
// online calculation of stack-of-blocks fee stats
@@ -486,7 +518,7 @@ class MempoolBlocks {
}
}
}
- return this.dataToMempoolBlocks(
+ mempoolBlocks[blockIndex] = this.dataToMempoolBlocks(
block,
transactions,
totalSize,
@@ -494,7 +526,7 @@ class MempoolBlocks {
totalFees,
(hasBlockStack && blockIndex === lastBlockIndex && feeStatsCalculator) ? feeStatsCalculator.getRawFeeStats() : undefined,
);
- });
+ };
if (saveResults) {
const deltas = this.calculateMempoolDeltas(this.mempoolBlocks, mempoolBlocks);
From 0f1def58226038d8047fac2eb3e9fa530700df0a Mon Sep 17 00:00:00 2001
From: nymkappa <9780671+nymkappa@users.noreply.github.com>
Date: Thu, 29 Aug 2024 20:53:40 +0200
Subject: [PATCH 2/5] [accelerator] make bid boost graph bar min height taller
---
.../acceleration-fees-graph.component.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontend/src/app/components/acceleration/acceleration-fees-graph/acceleration-fees-graph.component.ts b/frontend/src/app/components/acceleration/acceleration-fees-graph/acceleration-fees-graph.component.ts
index d78b663a4..68a2bdd52 100644
--- a/frontend/src/app/components/acceleration/acceleration-fees-graph/acceleration-fees-graph.component.ts
+++ b/frontend/src/app/components/acceleration/acceleration-fees-graph/acceleration-fees-graph.component.ts
@@ -264,7 +264,7 @@ export class AccelerationFeesGraphComponent implements OnInit, OnChanges, OnDest
type: 'bar',
barWidth: '90%',
large: true,
- barMinHeight: 1,
+ barMinHeight: 3,
},
],
dataZoom: (this.widget || data.length === 0 )? undefined : [{
From 04605e10a53a41c1f28bb17fdcae59ca57bdff5b Mon Sep 17 00:00:00 2001
From: softsimon
Date: Wed, 7 Aug 2024 11:44:21 +0200
Subject: [PATCH 3/5] only use sats, not sat
---
.../accelerate-checkout/accelerate-fee-graph.component.html | 2 +-
.../acceleration-timeline-tooltip.component.html | 6 +++---
.../accelerations-list/accelerations-list.component.html | 4 ++--
.../block-overview-tooltip.component.html | 2 +-
.../rbf-timeline/rbf-timeline-tooltip.component.html | 2 +-
.../transaction/transaction-preview.component.html | 2 +-
.../app/components/transaction/transaction.component.html | 4 ++--
.../transactions-list/transactions-list.component.html | 2 +-
8 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/frontend/src/app/components/accelerate-checkout/accelerate-fee-graph.component.html b/frontend/src/app/components/accelerate-checkout/accelerate-fee-graph.component.html
index a5e258210..564ee0ad1 100644
--- a/frontend/src/app/components/accelerate-checkout/accelerate-fee-graph.component.html
+++ b/frontend/src/app/components/accelerate-checkout/accelerate-fee-graph.component.html
@@ -12,7 +12,7 @@
- {{ bar.class === 'tx' ? '' : '+' }}{{ bar.fee | number }} sat
+ {{ bar.class === 'tx' ? '' : '+' }}{{ bar.fee | number }} sats
diff --git a/frontend/src/app/components/acceleration-timeline/acceleration-timeline-tooltip.component.html b/frontend/src/app/components/acceleration-timeline/acceleration-timeline-tooltip.component.html
index 07bcdc2f1..0f436f9ac 100644
--- a/frontend/src/app/components/acceleration-timeline/acceleration-timeline-tooltip.component.html
+++ b/frontend/src/app/components/acceleration-timeline/acceleration-timeline-tooltip.component.html
@@ -21,14 +21,14 @@
Fee |
- {{ accelerationInfo.fee | number }} sat |
+ {{ accelerationInfo.fee | number }} sats |
= 0 || accelerationInfo.feeDelta">
Out-of-band fees |
@if (accelerationInfo.status === 'accelerated') {
- {{ accelerationInfo.feeDelta | number }} sat |
+ {{ accelerationInfo.feeDelta | number }} sats |
} @else {
- {{ accelerationInfo.bidBoost | number }} sat |
+ {{ accelerationInfo.bidBoost | number }} sats |
}
diff --git a/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.html b/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.html
index 8bdd4f14d..ffd8e9c3d 100644
--- a/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.html
+++ b/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.html
@@ -33,7 +33,7 @@
- {{ (acceleration.feeDelta) | number }} sat
+ {{ (acceleration.feeDelta) | number }} sats
|
@@ -41,7 +41,7 @@
- {{ acceleration.boost | number }} sat
+ {{ acceleration.boost | number }} sats
|
~
diff --git a/frontend/src/app/components/block-overview-tooltip/block-overview-tooltip.component.html b/frontend/src/app/components/block-overview-tooltip/block-overview-tooltip.component.html
index f1f5bb3d4..f8fb3c89d 100644
--- a/frontend/src/app/components/block-overview-tooltip/block-overview-tooltip.component.html
+++ b/frontend/src/app/components/block-overview-tooltip/block-overview-tooltip.component.html
@@ -40,7 +40,7 @@
| |
Fee |
- {{ fee | number }} sat
+ | {{ fee | number }} sats
|
Fee rate |
diff --git a/frontend/src/app/components/rbf-timeline/rbf-timeline-tooltip.component.html b/frontend/src/app/components/rbf-timeline/rbf-timeline-tooltip.component.html
index 46cda0488..19c08bad9 100644
--- a/frontend/src/app/components/rbf-timeline/rbf-timeline-tooltip.component.html
+++ b/frontend/src/app/components/rbf-timeline/rbf-timeline-tooltip.component.html
@@ -19,7 +19,7 @@
Fee |
- {{ rbfInfo.tx.fee | number }} sat |
+ {{ rbfInfo.tx.fee | number }} sats |
Virtual size |
diff --git a/frontend/src/app/components/transaction/transaction-preview.component.html b/frontend/src/app/components/transaction/transaction-preview.component.html
index 63a11a8f0..066e0d442 100644
--- a/frontend/src/app/components/transaction/transaction-preview.component.html
+++ b/frontend/src/app/components/transaction/transaction-preview.component.html
@@ -21,7 +21,7 @@
0">{{ transactionTime * 1000 | date:'yyyy-MM-dd HH:mm' }}
- Fee {{ tx.fee | number }} sat
+ Fee {{ tx.fee | number }} sats
diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html
index b2e55a3b0..c0f5c6103 100644
--- a/frontend/src/app/components/transaction/transaction.component.html
+++ b/frontend/src/app/components/transaction/transaction.component.html
@@ -606,9 +606,9 @@
@if (!isLoadingTx) {
Fee |
- {{ tx.fee | number }} sat
+ | {{ tx.fee | number }} sats
@if (accelerationInfo?.bidBoost ?? tx.feeDelta > 0) {
- +{{ accelerationInfo?.bidBoost ?? tx.feeDelta | number }} sat
+ +{{ accelerationInfo?.bidBoost ?? tx.feeDelta | number }} sats
}
|
diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.html b/frontend/src/app/components/transactions-list/transactions-list.component.html
index 8954e4ecb..9b88678b4 100644
--- a/frontend/src/app/components/transactions-list/transactions-list.component.html
+++ b/frontend/src/app/components/transactions-list/transactions-list.component.html
@@ -321,7 +321,7 @@
– {{ tx.fee | number }} sat
+ i18n="shared.sats">sats
Show more inputs to reveal fee data
From 72a5f4a521177c9cc60cb4f7b779708b5e791215 Mon Sep 17 00:00:00 2001
From: softsimon
Date: Mon, 23 Sep 2024 00:18:59 +0800
Subject: [PATCH 4/5] amount selector sat -> sats
---
.../components/amount-selector/amount-selector.component.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontend/src/app/components/amount-selector/amount-selector.component.html b/frontend/src/app/components/amount-selector/amount-selector.component.html
index b509d6fe3..a16a24d4f 100644
--- a/frontend/src/app/components/amount-selector/amount-selector.component.html
+++ b/frontend/src/app/components/amount-selector/amount-selector.component.html
@@ -1,7 +1,7 @@
From e144e139b70bec3af496725a88706d41179912d6 Mon Sep 17 00:00:00 2001
From: Mononaut
Date: Sun, 22 Sep 2024 18:06:55 +0000
Subject: [PATCH 5/5] Update accelerating pie chart in real time
---
.../active-acceleration-box.component.html | 4 ++--
.../active-acceleration-box.component.ts | 12 ++++++++----
.../transaction/transaction.component.html | 2 +-
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/frontend/src/app/components/acceleration/active-acceleration-box/active-acceleration-box.component.html b/frontend/src/app/components/acceleration/active-acceleration-box/active-acceleration-box.component.html
index 13d38443e..dbc79fb95 100644
--- a/frontend/src/app/components/acceleration/active-acceleration-box/active-acceleration-box.component.html
+++ b/frontend/src/app/components/acceleration/active-acceleration-box/active-acceleration-box.component.html
@@ -10,10 +10,10 @@
- @if (accelerationInfo?.acceleratedFeeRate && (!tx.effectiveFeePerVsize || accelerationInfo.acceleratedFeeRate >= tx.effectiveFeePerVsize)) {
+ @if (accelerationInfo?.acceleratedFeeRate && (!effectiveFeeRate || accelerationInfo.acceleratedFeeRate >= effectiveFeeRate)) {
} @else {
-
+
}
|
diff --git a/frontend/src/app/components/acceleration/active-acceleration-box/active-acceleration-box.component.ts b/frontend/src/app/components/acceleration/active-acceleration-box/active-acceleration-box.component.ts
index f95bb71c8..fb727c1a4 100644
--- a/frontend/src/app/components/acceleration/active-acceleration-box/active-acceleration-box.component.ts
+++ b/frontend/src/app/components/acceleration/active-acceleration-box/active-acceleration-box.component.ts
@@ -1,4 +1,4 @@
-import { Component, ChangeDetectionStrategy, Input, Output, OnChanges, SimpleChanges, EventEmitter } from '@angular/core';
+import { Component, ChangeDetectionStrategy, Input, Output, OnChanges, SimpleChanges, EventEmitter, ChangeDetectorRef } from '@angular/core';
import { Transaction } from '../../../interfaces/electrs.interface';
import { Acceleration, SinglePoolStats } from '../../../interfaces/node-api.interface';
import { EChartsOption, PieSeriesOption } from '../../../graphs/echarts';
@@ -23,7 +23,8 @@ function toRGB({r,g,b}): string {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ActiveAccelerationBox implements OnChanges {
- @Input() tx: Transaction;
+ @Input() acceleratedBy?: number[];
+ @Input() effectiveFeeRate?: number;
@Input() accelerationInfo: Acceleration;
@Input() miningStats: MiningStats;
@Input() pools: number[];
@@ -41,10 +42,12 @@ export class ActiveAccelerationBox implements OnChanges {
timespan = '';
chartInstance: any = undefined;
- constructor() {}
+ constructor(
+ private cd: ChangeDetectorRef,
+ ) {}
ngOnChanges(changes: SimpleChanges): void {
- const pools = this.pools || this.accelerationInfo?.pools || this.tx.acceleratedBy;
+ const pools = this.pools || this.accelerationInfo?.pools || this.acceleratedBy;
if (pools && this.miningStats) {
this.prepareChartOptions(pools);
}
@@ -132,6 +135,7 @@ export class ActiveAccelerationBox implements OnChanges {
}
]
};
+ this.cd.markForCheck();
}
onChartInit(ec) {
diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html
index c0f5c6103..9d3c0d678 100644
--- a/frontend/src/app/components/transaction/transaction.component.html
+++ b/frontend/src/app/components/transaction/transaction.component.html
@@ -670,7 +670,7 @@
-
+
|