Skip to content

Commit

Permalink
Merge bitcoin#9548: Remove min reasonable fee
Browse files Browse the repository at this point in the history
ad82cb0 Remove unnecessary min fee argument in CTxMemPool constructor (Alex Morcos)
2a7b56c CBlockPolicyEstimator now uses hard coded minimum bucket feerate (Alex Morcos)
ac9d3d2 Change fee estimation bucket limit variable names (Alex Morcos)

Tree-SHA512: 6e3bc7df3497ed60c7620845d222063e33a0238020f5c3316e61e0eff758078588ea8dd51196ceb59aa561ba106f8cdae62cebe521adb3247108bb49f15252d6
  • Loading branch information
laanwj authored and PastaPastaPasta committed Feb 5, 2019
1 parent 1c08f9a commit b1d64f3
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/bench/mempool_eviction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void MempoolEviction(benchmark::State& state)
tx7.vout[1].scriptPubKey = CScript() << OP_7 << OP_EQUAL;
tx7.vout[1].nValue = 10 * COIN;

CTxMemPool pool(CFeeRate(1000));
CTxMemPool pool;

while (state.KeepRunning()) {
AddTx(tx1, 10000LL, pool);
Expand Down
8 changes: 4 additions & 4 deletions src/policy/fees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,13 @@ bool CBlockPolicyEstimator::removeTx(uint256 hash)
}
}

CBlockPolicyEstimator::CBlockPolicyEstimator(const CFeeRate& _minRelayFee)
CBlockPolicyEstimator::CBlockPolicyEstimator()
: nBestSeenHeight(0), trackedTxs(0), untrackedTxs(0)
{
static_assert(MIN_FEERATE > 0, "Min feerate must be nonzero");
minTrackedFee = _minRelayFee < CFeeRate(MIN_FEERATE) ? CFeeRate(MIN_FEERATE) : _minRelayFee;
static_assert(MIN_BUCKET_FEERATE > 0, "Min feerate must be nonzero");
minTrackedFee = CFeeRate(MIN_BUCKET_FEERATE);
std::vector<double> vfeelist;
for (double bucketBoundary = minTrackedFee.GetFeePerK(); bucketBoundary <= MAX_FEERATE; bucketBoundary *= FEE_SPACING) {
for (double bucketBoundary = minTrackedFee.GetFeePerK(); bucketBoundary <= MAX_BUCKET_FEERATE; bucketBoundary *= FEE_SPACING) {
vfeelist.push_back(bucketBoundary);
}
vfeelist.push_back(INF_FEERATE);
Expand Down
11 changes: 8 additions & 3 deletions src/policy/fees.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,13 @@ static const double MIN_SUCCESS_PCT = .95;
static const double SUFFICIENT_FEETXS = 1;

// Minimum and Maximum values for tracking feerates
static constexpr double MIN_FEERATE = 10;
static const double MAX_FEERATE = 1e7;
// The MIN_BUCKET_FEERATE should just be set to the lowest reasonable feerate we
// might ever want to track. Historically this has been 1000 since it was
// inheriting DEFAULT_MIN_RELAY_TX_FEE and changing it is disruptive as it
// invalidates old estimates files. So leave it at 1000 unless it becomes
// necessary to lower it, and then lower it substantially.
static constexpr double MIN_BUCKET_FEERATE = 1000;
static const double MAX_BUCKET_FEERATE = 1e7;
static const double INF_FEERATE = MAX_MONEY;
static const double INF_PRIORITY = 1e9 * MAX_MONEY;

Expand All @@ -199,7 +204,7 @@ class CBlockPolicyEstimator
{
public:
/** Create new BlockPolicyEstimator and initialize stats tracking classes with default values */
CBlockPolicyEstimator(const CFeeRate& minRelayFee);
CBlockPolicyEstimator();

/** Process all the transactions that have been included in a block */
void processBlock(unsigned int nBlockHeight,
Expand Down
8 changes: 4 additions & 4 deletions src/test/blockencodings_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static CBlock BuildBlockTestCase() {

BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
{
CTxMemPool pool(CFeeRate(0));
CTxMemPool pool;
TestMemPoolEntryHelper entry;
CBlock block(BuildBlockTestCase());

Expand Down Expand Up @@ -156,7 +156,7 @@ class TestHeaderAndShortIDs {

BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
{
CTxMemPool pool(CFeeRate(0));
CTxMemPool pool;
TestMemPoolEntryHelper entry;
CBlock block(BuildBlockTestCase());

Expand Down Expand Up @@ -222,7 +222,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)

BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
{
CTxMemPool pool(CFeeRate(0));
CTxMemPool pool;
TestMemPoolEntryHelper entry;
CBlock block(BuildBlockTestCase());

Expand Down Expand Up @@ -272,7 +272,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)

BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest)
{
CTxMemPool pool(CFeeRate(0));
CTxMemPool pool;
CMutableTransaction coinbase;
coinbase.vin.resize(1);
coinbase.vin[0].scriptSig.resize(10);
Expand Down
8 changes: 4 additions & 4 deletions src/test/mempool_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
}


CTxMemPool testPool(CFeeRate(0));
CTxMemPool testPool;

// Nothing in pool, remove should do nothing:
unsigned int poolSize = testPool.size();
Expand Down Expand Up @@ -117,7 +117,7 @@ void CheckSort(CTxMemPool &pool, std::vector<std::string> &sortedOrder)

BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
{
CTxMemPool pool(CFeeRate(0));
CTxMemPool pool;
TestMemPoolEntryHelper entry;

/* 3rd highest fee */
Expand Down Expand Up @@ -319,7 +319,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)

BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
{
CTxMemPool pool(CFeeRate(0));
CTxMemPool pool;
TestMemPoolEntryHelper entry;

/* 3rd highest fee */
Expand Down Expand Up @@ -431,7 +431,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)

BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
{
CTxMemPool pool(CFeeRate(1000));
CTxMemPool pool;
TestMemPoolEntryHelper entry;
entry.dPriority = 10.0;

Expand Down
2 changes: 1 addition & 1 deletion src/test/policyestimator_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BOOST_FIXTURE_TEST_SUITE(policyestimator_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
{
CTxMemPool mpool(CFeeRate(1000));
CTxMemPool mpool;
TestMemPoolEntryHelper entry;
CAmount basefee(2000);
CAmount deltaFee(100);
Expand Down
4 changes: 2 additions & 2 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee,
assert(int(nSigOpCountWithAncestors) >= 0);
}

CTxMemPool::CTxMemPool(const CFeeRate& _minReasonableRelayFee) :
CTxMemPool::CTxMemPool() :
nTransactionsUpdated(0)
{
_clear(); //lock free clear
Expand All @@ -359,7 +359,7 @@ CTxMemPool::CTxMemPool(const CFeeRate& _minReasonableRelayFee) :
// of transactions in the pool
nCheckFrequency = 0;

minerPolicyEstimator = new CBlockPolicyEstimator(_minReasonableRelayFee);
minerPolicyEstimator = new CBlockPolicyEstimator();
}

CTxMemPool::~CTxMemPool()
Expand Down
2 changes: 1 addition & 1 deletion src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ class CTxMemPool

/** Create a new CTxMemPool.
*/
CTxMemPool(const CFeeRate& _minReasonableRelayFee);
CTxMemPool();
~CTxMemPool();

/**
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ uint256 hashAssumeValid;
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;

CTxMemPool mempool(::minRelayTxFee);
CTxMemPool mempool;
std::map<uint256, int64_t> mapRejectedBlocks GUARDED_BY(cs_main);

static void CheckBlockIndex(const Consensus::Params& consensusParams);
Expand Down

0 comments on commit b1d64f3

Please sign in to comment.