<oembed><type>rich</type><version>1.0</version><author_name>npub1lwrwp8dzn9x5nqc7d735e0nuwxh0nyz5ezkfpjzr332efdxw9asq4z8zjm</author_name><author_url>https://nostr.ae/npub1lwrwp8dzn9x5nqc7d735e0nuwxh0nyz5ezkfpjzr332efdxw9asq4z8zjm</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2014-07-17&#xA;📝 Original message:OVERVIEW&#xA;&#xA;To improve block propagation, add a new block message that doesn&#39;t include&#xA;transactions the peer is known to have. The message must never require an&#xA;additional round trip due to any transactions the peer doesn&#39;t have, but&#xA;should&#xA;be compatible with peers sometimes forgetting transactions they have known.&#xA;&#xA;APPROACH&#xA;&#xA;For peers advertising support for squashed blocks: a node tracks what txes&#xA;it&#xA;knows each peer has seen (inv received, tx sent, tx appeared in competing&#xA;block&#xA;known to peer). Nodes push block contents as txes-not-already-known +&#xA;txids-known.&#xA;&#xA;A node should be able to forget invs it has seen without invalidating what&#xA;peers&#xA;know about its known txes. To allow for this, a node assembles a bloom&#xA;filter of&#xA;a set of txes it is going to forget, and sends it to peers. The node can&#xA;erase&#xA;the txes as soon as no blocks requested before the filter was pushed are in&#xA;flight (relying on the assumption that messages can be expected to be&#xA;processed&#xA;in order).&#xA;&#xA;When a node receives a forgotten-filter, it ORs it into its&#xA;forgotten-filter for&#xA;that peer. Any transactions matching the forgotten-filter are always&#xA;included in&#xA;full with a block. If the filter is getting full, the node can just clear it&#xA;along with peer.setTxKnown.&#xA;&#xA;COSTS&#xA;&#xA;Bloom filtering:&#xA;Since the bloom filter is likely to grow slowly and can be dropped when it&#xA;is&#xA;becoming full, a cheap set of hash functions and element size can be used to&#xA;keep overhead more restricted than the bloom filtering done for spv. It&#39;s&#xA;important for testing txes against the filter to be fast so that it doesn&#39;t&#xA;delay pushing the block more than the squashing helps.&#xA;Nodes currently forget txes rarely, so the bloom filters would only need to&#xA;be&#xA;used at all under conditions that are not currently common -- but I think&#xA;they&#39;re important to include to allow for different node behavior in this&#xA;regard&#xA;in the future.&#xA;&#xA;Tracking txes known to peers:&#xA;A multimap of txid-&gt;peerId would obviate the current setCurrentlyKnown, and&#xA;would not take much more space since each additional peer adds about 1&#xA;peerId&#xA;per txid (setCurrentlyKnown keeps a uint256 per peer per txid, although it&#xA;tracks somewhat fewer txid per node).&#xA;&#xA;Potential vulnerabilities:&#xA;- Since the bloom filters will have lower maximum overhead than the current&#xA;SPV&#xA;  filters and can be dropped at will, this shouldn&#39;t enable any resource&#xA;  exhaustion attacks that aren&#39;t already possible.&#xA;- A squashed block with bogus or missing data would be easily detected not&#xA;to&#xA;  produce the correct merkle root for its BlockHeader.&#xA;&#xA;BENEFITS&#xA;&#xA;Assuming a fairly typical 500 tx block with transaction sizes averaging 300b&#xA;(both on the low side), for a 150kb block:&#xA;&#xA;% pruned | block size reduction | relative size reduction&#xA;-------- | -------------------- | -----------------------&#xA;100      | 134 kB               | 89%&#xA;50       | 67 kB                | 45%&#xA;25       | 33.5 kB              | 17%&#xA;&#xA;I&#39;ve been doing some logging, and when my node pushes a block to a peer it&#xA;seems&#xA;to typically know that a peer has seen most of the txes in the block. Even&#xA;in&#xA;the case of a small block with only 25% known-known transactions, total&#xA;network&#xA;bandwidth saved is greater than the bloom filters transmitted unless a node&#xA;is&#xA;forgetting transactions so rapidly that it pushes new maximum-size&#xA;forget-filters every block.&#xA;&#xA;So this is a net gain even in total bandwidth usage, but most importantly&#xA;it&#39;s&#xA;an improvement in block propagation rate and in how block propagation rate&#xA;scales with additional transactions.&#xA;&#xA;IMPLEMENTATION QUESTIONS&#xA;&#xA;How should block squashing capability be advertised -- new service bit?&#xA;&#xA;Bloom filters:&#xA;- How fast to test against could a suitable bloom filter be made?&#xA;- How much memory would each filter need to take, at maximum?&#xA;- Can the inputs all being 32 byte hashes be used to optimize filter hash&#xA;  calculations?&#xA;&#xA;ROADMAP&#xA;&#xA;If there&#39;s support for this proposal, I can begin working on the specific&#xA;implementation details, such as the bloom filters, message format, and&#xA;capability advertisment, and draft a BIP once I have a concrete proposal for&#xA;what those would look like and a corresponding precise cost/benefit&#xA;analysis.&#xA;&#xA;--kaz&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20140717/810d2f69/attachment.html&gt;</html></oembed>