Increase success threshold for fee estimation to 95%
This provides more conservative estimates and reacts more quickly to a backlog. Unfortunately the unit test for fee estimation depends on the success threshold (and the decay) chosen; also modify the unit test for the new default success thresholds.
This commit is contained in:
parent
4fe28236c0
commit
f22ac4a22c
2 changed files with 22 additions and 19 deletions
|
@ -182,8 +182,8 @@ static const unsigned int MAX_BLOCK_CONFIRMS = 25;
|
||||||
/** Decay of .998 is a half-life of 346 blocks or about 2.4 days */
|
/** Decay of .998 is a half-life of 346 blocks or about 2.4 days */
|
||||||
static const double DEFAULT_DECAY = .998;
|
static const double DEFAULT_DECAY = .998;
|
||||||
|
|
||||||
/** Require greater than 85% of X fee transactions to be confirmed within Y blocks for X to be big enough */
|
/** Require greater than 95% of X fee transactions to be confirmed within Y blocks for X to be big enough */
|
||||||
static const double MIN_SUCCESS_PCT = .85;
|
static const double MIN_SUCCESS_PCT = .95;
|
||||||
static const double UNLIKELY_PCT = .5;
|
static const double UNLIKELY_PCT = .5;
|
||||||
|
|
||||||
/** Require an avg of 1 tx in the combined fee bucket per block to have stat significance */
|
/** Require an avg of 1 tx in the combined fee bucket per block to have stat significance */
|
||||||
|
|
|
@ -83,11 +83,13 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||||
block.clear();
|
block.clear();
|
||||||
if (blocknum == 30) {
|
if (blocknum == 30) {
|
||||||
// At this point we should need to combine 5 buckets to get enough data points
|
// At this point we should need to combine 5 buckets to get enough data points
|
||||||
// So estimateFee(1) should fail and estimateFee(2) should return somewhere around
|
// So estimateFee(1,2,3) should fail and estimateFee(4) should return somewhere around
|
||||||
// 8*baserate
|
// 8*baserate. estimateFee(4) %'s are 100,100,100,100,90 = average 98%
|
||||||
BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(0));
|
BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(0));
|
||||||
BOOST_CHECK(mpool.estimateFee(2).GetFeePerK() < 8*baseRate.GetFeePerK() + deltaFee);
|
BOOST_CHECK(mpool.estimateFee(2) == CFeeRate(0));
|
||||||
BOOST_CHECK(mpool.estimateFee(2).GetFeePerK() > 8*baseRate.GetFeePerK() - deltaFee);
|
BOOST_CHECK(mpool.estimateFee(3) == CFeeRate(0));
|
||||||
|
BOOST_CHECK(mpool.estimateFee(4).GetFeePerK() < 8*baseRate.GetFeePerK() + deltaFee);
|
||||||
|
BOOST_CHECK(mpool.estimateFee(4).GetFeePerK() > 8*baseRate.GetFeePerK() - deltaFee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,9 +98,9 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||||
// Highest feerate is 10*baseRate and gets in all blocks,
|
// Highest feerate is 10*baseRate and gets in all blocks,
|
||||||
// second highest feerate is 9*baseRate and gets in 9/10 blocks = 90%,
|
// second highest feerate is 9*baseRate and gets in 9/10 blocks = 90%,
|
||||||
// third highest feerate is 8*base rate, and gets in 8/10 blocks = 80%,
|
// third highest feerate is 8*base rate, and gets in 8/10 blocks = 80%,
|
||||||
// so estimateFee(1) should return 9*baseRate.
|
// so estimateFee(1) should return 10*baseRate.
|
||||||
// Third highest feerate has 90% chance of being included by 2 blocks,
|
// Second highest feerate has 100% chance of being included by 2 blocks,
|
||||||
// so estimateFee(2) should return 8*baseRate etc...
|
// so estimateFee(2) should return 9*baseRate etc...
|
||||||
for (int i = 1; i < 10;i++) {
|
for (int i = 1; i < 10;i++) {
|
||||||
origFeeEst.push_back(mpool.estimateFee(i).GetFeePerK());
|
origFeeEst.push_back(mpool.estimateFee(i).GetFeePerK());
|
||||||
origPriEst.push_back(mpool.estimatePriority(i));
|
origPriEst.push_back(mpool.estimatePriority(i));
|
||||||
|
@ -106,10 +108,11 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||||
BOOST_CHECK(origFeeEst[i-1] <= origFeeEst[i-2]);
|
BOOST_CHECK(origFeeEst[i-1] <= origFeeEst[i-2]);
|
||||||
BOOST_CHECK(origPriEst[i-1] <= origPriEst[i-2]);
|
BOOST_CHECK(origPriEst[i-1] <= origPriEst[i-2]);
|
||||||
}
|
}
|
||||||
BOOST_CHECK(origFeeEst[i-1] < (10-i)*baseRate.GetFeePerK() + deltaFee);
|
int mult = 11-i;
|
||||||
BOOST_CHECK(origFeeEst[i-1] > (10-i)*baseRate.GetFeePerK() - deltaFee);
|
BOOST_CHECK(origFeeEst[i-1] < mult*baseRate.GetFeePerK() + deltaFee);
|
||||||
BOOST_CHECK(origPriEst[i-1] < pow(10,10-i) * basepri + deltaPri);
|
BOOST_CHECK(origFeeEst[i-1] > mult*baseRate.GetFeePerK() - deltaFee);
|
||||||
BOOST_CHECK(origPriEst[i-1] > pow(10,10-i) * basepri - deltaPri);
|
BOOST_CHECK(origPriEst[i-1] < pow(10,mult) * basepri + deltaPri);
|
||||||
|
BOOST_CHECK(origPriEst[i-1] > pow(10,mult) * basepri - deltaPri);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mine 50 more blocks with no transactions happening, estimates shouldn't change
|
// Mine 50 more blocks with no transactions happening, estimates shouldn't change
|
||||||
|
@ -140,8 +143,8 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < 10;i++) {
|
for (int i = 1; i < 10;i++) {
|
||||||
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() > origFeeEst[i-1] - deltaFee);
|
BOOST_CHECK(mpool.estimateFee(i) == CFeeRate(0) || mpool.estimateFee(i).GetFeePerK() > origFeeEst[i-1] - deltaFee);
|
||||||
BOOST_CHECK(mpool.estimatePriority(i) > origPriEst[i-1] - deltaPri);
|
BOOST_CHECK(mpool.estimatePriority(i) == -1 || mpool.estimatePriority(i) > origPriEst[i-1] - deltaPri);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mine all those transactions
|
// Mine all those transactions
|
||||||
|
@ -161,9 +164,9 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||||
BOOST_CHECK(mpool.estimatePriority(i) > origPriEst[i-1] - deltaPri);
|
BOOST_CHECK(mpool.estimatePriority(i) > origPriEst[i-1] - deltaPri);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mine 100 more blocks where everything is mined every block
|
// Mine 200 more blocks where everything is mined every block
|
||||||
// Estimates should be below original estimates (not possible for last estimate)
|
// Estimates should be below original estimates
|
||||||
while (blocknum < 365) {
|
while (blocknum < 465) {
|
||||||
for (int j = 0; j < 10; j++) { // For each fee/pri multiple
|
for (int j = 0; j < 10; j++) { // For each fee/pri multiple
|
||||||
for (int k = 0; k < 5; k++) { // add 4 fee txs for every priority tx
|
for (int k = 0; k < 5; k++) { // add 4 fee txs for every priority tx
|
||||||
tx.vin[0].prevout.n = 10000*blocknum+100*j+k;
|
tx.vin[0].prevout.n = 10000*blocknum+100*j+k;
|
||||||
|
@ -177,7 +180,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||||
mpool.removeForBlock(block, ++blocknum, dummyConflicted);
|
mpool.removeForBlock(block, ++blocknum, dummyConflicted);
|
||||||
block.clear();
|
block.clear();
|
||||||
}
|
}
|
||||||
for (int i = 1; i < 9; i++) {
|
for (int i = 1; i < 10; i++) {
|
||||||
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() < origFeeEst[i-1] - deltaFee);
|
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() < origFeeEst[i-1] - deltaFee);
|
||||||
BOOST_CHECK(mpool.estimatePriority(i) < origPriEst[i-1] - deltaPri);
|
BOOST_CHECK(mpool.estimatePriority(i) < origPriEst[i-1] - deltaPri);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue