Skip to content

Conversation

@jimpo
Copy link
Contributor

@jimpo jimpo commented Jan 17, 2018

This is a revision of #609 that is intended as a replacement due to the number of substantial changes. Test vectors will be added once the BIP has been reviewed by the community and the reference implementation is updated.

Abstract

This BIP describes a new light client protocol in Bitcoin that improves upon currently available options. The standard light client protocol in use today, defined in BIP 37, has known flaws that weaken the security and privacy of clients and allow denial-of-service attack vectors on full nodes. The new protocol overcomes these issues by allowing light clients to obtain compact probabilistic filters of block content from full nodes and download full blocks if the filter matches relevant data.

New P2P messages empower light clients to securely sync the blockchain without relying on a trusted source. This BIP also defines a filter header, which serves as a commitment to all filters for previous blocks and provides the ability to efficiently detect malicious or faulty peers serving invalid filters. The resulting protocol guarantees that light clients with at least one honest peer are able to identify the correct block filters.

State of Implementation

We've tested the implementation of both a light client implementing this BIP, as well as the serving full-node on Bitcoin's testnet over the past several months. Additionally, this new operating mode also serves as the basis for our light weight Lightning node. These implementations are based on an earlier version of the spec, and require some updates.

@luke-jr
Copy link
Member

luke-jr commented Jan 18, 2018

Please use BIP number 158.

@luke-jr luke-jr changed the title Client Side Filtering BIP 158: Client Side Block Filtering Jan 18, 2018
@jimpo
Copy link
Contributor Author

jimpo commented Jan 18, 2018

@luke-jr Thanks! There are two BIPs now though. It would be nice to get two sequential numbers.

@luke-jr
Copy link
Member

luke-jr commented Jan 18, 2018

Two BIPs? What am I overlooking? I don't see that?

@jimpo
Copy link
Contributor Author

jimpo commented Jan 18, 2018

There are two files. They are related, but separate BIPs.

  1. Client Side Block Filtering
  2. Compact Block Filters for Light Clients

@luke-jr
Copy link
Member

luke-jr commented Jan 18, 2018

Sorry, totally overlooked that this PR had two files.. Let's go with 157 & 158 then? Also, note there is no Editor key in the preamble.

@jimpo
Copy link
Contributor Author

jimpo commented Jan 18, 2018

Great, thanks. Will update shortly.

@luke-jr luke-jr changed the title BIP 158: Client Side Block Filtering BIPs 157 & 158: Block Filtering stuff Jan 18, 2018
@jimpo jimpo force-pushed the client-side-filtering branch 8 times, most recently from 5125420 to c916101 Compare January 19, 2018 19:25
@jimpo
Copy link
Contributor Author

jimpo commented Jan 22, 2018

@luke-jr Anything else required for merge here?

@jimpo jimpo force-pushed the client-side-filtering branch from c916101 to 996c7c8 Compare January 22, 2018 21:54
@luke-jr
Copy link
Member

luke-jr commented Jan 23, 2018

Looks good

@luke-jr luke-jr merged commit ec54908 into bitcoin:master Jan 23, 2018
@hkjn
Copy link

hkjn commented Jan 23, 2018

Maybe you're already aware, but FYI there's a remaining TODO in BIP158 for test vectors:

cc @jimpo @luke-jr

@jimpo jimpo deleted the client-side-filtering branch March 8, 2018 22:19
sipa added a commit to bitcoin/bitcoin that referenced this pull request Apr 26, 2018
9b27047 [doc] Include txindex changes in the release notes. (Jim Posen)
ed77dd6 [test] Simple unit test for TxIndex. (Jim Posen)
6d772a3 [rpc] Public interfaces to GetTransaction block until synced. (Jim Posen)
a03f804 [index] Move disk IO logic from GetTransaction to TxIndex::FindTx. (Jim Posen)
e0a3b80 [validation] Replace tx index code in validation code with TxIndex. (Jim Posen)
8181db8 [init] Initialize and start TxIndex in init code. (Jim Posen)
f90c3a6 [index] TxIndex method to wait until caught up. (Jim Posen)
70d510d [index] Allow TxIndex sync thread to be interrupted. (Jim Posen)
94b4f8b [index] TxIndex initial sync thread. (Jim Posen)
34d68bf [index] Create new TxIndex class. (Jim Posen)
c88bcec [db] Migration for txindex data to new, separate database. (Jim Posen)
0cb8303 [db] Create separate database for txindex. (Jim Posen)

