fix pool-dependent accelerated audit handling
This commit is contained in:
parent
7c641544b2
commit
928a8be846
@ -130,7 +130,7 @@ impl AuditTransaction {
|
|||||||
score: 0.0,
|
score: 0.0,
|
||||||
used: false,
|
used: false,
|
||||||
modified: false,
|
modified: false,
|
||||||
dirty: effective_fee_per_vsize != tx.effective_fee_per_vsize,
|
dirty: effective_fee_per_vsize != tx.effective_fee_per_vsize || fee_delta > 0.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ class MempoolBlocks {
|
|||||||
return this.$rustMakeBlockTemplates(newMempool, false, useAccelerations, accelerationPool);
|
return this.$rustMakeBlockTemplates(newMempool, false, useAccelerations, accelerationPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async $rustUpdateBlockTemplates(newMempool: { [txid: string]: MempoolTransactionExtended }, mempoolSize: number, added: MempoolTransactionExtended[], removed: MempoolTransactionExtended[], useAccelerations: boolean, accelerationPool?: number): Promise<void> {
|
public async $rustUpdateBlockTemplates(newMempool: { [txid: string]: MempoolTransactionExtended }, mempoolSize: number, added: MempoolTransactionExtended[], removed: MempoolTransactionExtended[], useAccelerations: boolean, accelerationPool?: number): Promise<MempoolBlockWithTransactions[]> {
|
||||||
// GBT optimization requires that uids never get too sparse
|
// GBT optimization requires that uids never get too sparse
|
||||||
// as a sanity check, we should also explicitly prevent uint32 uid overflow
|
// as a sanity check, we should also explicitly prevent uint32 uid overflow
|
||||||
if (this.nextUid + added.length >= Math.min(Math.max(262144, 2 * mempoolSize), MAX_UINT32)) {
|
if (this.nextUid + added.length >= Math.min(Math.max(262144, 2 * mempoolSize), MAX_UINT32)) {
|
||||||
@ -397,8 +397,7 @@ class MempoolBlocks {
|
|||||||
|
|
||||||
if (!this.rustInitialized) {
|
if (!this.rustInitialized) {
|
||||||
// need to reset the worker
|
// need to reset the worker
|
||||||
await this.$rustMakeBlockTemplates(newMempool, true, useAccelerations, accelerationPool);
|
return this.$rustMakeBlockTemplates(newMempool, true, useAccelerations, accelerationPool);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
@ -435,13 +434,15 @@ class MempoolBlocks {
|
|||||||
if (mempoolSize !== resultMempoolSize) {
|
if (mempoolSize !== resultMempoolSize) {
|
||||||
throw new Error('GBT returned wrong number of transactions, cache is probably out of sync');
|
throw new Error('GBT returned wrong number of transactions, cache is probably out of sync');
|
||||||
} else {
|
} else {
|
||||||
this.processBlockTemplates(newMempool, blocks, blockWeights, rates, clusters, accelerations, accelerationPool, true);
|
const processed = this.processBlockTemplates(newMempool, blocks, blockWeights, rates, clusters, accelerations, accelerationPool, true);
|
||||||
}
|
|
||||||
this.removeUids(removedUids);
|
this.removeUids(removedUids);
|
||||||
logger.debug(`RUST updateBlockTemplates completed in ${(Date.now() - start)/1000} seconds`);
|
logger.debug(`RUST updateBlockTemplates completed in ${(Date.now() - start)/1000} seconds`);
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err('RUST updateBlockTemplates failed. ' + (e instanceof Error ? e.message : e));
|
logger.err('RUST updateBlockTemplates failed. ' + (e instanceof Error ? e.message : e));
|
||||||
this.resetRustGbt();
|
this.resetRustGbt();
|
||||||
|
return this.mempoolBlocks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,7 +661,7 @@ class WebsocketHandler {
|
|||||||
const isAccelerated = config.MEMPOOL_SERVICES.ACCELERATIONS && accelerationApi.isAcceleratedBlock(block, Object.values(mempool.getAccelerations()));
|
const isAccelerated = config.MEMPOOL_SERVICES.ACCELERATIONS && accelerationApi.isAcceleratedBlock(block, Object.values(mempool.getAccelerations()));
|
||||||
// template calculation functions have mempool side effects, so calculate audits using
|
// template calculation functions have mempool side effects, so calculate audits using
|
||||||
// a cloned copy of the mempool if we're running a different algorithm for mempool updates
|
// a cloned copy of the mempool if we're running a different algorithm for mempool updates
|
||||||
const separateAudit = config.MEMPOOL.ADVANCED_GBT_AUDIT !== config.MEMPOOL.ADVANCED_GBT_MEMPOOL || isAccelerated;
|
const separateAudit = config.MEMPOOL.ADVANCED_GBT_AUDIT !== config.MEMPOOL.ADVANCED_GBT_MEMPOOL;
|
||||||
if (separateAudit) {
|
if (separateAudit) {
|
||||||
auditMempool = deepClone(_memPool);
|
auditMempool = deepClone(_memPool);
|
||||||
if (config.MEMPOOL.ADVANCED_GBT_AUDIT) {
|
if (config.MEMPOOL.ADVANCED_GBT_AUDIT) {
|
||||||
@ -674,8 +674,8 @@ class WebsocketHandler {
|
|||||||
projectedBlocks = mempoolBlocks.updateMempoolBlocks(auditMempool, false);
|
projectedBlocks = mempoolBlocks.updateMempoolBlocks(auditMempool, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((config.MEMPOOL_SERVICES.ACCELERATIONS && !isAccelerated)) {
|
if ((config.MEMPOOL_SERVICES.ACCELERATIONS)) {
|
||||||
projectedBlocks = await mempoolBlocks.$makeBlockTemplates(auditMempool, false, false);
|
projectedBlocks = await mempoolBlocks.$rustUpdateBlockTemplates(auditMempool, Object.keys(auditMempool).length, [], [], isAccelerated, block.extras.pool.id);
|
||||||
} else {
|
} else {
|
||||||
projectedBlocks = mempoolBlocks.getMempoolBlocksWithTransactions();
|
projectedBlocks = mempoolBlocks.getMempoolBlocksWithTransactions();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user