fixes fork choice

This commit is contained in:
andri lim 2019-09-23 22:52:57 +07:00 committed by zah
parent 10fb81b781
commit ed01201233
3 changed files with 11 additions and 23 deletions

View File

@ -50,13 +50,13 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
```diff ```diff
+ CallContractThatCreateContractBeforeAndAfterSwitchover.json OK + CallContractThatCreateContractBeforeAndAfterSwitchover.json OK
+ ContractCreationFailsOnHomestead.json OK + ContractCreationFailsOnHomestead.json OK
HomesteadOverrideFrontier.json Skip + HomesteadOverrideFrontier.json OK
+ UncleFromFrontierInHomestead.json OK + UncleFromFrontierInHomestead.json OK
+ UnclePopulation.json OK + UnclePopulation.json OK
blockChainFrontierWithLargerTDvsHomesteadBlockchain.json Skip + blockChainFrontierWithLargerTDvsHomesteadBlockchain.json OK
blockChainFrontierWithLargerTDvsHomesteadBlockchain2.json Skip + blockChainFrontierWithLargerTDvsHomesteadBlockchain2.json OK
``` ```
OK: 4/7 Fail: 0/7 Skip: 3/7 OK: 7/7 Fail: 0/7 Skip: 0/7
## bcGasPricerTest ## bcGasPricerTest
```diff ```diff
+ RPC_API_Test.json OK + RPC_API_Test.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: 266/318 Fail: 0/318 Skip: 52/318 OK: 269/318 Fail: 0/318 Skip: 49/318

View File

@ -329,7 +329,7 @@ proc checkPOW(blockNumber: Uint256, miningHash, mixHash: Hash256, nonce: BlockNo
let cache = blockNumber.getCache() let cache = blockNumber.getCache()
let size = getDataSize(blockNumber) 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: if miningOutput.mixDigest != mixHash:
echo "actual: ", miningOutput.mixDigest echo "actual: ", miningOutput.mixDigest
echo "expected: ", mixHash echo "expected: ", mixHash
@ -516,9 +516,10 @@ proc importBlock(tester: var Tester, chainDB: BaseChainDB,
discard chainDB.persistHeaderToDb(preminedBlock.header) discard chainDB.persistHeaderToDb(preminedBlock.header)
proc applyFixtureBlockToChain(tester: var Tester, tb: TesterBlock, proc applyFixtureBlockToChain(tester: var Tester, tb: TesterBlock,
chainDB: BaseChainDB, fork: Fork, checkSeal, validation = true): (PlainBlock, PlainBlock, Blob) = chainDB: BaseChainDB, checkSeal, validation = true): (PlainBlock, PlainBlock, Blob) =
var var
preminedBlock = rlp.decode(tb.headerRLP, PlainBlock) preminedBlock = rlp.decode(tb.headerRLP, PlainBlock)
fork = vmConfigToFork(tester.vmConfig, preminedBlock.header.blockNumber)
minedBlock = tester.importBlock(chainDB, preminedBlock, fork, checkSeal, validation) minedBlock = tester.importBlock(chainDB, preminedBlock, fork, checkSeal, validation)
rlpEncodedMinedBlock = rlp.encode(minedBlock) rlpEncodedMinedBlock = rlp.encode(minedBlock)
result = (preminedBlock, minedBlock, rlpEncodedMinedBlock) result = (preminedBlock, minedBlock, rlpEncodedMinedBlock)
@ -532,22 +533,18 @@ proc runTester(tester: var Tester, chainDB: BaseChainDB, testStatusIMPL: var Tes
check chainDB.getCanonicalHead().blockHash == tester.genesisBlockHeader.blockHash check chainDB.getCanonicalHead().blockHash == tester.genesisBlockHeader.blockHash
let checkSeal = tester.shouldCheckSeal let checkSeal = tester.shouldCheckSeal
for testerBlock in tester.blocks: for idx, testerBlock in tester.blocks:
let shouldBeGoodBlock = testerBlock.blockHeader.isSome let shouldBeGoodBlock = testerBlock.blockHeader.isSome
if shouldBeGoodBlock: if shouldBeGoodBlock:
let blockNumber = testerBlock.blockHeader.get().blockNumber
let fork = vmConfigToFork(tester.vmConfig, blockNumber)
let (preminedBlock, minedBlock, blockRlp) = tester.applyFixtureBlockToChain( let (preminedBlock, minedBlock, blockRlp) = tester.applyFixtureBlockToChain(
testerBlock, chainDB, fork, checkSeal, validation = false) # we manually validate below testerBlock, chainDB, checkSeal, validation = false) # we manually validate below
check validateBlock(chainDB, preminedBlock, checkSeal) == true check validateBlock(chainDB, preminedBlock, checkSeal) == true
else: else:
var noError = true var noError = true
try: try:
let fork = vmConfigToFork(tester.vmConfig, 1.u256)
let (_, _, _) = tester.applyFixtureBlockToChain(testerBlock, let (_, _, _) = tester.applyFixtureBlockToChain(testerBlock,
chainDB, fork, checkSeal, validation = true) chainDB, 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

View File

@ -73,14 +73,5 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
"randomStatetest623BC.json", "randomStatetest623BC.json",
"randomStatetest76BC.json", "randomStatetest76BC.json",
"randomStatetest79BC.json", "randomStatetest79BC.json",
# bcFrontierToHomestead
"HomesteadOverrideFrontier.json",
"blockChainFrontierWithLargerTDvsHomesteadBlockchain.json",
"blockChainFrontierWithLargerTDvsHomesteadBlockchain2.json",
# bcInvalidHeaderTest
#"DifficultyIsZero.json",
#"wrongDifficulty.json",
] ]
result = name in allowedFailingGeneralStateTests result = name in allowedFailingGeneralStateTests