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

View File

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

View File

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