sipa / bitcoin

Bitcoin integration/staging tree
http://www.bitcoin.org
MIT License
88 stars 21 forks source link

Replace the concept of virtual block size, introduce the concept of block cost, and express CBS as a function of it #21

Closed NicolasDorier closed 8 years ago

NicolasDorier commented 8 years ago

The concept of MAX_BLOCK_SIZE can be removed more easily for the next block size HF. Using MAX_BLOCK_COST make it easier to adapt HF proposals after segwit deployment, because the limited resources will not really be MAX_BLOCK_SIZE anymore.

This will have another advantages for later: The notion of "Block cost" can be later tweaked to include other parameters like SigOp cost.

We can imagine, in the next hardfork, to remove the limitation on the number of SigOps, and just include SigOps as an additional cost parameter in the "Block Cost".

NicolasDorier commented 8 years ago

As an additional advantage it will make the BIP easier to explain.

btcdrak commented 8 years ago

Interesting idea.

NicolasDorier commented 8 years ago

Current rule about sig op can even be coded into GetBlockCost: (pseudocode)

size_t GetBlockCost(const CBlock& block)
{
    // witness data is 4 times less costly than core data, because we can prune it
    size_t coreCost = ::GetSerializeSize(block, SER_NETWORK, 0);
    size_t witCost = ::GetSerializeSize(block, SER_NETWORK, SERIALIZE_TRANSACTION_WITNESS) - coreCost;
    size_t sigCost = GetSigOpCount(block) > MAX_SIG_OPS ? MAX_BLOCK_COST + 1 : 0;
    return witCost + 4 * coreCost + sigCost;
}
NicolasDorier commented 8 years ago

https://github.com/sipa/bitcoin/pull/26