tothemoon-org / extension-blocks

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

Serialization for the P2P layer #4

Open chjj opened 7 years ago

chjj commented 7 years ago

Transactions

Transactions will keep the soft-forked BIP141 serialization to maintain compat with existing wallets.

Blocks

Originally had the idea of having the ext. block be a separate network message that was to be requested after seeing the ext. commitment, but for speed and simplicity it's easier to simply append the extension block to the block message.

I'm second guessing myself on whether it's worth it to include a whole new serialization format for block + ext block. Perhaps some soft-forked serialization like segwit tx serialization has. Have a marker byte set to zero where the varint tx count belongs. This simplifies parsing as parsers can parse either a regular block or a regular block + extension block.

Technically, they can do the same with the "appended" ext. block by checking for extra bytes after they're done parsing the canonical transactions, but I never really liked this sort of hack. Otherwise, parsers just need some context for what kind of block they need to parse, which leads me into my next thought...

Separate network messages for extension blocks and txs

I'm also considering having separate network messages for blocks and txs with extension serialization.

The whole reason BIP141 didn't implement new network messages was because the txs reside on the main chain and in the main block. It didn't really make sense to have two messages for this reason as well as simplicity.

This reason doesn't hold up as much anymore since we don't allow cross-chain spends (the ext. txs only exist on the extension chain).


Anyway, still thinking on this. Just dropping my thoughts here.

jujumax commented 7 years ago

Probably is simpler to guarantee compatibility with non-upgraded nodes if this has 2 separate networks for the ext-blocks and txs. If we consider at the beginning most of the nodes are not upgraded. Also may be good to consider how we can use Matt FIBRE to guarantee a fast propagation of the extended blocks across miners and improve the propagation in general.

jujumax commented 7 years ago

If we have a separate network we can use Bitcoin Testnet as is to do extensive tests with non-extension nodes including nodes supporting SW and older ones.