Merge pull request #4761 from mempool/mononaut/fix-block-acc-fees
Fix block acceleration fees calculation & api bugs
This commit is contained in:
commit
3d61e57b00
@ -33,7 +33,7 @@ interface GraphTx {
|
|||||||
vsize: number;
|
vsize: number;
|
||||||
weight: number;
|
weight: number;
|
||||||
fees: {
|
fees: {
|
||||||
base: number;
|
base: number; // in sats
|
||||||
};
|
};
|
||||||
depends: string[];
|
depends: string[];
|
||||||
spentby: string[];
|
spentby: string[];
|
||||||
@ -42,7 +42,7 @@ interface GraphTx {
|
|||||||
interface MempoolTx extends GraphTx {
|
interface MempoolTx extends GraphTx {
|
||||||
ancestorcount: number;
|
ancestorcount: number;
|
||||||
ancestorsize: number;
|
ancestorsize: number;
|
||||||
fees: {
|
fees: { // in sats
|
||||||
base: number;
|
base: number;
|
||||||
ancestor: number;
|
ancestor: number;
|
||||||
};
|
};
|
||||||
@ -317,7 +317,7 @@ class AccelerationCosts {
|
|||||||
throw new Error('invalid_tx_dependencies');
|
throw new Error('invalid_tx_dependencies');
|
||||||
}
|
}
|
||||||
|
|
||||||
let totalFee = Math.round(tx.fees.ancestor * 100_000_000);
|
let totalFee = tx.fees.ancestor;
|
||||||
|
|
||||||
// transaction is already CPFP-d above the target rate by some descendant
|
// transaction is already CPFP-d above the target rate by some descendant
|
||||||
if (includedInCluster) {
|
if (includedInCluster) {
|
||||||
@ -325,7 +325,7 @@ class AccelerationCosts {
|
|||||||
let clusterFee = 0;
|
let clusterFee = 0;
|
||||||
includedInCluster.forEach(entry => {
|
includedInCluster.forEach(entry => {
|
||||||
clusterSize += entry.vsize;
|
clusterSize += entry.vsize;
|
||||||
clusterFee += (entry.fees.base * 100_000_000);
|
clusterFee += entry.fees.base;
|
||||||
});
|
});
|
||||||
const clusterRate = clusterFee / clusterSize;
|
const clusterRate = clusterFee / clusterSize;
|
||||||
totalFee = Math.ceil(tx.ancestorsize * clusterRate);
|
totalFee = Math.ceil(tx.ancestorsize * clusterRate);
|
||||||
@ -448,8 +448,8 @@ class AccelerationCosts {
|
|||||||
* @param tx
|
* @param tx
|
||||||
*/
|
*/
|
||||||
private setAncestorScores(tx: MempoolTx): void {
|
private setAncestorScores(tx: MempoolTx): void {
|
||||||
tx.individualRate = (tx.fees.base * 100_000_000) / tx.vsize;
|
tx.individualRate = tx.fees.base / tx.vsize;
|
||||||
tx.ancestorRate = (tx.fees.ancestor * 100_000_000) / tx.ancestorsize;
|
tx.ancestorRate = tx.fees.ancestor / tx.ancestorsize;
|
||||||
tx.score = Math.min(tx.individualRate, tx.ancestorRate);
|
tx.score = Math.min(tx.individualRate, tx.ancestorRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import cpfpRepository from '../repositories/CpfpRepository';
|
|||||||
import { RowDataPacket } from 'mysql2';
|
import { RowDataPacket } from 'mysql2';
|
||||||
|
|
||||||
class DatabaseMigration {
|
class DatabaseMigration {
|
||||||
private static currentVersion = 72;
|
private static currentVersion = 73;
|
||||||
private queryTimeout = 3600_000;
|
private queryTimeout = 3600_000;
|
||||||
private statisticsAddedIndexed = false;
|
private statisticsAddedIndexed = false;
|
||||||
private uniqueLogs: string[] = [];
|
private uniqueLogs: string[] = [];
|
||||||
@ -612,6 +612,13 @@ class DatabaseMigration {
|
|||||||
await this.$executeQuery('UPDATE blocks_summaries SET version = 0 WHERE height >= 832000;');
|
await this.$executeQuery('UPDATE blocks_summaries SET version = 0 WHERE height >= 832000;');
|
||||||
await this.updateToSchemaVersion(72);
|
await this.updateToSchemaVersion(72);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (databaseSchemaVersion < 73 && isBitcoin === true) {
|
||||||
|
// Clear bad data
|
||||||
|
await this.$executeQuery(`TRUNCATE accelerations`);
|
||||||
|
this.uniqueLog(logger.notice, `'accelerations' table has been truncated`);
|
||||||
|
await this.updateToSchemaVersion(73);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,7 +73,8 @@ class AccelerationRepository {
|
|||||||
|
|
||||||
if (interval) {
|
if (interval) {
|
||||||
query += ` WHERE accelerations.added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() `;
|
query += ` WHERE accelerations.added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() `;
|
||||||
} else if (height != null) {
|
}
|
||||||
|
if (height != null) {
|
||||||
query += ` WHERE accelerations.height = ? `;
|
query += ` WHERE accelerations.height = ? `;
|
||||||
params.push(height);
|
params.push(height);
|
||||||
} else if (poolSlug != null) {
|
} else if (poolSlug != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user