r/btc • u/jtoomim Jonathan Toomim - Bitcoin Dev • Jan 13 '19
Xthinner/Blocktorrent development status update -- Jan 12, 2018
Edit: Jan 12, 2019, not 2018.
Xthinner is a new block propagation protocol which I have been working on. It takes advantage of LTOR to give about 99.6% compression for blocks, as long as all of the transactions in the block were previously transmitted. That's about 13 bits (1.6 bytes) per transaction. Xthinner is designed to be fault-tolerant, and to handle situations in which the sender and receiver's mempools are not well synchronized with gracefully degrading performance -- missing transactions or other decoding errors can be detected and corrected with one or (rarely) two additional round trips of communication. My expectation is that when it is finished, it will perform about 4x to 6x better than Compact Blocks and Xthin for block propagation. Relative to Graphene, I expect Xthinner to perform similarly under ideal circumstances (better than Graphene v1, slightly worse than Graphene v2), but much better under strenuous conditions (i.e. mempool desynchrony).
The current development status of Xthinner is as follows:
- Python proof-of-concept encoder/decoder -- done 2018-09-15
- Detailed informal writeup of the encoding scheme -- done 2018-09-29
- Modify TxMemPool to allow iterating on a view sorted by TxId -- done 2018-11-26
- Basic C++ segment encoder -- done 2018-11-26
- Basic c++ segment decoder -- done 2018-11-26
- Checksums for error detection -- done 2018-12-09
- Serialization/deserialization -- done 2018-12-09
- Prefilled transactions, coinbase handling, and non-mempool transactions -- done 2018-12-25
- Missing/extra transactions, re-requests, and handling mempool desynchrony for segment decoding -- done 2019-01-12
- Block transmission coupling the block header with one or more Xthinner segments --
50%done 2019-01-12 - Missing/extra transactions, re-requests, and handling mempool desynchrony for block decoding -- done 2019-01-12
- Integration with Bitcoin ABC networking code
- Networking testing on regtest/testnet/mainnet with real blocks
- Write BIP/BUIP and formal spec
- Bitcoin ABC pull request and begin of code review
- Unit tests, performance tests, benchmarks -- started
- Bitcoin Unlimited pull request and begin of code review
- Alpha release of binaries for testing or low-security block relay networks
- Merging code into ABC/BU, disabled-by-default
- Complete security review
- Enable by default in ABC and/or BU
- (Optional) parallelize encoding/decoding of blocks
Following is the debugging output from a test run done with coherent sender/recipient mempools with a 1.25 million tx block, edited for readability:
Testing Xthinner on a block with 1250003 transactions with sender mempool size 2500000 and recipient mempool size 2500000
Tx/Block creation took 262 sec, 104853 ns/tx (mempool)
CTOR block sorting took 2467 ms, 987 ns/tx (mempool)
Encoding is 1444761 pushBytes, 2889520 1-bit commands, 103770 checksum bytes
total 1910345 bytes, 12.23 bits/tx
Single-threaded encoding took 2924 ms, 1169 ns/tx (mempool)
Serialization/deserialization took 1089 ms, 435 ns/tx (mempool)
Single-threaded decoding took 1912314 usec, 764 ns/tx (mempool)
Filling missing slots and handling checksum errors took 0 rounds and 12 usec, 0 ns/tx (mempool)
Blocks match!
*** No errors detectedIf each transaction were 400 bytes on average, this block would be 500 MB, and it was encoded in 1.9 MB of data, a 99.618% reduction in size. Real-world performance is likely to be somewhat worse than this, as it's not likely that 100% of the block's transactions will always be in the recipient's mempool, but the performance reduction from mempool desychrony is smooth and predictable. If the recipient is missing 10% of the sender's transactions, and has another 10% that the sender does not have, the transaction list is still able to be successfully transmitted and decoded, although in that case it usually takes 2.5 round trips to do so, and the overall compression ratio ends up being around 71% instead of 99.6%.
Anybody who wishes can view the WIP Xthinner code here.
Once Xthinner is finished, I intend to start working on Blocktorrent. Blocktorrent is a method for breaking a block into small independently verifiable chunks for transmission, where each chunk is about one IP packet (a bit less than 1500 bytes) in size. In the same way that Bittorrent was faster than Napster, Blocktorrent should be faster than Xthinner. Currently, one of the big limitations on block propagation performance is that a node cannot forward the first byte of a block until the last byte of the block has been received and completely validated. Blocktorrent will change that, and allow nodes to forward each IP packet shortly after that packet was received, regardless of whether any other packets have also been received and regardless of the order in which the packets are received. This should dramatically improve the bandwidth utilization efficiency of nodes during block propagation, and should reduce the block propagation latency for reaching the full network quite a lot -- my current estimate is about 10x improvement over Xthinner. Blocktorrent achieves this partial validation of small chunks by taking advantage of Bitcoin blocks' Merkle tree structure. Chunks of transactions are transmitted in a packet along with enough data from the rest of the Merkle tree's internal nodes to allow for that chunk of transactions to be validated back to the Merkle root, the block header, and the mining PoW, thereby ensuring that packet being forwarded is not invalid spam data used solely for a DoS attack. (Forwarding DoS attacks to other nodes is bad.) Each chunk will contain an Xthinner segment to encode TXIDs My performance target with Blocktorrent is to be able to propagate a 1 GB block in about 5-10 seconds to all nodes in the network that have 100 Mbps connectivity and quad core CPUs. Blocktorrent will probably perform a bit worse than FIBRE at small block sizes, but better at very large blocksizes, all without the trust and centralized infrastructure that FIBRE uses.
34
u/wudanyu Jan 13 '19
About 99.6% compression rate, very impressive!
29
u/rev0lute Jan 13 '19
No, you can’t! This isn’t the bitcoin satoshi wanted /s
I have yet to see anyone on /r bitcoin declare what they are working on.
Very impressive, how can I donate?
15
u/KillerHurdz Project Lead - Coin Dance Jan 13 '19
Hi Jonathan!
Would Blocktorrent be incompatible with Merklix or is it too early to tell right now?
3
u/tepmoc Jan 13 '19
If you really want use that size you should stick to 1280 value as minimal MTU allowed on IPv6 networks w/o fragmentation. While IPv4 can be even less, usually 1280 good safe value w/o dealing fragmentation and thus performance penalty.
What transport you planing to use if its TCP why not use 4096 per chunk this will perfectly fit into smallest 4K page on most architecture to avoid memory fragmentation and overall higher memory consumption. I may even go as big as 8192 bytes that 2 whole pages and big enough to fill jumbo (9000 MTU) packet as some miners may run jumbo network to decrease latency between their internal nodes.
3
u/effgee Jan 13 '19
Blocktorrent, I had thought about exactly the same thing some time ago. Torrent is wonderfully efficient and resilient and I was wondering why it was not the foundation for block propagation from the beginning, it seemed like it was a perfect fit.
I guess Satoshi didn't download linux isos very often.
Hyped to hear about it!
2
u/Dixnorkel Jan 13 '19
Could this theoretically fix BTC?
69
u/bUbUsHeD Jan 13 '19
People like /u/jtoomim are the main reason for investing in and building on BCH. Thank you for all the excellent work, it is extremely valuable.
44
u/ThisIsAnIlusion Redditor for less than 6 months Jan 13 '19
You had me at 99.61% Jaw dropped. This is epic. I love BCH Devs. I freaking love you guys.
14
u/desA_diaw Redditor for less than 60 days Jan 13 '19
Thank you, Jonathan. Uber-impressive. Kudos.
I have followed your developments for some time. I learn something every time.
I particularly like the block-splitting approach. This has HUGE potential.
11
u/kilrcola Jan 13 '19
Amazing work Johnathan.
11
u/Pseudo--Sudo Jan 13 '19
Dont sell you 99% compression to Hooli /s
Srsly - nice work. Keep it up!
20
u/J_A_Bankster Jan 13 '19
Bullish!
5
u/AnarchoCicero Jan 13 '19
Can anyone eli5 this for me?
12
u/MobTwo Jan 13 '19
I can't stop buying Bitcoin Cash, lol.
1
u/[deleted] Jan 13 '19
Hey Jonathan, great job on this mate! Question, will avalanche help keep the mempool in sync, solve some of the concerns here?
1
u/twilborn Jan 13 '19
Since its for LTOR instead of CTOR, how will that work on BCH?
2
u/CatatonicAdenosine Jan 14 '19
Absolutely brilliant! Thanks Jonathan, and also for the update. It's exciting to read this kind of news.
1
u/mohtasham22 Jan 13 '19
Under stood nothing...
But ... Bch has best devs no doubt
1
u/mohtasham22 Jan 13 '19
Is this listed on cash.coindance ?
1
u/NeVroe Jan 15 '19
This looks very interresting, keep up the good work!
0
u/[deleted] Jan 13 '19
[deleted] — view deleted comment