rosetta-dogecoin / rosetta-dogecoin

Dogecoin Rosetta API implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parse v2 AuxPoW blocks

patricklodder opened this issue · comments

Is your feature request related to a problem? Please describe.

As of the merging of #19, block synchronization and indexing works for version 1 encoded blocks but not version 2 AuxPoW blocks. As validation is performed by dogecoind, at this point there is no value in processing and storing the AuxPoW headers themselves, but as the serialization of the blocks is different, and the auxpow header is of variable size, at least parsing and some syntactic validation needs to be performed to be able to process these blocks.

Describe the solution you'd like

Roughly the following needs to happen:

  1. We'll need a custom function that parses a version 2 encoded block, but returns a version 1 block struct as expected by the generic rosetta indexer service.
  2. In our custom getBlock function in bitcoin/client.go, a small change needs to be implemented that reads the first 4 bytes of a block and decides which type of block encoding we expect. A simple if/else construction can then be used to parse an AuxPoW block if required.
  3. Would be great if we'd have some unit tests with mocks for this.

References

  • AuxPoW serialization is documented as CAuxPow and CMerkleTx in Dogecoin Core, in src/auxpow.h
  • Detection rules for Auxpow-encoded blocks based on the version bytes is as follows:
    • byte 1 and 2 MUST equal the Chain ID which is 0x0062 for dogecoin, AND
    • byte 3 MUST equal 0x01 to signal that AuxPoW encoding was followed
  • The block heights for activation (per src/chainparams.cpp) are:
    • Mainnet: 371337
    • Testnet: 158100
    • Regtest: 20
  • @langerhans has done Dogecoin integration work on btcd in the past months and has been so kind to open up his work-in-progress at https://github.com/langerhans/btcd/tree/doge and / https://github.com/langerhans/btcutil which can serve as guidance of how to parse the AuxPoW blocks.
commented

was waiting on that issue to appear bluezr and I were on it unless something did change

commented

hey patrick I did look the other PR and I was redoing mine in about the same way. So might as well go with it, I spent 2 night not sleeping trying to find the perfect way to do it and always ended up the btcd way. If he needs help on fixing stuff in his pr, I am available. No reason to compete with each other when we have a common goal.

Also on a side note, how can I get a hold of you I would like to ask you a question re doge dev (private one) and one of the contribs im planning. Thanks

fixed with #27