|
|
@ -23,6 +23,7 @@ |
|
|
|
#include <boost/filesystem.hpp> |
|
|
|
#include <libdevcore/FileSystem.h> |
|
|
|
#include <libdevcore/TransientDirectory.h> |
|
|
|
#include <libethcore/Params.h> |
|
|
|
#include <libethereum/CanonBlockChain.h> |
|
|
|
#include <libethereum/TransactionQueue.h> |
|
|
|
#include <test/TestHelper.h> |
|
|
@ -127,13 +128,15 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) |
|
|
|
TransientDirectory td_stateDB, td_bc; |
|
|
|
FullBlockChain<Ethash> bc(rlpGenesisBlock.out(), StateDefinition(), td_bc.path(), WithExisting::Kill); |
|
|
|
State state(OverlayDB(State::openDB(td_stateDB.path(), h256{}, WithExisting::Kill)), BaseState::Empty); |
|
|
|
trueState.setAddress(biGenesisBlock.coinbaseAddress()); |
|
|
|
state.setAddress(biGenesisBlock.coinbaseAddress()); |
|
|
|
importer.importState(o["pre"].get_obj(), state); |
|
|
|
state.commit(); |
|
|
|
state.sync(bc); |
|
|
|
|
|
|
|
for (size_t i = 1; i < importBlockNumber; i++) //0 block is genesis
|
|
|
|
{ |
|
|
|
BlockQueue uncleQueue; |
|
|
|
uncleQueue.setChain(bc); |
|
|
|
uncleList uncles = blockSets.at(i).second; |
|
|
|
for (size_t j = 0; j < uncles.size(); j++) |
|
|
|
uncleQueue.import(&uncles.at(j), false); |
|
|
@ -162,6 +165,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) |
|
|
|
blObj["uncleHeaders"] = importUncles(blObj, vBiUncles, vBiBlocks, blockSets); |
|
|
|
|
|
|
|
BlockQueue uncleBlockQueue; |
|
|
|
uncleBlockQueue.setChain(bc); |
|
|
|
uncleList uncleBlockQueueList; |
|
|
|
cnote << "import uncle in blockQueue"; |
|
|
|
for (size_t i = 0; i < vBiUncles.size(); i++) |
|
|
@ -207,7 +211,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) |
|
|
|
txList.push_back(txi); |
|
|
|
blObj["transactions"] = writeTransactionsToJson(txList); |
|
|
|
|
|
|
|
BlockHeader current_BlockHeader = state.info(); |
|
|
|
BlockHeader current_BlockHeader(state.blockData()); |
|
|
|
|
|
|
|
RLPStream uncleStream; |
|
|
|
uncleStream.appendList(vBiUncles.size()); |
|
|
@ -666,19 +670,19 @@ void overwriteBlockHeader(BlockHeader& _header, mObject& _blObj) |
|
|
|
if (ho.size() != 14) |
|
|
|
{ |
|
|
|
BlockHeader tmp = constructHeader( |
|
|
|
ho.count("parentHash") ? h256(ho["parentHash"].get_str()) : h256{}, |
|
|
|
ho.count("uncleHash") ? h256(ho["uncleHash"].get_str()) : EmptyListSHA3, |
|
|
|
ho.count("coinbase") ? Address(ho["coinbase"].get_str()) : Address{}, |
|
|
|
ho.count("stateRoot") ? h256(ho["stateRoot"].get_str()): h256{}, |
|
|
|
ho.count("transactionsTrie") ? h256(ho["transactionsTrie"].get_str()) : EmptyTrie, |
|
|
|
ho.count("receiptTrie") ? h256(ho["receiptTrie"].get_str()) : EmptyTrie, |
|
|
|
ho.count("bloom") ? LogBloom(ho["bloom"].get_str()) : LogBloom{}, |
|
|
|
ho.count("difficulty") ? toInt(ho["difficulty"]) : u256(0), |
|
|
|
ho.count("number") ? toInt(ho["number"]) : u256(0), |
|
|
|
ho.count("gasLimit") ? toInt(ho["gasLimit"]) : u256(0), |
|
|
|
ho.count("gasUsed") ? toInt(ho["gasUsed"]) : u256(0), |
|
|
|
ho.count("timestamp") ? toInt(ho["timestamp"]) : u256(0), |
|
|
|
ho.count("extraData") ? importByteArray(ho["extraData"].get_str()) : bytes{}); |
|
|
|
ho.count("parentHash") ? h256(ho["parentHash"].get_str()) : _header.parentHash(), |
|
|
|
ho.count("uncleHash") ? h256(ho["uncleHash"].get_str()) : _header.sha3Uncles(), |
|
|
|
ho.count("coinbase") ? Address(ho["coinbase"].get_str()) : _header.coinbaseAddress(), |
|
|
|
ho.count("stateRoot") ? h256(ho["stateRoot"].get_str()): _header.stateRoot(), |
|
|
|
ho.count("transactionsTrie") ? h256(ho["transactionsTrie"].get_str()) : _header.transactionsRoot(), |
|
|
|
ho.count("receiptTrie") ? h256(ho["receiptTrie"].get_str()) : _header.receiptsRoot(), |
|
|
|
ho.count("bloom") ? LogBloom(ho["bloom"].get_str()) : _header.logBloom(), |
|
|
|
ho.count("difficulty") ? toInt(ho["difficulty"]) : _header.difficulty(), |
|
|
|
ho.count("number") ? toInt(ho["number"]) : _header.number(), |
|
|
|
ho.count("gasLimit") ? toInt(ho["gasLimit"]) : _header.gasLimit(), |
|
|
|
ho.count("gasUsed") ? toInt(ho["gasUsed"]) : _header.gasUsed(), |
|
|
|
ho.count("timestamp") ? toInt(ho["timestamp"]) : _header.timestamp(), |
|
|
|
ho.count("extraData") ? importByteArray(ho["extraData"].get_str()) : _header.extraData()); |
|
|
|
|
|
|
|
// find new valid nonce
|
|
|
|
if (static_cast<BlockInfo>(tmp) != static_cast<BlockInfo>(_header) && tmp.difficulty()) |
|
|
|