more debugging

This commit is contained in:
Martin Holst Swende 2020-01-21 08:32:39 +01:00
parent b1756c4312
commit 1613e1d884
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
2 changed files with 10 additions and 0 deletions

View file

@ -548,6 +548,14 @@ func (ethash *Ethash) verifySeal(chain consensus.ChainReader, header *types.Head
ctx = append(ctx, "sealHash", fmt.Sprintf("%x", sealHash))
digest, result = hashimotoLight(size, cache.cache, sealHash, nonce)
ctx = append(ctx, "result", fmt.Sprintf("%x", result))
ctx = append(ctx, "epoch", cache.epoch)
// For debuggging only
sum := uint32(0)
for _, val := range cache.cache {
sum = sum ^ val
}
ctx = append(ctx, "cachexor", fmt.Sprintf("%x", sum))
// Caches are unmapped in a finalizer. Ensure that the cache stays alive
// until after the call to hashimotoLight so it's not unmapped while being used.
runtime.KeepAlive(cache)
@ -556,6 +564,7 @@ func (ethash *Ethash) verifySeal(chain consensus.ChainReader, header *types.Head
if !bytes.Equal(header.MixDigest[:], digest) {
ctx = append(ctx, "digest", fmt.Sprintf("%x", digest))
ctx = append(ctx, "hdr.digest", fmt.Sprintf("%x", header.MixDigest[:]))
log.Error("Invalid mix digest", ctx...)
return errInvalidMixDigest
}

View file

@ -197,6 +197,7 @@ func TestEthashVerification(t *testing.T) {
)
cache := engine.cache(number)
size := datasetSize(number)
fmt.Printf("number: %d\n", number)
fmt.Printf("datasetSize: %d\n", size)
digest, result := hashimotoLight(size, cache.cache, sealHash, nonce)
fmt.Printf("nonce: %v\n", nonce)