Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Implement BIPs 141, 142, 143, 145 and 147 (Segregated Witness) #656
This PR makes several modifications across
This PR currently implements the changes dictated by the following BIPS:
As of the writing of this PR description, with this patch set
The changes across all packages are briefly summarized below:
Thanks to @T909 for the initial work which laid the base for much of this PR, along with coming up with the initial idea for the
This commit adds verification of the post-segwit standardness requirement that all pubkeys involved in checks operations MUST be serialized as compressed public keys. A new ScriptFlag has been added to guard this behavior when executing scripts.
This commit implements the new “weight” metric introduced as part of the segwit soft-fork. Post-fork activation, rather than limiting the size of blocks and transactions based purely on serialized size, a new metric “weight” will instead be used as a way to more accurately reflect the costs of a tx/block on the system. With blocks constrained by weight, the maximum block-size increases to ~4MB.
This commit implements the new block validation rules as defined by BIP0141. The new rules include the constraints that if a block has transactions with witness data, then there MUST be a commitment within the conies transaction to the root of a new merkle tree which commits to the wtxid of all transactions. Additionally, rather than limiting the size of a block by size in bytes, blocks are now limited by their total weight unit. Similarly, a newly define “sig op cost” is now used to limit the signature validation cost of transactions found within blocks.
…itment This commit modifies the existing block selection logic to limit preferentially by weight instead of serialized block size, and also to adhere to the new sig-op cost limits which are weighted according to the witness discount.
This commit adds set of BIP0009 (Version Bits) deployment parameters for all networks detailing the activation parameters for the segwit soft-fork. Additionally, the BIP0009 integration test has been updated to test for the proper transitioning of version bits state for the segwit soft fork. Finally, the `getblockchaininfo` test has also been updated to properly display the state of segwit.
This commit updates the new segwit validation logic within block validation to be guarded by an initial check to the version bits state before conditionally enforcing the logic based off of the state.
This commit updates the block template generation logic to only include witness transactions once the soft-fork has activated and to also include the OP_RETURN witness commitment (with additional block weight accounting).