Skip to content

Commit

Permalink
Lower tx fees 10x (#1632)
Browse files Browse the repository at this point in the history
* Lower tx fees 10x

* add DEFAULT_DIP0001_*FEE constants
  • Loading branch information
UdjinM6 committed Sep 17, 2017
1 parent 825b3cc commit 8f850c6
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 8 deletions.
13 changes: 13 additions & 0 deletions src/dsnotificationinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "masternode-payments.h"
#include "masternode-sync.h"
#include "privatesend-client.h"
#include "txmempool.h"

void CDSNotificationInterface::InitializeCurrentBlockTip()
{
Expand Down Expand Up @@ -39,9 +40,21 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con

// DIP0001 updates

bool fDIP0001ActiveAtTipTmp = fDIP0001ActiveAtTip;
// Update global flags
fDIP0001LockedInAtTip = (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_LOCKED_IN);
fDIP0001ActiveAtTip = (VersionBitsState(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0001, versionbitscache) == THRESHOLD_ACTIVE);

// Update min fees only if activation changed and we are using default minRelayTxFee
if (fDIP0001ActiveAtTipTmp != fDIP0001ActiveAtTip) {
if (!mapArgs.count("-minrelaytxfee")) {
::minRelayTxFee = CFeeRate(fDIP0001ActiveAtTip ? DEFAULT_DIP0001_MIN_RELAY_TX_FEE : DEFAULT_LEGACY_MIN_RELAY_TX_FEE);
mempool.UpdateMinFee(::minRelayTxFee);
}
if (!mapArgs.count("-mintxfee")) {
CWallet::minTxFee = CFeeRate(fDIP0001ActiveAtTip ? DEFAULT_DIP0001_TRANSACTION_MINFEE : DEFAULT_LEGACY_TRANSACTION_MINFEE);
}
}
}

void CDSNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlock *pblock)
Expand Down
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-fallbackfee=<amt>", strprintf(_("A fee rate (in %s/kB) that will be used when fee estimation has insufficient data (default: %s)"),
CURRENCY_UNIT, FormatMoney(DEFAULT_FALLBACK_FEE)));
strUsage += HelpMessageOpt("-mintxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)"),
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MINFEE)));
CURRENCY_UNIT, FormatMoney(DEFAULT_LEGACY_TRANSACTION_MINFEE)));
strUsage += HelpMessageOpt("-paytxfee=<amt>", strprintf(_("Fee (in %s/kB) to add to transactions you send (default: %s)"),
CURRENCY_UNIT, FormatMoney(payTxFee.GetFeePerK())));
strUsage += HelpMessageOpt("-rescan", _("Rescan the block chain for missing wallet transactions on startup"));
Expand Down Expand Up @@ -567,7 +567,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf("Limit size of signature cache to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE));
}
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"),
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)));
CURRENCY_UNIT, FormatMoney(DEFAULT_LEGACY_MIN_RELAY_TX_FEE)));
strUsage += HelpMessageOpt("-printtoconsole", _("Send trace/debug info to console instead of debug.log file"));
strUsage += HelpMessageOpt("-printtodebuglog", strprintf(_("Send trace/debug info to debug.log file (default: %u)"), 1));
if (showDebug)
Expand Down
2 changes: 1 addition & 1 deletion src/instantx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ bool CTxLockRequest::IsValid() const

