You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bitcoin Verde DAA implementation is not compatible with of the other implementations.
This is not the fault of Bitcoin Verde, but the fault of how badly specified DAA is and how poorly implemented by ABC.
Verde and Knuth are the only 2 node implementations that have written DAA from scratch, the rest of the nodes have only copied or translated the Bitcoin ABC code, so they don't have this issue.
Given the following code, Bitcoin Verde prints "1" and Bitcoin ABC prints "2", so the consensus rules differ.
I would have liked to try this on testnet to probe it in a better way, generating a similar 3-blocks pattern, but I haven't had enough HP to do it.
package app;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
final class BlockHeader {
public Long Height;
public Long Timestamp;
}
final class DifficultyCalculator {
public BlockHeader[] _calculateNewBitcoinCashTarget(final BlockHeader[] firstBlockHeaders, final BlockHeader[] lastBlockHeaders) {
final Comparator<BlockHeader> sortBlockHeaderByTimestampDescending = new Comparator<BlockHeader>() {
@Override
public int compare(final BlockHeader blockHeader0, final BlockHeader blockHeader1) {
return blockHeader1.Timestamp.compareTo(blockHeader0.Timestamp);
}
};
Arrays.sort(lastBlockHeaders, sortBlockHeaderByTimestampDescending);
Arrays.sort(firstBlockHeaders, sortBlockHeaderByTimestampDescending);
final BlockHeader firstBlockHeader = firstBlockHeaders[1];
final BlockHeader lastBlockHeader = lastBlockHeaders[1];
final BlockHeader[] res = {firstBlockHeader, lastBlockHeader};
return res;
}
}
public class App {
public static void main(final String[] args) throws Exception {
final BlockHeader[] firstBlockHeaders = new BlockHeader[3]; // The oldest BlockHeaders...
firstBlockHeaders[0] = new BlockHeader();
firstBlockHeaders[0].Timestamp = (long) 1558731500;
firstBlockHeaders[0].Height = (long) 3;
firstBlockHeaders[1] = new BlockHeader();
firstBlockHeaders[1].Timestamp = (long) 1558731501;
firstBlockHeaders[1].Height = (long) 2;
firstBlockHeaders[2] = new BlockHeader();
firstBlockHeaders[2].Timestamp = (long) 1558731501;
firstBlockHeaders[2].Height = (long) 1;
final BlockHeader[] lastBlockHeaders = new BlockHeader[3]; // The newest BlockHeaders...
lastBlockHeaders[0] = new BlockHeader();
lastBlockHeaders[0].Timestamp = (long) 1558731500;
lastBlockHeaders[0].Height = (long) 3;
lastBlockHeaders[1] = new BlockHeader();
lastBlockHeaders[1].Timestamp = (long) 1558731500;
lastBlockHeaders[1].Height = (long) 2;
lastBlockHeaders[2] = new BlockHeader();
lastBlockHeaders[2].Timestamp = (long) 1558730000;
lastBlockHeaders[2].Height = (long) 1;
DifficultyCalculator c = new DifficultyCalculator();
final BlockHeader[] selected = c._calculateNewBitcoinCashTarget(firstBlockHeaders, lastBlockHeaders);
System.out.println(selected[0].Height);
}
}
The text was updated successfully, but these errors were encountered:
Thanks for reporting this, Fernando. I've verified this behavior in the specification as well in ABC's code.
I've created a replicating test case and a resolution to this issue. PR #12 will resolve this issue once tests are executed and a full chain validation is successful on our test node.
Bitcoin Verde DAA implementation is not compatible with of the other implementations.
This is not the fault of Bitcoin Verde, but the fault of how badly specified DAA is and how poorly implemented by ABC.
Verde and Knuth are the only 2 node implementations that have written DAA from scratch, the rest of the nodes have only copied or translated the Bitcoin ABC code, so they don't have this issue.
Here is a reference in this regard:
https://read.cash/@Fernando/on-daa-implementation-algorithms-and-specifications-b739e631
Given the following code, Bitcoin Verde prints "1" and Bitcoin ABC prints "2", so the consensus rules differ.
I would have liked to try this on testnet to probe it in a better way, generating a similar 3-blocks pattern, but I haven't had enough HP to do it.
The text was updated successfully, but these errors were encountered: