15

I see from the source code (script.cpp) that there is an upper limit in the script size. It there any other limit to avoid a single transaction preventing other transactions of smaller sizes to get into a block?

How is this kind of attack prevented?

I've read in CTransaction::AcceptToMemoryPool the line:

if .... ::GetSerializeSize(*this, SER_NETWORK) < 100) 
    return error("..."); 

Does this line means that the maximum transaction size is 100 bytes?

  • 2
    The posted line seems to limit the minimum size, not the maximum! – SDL Oct 31 '11 at 15:29
6

If there is a max transaction size it is much higher than 100 bytes. Not sure what that snippet is refering to but the average transaction is closer to ~300 bytes looking at the average # of transactions and block size for last 1000 blocks.

What limits transaction size is cost. As transaction size (of all transactions awaiting next block) increases the min required fee increases non-linearly.

0.01 BTC fee per kilobyte of transaction, but: If the blocksize (size of all transactions currently waiting to be included in a block) is less than 27 kB, transactions are free. If the blocksize is more than 250 kB, transactions get increasingly more expensive as the blocksize approaches the limit of 500 kB. Sending a transaction when the blocksize is 400 kB will cost 5 times the normal amount; sending when it's 499 kB will cost 500x, etc.

https://en.bitcoin.it/wiki/Transaction_fees

So you could make a 500KB transaction but the required minimum fee would be 5BTC. The developers have indicated they intend to change transaction fee rules in the future but given block space is a valuable commodity any new rules are likely to be constructed to encourage (via larger fees) smaller transaction sizes.

  • This answer is obsolete. Blocks are full. Always. – Giszmo Jan 8 '18 at 14:25
18

The maximum transaction size is the size of the block. Source.

// Size limits (this doesn't take the witness into account, as that hasn't been checked for malleability)
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT)
    return state.DoS(100, false, REJECT_INVALID, "bad-txns-oversize");

Transactions larger than 100 kilobytes (including witness at a 75% discount rate) are non-standard. Source 1. Source 2.

static const unsigned int MAX_STANDARD_TX_WEIGHT = 400000;
...
if (sz >= MAX_STANDARD_TX_WEIGHT)
{
    LogPrint(BCLog::MEMPOOL, "ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString());
    return false;
}
  • "Transactions larger than 100 kilobytes are non-standard" has been removed. They've removed the 100 kb limit. – MCCCS Nov 24 '17 at 12:25
  • 1
    I disagree. It has been changed from a pure measurement of size to one of weight, but that only makes it slightly roomier - it doesn't remove it entirely. – Nick ODell Nov 26 '17 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.