CAmount CTxLockRequest::GetMinFee() const
{
CAmount nMinFee = MIN_FEE;
CAmount nMinFee = fDIP0001ActiveAtTip ? MIN_FEE / 10 : MIN_FEE;
return std::max(nMinFee, CAmount(vin.size() * nMinFee));
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/transaction_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
// not dust:
t.vout[0].nValue = 6735;
BOOST_CHECK(IsStandardTx(t, reason));
minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
minRelayTxFee = CFeeRate(DEFAULT_LEGACY_MIN_RELAY_TX_FEE);

t.vout[0].scriptPubKey = CScript() << OP_1;
BOOST_CHECK(!IsStandardTx(t, reason));
Expand Down
8 changes: 8 additions & 0 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,14 @@ CFeeRate CTxMemPool::GetMinFee(size_t sizelimit) const {
return std::max(CFeeRate(rollingMinimumFeeRate), minReasonableRelayFee);
}

void CTxMemPool::UpdateMinFee(const CFeeRate& _minReasonableRelayFee)
{
LOCK(cs);
delete minerPolicyEstimator;
minerPolicyEstimator = new CBlockPolicyEstimator(_minReasonableRelayFee);
minReasonableRelayFee = _minReasonableRelayFee;
}

void CTxMemPool::trackPackageRemoved(const CFeeRate& rate) {
AssertLockHeld(cs);
if (rate.GetFeePerK() > rollingMinimumFeeRate) {
Expand Down
1 change: 1 addition & 0 deletions src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ class CTxMemPool
* would otherwise be half of this, it is set to 0 instead.
*/
CFeeRate GetMinFee(size_t sizelimit) const;
void UpdateMinFee(const CFeeRate& _minReasonableRelayFee);

/** Remove transactions from the mempool until its dynamic size is <= sizelimit.
* pvNoSpendsRemaining, if set, will be populated with the list of transactions
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ std::atomic<bool> fDIP0001ActiveAtTip{false};
uint256 hashAssumeValid;

/** Fees smaller than this (in duffs) are considered zero fee (for relaying, mining and transaction creation) */
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_LEGACY_MIN_RELAY_TX_FEE);

CTxMemPool mempool(::minRelayTxFee);
map<uint256, int64_t> mapRejectedBlocks GUARDED_BY(cs_main);
Expand Down
4 changes: 3 additions & 1 deletion src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ static const bool DEFAULT_WHITELISTFORCERELAY = true;
/** Default for -minrelaytxfee, minimum relay fee for transactions
* We are ~100 times smaller then bitcoin now (2016-03-01), set minRelayTxFee only 10 times higher
* so it's still 10 times lower comparing to bitcoin.
* 2017-07: we are 10x smaller now, let's lower defaults 10x via the same BIP9 bit as DIP0001
*/
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 10000; // was 1000
static const unsigned int DEFAULT_LEGACY_MIN_RELAY_TX_FEE = 10000; // was 1000
static const unsigned int DEFAULT_DIP0001_MIN_RELAY_TX_FEE = 1000;
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
/** Default for -limitancestorcount, max number of in-mempool ancestors */
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool fSendFreeTransactions = DEFAULT_SEND_FREE_TRANSACTIONS;
* Fees smaller than this (in duffs) are considered zero fee (for transaction creation)
* Override with -mintxfee
*/
CFeeRate CWallet::minTxFee = CFeeRate(DEFAULT_TRANSACTION_MINFEE);
CFeeRate CWallet::minTxFee = CFeeRate(DEFAULT_LEGACY_TRANSACTION_MINFEE);
/**
* If fee estimation does not have enough data to provide estimates, use this fee instead.
* Has no effect if not using fee estimation
Expand Down
4 changes: 3 additions & 1 deletion src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ static const CAmount DEFAULT_FALLBACK_FEE = 20000;
/**
* We are ~100 times smaller then bitcoin now (2016-03-01), set minTxFee 10 times higher
* so it's still 10 times lower comparing to bitcoin.
* 2017-07: we are 10x smaller now, let's lower defaults 10x via the same BIP9 bit as DIP0001
*/
static const CAmount DEFAULT_TRANSACTION_MINFEE = 10000; // was 1000
static const CAmount DEFAULT_LEGACY_TRANSACTION_MINFEE = 10000; // was 1000
static const CAmount DEFAULT_DIP0001_TRANSACTION_MINFEE = 1000;
//! -maxtxfee default
static const CAmount DEFAULT_TRANSACTION_MAXFEE = 0.2 * COIN; // "smallest denom" + X * "denom tails"
//! minimum change amount
Expand Down

0 comments on commit 8f850c6

Please sign in to comment.