Pull request description:

  I'm re-opening #11857 as a new pull request because the last one stopped loading for people

  -------------------------------

  This refactors the tx index code to be in it's own class and get built concurrently with validation code. The main benefit is decoupling and moving the txindex into a separate DB. The primary motivation is to lay the groundwork for other indexers that might be desired (such as the [compact filters](bitcoin/bips#636)). The basic idea is that the TxIndex spins up its own thread, which first syncs the txindex to the current block index, then once in sync the BlockConnected ValidationInterface hook writes new blocks.

  ### DB changes

  At the suggestion of some other developers, the txindex has been split out into a separate database. A data migration runs at startup on any nodes with a legacy txindex. Currently the migration blocks node initialization until complete.

  ### Open questions

  - Should the migration of txindex data from the old DB to the new DB block in init or should it happen in a background thread? The downside to backgrounding it is that `getrawtransaction` would return an error message saying the txindex is syncing while the migration is running.

  ### Impact

  In a sample size n=1 test where I synced nodes from scratch, the average time [Index writing](https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1903) was 3.36ms in master and 1.72ms in this branch. The average time between `UpdateTip` log lines for sequential blocks between 400,000 and IBD end on mainnet was 0.297204s in master and 0.286134s in this branch. Most likely this is just variance in IBD times, but I can try with some more trials if people want.

Tree-SHA512: 451fd7d95df89dfafceaa723cdf0f7b137615b531cf5c5035cfb54e9ccc2026cec5ac85edbcf71b7f4e2f102e36e9202b8b3a667e1504a9e1a9976ab1f0079c4
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request May 25, 2021
9b27047 [doc] Include txindex changes in the release notes. (Jim Posen)
ed77dd6 [test] Simple unit test for TxIndex. (Jim Posen)
6d772a3 [rpc] Public interfaces to GetTransaction block until synced. (Jim Posen)
a03f804 [index] Move disk IO logic from GetTransaction to TxIndex::FindTx. (Jim Posen)
e0a3b80 [validation] Replace tx index code in validation code with TxIndex. (Jim Posen)
8181db8 [init] Initialize and start TxIndex in init code. (Jim Posen)
f90c3a6 [index] TxIndex method to wait until caught up. (Jim Posen)
70d510d [index] Allow TxIndex sync thread to be interrupted. (Jim Posen)
94b4f8b [index] TxIndex initial sync thread. (Jim Posen)
34d68bf [index] Create new TxIndex class. (Jim Posen)
c88bcec [db] Migration for txindex data to new, separate database. (Jim Posen)
0cb8303 [db] Create separate database for txindex. (Jim Posen)

Pull request description:

  I'm re-opening bitcoin#11857 as a new pull request because the last one stopped loading for people

  -------------------------------

  This refactors the tx index code to be in it's own class and get built concurrently with validation code. The main benefit is decoupling and moving the txindex into a separate DB. The primary motivation is to lay the groundwork for other indexers that might be desired (such as the [compact filters](bitcoin/bips#636)). The basic idea is that the TxIndex spins up its own thread, which first syncs the txindex to the current block index, then once in sync the BlockConnected ValidationInterface hook writes new blocks.

  ### DB changes

  At the suggestion of some other developers, the txindex has been split out into a separate database. A data migration runs at startup on any nodes with a legacy txindex. Currently the migration blocks node initialization until complete.

  ### Open questions

  - Should the migration of txindex data from the old DB to the new DB block in init or should it happen in a background thread? The downside to backgrounding it is that `getrawtransaction` would return an error message saying the txindex is syncing while the migration is running.

  ### Impact

  In a sample size n=1 test where I synced nodes from scratch, the average time [Index writing](https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1903) was 3.36ms in master and 1.72ms in this branch. The average time between `UpdateTip` log lines for sequential blocks between 400,000 and IBD end on mainnet was 0.297204s in master and 0.286134s in this branch. Most likely this is just variance in IBD times, but I can try with some more trials if people want.

Tree-SHA512: 451fd7d95df89dfafceaa723cdf0f7b137615b531cf5c5035cfb54e9ccc2026cec5ac85edbcf71b7f4e2f102e36e9202b8b3a667e1504a9e1a9976ab1f0079c4
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Apr 30, 2022
9b27047 [doc] Include txindex changes in the release notes. (Jim Posen)
ed77dd6 [test] Simple unit test for TxIndex. (Jim Posen)
6d772a3 [rpc] Public interfaces to GetTransaction block until synced. (Jim Posen)
a03f804 [index] Move disk IO logic from GetTransaction to TxIndex::FindTx. (Jim Posen)
e0a3b80 [validation] Replace tx index code in validation code with TxIndex. (Jim Posen)
8181db8 [init] Initialize and start TxIndex in init code. (Jim Posen)
f90c3a6 [index] TxIndex method to wait until caught up. (Jim Posen)
70d510d [index] Allow TxIndex sync thread to be interrupted. (Jim Posen)
94b4f8b [index] TxIndex initial sync thread. (Jim Posen)
34d68bf [index] Create new TxIndex class. (Jim Posen)
c88bcec [db] Migration for txindex data to new, separate database. (Jim Posen)
0cb8303 [db] Create separate database for txindex. (Jim Posen)

