tothemoon-org / extension-blocks

Extension blocks soft-fork specification
40 stars 6 forks source link

spec: implement compatibility with segwit. #16

Open chjj opened 7 years ago

chjj commented 7 years ago

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

P2P

Policy

Other considerations / Todo

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

afk11 commented 7 years ago

I'm pretty sure LN no longer requires SIGHASH_NOINPUT, but maybe someone else can advise better?

chjj commented 7 years ago

@afk11, segwit gave LN the malleability fix it needed, but LN can still benefit from SIGHASH_NOINPUT for easier outsourcing of blockchain monitoring. A third party can create a penalty transaction on your behalf, assuming you give them a half-created transaction and a signature ahead of time.

Explained here: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2016-February/012460.html

However, it is very useful for LN if there is a certain level of outsourcibility for transactions without this 3rd party taking on onerous costs. In LN, there is a dispute resolution period established to prevent the counterparty from attesting an incorrect channel state (represented by broadcasting a timelocked transaction). In other words, if someone in a channel broadcasts an incorrect state, the output can be redeemed by a 3rd party (but this 3rd party is not a custodian, since the output goes to the other party in the channel).

There may be other use cases for LN I'm not aware of. @josephpoon or @Roasbeef would be able to fill in the blanks better than I can.