Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: kittdigital on February 06, 2014, 03:52:15 PM



Title: How does the system prioritise transactions for mining?
Post by: kittdigital on February 06, 2014, 03:52:15 PM
Hi all,

I have been reading this forum for a while and the information has been invaluable.  I am investigating cryptocurrencies as part of a bigger project that I am involved in.

One thing I can't seem to find an answer for is that when mining is there anything that prioritises transactions that have a transaction fee attached so they get mined first?  If so does that mean that eventually everyone will have to pay a transaction fee or else their transaction will never be verified?

Also, how does it work it out? is it based on a percentage of the transaction or is it more just the higher the transaction fee the quicker it will get mined?

What I think is confusing me is that as far as I understand  it the transactions are allocated to a block on a time basis so there is no real prioritisation for transaction fees?

Hope you guys can help.


Title: Re: How does the system prioritise transactions for mining?
Post by: Foxpup on February 07, 2014, 03:26:52 AM
First, 27kB of a block is set aside for free transactions, provided they meet certain criteria (no larger than 1kB and high "priority"). These are sorted by "priority", which is the total value of the transaction times the age of the inputs, divided by the transaction size in bytes. If there are more than 27kB of free transactions, only the highest priority transactions will be confirmed. Note that since priority depends on the age of the transaction inputs, a transaction's priority will constantly increase without limit the longer it waits for confirmation, so all free transactions less than 1kB should eventually be confirmed, though it may take a very long time.

The remainder of the block is filled with fee-paying transactions, which are sorted by transaction fee per kilobyte. The fee must be more than the minimum fee; transaction paying less than the minimum fee are treated as free transactions. Only 250kB is available for transactions paying the minimum fee - if a block is to include more transactions than that, the transactions must pay higher fees (the block will never come close to the absolute block size limit unless extremely high fees are paid). Note that if a fee-paying transaction meet the criteria for free transactions, it will be included in that space if its priority is high enough, but otherwise priority has no effect on fee-paying transactions (and the fee, if any, has no effect on transactions that qualify as free).

The practical consequences of this system are:
* Paying less than the minimum fee is the same as paying no fee.
* Free transactions, although described as "high priority", may take a very long time to confirm due to limited amount of space allocated for such transactions.
* Transactions paying the minimum fee will usually be confirmed in the next block, unless the block is getting full.
* Paying more than the minimum fee will get your transaction into otherwise full blocks (at the moment, paying more than double the minimum fee all but guarantees next block confirmation).

Note that these are the default rules, used by most miners. Miners are free to choose their own fee rules, which may be radically different.


Title: Re: How does the system prioritise transactions for mining?
Post by: kittdigital on February 07, 2014, 10:03:17 AM
@Foxpup - Awesome!  That gives me a great starting point for further understanding thank you :)

You mention that free transactions have to be 'no larger than 1kB and high "priority".' Will we reach a stage where a free transaction is over 1KB?  if so what happens to that transaction?

Also, as part of my investigation I have set up some mining rigs to understand the process but I have not seen anywhere that I would set my fee rules?


Title: Re: How does the system prioritise transactions for mining?
Post by: Foxpup on February 07, 2014, 10:25:39 AM
You mention that free transactions have to be 'no larger than 1kB and high "priority".' Will we reach a stage where a free transaction is over 1KB?  if so what happens to that transaction?
The default transaction fee policy has changed several times in the past, and it is difficult to predict what changes will be made in the future. I think it is likely that free transactions will eventually be phased out altogether, as the block subsidy drops and the network becomes more dependent on fees. In any case, a transaction that pays insufficient fees and does not meet the requirements for free transactions will never be confirmed unless a miner with a different fee policy decides to accept it.

Also, as part of my investigation I have set up some mining rigs to understand the process but I have not seen anywhere that I would set my fee rules?
For solo mining and p2pool, the fee policy is set by your Bitcoin node. The basic parameters (minimum fee, amount of space to allocate for free transactions, etc) can be set in bitcoin.conf or the command line; more radical changes require modifying and recompiling the code. For pooled mining (other than p2pool), the fee policy is set by the pool's Bitcoin node. If you disapprove of your pool's fee policy, your only option is to switch to a different one.


Title: Re: How does the system prioritise transactions for mining?
Post by: kittdigital on February 07, 2014, 10:52:12 AM
I was hoping for something like that :)

In my head coins will eventually have to have a minimum level of enforced transaction fee else there is no reward for miners and actually the whole system collapses.


Title: Re: How does the system prioritise transactions for mining?
Post by: fbueller on February 07, 2014, 11:57:09 AM
Certain transactions end up with a larger size, and may exceed the limit. Multi-signature transactions containing many signatures will encounter problems with size if people aren't careful when including fee's.