From 1613e1d884c27385b367832b2b8a28259148da82 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 21 Jan 2020 08:32:39 +0100 Subject: [PATCH] more debugging --- consensus/ethash/consensus.go | 9 +++++++++ consensus/ethash/ethash_test.go | 1 + 2 files changed, 10 insertions(+) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 4b6a07358f..7c7820b117 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -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 } diff --git a/consensus/ethash/ethash_test.go b/consensus/ethash/ethash_test.go index cfa2e28d83..a16c1fd45c 100644 --- a/consensus/ethash/ethash_test.go +++ b/consensus/ethash/ethash_test.go @@ -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)