All related to block (block size, block time, how it works) question

+4 votes

I have a question (or more) regarding the block in blockchain and how it stores transactions. I don't know if this question is 100% related to multichain but i tried to google for answers but didn't find any.

I am doing a project where i create different blockchain networks with different block size. The only parameters that i change when i create those networks are: skip-pow-check = true and the block size = variable (it's manually changed for every network). The block time is set to 15 seconds.

Let's take a block with a size of 500KB. Over a period of 5 minutes i send transactions to the blockchain using the sendwithdata function (sendwithdata(addrs, coin_amount, data)). Here the data is 20 bytes (i send 20 "a" characters). The transaction has a size of around 250 bytes.

After 5 minutes of sending transaction my blocks look like this:

block 2791796 tx stored
block 280950 tx stored
block 28113 tx stored
block 2821451 tx stored
block 2831669 tx stored
block 2841047 tx stored
block 285607 tx stored
block 2861537 tx stored
block 287240 tx stored
block 2881024 tx stored
block 2891341 tx stored
block 2901480 tx stored
block 2912666 tx stored
block 2922495 tx stored
block 2931056 tx stored
block 2942311 tx stored
block 2951354 tx stored
block 2961358 tx stored
block 2971016 tx stored
block 2981577 tx stored
block 2992225 tx stored
block 300441 tx stored
block 3012174 tx stored
block 3021142 tx stored
block 30312 tx stored
block 3042 tx stored

Total of tx sent: 32984

 

So my questions are this:

1. Why such a big discrepancy between the amount of tx saved in each block? (block 229 -- 2225 tx stored while block 300 -- 441 tx stored)

2. Why sometimes my block is added to the blockchain before the 15 seconds block time?

3. Why the blocks never reach the full size (500KB), the maximum transactions size goes up to only 300KB. The other 200KB is some metadata, is reserved for the block header?

4. Can the transaction size be lower than 250 bytes, let's say under 100 bytes?

All of this happens even if the block is 5KB or 1MB, 10MB or 100MB

 

Again, i am sorry if this is not the right website to ask this question but maybe someone more knowledgeable than me can give me some answers.

asked May 17, 2023 by linked

1 Answer

0 votes
1. In general, there is no guarantee that blocks will be a consistent size. The node which builds a block will include the transactions that it currently knows about, and there could still be other transactions on the network it has not yet seen.

2. Also, MultiChain adds some randomness into the block times, to prevent too many "forks", in which multiple nodes generate a block simultaneously. Forks are not a major problem, and are resolved automatically, but they create some inefficiency in the chain's performance.

3. This is related to point 1, there may not be enough transactions available to fill the block at the time of its creation.

4. The most basic transaction (sending some native asset, one input and one ouput, without a change output) will be around 225 bytes in size. More information here: https://www.multichain.com/qa/6551/how-to-calculate-transaction-size?show=6553#a6553
answered May 17, 2023 by MultiChain
...