spec: implement compatibility with segwit. #16
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.
This is something I've considered for a while. I've been thinking about it more frequently for the past week or two: mainchain segwit adds a few benefits to extblk. The exclusion of mainchain segwit wasn't a very conscious technical decision initially. It was just the simplest path for the code at the time, and less complexity. I think this decision should be reexamined technically for this reason.
I've revised some major parts of the specification, mostly pertaining to how entrance into and exits from the extension block behave. The new behavior is similar to Johnson's 2017 proposal. Listing changes and potential benefits here.
Changes
Consensus
0xaa21a9ef
to0x45424c4b
(ascii: EBLK). This is to avoid confusion.P2P
getdata
inv type is used with the witness bit.getdata
witness bit.Policy
Other considerations / Todo
flags
bit set to1
(implementations must now track this). This gives an easy non-contextual check for which chain the transaction is in, which has nice implications for wallets and protocols like compact block relay. Note that the flags byte is malleable in the mempool. I also don't think the flag byte was intended to be used this way, but rather for future serialization changes.I have a preliminary reference implementation here: https://github.com/bcoin-org/bcoin-extension-blocks/tree/extblk-sw2. Everything outlined above is more or less present, but the code still needs some work and more tests.
If consider this route, I think we can have extnet2 up in a reasonable amount of time to play around with this.
Opening it up for discussion. Thoughts?
cc @gasteve @josephpoon