From 81a7f463851e308e9427959c8d6f40b00b8c75aa Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 2 Jun 2015 10:13:12 +0200 Subject: [PATCH] forbid uncle to be your brother --- libethcore/Exceptions.h | 15 ++++++++------- libethereum/State.cpp | 8 ++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 8b73c96fe..9362e4fed 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -49,27 +49,28 @@ struct FeeTooSmall: virtual dev::Exception {}; struct TooMuchGasUsed: virtual dev::Exception {}; struct ExtraDataTooBig: virtual dev::Exception {}; struct InvalidSignature: virtual dev::Exception {}; -class InvalidBlockFormat: virtual public dev::Exception {}; +struct InvalidBlockFormat: virtual dev::Exception {}; struct InvalidUnclesHash: virtual dev::Exception {}; struct InvalidUncle: virtual dev::Exception {}; struct TooManyUncles: virtual dev::Exception {}; struct UncleTooOld: virtual dev::Exception {}; -class UncleInChain: virtual public dev::Exception {}; +struct UncleIsBrother: virtual dev::Exception {}; +struct UncleInChain: virtual dev::Exception {}; struct DuplicateUncleNonce: virtual dev::Exception {}; struct InvalidStateRoot: virtual dev::Exception {}; struct InvalidGasUsed: virtual dev::Exception {}; -class InvalidTransactionsHash: virtual public dev::Exception {}; +struct InvalidTransactionsHash: virtual dev::Exception {}; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception {}; +struct InvalidGasLimit: virtual dev::Exception {}; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; struct InvalidReceiptsStateRoot: virtual dev::Exception {}; struct InvalidTimestamp: virtual dev::Exception {}; struct InvalidLogBloom: virtual dev::Exception {}; -class InvalidNonce: virtual public dev::Exception {}; -class InvalidBlockHeaderItemCount: virtual public dev::Exception {}; -class InvalidBlockNonce: virtual public dev::Exception {}; +struct InvalidNonce: virtual dev::Exception {}; +struct InvalidBlockHeaderItemCount: virtual dev::Exception {}; +struct InvalidBlockNonce: virtual dev::Exception {}; struct InvalidParentHash: virtual dev::Exception {}; struct InvalidNumber: virtual dev::Exception {}; struct InvalidContractAddress: virtual public dev::Exception {}; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index b35ef98ce..09765d9ee 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -726,6 +726,14 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, ImportRequirement cwarn << " Block number: " << m_currentBlock.number; BOOST_THROW_EXCEPTION(UncleTooOld()); } + else if (uncle.number == m_currentBlock.number) + { + badBlock(_block, "Uncle is brother"); + cwarn << " Uncle number: " << uncle.number; + cwarn << " Uncle parent number: " << uncleParent.number; + cwarn << " Block number: " << m_currentBlock.number; + BOOST_THROW_EXCEPTION(UncleIsBrother()); + } uncle.verifyParent(uncleParent); // tdIncrease += uncle.difficulty;