BOMBARCHIVE
Explore

A living reference collection. Written in the wiki, preserved in Git.

The archiveBitcoin

BIP 158

BIP 158, Compact Block Filters for Light Clients, specifies the deterministic, compressed block filters used by the BIP 157 network protocol. Its authors are Olaoluwa Osuntokun and Alex Akselrod; its assigned date is 24 May 2017. The distinction is deliberate: BIP 158 defines what a filter contains and how to encode it, while BIP 157 defines how Bitcoin peers exchange, compare and check filters. Maintained BIP 158 specification

A block's scripts in a compact search structure

The initial and specified type is basic, code 0x00. For every transaction in a block, its filter includes the scriptPubKey of each new output except outputs whose script begins with OP_RETURN. For every non-coinbase input it also includes the scriptPubKey of the previous output being spent. These are script bytes, not printed wallet addresses, transaction identifiers or arbitrary transaction bodies. Duplicate input elements are treated as a set. Basic filter contents

That spent-output requirement matters when rebuilding a filter from Bitcoin history: the previous output's script is not necessarily written in the block being filtered. A construction system needs a trustworthy way to obtain the referenced output, such as validated historical block/UTXO data. It cannot faithfully derive a basic filter merely by scanning the current block's new output scripts. Filter content rules

The filter uses a Golomb-coded set (GCS), not a traditional Bloom filter. Its construction hashes the items to integers in a bounded range, sorts the integers, and compresses successive differences with Golomb–Rice coding. The specified basic parameters are P = 19 and M = 784931. The SipHash key is derived from the first 16 bytes of the block hash in its specified byte order. Each block therefore has reproducibly derived filter bytes for this filter type when the underlying chain data is fixed. Golomb-coded set, basic construction

A GCS member is guaranteed to match its correctly constructed filter; unrelated queried items can sometimes match by chance. The probability described by the BIP is governed by M. A match therefore says this block may be relevant. The client must fetch and inspect the full block to establish that it actually contains the script or transaction it wants. A non-match is meaningful only if the served filter is complete and authentic. Golomb-coded sets · BIP 157

A filter can be correct while a matcher is wrong

A concrete client-side failure appeared in April 2019. The btcsuite/btcutil GCS library could mishandle the legitimate case where an item's keyed hash reduced to zero. Its old Match implementation entered the search loop only if an accumulator initially set to zero was less than the query term; with a term of zero, it skipped the search and could return a false negative. A separate ZipMatchAny start-state problem could incorrectly match a zero-valued query. These are software matching defects, not evidence that BIP 158's prescribed filter omits correctly inserted elements. Source correction

A 25 April 2019 regression test constructed a 13-item set with a specifically chosen reduced-zero target, checking inclusion and exclusion cases. Neutrino PR #148 adopted the corrected library the next day; the 7 May Lightning App 0.5.1-alpha release separately reported a matching fix capable of preventing missed transactions. BIP 157 traces the full dependency chain and its evidentiary limits. Neither those release notes nor the test establish observed user losses.

What the basic filter deliberately leaves out

The OP_RETURN omission is an explicit specification choice. The BIP's rationale was to keep open a future possibility of committing filter data inside an OP_RETURN output without making construction depend on itself. That rationale documents a design option, not a claim that Bitcoin adopted such a consensus commitment. Basic filter, contents and rationale

For archival indexing, the scope is consequential. A BIP 158 basic filter does not index the raw contents of a witness, an inscription envelope, an OP_RETURN payload or a Bitmap District name. It indexes the specified scripts. It may help a wallet decide which blocks involve known scripts, but it is not an Ordinals search engine, a general full-text blockchain search service or a proof of application-level rules. This is an inference from the explicitly enumerated inputs to the filter, not a tested claim about any particular inscription indexer. Enumerated filter elements

The 2017 public draft and its measurement boundary

The earliest public announcement I found for this line of work is 1 June 2017, when Olaoluwa Osuntokun introduced an unnumbered Compact Client Side Filtering for Light Clients proposal with Alex Akselrod. Their bitcoin-dev message described both basic/normal and extended filters and a fixed false-positive parameter expressed then as 1/2^20. It reported a 6.9-GB total mainnet index from their experiment, partitioned between approximately 3.1 GB of normal filters and 3.9 GB of extended filters. These numbers describe the author's 2017 experimental dataset and then-proposed contents; they are not independent measurements or present-day BIP 158 storage requirements. Contemporary author announcement and figures

