tighten sanity checks in block audit
This commit is contained in:
parent
28de93d0ff
commit
61f24562fd
@ -39,17 +39,19 @@ class Audit {
|
|||||||
} else {
|
} else {
|
||||||
isCensored[txid] = true;
|
isCensored[txid] = true;
|
||||||
}
|
}
|
||||||
displacedWeight += mempool[txid].weight;
|
displacedWeight += mempool[txid]?.weight || 0;
|
||||||
} else {
|
} else {
|
||||||
matchedWeight += mempool[txid].weight;
|
matchedWeight += mempool[txid]?.weight || 0;
|
||||||
}
|
}
|
||||||
projectedWeight += mempool[txid].weight;
|
projectedWeight += mempool[txid]?.weight || 0;
|
||||||
inTemplate[txid] = true;
|
inTemplate[txid] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
displacedWeight += (4000 - transactions[0].weight);
|
if (transactions[0]) {
|
||||||
projectedWeight += transactions[0].weight;
|
displacedWeight += (4000 - transactions[0].weight);
|
||||||
matchedWeight += transactions[0].weight;
|
projectedWeight += transactions[0].weight;
|
||||||
|
matchedWeight += transactions[0].weight;
|
||||||
|
}
|
||||||
|
|
||||||
// we can expect an honest miner to include 'displaced' transactions in place of recent arrivals and censored txs
|
// we can expect an honest miner to include 'displaced' transactions in place of recent arrivals and censored txs
|
||||||
// these displaced transactions should occupy the first N weight units of the next projected block
|
// these displaced transactions should occupy the first N weight units of the next projected block
|
||||||
@ -59,19 +61,22 @@ class Audit {
|
|||||||
let failures = 0;
|
let failures = 0;
|
||||||
while (projectedBlocks[1] && index < projectedBlocks[1].transactionIds.length && failures < 500) {
|
while (projectedBlocks[1] && index < projectedBlocks[1].transactionIds.length && failures < 500) {
|
||||||
const txid = projectedBlocks[1].transactionIds[index];
|
const txid = projectedBlocks[1].transactionIds[index];
|
||||||
const fits = (mempool[txid].weight - displacedWeightRemaining) < 4000;
|
const tx = mempool[txid];
|
||||||
const feeMatches = mempool[txid].effectiveFeePerVsize >= lastFeeRate;
|
if (tx) {
|
||||||
if (fits || feeMatches) {
|
const fits = (tx.weight - displacedWeightRemaining) < 4000;
|
||||||
isDisplaced[txid] = true;
|
const feeMatches = tx.effectiveFeePerVsize >= lastFeeRate;
|
||||||
if (fits) {
|
if (fits || feeMatches) {
|
||||||
lastFeeRate = Math.min(lastFeeRate, mempool[txid].effectiveFeePerVsize);
|
isDisplaced[txid] = true;
|
||||||
|
if (fits) {
|
||||||
|
lastFeeRate = Math.min(lastFeeRate, tx.effectiveFeePerVsize);
|
||||||
|
}
|
||||||
|
if (tx.firstSeen == null || (now - (tx?.firstSeen || 0)) > PROPAGATION_MARGIN) {
|
||||||
|
displacedWeightRemaining -= tx.weight;
|
||||||
|
}
|
||||||
|
failures = 0;
|
||||||
|
} else {
|
||||||
|
failures++;
|
||||||
}
|
}
|
||||||
if (mempool[txid].firstSeen == null || (now - (mempool[txid]?.firstSeen || 0)) > PROPAGATION_MARGIN) {
|
|
||||||
displacedWeightRemaining -= mempool[txid].weight;
|
|
||||||
}
|
|
||||||
failures = 0;
|
|
||||||
} else {
|
|
||||||
failures++;
|
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@ -108,20 +113,23 @@ class Audit {
|
|||||||
index = projectedBlocks[0].transactionIds.length - 1;
|
index = projectedBlocks[0].transactionIds.length - 1;
|
||||||
while (index >= 0) {
|
while (index >= 0) {
|
||||||
const txid = projectedBlocks[0].transactionIds[index];
|
const txid = projectedBlocks[0].transactionIds[index];
|
||||||
if (overflowWeightRemaining > 0) {
|
const tx = mempool[txid];
|
||||||
if (isCensored[txid]) {
|
if (tx) {
|
||||||
delete isCensored[txid];
|
if (overflowWeightRemaining > 0) {
|
||||||
}
|
if (isCensored[txid]) {
|
||||||
if (mempool[txid].effectiveFeePerVsize > maxOverflowRate) {
|
delete isCensored[txid];
|
||||||
maxOverflowRate = mempool[txid].effectiveFeePerVsize;
|
}
|
||||||
rateThreshold = (Math.ceil(maxOverflowRate * 100) / 100) + 0.005;
|
if (tx.effectiveFeePerVsize > maxOverflowRate) {
|
||||||
}
|
maxOverflowRate = tx.effectiveFeePerVsize;
|
||||||
} else if (mempool[txid].effectiveFeePerVsize <= rateThreshold) { // tolerance of 0.01 sat/vb + rounding
|
rateThreshold = (Math.ceil(maxOverflowRate * 100) / 100) + 0.005;
|
||||||
if (isCensored[txid]) {
|
}
|
||||||
delete isCensored[txid];
|
} else if (tx.effectiveFeePerVsize <= rateThreshold) { // tolerance of 0.01 sat/vb + rounding
|
||||||
|
if (isCensored[txid]) {
|
||||||
|
delete isCensored[txid];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
overflowWeightRemaining -= (mempool[txid]?.weight || 0);
|
||||||
}
|
}
|
||||||
overflowWeightRemaining -= (mempool[txid]?.weight || 0);
|
|
||||||
index--;
|
index--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user