Hi. Is anyone here, who can explain what exactly is happening in the m_saveAncestors
and priv_fastGetBlockHash__
functions in btcChain.se? I understand the idea of the indexing of block ancestors but I'm concerned about the exact details of the implementation.
Specifically, this code block in m_saveAncestors
with $i = 1:
while $i < NUM_ANCESTOR_DEPTHS:
with $depth = m_getAncDepth($i):
if m_getHeight($blockHash) % $depth == 1:
m_mwrite32(ref($ancWord) + 4*$i, $prevIbIndex)
else:
m_mwrite32(ref($ancWord) + 4*$i, m_getAncestor($hashPrevBlock, $i))
$i += 1
Also, could it be, that priv_fastGetBlockHash__
fails if the requested block has more than 78125 confirmations? I may be wrong, but it seems to me that the following check will fail in this case:
(excerpt from priv_fastGetBlockHash__
):
blockHash = self.heaviestBlock
anc_index = NUM_ANCESTOR_DEPTHS - 1 <-- this is equal to 7
while m_getHeight(blockHash) > blockHeight:
while m_getHeight(blockHash) - blockHeight < m_getAncDepth(anc_index) && anc_index > 0:
anc_index -= 1
blockHash = self.internalBlock[m_getAncestor(blockHash, anc_index)]
return(blockHash)
Note: m_getAncDepth(7)
returns 78125
Thx!
Hi all. We've done (and are still doing) some PoC work on new BTC Relay designs (Solidity and Rust) and have used the "deprecated" BTC Relay implementation (Serpent) for some experiments.
You can find some info on how chain relays (BTC Relay incl.) work in this paper: https://eprint.iacr.org/2018/643.pdf (Sections V.B and Appendix D) or here (more high level. Note: the code in this repo is not up to date I think): https://github.com/crossclaim/btcrelay-sol
BTC relay itself is live on Ethereum, but it has not been used for ages. Also not sure if it can still be used.