That message linked a mutable unnumbered draft. The earliest surviving versioned Git object has a 1 June author timestamp but a 9 November 2017 committer timestamp. Its combined specification defined Normal (0x00) and Extended (0x01) filters, network discovery messages and reference test vectors. November fixup commits changed that draft further, so treating today's branch tip as an immutable 1 June snapshot would misdate its contents. When the canonical BIPs repository received separate 157 and 158 files on 22 January 2018, that new commit retained a 1 June 2017 author date but has a January 2018 committer date. 30 November revision · Canonical addition

The original 2017 combined proposal is therefore evidence of an earlier wider filter and protocol design, not proof that deployed BIP 158 clients ever used extended filters. See BIP 157 for the separate history of filter transport and verification.

The earlier filters that did not survive 2018

The filter's present simplicity was a design choice reached through revision, not the whole 2017–2018 proposal. The first identified BIPs-repository version, committed 22 January 2018, defined two filter types. Its 0x00 basic filter included each non-coinbase input's outpoint, individual data pushes from parseable output scripts, and every transaction's txid. Its separate 0x01 extended filter included witness-stack items and scriptSig data pushes for non-coinbase transactions. The original also set P = 20 with a hash range derived from N * 2^P. These are proposed filter contents in an archived draft, not evidence that today's BIP 158 or Bitcoin Core serves witness-aware extended filters. January 2018 specification — primary Git artifact

The first adjustment came on 1 April 2018: a BIPs commit replaced the output-script data pushes with each output's whole scriptPubKey. That is a concrete encoding change: two outputs that contain the same pushed data but differ in script structure are not interchangeable as whole-script elements. April 2018 source change

A larger redesign was merged on 5 July 2018, following a pull request opened 1 June. It removed transaction IDs from the basic filter and removed the extended filter type altogether. It replaced spent outpoints with the scripts of the previous outputs being spent, excluded new outputs whose scripts begin with OP_RETURN, and separated the Golomb–Rice coding parameter P from the hash-range parameter M. The resulting basic configuration was P = 19, M = 784931. Accordingly, the earlier and later 0x00 filters encode different sets of items despite retaining the same type number; stored old-draft filter bytes cannot simply be relabelled as the later specification's basic filters. This is a comparison of the source definitions, not an independently reproduced cross-version network test. Revision PR and rationale · Merged source and test-vector changes

The pull-request author, Olaoluwa Osuntokun, argued that wallets could first match an output script and then inspect the relevant full block for an exact transaction ID, while the extended type lacked a clear use case and increased server storage. Those are contemporary first-party design reasons, not an independent benchmark proving that every application could dispense with the discarded elements. On 10 July, a follow-up commit corrected the text's description of the false-positive rate to relate it to 1/M, not 2^(-P); the current definition keeps P for Rice encoding. Subsequent source changes clarified the block-hash byte order and updated the test vectors, making reproducible filter bytes more precise than the early draft alone. Author's explanation · 10 July correction · 28 August endianness clarification · September test-vector update

For Ordinals history, this is a useful counterfactual with a clear boundary: an abandoned BIP 158 extended-filter design referred to witness-stack items, while the maintained and deployed basic-filter definition does not. Neither proposal nor deployed basic filters should be retrospectively described as a general inscription-content index. Inscription metadata and Inscription provenance require their own parsing and validation.

Filter hashes and verification

BIP 158 specifies the serialized filter. BIP 157 hashes those bytes and constructs a chain of filter headers for peers to compare. A client can compare the header chains supplied by multiple peers, find a disagreement and download the disputed full block to recompute its correct filter.

The filter-header sequence is not committed to by Bitcoin block headers under this design. Without a truthful comparison source, several colluding peers could present identical false filter chains. The BIP 157 protocol describes its stronger assurances under an assumption that at least one contacted peer is honest. A filter alone is neither a Bitcoin proof-of-work certificate nor a proof that no relevant payment was hidden by a malicious server. Filter headers, client operation and rationale

A first-party development chronology

