Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compressed block headers & merkle proofs over low bandwidth communications #1007

Closed
willcl-ark opened this issue May 20, 2020 · 9 comments
Closed

Comments

@willcl-ark
Copy link

I have written up an Electrum Protocol proposal which seeks to improve both:

  1. Reduce RPC bandwidth requirements (compressed block headers + protobuf/CBOR (de)serialisation)
  2. Reduce requirements of Clients making calls (removing block_height requirement)

The proposal can be found here: https://github.com/willcl-ark/electrum-low-bandwidth/blob/master/spec.adoc

I will cross-reference kyuupichan/aiorpcX#12, because it covers much of the same ground.

I am currently looking for feedback and would appreciate any comments on the proposal you may have.

@JeremyRand I notice in kyuupichan/aiorpcX#12 there is some conversation on performance; do you have any data on how many requests some of the more active Electrum Servers are handling? I want to understand if serialisation performance can really be significant or not

@willcl-ark
Copy link
Author

I should also cross-reference #712 from this repo

@JeremyRand
Copy link
Contributor

Okay, so regarding compressed block headers, I have some comments about how this might interact with AuxPoW chains:

  1. It would probably make sense to compress the parent block header.
  2. SIdechains frequently have more than 1 parent chain, e.g. Bitcoin and BCH are both regularly used as parent chains of Namecoin.
  3. The parent header's version field may be more diverse because of the use of multiple parent chains, i.e. there may be some benefit to supporting more than 7 previous values.
  4. The parent header's previous block hash field might be a repeat of the previous block's, because the sidechain and the parent chain have different difficulties.
  5. The parent header's previous block hash field might be the hash of a block from more than 1 block ago, due to the usage of multiple parent chains.
  6. The parent header's nbits field is likely to change every time the parent chain changes, so being able to remember more than 1 previous nbits value might be helpful. (Also, my understanding is that BCH's nbits changes every block, so compression of nbits is only useful for a subset of parent chains.)
  7. Implementing all of the above suggestions would probably cause the compression bitfield header to be more than 1 byte, so it would be beneficial to get some data on exactly how the tradeoff works in practice.
  8. It would be useful to evaluate how much compression each of these proposals achieves both with and without DEFLATE. E.g. long repeated strings are likely to be heavily compressed by DEFLATE even if we don't explicitly compress them in the protocol.

Also tagging Namecoin Core maintainer @domob1812 in case he has opinions on how this serialization might interact with the Namecoin P2P wire protocol.

@JeremyRand
Copy link
Contributor

@JeremyRand I notice in kyuupichan/aiorpcX#12 there is some conversation on performance; do you have any data on how many requests some of the more active Electrum Servers are handling?

I don't personally run any public ElectrumX servers. I have contact info for some of the operators of the public Namecoin ElectrumX servers, but I'm guessing that the Bitcoin ElectrumX servers are under considerably heavier load than Namecoin, so the Bitcoin ElectrumX operators are probably the people whose data matters.

@domob1812
Copy link
Contributor

I don't have any specific things to add to what @JeremyRand already posted.

@SomberNight
Copy link
Contributor

I have written up an Electrum Protocol proposal which seeks to improve both:
(1) Reduce RPC bandwidth requirements (compressed block headers + protobuf/CBOR (de)serialisation)
(2) Reduce requirements of Clients making calls (removing block_height requirement)

I think these are independent proposals.

Re (2),

Make height an optional parameter, now safe since BIP30 [8] and BIP34 [9]

note that the current implementation of blockchain.transaction.get_merkle in this present codebase uses the block_height to answer the request:

async def merkle_branch_for_tx_hash(self, height, tx_hash):
'''Return a triple (branch, tx_pos, cost).'''
tx_hashes, tx_hashes_cost = await self.tx_hashes_at_blockheight(height)

(although this could be changed; e.g. by calling the bitcoind getrawtransaction RPC (though minimising the bitcoind RPC invocations helps performance))

Add an additional transaction_index field to the return values in addition to the block_height so that a short_channel_id can be created for the transaction’s outputs.

I don't understand this. as per https://github.com/kyuupichan/electrumx/blob/bc175a6ed42cd6b968a556e27ba0f4408ae3b800/docs/protocol-methods.rst#blockchaintransactionget_merkle
the result already includes a block_height and a pos. Assuming you have the raw tx and can figure out the output index yourself, what else do you need to calculate a short_channel_id?

@remyers
Copy link

remyers commented May 22, 2020 via email

@remyers
Copy link

remyers commented May 22, 2020 via email

@kyuupichan
Copy link
Owner

I'll be taking the protocol in a different direction going forwards

@willcl-ark
Copy link
Author

@kyuupichan what direction are you looking to take it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants