fixes difficulty validation

This commit is contained in:
andri lim 2019-09-23 21:35:48 +07:00 committed by zah
parent 58a7d5af83
commit a2a8e81265
3 changed files with 13 additions and 16 deletions

View File

@ -80,7 +80,7 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
## bcInvalidHeaderTest
```diff
+ DifferentExtraData1025.json OK
DifficultyIsZero.json Skip
+ DifficultyIsZero.json OK
+ ExtraData1024.json OK
+ ExtraData33.json OK
+ GasLimitHigherThan2p63m1.json OK
@ -89,11 +89,11 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ log1_wrongBloom.json OK
+ timeDiff0.json OK
+ wrongCoinbase.json OK
wrongDifficulty.json Skip
+ wrongDifficulty.json OK
+ wrongGasLimit.json OK
+ wrongGasUsed.json OK
wrongMixHash.json Skip
wrongNonce.json Skip
+ wrongMixHash.json OK
+ wrongNonce.json OK
+ wrongNumber.json OK
+ wrongParentHash.json OK
+ wrongParentHash2.json OK
@ -103,7 +103,7 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ wrongTransactionsTrie.json OK
+ wrongUncleHash.json OK
```
OK: 19/23 Fail: 0/23 Skip: 4/23
OK: 23/23 Fail: 0/23 Skip: 0/23
## bcMultiChainTest
```diff
+ CallContractFromNotBestBlock.json OK
@ -323,11 +323,11 @@ OK: 11/11 Fail: 0/11 Skip: 0/11
+ timestampTooHigh.json OK
+ timestampTooLow.json OK
+ unknownUncleParentHash.json OK
wrongMixHash.json Skip
+ wrongMixHash.json OK
+ wrongParentHash.json OK
+ wrongStateRoot.json OK
```
OK: 21/22 Fail: 0/22 Skip: 1/22
OK: 22/22 Fail: 0/22 Skip: 0/22
## bcUncleSpecialTests
```diff
+ futureUncleTimestamp2.json OK
@ -404,4 +404,4 @@ OK: 20/20 Fail: 0/20 Skip: 0/20
OK: 5/5 Fail: 0/5 Skip: 0/5
---TOTAL---
OK: 261/318 Fail: 0/318 Skip: 57/318
OK: 266/318 Fail: 0/318 Skip: 52/318

View File

@ -329,7 +329,7 @@ proc checkPOW(blockNumber: Uint256, miningHash, mixHash: Hash256, nonce: BlockNo
let cache = blockNumber.getCache()
let size = getDataSize(blockNumber)
let miningOutput = hashimotoLight(size, cache, miningHash, uint64.fromBytesBE(nonce))
let miningOutput = hashimotoLight(size, cache, miningHash, uint64.fromBytesBE(nonce))
if miningOutput.mixDigest != mixHash:
echo "actual: ", miningOutput.mixDigest
echo "expected: ", mixHash
@ -505,6 +505,7 @@ proc importBlock(tester: var Tester, chainDB: BaseChainDB,
processBlock(tester.vmState, result, fork)
result.header.stateRoot = tester.vmState.blockHeader.stateRoot
result.header.parentHash = parentHeader.hash
result.header.difficulty = baseHeaderForImport.difficulty
if validation:
if not validateBlockUnchanged(result, preminedBlock):
@ -546,7 +547,7 @@ proc runTester(tester: var Tester, chainDB: BaseChainDB, testStatusIMPL: var Tes
try:
let fork = vmConfigToFork(tester.vmConfig, 1.u256)
let (_, _, _) = tester.applyFixtureBlockToChain(testerBlock,
chainDB, fork, checkSeal = false, validation = true)
chainDB, fork, checkSeal, validation = true)
except ValueError, ValidationError, BlockNotFound, MalformedRlpError, RlpTypeMismatch:
# failure is expected on this bad block
noError = false
@ -595,7 +596,6 @@ proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus, debugMode = fal
var fixtureTested = false
for fixtureName, fixture in node:
cacheByEpoch.clear()
inc fixtureIndex
if specifyIndex > 0 and fixtureIndex != specifyIndex:
continue

View File

@ -80,10 +80,7 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
"blockChainFrontierWithLargerTDvsHomesteadBlockchain2.json",
# bcInvalidHeaderTest
"DifficultyIsZero.json",
"wrongDifficulty.json",
"wrongMixHash.json",
"wrongNonce.json",
#"DifficultyIsZero.json",
#"wrongDifficulty.json",
]
result = name in allowedFailingGeneralStateTests