Replies: 1 comment
-
We ended up going for the latest option: #132 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem statement
teos
is currently designed to run on top ofbitcoind
usingtxindex=1
. The rationale for this is potentially having to query the block height where a monitored transaction was included in order to account for its confirmations. That is:bitcoind
(throughsendrawtransaction
) it could be the case that the transaction is already known by our node (by either being in mempool or already in a block). In the latter, we need to query the block height of the block that included the transaction so we can monitor until it getsIRREVOCABLY_RESOLVED
. That's done by both queryinggetrawtransaction
, parsing theblock_hash
, and then queryinggetblockheader
.penalty
), and potentially its parent (e.g.commitment
) have been reorged. To know so,getrawtransaction
is queried and theblock_hash
is pulled.In both cases, we are querying
getrawtransaction
for transactions that are not part of our wallet, hence requiringtxindex=1
. Unfortunately, running with transaction indexing is incomparible with pruning, which means the node needs to download and keep a full version of the chain (~430 GiB at the time of writing).Potential solutions
txindex
+prune
The simplest solution, albeit probably the hardest, would be to PR Bitcoin Core and add support for
txindex
in prunning mode. There does not seem to be any technical reason not to have this feature (bitcoin/bitcoin#12651): It has been proposed in the past but rejected for not being interesting enough (or not having a well-defined / reasoned use case).Being able to run
txindex
for the lastn
blocks in the chain will allow us to have the same functionality while maintaining the simplicity of the codebase.Pinging @willcl-ark given, after some conversations during BTCAzores, he seemed pretty interested in championing this into Core.
Descriptor wallets +
gettransaction
As previously state, the only reason why we need
txindex
is that we are querying transactions that do not belong to any of our wallets. A potential solution (proposed by @darosior also during BTCAzores) would be to use descriptor wallets alongsidegettransaction
to query the necessary data. This would work as follows:For every blob that we decrypt we get the channel funding outpoint and add its descriptor as watch-only. This will allow us to query
gettransaction
instead ofgetrawtransaction
(or most likely a combination of both, the former for data on chain and the latter for data in the mempool) for its descendants, meaning it will cover both thecommitment
and thepenalty
.Foreseeable issues
IRREVOCABLY_RESOLVED
. Some testing would be needed to see how expensive that could be.Build our own
txindex
We could also build our own
txindex
in a similar fashion to how we built theLocatorCache
for theWatcher
. This would mean having an index of blocks (potentially tracking the lastIRREVOCABLY_RESOLVED
blocks), which may imply a couple of maps:a
block_hash
-> (tx_ids
,height
) map, and atxid
->block_hash
map. The index will need to be populated/pruned when a new block is connected/disconnected*.*Notice that all reorg logic would need to be managed by us since currently, we offload some of it to
bitcoind
.Beta Was this translation helpful? Give feedback.
All reactions