Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: simpleSliv3r on June 21, 2023, 07:40:37 PM



Title: [NOT A DISCUSION ABOUT INCREMENTING BLOCK SIZE] Bitcoin blocks size
Post by: simpleSliv3r on June 21, 2023, 07:40:37 PM
Hi,

Could someone point me to the code file where the block size is defined?
I need to know the theoretical max block size if we ignore SegWit, etc.

Thanks in advace.


Regards,
SS


Title: Re: [NOT A DISCUSION ABOUT INCREMENTING BLOCK SIZE] Bitcoin blocks size
Post by: BlackHatCoiner on June 21, 2023, 07:49:03 PM
The maximum block size is defined in src/consensus/consensus.h (https://github.com/bitcoin/bitcoin/blob/master/src/consensus/consensus.h).
Code:
/** The maximum allowed weight for a block, see BIP 141 (network rule) */
static const unsigned int MAX_BLOCK_WEIGHT = 4000000;

If you search for WITNESS_SCALE_FACTOR (https://github.com/search?q=repo%3Abitcoin%2Fbitcoin%20WITNESS_SCALE_FACTOR&type=code) (which is also defined in the above file as 4), you'll notice it also appears in other parts where there are bytes that need to be measured. In other words there isn't a parameter equal to 1 MB, there's just the above, and the code takes into account the fact that 1 byte is equal with 4 weight units.


Title: Re: [NOT A DISCUSION ABOUT INCREMENTING BLOCK SIZE] Bitcoin blocks size
Post by: witcher_sense on June 22, 2023, 05:26:16 AM
Your question has already been answered here: Block size limit in source code  (https://bitcointalk.org/index.php?topic=2196785.0)


Title: Re: [NOT A DISCUSION ABOUT INCREMENTING BLOCK SIZE] Bitcoin blocks size
Post by: simpleSliv3r on June 25, 2023, 09:15:21 AM
The maximum block size is defined in src/consensus/consensus.h (https://github.com/bitcoin/bitcoin/blob/master/src/consensus/consensus.h).
Code:
/** The maximum allowed weight for a block, see BIP 141 (network rule) */
static const unsigned int MAX_BLOCK_WEIGHT = 4000000;

If you search for WITNESS_SCALE_FACTOR (https://github.com/search?q=repo%3Abitcoin%2Fbitcoin%20WITNESS_SCALE_FACTOR&type=code) (which is also defined in the above file as 4), you'll notice it also appears in other parts where there are bytes that need to be measured. In other words there isn't a parameter equal to 1 MB, there's just the above, and the code takes into account the fact that 1 byte is equal with 4 weight units.
Your question has already been answered here: Block size limit in source code  (https://bitcointalk.org/index.php?topic=2196785.0)

Hi thanks both for your answers. I appreciate it.


Regards,
SS