Hi All,
Something I've been playing with for a while and was thinking would require a BUIP but @theZerg thinks maybe it doesn't rise to the level of requiring one. It's only about 15 lines of code and doesn't change much but is another performance enhancement and really the second part to Xtreme Thinblocks. I've attached what was going to be the BUIP details below and your comments are appreciated as well as whether you think this type of change needs a formal vote. (Thanks to @YarkoL for the branding and for being a sounding board)
Summary
The problem of quickly relaying blocks of any size to all nodes worldwide within just a few seconds has remained elusive. Without the ability to do so means there is no way to effectively increase block size without potentially causing problems for nodes which would no longer be able to keep up with the blockchain and not be able to consistently relay transactions in a timely manner. Often forgotten in the debate is that during the time a block is downloaded and validated, no transactions can be relayed by that node. If today it takes a node 10 to 60 seconds to download and validate a block then as we increase block size further we will only create ever larger queues of un-propagated transactions with subsequent sudden transaction spikes as the queues become unblocked.
Xtreme Thinblocks fixed the first part of p2p block relay; the downloading of a block of almost any size is now in the sub second region. However, the second part of relay, the validation of the block is equally important and can be more time consuming. Enter Xpress Validation or XV. XV builds on Xtreme Thinblock technology and now makes it possible to validate a block of virtually any size in a consistently short period of time. By using the XV reference client, testing shows that full blocks are typically downloaded and then fully verified, with the tip connected, in approximately 0.75 to 1.5 seconds for the full round trip (* NOTE: these numbers are all from the v11.2 client on a very slow laptop, I'll update these as I get to v12). Therefore XV in addition to Xtreme Thinblocks will make it possible to relay newly mined blocks of almost any size to the entire global network of nodes within 5 to 10 seconds, thus freeing up local CPU and bandwidth while also allowing for a more consistent and reliable flow of transactions throughout the p2p network than is currently possible.
Design
There are several steps within the process of validating a block. Most of them are relatively quick and in terms of milliseconds or tenths of a second to execute. Where block validation gets slow is during the process of checking inputs. So how can we get around that and still fully validate the block before relaying it to another node?
As it turns out it’s not that difficult with the reason being that currently every transaction in a block is actually checked twice; once, during the process of accepting a transaction into the memory pool and once again when the block is verified; this double checking works in our favour as follows. With Xtreme Thinblocks we re-construct the block from transactions that already exist in the memory pool and have been previously verified, their inputs have already checked; we don’t have to check those again! The only transactions we have to check are the ones we know nothing about, the ones arriving in the XThinblock and which are only a handful in number. So out of a typically 1500 to 2500 transaction block we only need to verify a few of them before connecting the tip. In this way, verifying a full block typically takes about 0.75 seconds rather than 10 to 30 seconds and sometimes longer. Furthermore, it has shown to be twice as fast as when relying on the signature cache.
Testing
In order to easily test XV you must also download XThinblocks. Use the following setting to connect to a thinblock provider.
connect-thinblock=<ip>
When this setting is used the node will connect to the IP address(es) specified and only download blocks or thinblocks from those IP addresses. However, transactions will still be downloaded from all connected peers regardless of this setting in order to keep the memory pools in relative sync.
Test Results
The following results show an example of the requesting of an almost 1MB block (over the internet to a node 1200 miles away) to the receiving of the block and the final updating of the tip with the associated response times, and performed on an antiquated dual core laptop with an Intel B820 processor.
2016-02-02 15:28:01 Starting creation of bloom filter
2016-02-02 15:28:01 Sending bloom filter: 9312 bytes peer=3610
2016-02-02 15:28:01 Requesting Thinblock 000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 (396326) peer=3610
2016-02-02 15:28:01 Received Thinblock 000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 peer=3610 (9408 bytes)
2016-02-02 15:28:01 Reassembled Thinblock for 000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 (949216 bytes)
2016-02-02 15:28:01 Received block 000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 in 0.47 seconds
2016-02-02 15:28:02 UpdateTip: new best=000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 height=396326 log2_work=84.026511 tx=107482487 date=2016-02-02 15:26:59 progress=0.999999 cache=57.3MiB(23696tx)
2016-02-02 15:28:02 Processed block 000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 in 0.56 seconds
Backward Compatibility
Although XV is potentially compatible with any client, it is currently only invoked when receiving an XThinblock and when “use-thinblocks” is enabled on the client. In other words, we can download blocks from any client, but XV is only used when downloading a block from a node that supports thinblocks.
Fall Back
Turning off XV is the same as turning off XThinblocks and is a straightforward “bitcoin.conf” entry. By setting “use-thinblocks” to zero the downloading of thinblocks and XV will be turned off.
use-thinblocks=0
Deployment
This enhancement does not require a hard or soft fork.
Future Strategies
Lightning Block Relay (for Miners): Now that the groundwork is done for the p2p node network it would be possible to build a truly decentralized relay for miners.
Enhanced Memory Pool Synchronization: Although XThinblocks and XV will improve mempool synchronization by relieving stress on the single threaded network layer there is much more to be done in order to scale into the 100’s or 1000’s of transactions per second and higher. Several initiatives could improve the fast relay of transactions throughout the network such as transaction bundling combined with datastream compression and a multithreaded network.
Something I've been playing with for a while and was thinking would require a BUIP but @theZerg thinks maybe it doesn't rise to the level of requiring one. It's only about 15 lines of code and doesn't change much but is another performance enhancement and really the second part to Xtreme Thinblocks. I've attached what was going to be the BUIP details below and your comments are appreciated as well as whether you think this type of change needs a formal vote. (Thanks to @YarkoL for the branding and for being a sounding board)
Summary
The problem of quickly relaying blocks of any size to all nodes worldwide within just a few seconds has remained elusive. Without the ability to do so means there is no way to effectively increase block size without potentially causing problems for nodes which would no longer be able to keep up with the blockchain and not be able to consistently relay transactions in a timely manner. Often forgotten in the debate is that during the time a block is downloaded and validated, no transactions can be relayed by that node. If today it takes a node 10 to 60 seconds to download and validate a block then as we increase block size further we will only create ever larger queues of un-propagated transactions with subsequent sudden transaction spikes as the queues become unblocked.
Xtreme Thinblocks fixed the first part of p2p block relay; the downloading of a block of almost any size is now in the sub second region. However, the second part of relay, the validation of the block is equally important and can be more time consuming. Enter Xpress Validation or XV. XV builds on Xtreme Thinblock technology and now makes it possible to validate a block of virtually any size in a consistently short period of time. By using the XV reference client, testing shows that full blocks are typically downloaded and then fully verified, with the tip connected, in approximately 0.75 to 1.5 seconds for the full round trip (* NOTE: these numbers are all from the v11.2 client on a very slow laptop, I'll update these as I get to v12). Therefore XV in addition to Xtreme Thinblocks will make it possible to relay newly mined blocks of almost any size to the entire global network of nodes within 5 to 10 seconds, thus freeing up local CPU and bandwidth while also allowing for a more consistent and reliable flow of transactions throughout the p2p network than is currently possible.
Design
There are several steps within the process of validating a block. Most of them are relatively quick and in terms of milliseconds or tenths of a second to execute. Where block validation gets slow is during the process of checking inputs. So how can we get around that and still fully validate the block before relaying it to another node?
As it turns out it’s not that difficult with the reason being that currently every transaction in a block is actually checked twice; once, during the process of accepting a transaction into the memory pool and once again when the block is verified; this double checking works in our favour as follows. With Xtreme Thinblocks we re-construct the block from transactions that already exist in the memory pool and have been previously verified, their inputs have already checked; we don’t have to check those again! The only transactions we have to check are the ones we know nothing about, the ones arriving in the XThinblock and which are only a handful in number. So out of a typically 1500 to 2500 transaction block we only need to verify a few of them before connecting the tip. In this way, verifying a full block typically takes about 0.75 seconds rather than 10 to 30 seconds and sometimes longer. Furthermore, it has shown to be twice as fast as when relying on the signature cache.
Testing
In order to easily test XV you must also download XThinblocks. Use the following setting to connect to a thinblock provider.
connect-thinblock=<ip>
When this setting is used the node will connect to the IP address(es) specified and only download blocks or thinblocks from those IP addresses. However, transactions will still be downloaded from all connected peers regardless of this setting in order to keep the memory pools in relative sync.
Test Results
The following results show an example of the requesting of an almost 1MB block (over the internet to a node 1200 miles away) to the receiving of the block and the final updating of the tip with the associated response times, and performed on an antiquated dual core laptop with an Intel B820 processor.
2016-02-02 15:28:01 Starting creation of bloom filter
2016-02-02 15:28:01 Sending bloom filter: 9312 bytes peer=3610
2016-02-02 15:28:01 Requesting Thinblock 000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 (396326) peer=3610
2016-02-02 15:28:01 Received Thinblock 000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 peer=3610 (9408 bytes)
2016-02-02 15:28:01 Reassembled Thinblock for 000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 (949216 bytes)
2016-02-02 15:28:01 Received block 000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 in 0.47 seconds
2016-02-02 15:28:02 UpdateTip: new best=000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 height=396326 log2_work=84.026511 tx=107482487 date=2016-02-02 15:26:59 progress=0.999999 cache=57.3MiB(23696tx)
2016-02-02 15:28:02 Processed block 000000000000000006659c241d9f078952c3ed821433cc79e00e41ff02f8c822 in 0.56 seconds
Backward Compatibility
Although XV is potentially compatible with any client, it is currently only invoked when receiving an XThinblock and when “use-thinblocks” is enabled on the client. In other words, we can download blocks from any client, but XV is only used when downloading a block from a node that supports thinblocks.
Fall Back
Turning off XV is the same as turning off XThinblocks and is a straightforward “bitcoin.conf” entry. By setting “use-thinblocks” to zero the downloading of thinblocks and XV will be turned off.
use-thinblocks=0
Deployment
This enhancement does not require a hard or soft fork.
Future Strategies
Lightning Block Relay (for Miners): Now that the groundwork is done for the p2p node network it would be possible to build a truly decentralized relay for miners.
Enhanced Memory Pool Synchronization: Although XThinblocks and XV will improve mempool synchronization by relieving stress on the single threaded network layer there is much more to be done in order to scale into the 100’s or 1000’s of transactions per second and higher. Several initiatives could improve the fast relay of transactions throughout the network such as transaction bundling combined with datastream compression and a multithreaded network.