-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BIP++1: First pass. #1
base: master
Are you sure you want to change the base?
Conversation
DO NOT USE YET outside testnets. Read readme.md.
bitcoin/src/blockencodings.cpp Line 52 in 5b2bfba
Non consensus code, immediately increase max size. Larger actual compact block sizes support will come soon. |
Line 282 in 5b2bfba
This only affects AccessByTxid, used in DisconnectBlock and gettxproofs. Non-consensus. |
Line 155 in 5b2bfba
Non consensus code quick validity check. Used by backup and txoutproof only. |
Line 833 in 1bb1792
As mentioned previously, per TX limits aren't changing. |
Line 2689 in 1bb1792
Network IO limit already adjusted before activation. Required when disconnecting blocks near activation. May need to change other constants such as MAX_UPLOAD_TIMEFRAME. |
Line 4394 in 1bb1792
Read disk buffer will become 1GB in-memory size. Mentioned in the readme. Non-concurrent from first look so would not blow out. |
static const unsigned int minTxOutSz = 9; | ||
static const unsigned int maxVout = MAX_BLOCK_WEIGHT / (WITNESS_SCALE_FACTOR * minTxOutSz); | ||
static const unsigned int maxVout = MAX_BLOCK_WEIGHT_LEGACY / (WITNESS_SCALE_FACTOR * minTxOutSz); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rationalize: No need to adjust this limit. tx_check.cpp also uses the legacy MAX_BLOCK_WEIGHT for tx sizes. There is enough UTX IN/OUT count in the base protocol size.
@@ -16,7 +16,7 @@ bool CheckTransaction(const CTransaction& tx, TxValidationState& state) | |||
if (tx.vout.empty()) | |||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-vout-empty"); | |||
// Size limits (this doesn't take the witness into account, as that hasn't been checked for malleability) | |||
if (::GetSerializeSize(tx, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT) | |||
if (::GetSerializeSize(tx, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT_LEGACY /* Retain old block weight for max sz tx size. */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioned above, no need to adjust this rule. Feel free to argue otherwise.
: chainparams{chainstate.m_chainman.GetParams()}, | ||
m_mempool(mempool), | ||
m_chainstate(chainstate) | ||
{ | ||
blockMinFeeRate = options.blockMinFeeRate; | ||
// Limit weight to between 4K and MAX_BLOCK_WEIGHT-4K for sanity: | ||
nBlockMaxWeight = std::max<size_t>(4000, std::min<size_t>(MAX_BLOCK_WEIGHT - 4000, options.nBlockMaxWeight)); | ||
nBlockMaxWeight = std::max<size_t>(4000, std::min<size_t>((fPlusPlusActivated ? MAX_BLOCK_WEIGHT : MAX_BLOCK_WEIGHT_LEGACY) - 4000, options.nBlockMaxWeight)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nBlockMaxWeight will only adjust in block assembler once BIP++1 activated.
Old limit will remain indefinitely until then. After activation and no limit is specified by the miner then 2MB non-weighted will become the default.
@@ -20,7 +20,7 @@ class CFeeRate; | |||
class CScript; | |||
|
|||
/** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/ | |||
static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT - 4000}; | |||
static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT_LEGACY - 4000}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment in miner.cpp. This gets overridden by option value anyway.
@@ -3406,7 +3412,8 @@ bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensu | |||
// checks that use witness data may be performed here. | |||
|
|||
// Size limits | |||
if (block.vtx.empty() || block.vtx.size() * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT || ::GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT) | |||
const unsigned int maxWeight = fPlusPlusActivated ? MAX_BLOCK_WEIGHT : MAX_BLOCK_WEIGHT_LEGACY; | |||
if (block.vtx.empty() || block.vtx.size() * WITNESS_SCALE_FACTOR > maxWeight || ::GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > maxWeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contextual flag has been put in this routine. I did not want to move the check into AcceptBlock().
@@ -3433,7 +3440,7 @@ bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensu | |||
{ | |||
nSigOps += GetLegacySigOpCount(*tx); | |||
} | |||
if (nSigOps * WITNESS_SCALE_FACTOR > MAX_BLOCK_SIGOPS_COST) | |||
if (nSigOps * WITNESS_SCALE_FACTOR > (fPlusPlusActivated ? MAX_BLOCK_SIGOPS_COST : MAX_BLOCK_SIGOPS_COST_LEGACY)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@@ -201,7 +202,7 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost | |||
if (nBlockWeight + WITNESS_SCALE_FACTOR * packageSize >= nBlockMaxWeight) { | |||
return false; | |||
} | |||
if (nBlockSigOpsCost + packageSigOpsCost >= MAX_BLOCK_SIGOPS_COST) { | |||
if (nBlockSigOpsCost + packageSigOpsCost >= (nPlusPlusActivated ? MAX_BLOCK_SIGOPS_COST : MAX_BLOCK_SIGOPS_COST_LEGACY)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Block assembly max ops only bumped after activation.
@@ -30,7 +30,7 @@ static constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{82}; | |||
/** Maximum number of signature check operations in an IsStandard() P2SH script */ | |||
static constexpr unsigned int MAX_P2SH_SIGOPS{15}; | |||
/** The maximum number of sigops we're willing to relay/mine in a single tx */ | |||
static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/5}; | |||
static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST_LEGACY / 5}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned previously, per TX limits aren't changing.
BIP++1 is only described in the adjusted readme.md.
DO NOT USE YET outside testnets. Read readme.md.
I've only been studying bitcoin core code for a few days. Things I've noticed need looking at:
TODO:
Please assist me in making this patch more viable before more formal validation takes place. Submit a PR to the BIP++1 branch.