24 May 2017
The BIP's assigned date. It identifies a proposal, not a software-release milestone. BIP header
1 June 2017
Osuntokun circulated the combined, unnumbered GCS filtering proposal and reported early normal-plus-extended filter measurements. The email verifies public circulation and the author's report, not independently reproducible storage totals. Contemporary announcement
9–30 November 2017
Versioned personal-fork commits preserve the combined filter design and later draft edits; their committer timestamps postdate the proposal's public announcement. Versioned draft · Revised draft
22 January 2018
The first identified bitcoin/bips commit adds the BIP 157 and 158 texts together. The later maintained document includes further revisions, so its exact wording should not be attributed wholesale to this initial record. Repository addition
1 April 2018
The draft changed its basic filter from individual output data pushes to complete output scripts. Source commit
5 July 2018
BIPs PR #687 merged a new basic-filter definition: no txids or extended filter, spent-prevout scripts rather than input outpoints, exclusion of OP_RETURN outputs, and P = 19, M = 784931. The June proposal and July merge are distinct dates. First-party proposal and merge
26 August 2018
Bitcoin Core merged its BIP 158 filter-construction implementation. The PR explicitly stated that the code was **not yet used elsewhere in Core**; no peer service was established by this merge. Merged construction PR
28 August–7 September 2018
The source clarified block-hash endianness for SipHash keys and updated test vectors, including unusual script cases. These refinements followed the July redesign rather than establishing a separate new deployed filter type. Endianness commit · Vector changes
14 September 2018
Lightning Labs announced Neutrino light-client support in lnd 0.5-beta and an associated testnet Lightning App alpha. It documented real implementation work, with mainnet adoption beyond this announcement still a separate question. Contemporary release announcement
18 April 2019
Bitcoin Core merged the persistent BlockFilterIndex, which stores filters, their hashes and filter headers. The PR described a roughly 3.8-GiB index at its then-tested height 565500; that is a historical benchmark, not the index's current size. Merged index PR and measured size
25–26 April 2019
btcutil added a zero-hash GCS match regression test and correction, and Neutrino adopted the updated dependency. This was an implementation repair, **not** a specification change to BIP 158. Test · Fix · Dependency update
24 November 2019
Bitcoin Core 0.19.0.1 released -blockfilterindex and the getblockfilter RPC, with release notes estimating roughly **4 GiB** for the historical index at that time. The release expressly **did not** offer filter retrieval over the P2P network. Release notes · Dated release notice
14 January 2021
Bitcoin Core 0.21.0 shipped the ability to **serve** BIP 157 filters over P2P with -blockfilterindex=1 -peerblockfilters=1. This was an explicitly configured service, not an automatic consequence of running a default node. Release notes
11 September 2025
The BIPs repository promoted BIP 158's metadata from **Draft** to **Final**, alongside BIP 157. A separate commit added mutual Requires references. The documents themselves and the implementation precede this status change by years. BIP 158 status · Cross-reference update
12 January 2026
A broad maintenance commit changed BIP metadata from **Final** or **Active** to **Deployed**. The current BIP 158 header uses that label, but the commit is not a node census or first-deployment event. Repository-wide status migration

Different indexes, different promises

The BlockFilterIndex is a compact search aid for wallet-relevant scripts. A full transaction index can locate historical transaction identifiers, while an Ordinals index parses inscription envelopes and determines application-specific identities and ordering. These structures answer different questions and may be operated together; their names and capabilities should not be exchanged.

BIP 152's compact blocks are also different. BIP 152 reduces redundant block-relay data between peers who have already seen many transactions. BIP 158 summarises scripts in confirmed blocks for light-client scanning. The similar adjective compact hides a different purpose. BIP 152 · BIP 158

Open research

Open question
Recover versioned 2018 test clients or released filter stores that followed the early two-filter specification, and determine whether any real interoperability or migration problem arose before the July 2018 redesign. A changed draft alone does not prove a production-network break.
Open question
Reproduce basic filter bytes for a small set of archived mainnet blocks using two independent implementations, including spent-prevout scripts and OP_RETURN exclusions. Record block hashes, software versions and results.
Open question
Establish measured 2026 filter-index size and coverage on a configured Bitcoin Core release; do not reuse the 2019 4-GiB estimate as a timeless storage requirement.