Commit graph

63 commits

Author SHA1 Message Date
Brannon King
4e63bef33b [lbry] docs: update docs for LBRY
Co-authored-by: Roy Lee <roylee17@gmail.com>
2021-12-14 14:01:09 -08:00
Roy Lee
28a5e6fc65 [lbry] rename btcd to lbcd
Co-authored-by: Brannon King <countprimes@gmail.com>
2021-12-14 14:00:59 -08:00
Jake Sylvestre
d08785547a docs: update shields 2021-03-05 07:45:19 -05:00
David Hill
f7399e6157 build: clean linter warnings 2020-05-13 08:58:39 -04:00
qshuai
ef4cecf42b blockchain/indexers: Start a new line for long code 2020-03-04 09:42:00 -05:00
Olaoluwa Osuntokun
be191ca111
blockchain/indexers: fix bug in indexer re-org catch up
In this commit, we fix an existing bug in the re-org catch up logic for
the `IndexManager`. Before this commit, we would assign the block to the
_local_ scope rather than the outer scope. As a result, we would never
properly bisect the chain to find the fork point to be able to reconcile
the index state to the main chain only after a re-org occurs.

Fixes #1261
2018-08-22 19:46:27 -07:00
Olaoluwa Osuntokun
298efd8359
blockchain/indexers: ensure the cfindex gets inputs 2018-07-06 16:15:24 -07:00
Olaoluwa Osuntokun
102ca293f6
blockchain: pass in prevScript for constructing the basic filter 2018-07-06 16:15:24 -07:00
Olaoluwa Osuntokun
576800a99e
blockchain/indexer: remove extended filter 2018-07-06 16:15:23 -07:00
Olaoluwa Osuntokun
a26e2634fa
blockchain/indexers: update indexing to use stxos instead of utxo view for blocks
In this commit, we update all the indexers to use the stxo set for a
particular block rather than the utxo view for the block. We do this as
we can eliminate a large number of random reads for each block, and can
instead deserialize a single instance of all the outputs spent in that
block and feed in the prev input scripts to each indexer.
2018-05-30 20:47:40 -07:00
Dave Collins
a59ac5b18f
multi: Rework utxoset/view to use outpoints.
This modifies the utxoset in the database and related UtxoViewpoint to
store and work with unspent transaction outputs on a per-output basis
instead of at a transaction level.  This was inspired by similar recent
changes in Bitcoin Core.

The primary motivation is to simplify the code, pave the way for a
utxo cache, and generally focus on optimizing runtime performance.

The tradeoff is that this approach does somewhat increase the size of
the serialized utxoset since it means that the transaction hash is
duplicated for each output as a part of the key and some additional
details such as whether the containing transaction is a coinbase and the
block height it was a part of are duplicated in each output.

However, in practice, the size difference isn't all that large, disk
space is relatively cheap, certainly cheaper than memory, and it is much
more important to provide more efficient runtime operation since that is
the ultimate purpose of the daemon.

While performing this conversion, it also simplifies the code to remove
the transaction version information from the utxoset as well as the
spend journal.  The logic for only serializing it under certain
circumstances is complicated and it isn't actually used anywhere aside
from the gettxout RPC where it also isn't used by anything important
either.  Consequently, this also removes the version field of the
gettxout RPC result.

The utxos in the database are automatically migrated to the new format
with this commit and it is possible to interrupt and resume the
migration process.

Finally, it also updates the tests for the new format and adds a new
function to the tests to convert the old test data to the new format for
convenience.  The data has already been converted and updated in the
commit.

An overview of the changes are as follows:

- Remove transaction version from both spent and unspent output entries
  - Update utxo serialization format to exclude the version
  - Modify the spend journal serialization format
    - The old version field is now reserved and always stores zero and
      ignores it when reading
    - This allows old entries to be used by new code without having to
      migrate the entire spend journal
  - Remove version field from gettxout RPC result
- Convert UtxoEntry to represent a specific utxo instead of a
  transaction with all remaining utxos
  - Optimize for memory usage with an eye towards a utxo cache
    - Combine details such as whether the txout was contained in a
      coinbase, is spent, and is modified into a single packed field of
      bit flags
    - Align entry fields to eliminate extra padding since ultimately
      there will be a lot of these in memory
    - Introduce a free list for serializing an outpoint to the database
      key format to significantly reduce pressure on the GC
  - Update all related functions that previously dealt with transaction
    hashes to accept outpoints instead
  - Update all callers accordingly
  - Only add individually requested outputs from the mempool when
    constructing a mempool view
- Modify the spend journal to always store the block height and coinbase
  information with every spent txout
  - Introduce code to handle fetching the missing information from
    another utxo from the same transaction in the event an old style
    entry is encountered
    - Make use of a database cursor with seek to do this much more
      efficiently than testing every possible output
- Always decompress data loaded from the database now that a utxo entry
  only consists of a specific output
- Introduce upgrade code to migrate the utxo set to the new format
  - Store versions of the utxoset and spend journal buckets
  - Allow migration process to be interrupted and resumed
- Update all tests to expect the correct encodings, remove tests that no
  longer apply, and add new ones for the new expected behavior
  - Convert old tests for the legacy utxo format deserialization code to
    test the new function that is used during upgrade
  - Update the utxostore test data and add function that was used to
    convert it
- Introduce a few new functions on UtxoViewpoint
  - AddTxOut for adding an individual txout versus all of them
  - addTxOut to handle the common code between the new AddTxOut and
    existing AddTxOuts
  - RemoveEntry for removing an individual txout
  - fetchEntryByHash for fetching any remaining utxo for a given
    transaction hash