Pull request description:

  I'm re-opening bitcoin#11857 as a new pull request because the last one stopped loading for people

  -------------------------------

  This refactors the tx index code to be in it's own class and get built concurrently with validation code. The main benefit is decoupling and moving the txindex into a separate DB. The primary motivation is to lay the groundwork for other indexers that might be desired (such as the [compact filters](bitcoin/bips#636)). The basic idea is that the TxIndex spins up its own thread, which first syncs the txindex to the current block index, then once in sync the BlockConnected ValidationInterface hook writes new blocks.

  ### DB changes

  At the suggestion of some other developers, the txindex has been split out into a separate database. A data migration runs at startup on any nodes with a legacy txindex. Currently the migration blocks node initialization until complete.

  ### Open questions

  - Should the migration of txindex data from the old DB to the new DB block in init or should it happen in a background thread? The downside to backgrounding it is that `getrawtransaction` would return an error message saying the txindex is syncing while the migration is running.

  ### Impact

  In a sample size n=1 test where I synced nodes from scratch, the average time [Index writing](https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1903) was 3.36ms in master and 1.72ms in this branch. The average time between `UpdateTip` log lines for sequential blocks between 400,000 and IBD end on mainnet was 0.297204s in master and 0.286134s in this branch. Most likely this is just variance in IBD times, but I can try with some more trials if people want.

Tree-SHA512: 451fd7d95df89dfafceaa723cdf0f7b137615b531cf5c5035cfb54e9ccc2026cec5ac85edbcf71b7f4e2f102e36e9202b8b3a667e1504a9e1a9976ab1f0079c4
malbit pushed a commit to malbit/raptoreum that referenced this pull request Aug 7, 2022
9b2704777c [doc] Include txindex changes in the release notes. (Jim Posen)
ed77dd6b30 [test] Simple unit test for TxIndex. (Jim Posen)
6d772a3d44 [rpc] Public interfaces to GetTransaction block until synced. (Jim Posen)
a03f804f2a [index] Move disk IO logic from GetTransaction to TxIndex::FindTx. (Jim Posen)
e0a3b80033 [validation] Replace tx index code in validation code with TxIndex. (Jim Posen)
8181db88f6 [init] Initialize and start TxIndex in init code. (Jim Posen)
f90c3a62f5 [index] TxIndex method to wait until caught up. (Jim Posen)
70d510d93c [index] Allow TxIndex sync thread to be interrupted. (Jim Posen)
94b4f8bbb9 [index] TxIndex initial sync thread. (Jim Posen)
34d68bf3a3 [index] Create new TxIndex class. (Jim Posen)
c88bcec93f [db] Migration for txindex data to new, separate database. (Jim Posen)
0cb8303241 [db] Create separate database for txindex. (Jim Posen)

Pull request description:

  I'm re-opening #11857 as a new pull request because the last one stopped loading for people

  -------------------------------

  This refactors the tx index code to be in it's own class and get built concurrently with validation code. The main benefit is decoupling and moving the txindex into a separate DB. The primary motivation is to lay the groundwork for other indexers that might be desired (such as the [compact filters](bitcoin/bips#636)). The basic idea is that the TxIndex spins up its own thread, which first syncs the txindex to the current block index, then once in sync the BlockConnected ValidationInterface hook writes new blocks.

  ### DB changes

  At the suggestion of some other developers, the txindex has been split out into a separate database. A data migration runs at startup on any nodes with a legacy txindex. Currently the migration blocks node initialization until complete.

  ### Open questions

  - Should the migration of txindex data from the old DB to the new DB block in init or should it happen in a background thread? The downside to backgrounding it is that `getrawtransaction` would return an error message saying the txindex is syncing while the migration is running.

  ### Impact

  In a sample size n=1 test where I synced nodes from scratch, the average time [Index writing](https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1903) was 3.36ms in master and 1.72ms in this branch. The average time between `UpdateTip` log lines for sequential blocks between 400,000 and IBD end on mainnet was 0.297204s in master and 0.286134s in this branch. Most likely this is just variance in IBD times, but I can try with some more trials if people want.

Tree-SHA512: 451fd7d95df89dfafceaa723cdf0f7b137615b531cf5c5035cfb54e9ccc2026cec5ac85edbcf71b7f4e2f102e36e9202b8b3a667e1504a9e1a9976ab1f0079c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants