This repository was archived by the owner on Jan 29, 2020. It is now read-only.
Update README#1
Open
PaulCapestany wants to merge 62 commits into
Open
Conversation
This commit adds BIP-9 deployment parameters for all registered networks for the CSV soft-fork package. The mainnet and testnet parameters have been set in accordance to the finalized BIPs. For simnet, and the regression net, the activation date is back-dated in order to allow signaling for the soft-fork at any time. Additionally the expiration time for simnet and regrets has been set to math.MaxInt64, meaning they’ll never expire.
This commit modifies the existing block validation logic to examine the current version bits state of the CSV soft-fork, enforcing the new validation rules (BIPs 68, 112, and 113) accordingly based on the current `ThesholdState`.
This commit publicly exports the CreateBlock function as it can be very useful for generating blocks for tests. Additionally, the behavior of the function has been modified slightly to build off of the genesis block for the specified chain if the `prevBlock` paramter is nil.
This commit introduces the new SFNodeWitness service bit which has been added to the protocol as part of BIP0144. The new service bit allows peers on the network to signal their acceptance and adherence to the new rules defined as part of the segwit soft-fork package.
…lization This commit modifies the existing wire.Message interface to introduce a new MessageEncoding variant which dictates the exact encoding to be used when serializing and deserializing messages. Such an option is now necessary due to the segwit soft-fork package, as btcd will need to be able to optionally encode transactions/blocks without witness data to un-upgraded peers. Two new functions have been introduced: ReadMessageWithEncodingN and WriteMessageWithEncodingN which wrap BtcDecode/BtcEncode with the desired encoding format.
This commit adds the new inventory types for segwit which are used by the responder to explicitly request that transactions/blocks sent for a particular inv hash should include all witness data.
This commit implements the new witness encoding/decoding for transactions as specified by BIP0144. After segwit activation, a special transaction encoding is used to signal to upgraded nodes that the transaction being deserialized bares witness data. The prior BtcEncode and BtcDecode methods have been extended to be aware of the new signaling bytes and the encoding of witness data within transactions. Additionally, a new method has been added to calculate the “stripped size” of a transaction/block which is defined as the size of a transaction/block *excluding* any witness data.
…sages This commit modifies the base peer struct to ascertain when a peer is able to understand the new witness encoding, and specify the peer’s supported encoding explicitly before/after the version handshake.
This commit modifies the logic within the block manager and service to preferentially fetch transactions and blocks which include witness data from fully upgraded peers. Once the initial version handshake has completed, the server now tracks which of the connected peers are witness enabled (they advertise SFNodeWitness). From then on, if a peer is witness enabled, then btcd will always request full witness data when fetching transactions/blocks. server: only preferentially connect to segwit peers post-activation blockmanager: only use witness get data after activation
This commit implements most of BIP0143 by adding logic to implement the new sighash calculation, signing, and additionally introduces the HasCache optimization which eliminates the O(N^2) computational complexity for the SIGHASH_ALL sighash type. The HashCache struct is the equivalent to the existing Sigcache struct, but fore caching the reusable misstate for transactions which are spending segwitty outputs.
…per funcs This commit introduces a series of internal and external helper functions which enable the txscript package to be aware of the new standard script templates introduced as part of BIP0141. The two new standard script templates recognized are pay-to-witness-key-hash (P2WKH) and pay-to-witness-script-hash (P2WSH).
…n segwit This commit fixes an off-by-one error which is only manifested by the new behavior of OP_CODESEPARATOR within sig hashes triggered by the segwit behavior. The current behavior within the Script VM (txscript.Engine) known to be fully correct to the extent that it has been verified. However, once segwit activates a consensus divergence would emerge due exactly *when* the program counter was incremented in the previous code (pre-this-commit). Currently (pre-segwit) when calculating the pre-image to a transaction sighash for signature verification, *all* instances of OP_CODESEPARATOR are removed from the subScript being signed before generating the final sighash. The addition of SegWIt has additional nerved the behavior of OP_CODESEPARATOR by no longer removing them (and starting after the last instance), but instead simply starting the subScript to be directly *after* the last instance of an OP_CODESEPARATOR within the pkScript. Due to this new behavior, without this commit, an off-by-one error (which only matters post-segwit), would case txscript to generate an incorrect subScript since the instance of OP_CODESEPARATOR would remain as part of the subScript instead of being sliced off as the new behavior dictates. The off-by-one error itself is manifsted due to a slight divergence in txscript.Engine’s logic compared to Bitcoin Core. In Bitcoin Core script verification is as follows: first the next op-code is fetched, then program counter is incremented, and finally the op-code itself is executed. Before this commit, btcd flipped the order of the last two steps, executing the op-code *before* the program counter was incremented. This commit fixes the post-segwit consensus divergence by incrementing the program-counter *before* the next op-code is executed. It is important to note that this divergence is only significant pre-segwit, meaning that txscript.Engine is still consensus compliant independent of this commit.
This commit implements full witness program validation for the currently defined version 0 witness programs. This includes validation logic for nested p2sh, p2wsh, and p2wkh. Additionally, when in witness validation mode, an additional set of constrains are enforced such as using the new sighash digest algorithm and enforcing clean stack behavior within witness programs.
This commit implements the flag activation portion of BIP 0147. The verification behavior triggered by the NULLDUMMY script verification flag has been present within btcd for some time, however it wasn’t activated by default. With this commit, once segwit has activated, the ScriptStrictMultiSig will also be activated within the Script VM. Additionally, the ScriptStrictMultiSig is now a standard script verification flag which is used unconditionally within the mempool.
This commit adds a new function to btcec: IsCompressedPubKey. This function returns true iff the passed serialized public key is encoded in compressed format.
This commit modifies the op-code execution for OP_IF and OP_NOTIF to enforce the additional “minimal if” constraints which require the top-stack item when the op codes are encountered to be either an empty vector, or exactly [0x01].
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.
…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).
This commit adds a new PowHash method to the BlockHeader struct. This method will be used internally during block validation to compute the proper block hash using litecoin’s scypt parameters.
Roasbeef
pushed a commit
that referenced
this pull request
Aug 26, 2017
|
@losh11 Can we close this PR? It is super stale (looks like this was an attempted upgrade) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.