Skip to content

read hashReserved from disk#2931

Merged
zkbot merged 1 commit intozcash:masterfrom
jc23424:hashreserved-diskindex
Feb 21, 2018
Merged

read hashReserved from disk#2931
zkbot merged 1 commit intozcash:masterfrom
jc23424:hashreserved-diskindex

Conversation

@jc23424
Copy link
Copy Markdown

@jc23424 jc23424 commented Feb 5, 2018

This fixes a bug where the hashReserved field of the block header is not properly read back into CBlockIndex when loaded from disk. This happens to cause no issues currently because hashReserved has always been its default value (== 0), but if a block were ever mined where this was not the case, headers read back from disk would appear to have an invalid solution

@bitcartel bitcartel added the C-bug Category: This is a bug label Feb 5, 2018
@bitcartel bitcartel added this to the 1.0.15 milestone Feb 5, 2018
@str4d str4d added the A-consensus Area: Consensus rules label Feb 6, 2018
@cronicc
Copy link
Copy Markdown
Contributor

cronicc commented Feb 16, 2018

ZenCash is actually affected by this as we've had some blocks from a pool that is misconfigured with BTG settings (block height in hashReserved).

The blocks pass intial sync and getblockheader shows the correct value for hashReserved
but on a restart txdb.cpp#L317 triggers with an incorrect blockhash and a reindex is needed to get going again.

Daemon failure:

Error loading block database.
Please restart with -reindex to recover.
zend: /tmp/zen/depends/x86_64-unknown-linux-gnu/share/../include/boost/thread/pthread/mutex.hpp:111: boost::mutex::~mutex(): Assertion `!res' failed.

Debug log:

2018-02-12 00:12:47 ERROR: CheckProofOfWork(): hash doesn't match nBits
2018-02-12 00:12:47 ERROR: LoadBlockIndex(): CheckProofOfWork failed: CBlockIndex(pprev=0x5599618161b0, nHeight=255111, merkle=35a7c37a0148c2e24a6b41af0b721b7a32de563e4efc2cf04d5936401192759f, hashBlock=66c1ba5febb9e3616ce15d691552f0a956c8df93504274f92a32e08cafb9f80d)
2018-02-12 00:12:47 : Error loading block database.
Please restart with -reindex to recover.

@leto
Copy link
Copy Markdown
Contributor

leto commented Feb 17, 2018

This problem was effecting the Hush network as well, we are seeing hashReserved = Hush block number, which seems to indicate that people are potentially using BTG mining software to mine on other Equihash coins, not realizing that BTG changed their Equihash headers.

MyHush/hush#98

Thanks for the patch @jc23424 👍

jl777 added a commit to jl777/komodo that referenced this pull request Feb 18, 2018
jl777 added a commit to jl777/komodo that referenced this pull request Feb 18, 2018
@jl777 jl777 mentioned this pull request Feb 18, 2018
Copy link
Copy Markdown
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK. Needs a test -- ideally for 1.0.15, but not having a test should not block this PR for 1.0.15 IMHO.

@str4d
Copy link
Copy Markdown
Contributor

str4d commented Feb 21, 2018

Opened #2976 for the test. utACK.

@zkbot r+

@zkbot
Copy link
Copy Markdown
Contributor

zkbot commented Feb 21, 2018

📌 Commit 15fb13f has been approved by str4d

zkbot added a commit that referenced this pull request Feb 21, 2018
read hashReserved from disk

This fixes a bug where the hashReserved field of the block header is not properly read back into CBlockIndex when loaded from disk. This happens to cause no issues currently because hashReserved has always been its default value (== 0), but if a block were ever mined where this was not the case, headers read back from disk would appear to have an invalid solution
@zkbot
Copy link
Copy Markdown
Contributor

zkbot commented Feb 21, 2018

⌛ Testing commit 15fb13f with merge 6264927...

@zkbot
Copy link
Copy Markdown
Contributor

zkbot commented Feb 21, 2018

☀️ Test successful - pr-merge
Approved by: str4d
Pushing 6264927 to master...

@zkbot zkbot merged commit 15fb13f into zcash:master Feb 21, 2018
@tearodactyl tearodactyl mentioned this pull request May 9, 2018
tearodactyl pushed a commit to tearodactyl/z18 that referenced this pull request May 9, 2018
Update version string
Pull in select 1.0.15 Zcash fixes:
read hashReserved from disk zcash#2931
improve sync performance by increasing default value of dbcache. zcash#2873
z_importviewingkey fix from leto/zero/pull/1
Update README.md throughout, particularly the addnode addresses, plus add a sample zero.conf to ./contrib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-consensus Area: Consensus rules C-bug Category: This is a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants