Skip to content

Commit e9773a0

Browse files
committed
Fix large-reorg height and b4? duplicate hash issue
1 parent 1abbd84 commit e9773a0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed
90 Bytes
Binary file not shown.

FullBlockTestGenerator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,9 @@ public boolean add(Rule element) {
980980

981981
// Block with invalid merkle hash
982982
Block b49 = createNextBlock(b44, chainHeadHeight + 16, out15, null);
983-
b49.setMerkleRoot(Sha256Hash.ZERO_HASH);
983+
byte[] b49MerkleHash = Sha256Hash.ZERO_HASH.getBytes().clone();
984+
b49MerkleHash[1] = (byte) 0xDE;
985+
b49.setMerkleRoot(Sha256Hash.create(b49MerkleHash));
984986
b49.solve();
985987
blocks.add(new BlockAndValidity(blockToHeightMap, hashHeaderMap, b49, false, true, b44.getHash(), chainHeadHeight + 15, "b49"));
986988

@@ -1563,7 +1565,7 @@ public boolean add(Rule element) {
15631565
new TransactionOutPoint(params, 0, b1001.getTransactions().get(0).getHash()),
15641566
b1001.getTransactions().get(0).getOutputs().get(0).getValue(),
15651567
b1001.getTransactions().get(0).getOutputs().get(0).getScriptPubKey()));
1566-
int nextHeight = chainHeadHeight + 31;
1568+
int heightAfter1001 = chainHeadHeight + 31;
15671569

15681570
if (runLargeReorgs) {
15691571
// No way you can fit this test in memory
@@ -1572,6 +1574,7 @@ public boolean add(Rule element) {
15721574
Block lastBlock = b1001;
15731575
TransactionOutPoint lastOutput = new TransactionOutPoint(params, 2, b1001.getTransactions().get(1).getHash());
15741576
int blockCountAfter1001;
1577+
int nextHeight = heightAfter1001;
15751578

15761579
List<Sha256Hash> hashesToSpend = new LinkedList<Sha256Hash>(); // all index 0
15771580
final int TRANSACTION_CREATION_BLOCKS = 100;
@@ -1611,7 +1614,7 @@ public boolean add(Rule element) {
16111614
// Reorg back to b1001 + empty blocks
16121615
Sha256Hash firstHash = lastBlock.getHash();
16131616
int height = nextHeight-1;
1614-
nextHeight = chainHeadHeight + 26;
1617+
nextHeight = heightAfter1001;
16151618
lastBlock = b1001;
16161619
for (int i = 0; i < blockCountAfter1001; i++) {
16171620
Block block = createNextBlock(lastBlock, nextHeight++, null, null);

0 commit comments

Comments
 (0)