From 07fb73bf5807a50175d56057647667a37fddf1b3 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 21 Oct 2014 18:05:05 +0300 Subject: [PATCH] sha3Uncles is empty when uncles is empty. --- libethcore/BlockInfo.cpp | 7 +++---- libethcore/CommonEth.cpp | 2 +- libethereum/State.cpp | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 6060ac032..a99f677a7 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -78,7 +78,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) try { parentHash = _header[field = 0].toHash(); - sha3Uncles = _header[field = 1].toHash(); + sha3Uncles = _header[field = 1].isEmpty() ? h256() : _header[field = 1].toHash(); coinbaseAddress = _header[field = 2].toHash
(); stateRoot = _header[field = 3].toHash(); transactionsRoot = _header[field = 4].toHash(); @@ -148,7 +148,7 @@ void BlockInfo::verifyInternals(bytesConstRef _block) const if (minGasPrice > mgp) BOOST_THROW_EXCEPTION(InvalidMinGasPrice(minGasPrice, mgp)); - if (sha3Uncles != sha3(root[2].data())) + if ((sha3Uncles && root[2].isEmpty()) || (!sha3Uncles && sha3Uncles != sha3(root[2].data()))) BOOST_THROW_EXCEPTION(InvalidUnclesHash()); } @@ -179,8 +179,7 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const } void BlockInfo::verifyParent(BlockInfo const& _parent) const -{ - // Check difficulty is correct given the two timestamps. +{ // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 54656173b..5f989689c 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -34,7 +34,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 35; +const unsigned c_protocolVersion = 36; const unsigned c_databaseVersion = 3; static const vector> g_units = diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 931ee2cf6..33a0052fb 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -826,7 +826,7 @@ void State::commitToMine(BlockChain const& _bc) RLPStream(unclesCount).appendRaw(unclesData.out(), unclesCount).swapOut(m_currentUncles); m_currentBlock.transactionsRoot = transactionReceipts.root(); - m_currentBlock.sha3Uncles = sha3(m_currentUncles); + m_currentBlock.sha3Uncles = unclesCount ? sha3(m_currentUncles) : h256(); // Apply rewards last of all. applyRewards(uncleAddresses);