2018-05-27 03:07:41 -05:00
Olaoluwa Osuntokun
2b7326ae52 blockchain/indexers: use latest API for cf indexing 2018-05-23 16:46:15 -07:00
Olaoluwa Osuntokun
b72e16f0d6 multi: correct all import paths 2018-05-23 16:46:15 -07:00
Jim Posen
3425d33506 blockchain/indexers: Add methods on CfIndex for batch retrieval.
Fetching all items in one db transaction will save time when
responding to getcfilters or getcfheaders requests.
2018-05-23 16:46:15 -07:00
Jim Posen
e617483b44 blockchain/indexers: Store filter hashes with cfindex. 2018-05-23 16:46:15 -07:00
Jim Posen
d07fd2f333 blockchain/indexers: Reduce duplication in cfindex.
The index will hold three types of entries for each filter type, block
pair: filter, header, and hash. Since they all have similar methods
and implementations, refactor to reduce duplication.
2018-05-23 16:46:15 -07:00
Olaoluwa Osuntokun
10432160d5 multi: rebase to upstream, update API's 2018-05-23 16:46:15 -07:00
Alex
f4060b107c blockchain/indexers: check for ErrNoData in extended filters
Since the tx hash has moved to the basic filter, generating an extended filter
can result in `ErrNoData`. This is handled by writing a nil filter and giving
it a zero hash.
2018-05-23 16:46:15 -07:00
Alex
c7e7acc7fd multi: use hidden varint for cftypes count; make filter type enum, not uint8 2018-05-23 16:46:15 -07:00
Alex
621c73dad1 multi: change cfilter Extended bool to FilterType uint8
The cfilter BIP specifies that the filter type is a uint8. The
current code encodes it correctly on the wire, but everywhere else,
it's treated as a boolean (false for basic filter, true for
extended). This commit corrects that to account for possible
additional filter types in the future. All package changes are
done in one commit as they're all interdependent. The following
packages are updated:

* blockchain/indexers
* btcjson
* peer
* wire
* main (server.go and rpcserver.go)
2018-05-23 16:46:15 -07:00
Olaoluwa Osuntokun
9b9ef42f8a blockchain/indexers: proper handling of empty filters 2018-05-23 16:46:15 -07:00
Olaoluwa Osuntokun
e0943a84bd blockchain/indexers: add a bit more line spacing to cfindex.go 2018-05-23 16:46:15 -07:00
Alex
1c5f25bbf2 blockchain/cfindex: Factor out filter/header calc. 2018-05-23 16:46:15 -07:00
Alex
860100019f blockchain: fix --dropcfindex 2018-05-23 16:46:15 -07:00
Alex
ba7b5f3308 Use NBytes() instead of Bytes() in CFIndex 2018-05-23 16:46:15 -07:00
Alex
9780ef5997 Skip TxIn on coinbase transaction when indexing 2018-05-23 16:46:15 -07:00
Alex
6102e129c5 Fixed a couple of bugs and added --dropcfindex option 2018-05-23 16:46:15 -07:00
pedro martelletto
a5bf8941d5 Define FilterHeaderByBlockHash() 2018-05-23 16:46:15 -07:00
pedro martelletto
e620538343 Generate and store filter headers 2018-05-23 16:46:15 -07:00
pedro martelletto
b53c42f5dc Define dbFetch{Basic,Extended}Header() 2018-05-23 16:46:15 -07:00
pedro martelletto
7673859108 Create db buckets for committed filter hashes 2018-05-23 16:46:15 -07:00
pedro martelletto
ddfaed7f6f Delete extended filters in DisconnectBlock() 2018-05-23 16:46:15 -07:00
pedro martelletto
0a841fefcf Generate and store extended filters in ConnectBlock() 2018-05-23 16:46:15 -07:00
pedro martelletto
71c421db66 Differentiate between basic/extended filters in p2p/RPC 2018-05-23 16:46:15 -07:00
pedro martelletto
f703e18652 Populate filter #1 (extended) 2018-05-23 16:46:15 -07:00
pedro martelletto
f16da156c9 Include data pushes from pkscripts 2018-05-23 16:46:15 -07:00
pedro martelletto
396d28955c better separation between filters; comments 2018-05-23 16:46:15 -07:00
pedro martelletto
57995fd111 Start preparing the ground for layer {0,1} filters 2018-05-23 16:46:15 -07:00
pedro martelletto
472141f88d Switch to new GCS builder interface 2018-05-23 16:46:15 -07:00
pedro martelletto
6d6677b797 zap errCFEntry 2018-05-23 16:46:15 -07:00
pedro martelletto
92c8ec4094 cbfindex.go -> cfindex.go 2018-05-23 16:46:15 -07:00
pedro martelletto
6e5f650be9 CBFilter -> CFilter, discussed with davec@ 2018-05-23 16:46:15 -07:00
pedro martelletto
a77b1e00d5 FilterByBlockHash(), pointed out by davec@ 2018-05-23 16:46:15 -07:00
pedro martelletto
9f02951b0e CloneBytes() -> [:], pointed out by davec@ 2018-05-23 16:46:15 -07:00
pedro martelletto
8b8c7bcf05 Implement DisconnectBlock() for the CBF Indexer 2018-05-23 16:46:15 -07:00
pedro martelletto
43bf8db793 Look up filters from p2p GetCBF message 2018-05-23 16:46:15 -07:00
pedro martelletto
76926f8904 Roll in a dbFetchCBFIndexEntry() 2018-05-23 16:46:15 -07:00
pedro martelletto
9809f4ffdd Instrument basic logging 2018-05-23 16:46:15 -07:00
pedro martelletto
cf74c8c3ca Abstract filter generation to a separate function 2018-05-23 16:46:15 -07:00
pedro martelletto
05d2fdeb11 Rename a variable in CBF's ConnectBlock() 2018-05-23 16:46:15 -07:00