@did-btcr2/bitcoin (PATCH: the export ESPLORA_CHAIN_PAGE_SIZE; the chain listing request sets max_txs); @did-btcr2/method (MINOR: BeaconSignalDiscovery.indexer reads the full history and needs the chain listing); @did-btcr2/api (MINOR: dependency uptake, the same resolve behavior)The indexer signal discovery of @did-btcr2/method (BeaconSignalDiscovery.indexer) reads the beacon signals of a beacon address from an Esplora REST API. It made one call to address.getTxs, which is GET /address/:address/txs. That listing holds the mempool transactions and only the first page of the confirmed history: the newest 25 confirmed transactions. Discovery read no other page.
The specification (Resolve, Find Beacon Signals) tells the resolver to “Find the Bitcoin transactions” that spend from the beacon address and carry Signal Bytes. Then it tells the resolver what to do “For each transaction found”. The specification sets no limit on the history.
Any person can pay a beacon address. Thus any person can push an old signal off the first page with 25 payments to the beacon address. Then the resolver does not see that signal. It returns the DID document before that update, with no error. If the update rotated or removed a key, the old key still reads as valid.
Esplora pages the confirmed history with GET /address/:address/txs/chain[/:last_seen_txid]. The facts below come from the source of Blockstream electrs and mempool-electrs, and from live probes.
max_txs. mempool-electrs uses an operator setting (default 25), and the query parameter max_txs overrides it.[] with HTTP 200 if the serving state does not know the last_seen_txid transaction. A block reorganization makes a cursor unknown. A load-balanced server with an instance that is some blocks behind also does this. Thus an empty page does not prove the end of the history.chain_stats.tx_count. The separate request can go to a different instance, with a different state.MEMPOOL_BACKEND other than esplora has no chain listing. It sends HTTP 404. Electrum mode is the default of the mempool Docker image.BeaconSignalDiscovery.indexer calls addressSignals for each beacon address. addressSignals reads the history one page after the other with address.getConfirmedTxs (the chain listing), newest first. It reads each transaction one time. The signal rules of ADR 086 apply to each transaction with no change. The method returns the signals of the full history, or it throws. It never returns a part of the history.
The chain listing holds no mempool transaction, so discovery does not use /address/:address/txs any more. The check of status.confirmed stays as a guard.
The walk has four rules:
ESPLORA_CHAIN_PAGE_SIZE (25) transactions is the last page.block_hash on both pages. Else discovery throws INTERNAL_ERROR.INTERNAL_ERROR, because the walk does not advance. An example is a server that ignores the cursor and sends page 1 again.Rule 3 proves that the two pages come from the same chain. The same block hash at one height means the same chain at that height and below. Thus the rest of the history is the same. The proof is in the page data, so it is sound if the two pages come from different instances. An empty page after a full page breaks rule 3, so an unknown cursor never ends the walk.
A history of exactly 25 transactions needs two requests. The second page holds only the overlap transaction.
EsploraProtocol.getAddressTxsChain adds ?max_txs=25 to the request. The new export ESPLORA_CHAIN_PAGE_SIZE of @did-btcr2/bitcoin holds the value. Rule 2 needs a known page size. A mempool-electrs server with a different default sends 25 transactions because of the query parameter.
Discovery does not check chain_stats.tx_count. These are the reasons:
max_txs.The 25-per-page requirement goes into the documentation (decision 5).
If rule 3 or rule 4 stops the walk, discovery throws INTERNAL_ERROR with the data { address }. The message tells the caller to resolve again later. Discovery does not start a second walk.
A second walk directly after the stop usually starts in the reorganization window (fact 6). The state in the window is consistent, so the second walk ends with no stop. Then the resolve returns the DID document at the fork height, with no error. That is the defect that this ADR removes. A resolve that the caller starts later usually comes after the window.
The new section “Esplora server requirements” in packages/bitcoin/README.md holds a warning with three requirements:
MEMPOOL_BACKEND=esplora.The btc.rest row of packages/cli/docs/config-file.md links to the section.
A server that breaks requirement 1 or 2 fails closed. An HTTP 404 on the chain listing becomes an INTERNAL_ERROR that names the requirement and the fullnode signal discovery. Other HTTP errors propagate with no change. A server with an arbitrary order breaks rule 3 at the second page, so each resolve of an address with 25 or more transactions throws INTERNAL_ERROR.
chain_stats.tx_count after the walk. Rejected (decision 3).indexer discovery finds each signal of a beacon address, also if the address has more than 25 confirmed transactions. 25 payments to a beacon address do not hide a signal any more.packages/bitcoin has no retry for HTTP 429, so a public server with a rate limit can make such a resolve fail.INTERNAL_ERROR occurs more frequently for a short time: in a block reorganization, or if a load-balanced instance is some blocks behind when discovery reads page 2. The caller resolves again later. Only an address with 25 or more confirmed transactions needs a second page, so only such an address gets this error.INTERNAL_ERROR for some seconds after that block, on a load-balanced server. The resolve never returns a wrong document.indexer discovery any more. Before this change, it served the first page. This is the reason for the MINOR bump of method and api. The fullnode discovery and the default REST endpoints of @did-btcr2/api are not affected./address/:address/txs any more. Discovery skipped those transactions before, so it loses no signal.RECOMMENDED_* value, as ADR 059 does for the discovery rounds.packages/bitcoin.packages/bitcoin/src/client/rest/protocol.ts: ESPLORA_CHAIN_PAGE_SIZE; getAddressTxsChain adds ?max_txs=25.packages/bitcoin/src/index.ts: the export. packages/bitcoin/src/client/rest/address.ts: the JSDoc of getConfirmedTxs.packages/bitcoin/tests/rest-client.spec.ts: the request URLs.packages/method/src/core/beacon/signal-discovery.ts: addressSignals (the walk), historyPage (the HTTP 404 error), continuesAfter (rule 3), indexerSignal (the old loop body), IndexerRun, walkStopped, isNotFound.packages/method/tests/signal-discovery.spec.ts: the “history walk” tests.packages/api/tests/did-method-api.spec.ts, packages/api/tests/did-method-api-cas-policy.spec.ts: the test REST backends serve the chain listing.packages/bitcoin/README.md: the section “Esplora server requirements”. packages/cli/docs/config-file.md: the link in the btc.rest row.GET /address/:address/txs/chain[/:last_seen_txid].schema.rs and mempool-electrs schema.rs: the history listing.