Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Dash synchronisation stuck in an infinite loop #605

Open
fpcornelis opened this issue Jul 4, 2022 · 6 comments
Open

Dash synchronisation stuck in an infinite loop #605

fpcornelis opened this issue Jul 4, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@fpcornelis
Copy link

I have a Dash wallet that stops the synchronisation when it arrives to this transaction

https://blockchair.com/es/dash/transaction/3cc6e81dbb258a6fb88fb46e35b0a8e6e6c77fd4699d4a8100b9c700a5a7b3de

This transaction comes from Dash masternode, and it has a coinbase input, I believe that DashKit doesn't support this type of inputs and it gets stuck in an infinite loop.

https://dashcore.readme.io/docs/core-ref-transactions-raw-transaction-format#coinbase-input-the-input-of-the-first-transaction-in-a-block

@fpcornelis
Copy link
Author

fpcornelis commented Jul 5, 2022

I think the problem is because the datahash is not being calculated correctly for coinbase transactions and after the transactionis not found in the block.

The datahash is calculated in struct FullTransaction

  public init(header: Transaction, inputs: [Input], outputs: [Output]) {
     ...
     self.header.dataHash = Kit.sha256sha256(TransactionSerializer.serialize(transaction: self, withoutWitness: true))
     ...
  }

but for coinbase transaction there are more fields.

I fix the problem moving the calculation of datahash to method deserialize in the class TransactionSerializer

   static public func deserialize(byteStream: ByteStream) -> FullTransaction {
        transaction.lockTime = Int(byteStream.read(UInt32.self))
        transaction.dataHash = Kit.sha256sha256(byteStream.data)
        return FullTransaction(header: transaction, inputs: inputs, outputs: outputs)
    }

@fpcornelis
Copy link
Author

The problem is not completely solved, now only takes into account the last coinbase transaction, other coinbase transactions are ignored.

@fpcornelis
Copy link
Author

This type of input always have the same txid

0000000000000000000000000000000000000000000000000000000000

and only the last is stored in database

@ealymbaev ealymbaev added the bug Something isn't working label Jul 21, 2022
@fpcornelis
Copy link
Author

This type of input always have the same txid

0000000000000000000000000000000000000000000000000000000000

and only the last is stored in database

I'm wrong is not txid, is previousOutputTxHash .

For coinbase input previousOutputTxHash always have the value 0x0000000000000000000000000000000000000000000000000000000000, if you have multiple coinbase transactions only the last transaction input is stored, and other transactions are invalidated.

@ealymbaev
Copy link
Member

Fixed in #607, #608

@fpcornelis
Copy link
Author

With this changes only stores last coinbase transaction

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants