diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp
index 5d4f9770e..7fdb058d8 100644
--- a/alethzero/MainWin.cpp
+++ b/alethzero/MainWin.cpp
@@ -1059,8 +1059,7 @@ void Main::refreshBlockCount()
{
cwatch << "refreshBlockCount()";
auto d = ethereum()->blockChain().details();
- auto diff = BlockInfo(ethereum()->blockChain().block()).difficulty;
- ui->blockCount->setText(QString("%6 #%1 @%3 T%2 PV%4 D%5").arg(d.number).arg(toLog2(d.totalDifficulty)).arg(toLog2(diff)).arg(c_protocolVersion).arg(c_databaseVersion).arg(m_privateChain.size() ? "[" + m_privateChain + "] " : "testnet"));
+ ui->blockCount->setText(QString("%4 #%1 PV%2 D%3 H%5").arg(d.number).arg(c_protocolVersion).arg(c_databaseVersion).arg(m_privateChain.size() ? "[" + m_privateChain + "] " : "testnet").arg(c_ethashVersion));
}
void Main::on_turboMining_triggered()
@@ -1429,63 +1428,64 @@ void Main::on_blocks_currentItemChanged()
s << "
" << h << "
";
s << "#" << info.number;
s << " " << timestamp << "
";
- s << "
D/TD: " << info.difficulty << "/" << details.totalDifficulty << " = 2^" << log2((double)info.difficulty) << "/2^" << log2((double)details.totalDifficulty);
- s << " Children: " << details.children.size() << "";
- s << "
Gas used/limit: " << info.gasUsed << "/" << info.gasLimit << "";
- s << "
Coinbase: " << pretty(info.coinbaseAddress).toHtmlEscaped().toStdString() << " " << info.coinbaseAddress;
- s << "
Seed hash: " << info.seedHash() << "";
- s << "
Mix hash: " << info.mixHash << "";
- s << "
Nonce: " << info.nonce << "";
- s << "
Hash w/o nonce: " << info.headerHash(WithoutNonce) << "";
- s << "
Difficulty: " << info.difficulty << "";
+ s << "D/TD: " << info.difficulty << "/" << details.totalDifficulty << " = 2^" << log2((double)info.difficulty) << "/2^" << log2((double)details.totalDifficulty) << "
";
+ s << " Children: " << details.children.size() << "";
+ s << "Gas used/limit: " << info.gasUsed << "/" << info.gasLimit << "" << "
";
+ s << "Beneficiary: " << pretty(info.coinbaseAddress).toHtmlEscaped().toStdString() << " " << info.coinbaseAddress << "" << "
";
+ s << "Seed hash: " << info.seedHash() << "" << "
";
+ s << "Mix hash: " << info.mixHash << "" << "
";
+ s << "Nonce: " << info.nonce << "" << "
";
+ s << "Hash w/o nonce: " << info.headerHash(WithoutNonce) << "" << "
";
+ s << "Difficulty: " << info.difficulty << "" << "
";
if (info.number)
{
auto e = Ethasher::eval(info);
- s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")";
- s << "
Parent: " << info.parentHash << "";
+ s << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")" << "
";
+ s << "Parent: " << info.parentHash << "" << "
";
}
else
{
- s << "
Proof-of-Work: Phil has nothing to prove";
- s << "
Parent: It was a virgin birth";
+ s << "Proof-of-Work: Phil has nothing to prove
";
+ s << "Parent: It was a virgin birth
";
}
-// s << "
Bloom: " << details.bloom << "";
+// s << "Bloom:
" << details.bloom << "";
if (!!info.logBloom)
s << "
Log Bloom: " << info.logBloom << "
";
else
s << "
Log Bloom: Uneventful
";
- s << "
Transactions:
" << block[1].itemCount() << " @
" << info.transactionsRoot << "";
- s << "
Receipts: @
" << info.receiptsRoot << ":";
- s << "
Uncles:
" << block[2].itemCount() << " @
" << info.sha3Uncles << "";
+ s << "
Transactions: " << block[1].itemCount() << " @" << info.transactionsRoot << "" << "
";
+ s << "
Uncles: " << block[2].itemCount() << " @" << info.sha3Uncles << "" << "
";
for (auto u: block[2])
{
BlockInfo uncle = BlockInfo::fromHeader(u.data());
- char const* line = "
";
- s << line << "Hash:
" << uncle.hash << "";
- s << line << "Parent:
" << uncle.parentHash << "";
- s << line << "Number:
" << uncle.number << "";
- s << line << "Coinbase:
" << pretty(uncle.coinbaseAddress).toHtmlEscaped().toStdString() << " " << uncle.coinbaseAddress;
- s << line << "Seed hash:
" << uncle.seedHash() << "";
- s << line << "Mix hash:
" << uncle.mixHash << "";
- s << line << "Nonce:
" << uncle.nonce << "";
- s << line << "Hash w/o nonce:
" << uncle.headerHash(WithoutNonce) << "";
- s << line << "Difficulty:
" << uncle.difficulty << "";
+ char const* line = "
";
+ s << line << "Hash: " << uncle.hash << "" << "
";
+ s << line << "Parent:
" << uncle.parentHash << "" << "
";
+ s << line << "Number: " << uncle.number << "" << "";
+ s << line << "Coinbase: " << pretty(uncle.coinbaseAddress).toHtmlEscaped().toStdString() << " " << uncle.coinbaseAddress << "" << "";
+ s << line << "Seed hash: " << uncle.seedHash() << "" << "";
+ s << line << "Mix hash: " << uncle.mixHash << "" << "";
+ s << line << "Nonce: " << uncle.nonce << "" << "";
+ s << line << "Hash w/o nonce: " << uncle.headerHash(WithoutNonce) << "" << "";
+ s << line << "Difficulty: " << uncle.difficulty << "" << "";
auto e = Ethasher::eval(uncle);
- s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")";
+ s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")" << "";
}
if (info.parentHash)
- s << "
Pre: " << BlockInfo(ethereum()->blockChain().block(info.parentHash)).stateRoot << "";
+ s << "Pre: " << BlockInfo(ethereum()->blockChain().block(info.parentHash)).stateRoot << "" << "
";
else
- s << "
Pre: Nothing is before Phil";
+ s << "Pre: Nothing is before Phil" << "
";
+
+ s << "Receipts: @" << info.receiptsRoot << ":" << "
";
BlockReceipts receipts = ethereum()->blockChain().receipts(h);
unsigned ii = 0;
for (auto const& i: block[1])
{
- s << "
" << sha3(i.data()).abridged() << ": " << receipts.receipts[ii].stateRoot() << " [" << receipts.receipts[ii].gasUsed() << " used]";
+ s << "" << sha3(i.data()).abridged() << ": " << receipts.receipts[ii].stateRoot() << " [" << receipts.receipts[ii].gasUsed() << " used]" << "
";
++ii;
}
- s << "
Post: " << info.stateRoot << "";
- s << "
Dump: " Span(Mono) << toHex(block[0].data()) << "";
+ s << "Post: " << info.stateRoot << "" << "
";
+ s << "Dump: " Span(Mono) << toHex(block[0].data()) << "" << "
";
s << "Receipts-Hex: " Span(Mono) << toHex(receipts.rlp()) << "
";
}
else
@@ -1497,19 +1497,19 @@ void Main::on_blocks_currentItemChanged()
TransactionReceipt receipt = ethereum()->blockChain().receipts(h).receipts[txi];
s << "" << th << "
";
s << "" << h << "[" << txi << "]
";
- s << "
From: " << pretty(ss).toHtmlEscaped().toStdString() << " " << ss;
+ s << "From: " << pretty(ss).toHtmlEscaped().toStdString() << " " << ss << "" << "
";
if (tx.isCreation())
- s << "
Creates: " << pretty(right160(th)).toHtmlEscaped().toStdString() << " " << right160(th);
+ s << "Creates: " << pretty(right160(th)).toHtmlEscaped().toStdString() << " " << right160(th) << "
";
else
- s << "
To: " << pretty(tx.receiveAddress()).toHtmlEscaped().toStdString() << " " << tx.receiveAddress();
- s << "
Value: " << formatBalance(tx.value()) << "";
- s << " #" << tx.nonce() << "";
- s << "
Gas price: " << formatBalance(tx.gasPrice()) << "";
- s << "
Gas: " << tx.gas() << "";
- s << "
V: " << hex << nouppercase << (int)tx.signature().v << " + 27";
- s << "
R: " << hex << nouppercase << tx.signature().r << "";
- s << "
S: " << hex << nouppercase << tx.signature().s << "";
- s << "
Msg: " << tx.sha3(eth::WithoutSignature) << "";
+ s << "To: " << pretty(tx.receiveAddress()).toHtmlEscaped().toStdString() << " " << tx.receiveAddress() << "
";
+ s << "Value: " << formatBalance(tx.value()) << "" << "
";
+ s << " #" << tx.nonce() << "" << "";
+ s << "Gas price: " << formatBalance(tx.gasPrice()) << "" << "
";
+ s << "Gas: " << tx.gas() << "" << "
";
+ s << "V: " << hex << nouppercase << (int)tx.signature().v << " + 27" << "
";
+ s << "R: " << hex << nouppercase << tx.signature().r << "" << "
";
+ s << "S: " << hex << nouppercase << tx.signature().s << "" << "
";
+ s << "Msg: " << tx.sha3(eth::WithoutSignature) << "" << "
";
if (!tx.data().empty())
{
if (tx.isCreation())
@@ -1522,7 +1522,7 @@ void Main::on_blocks_currentItemChanged()
if (!!receipt.bloom())
s << "Log Bloom: " << receipt.bloom() << "
";
else
- s << "Log Bloom: Uneventful
";
+ s << "Log Bloom: Uneventful
";
auto r = receipt.rlp();
s << "Receipt: " << toString(RLP(r)) << "
";
s << "Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "
";
diff --git a/libdevcore/Assertions.h b/libdevcore/Assertions.h
new file mode 100644
index 000000000..7b4a4a765
--- /dev/null
+++ b/libdevcore/Assertions.h
@@ -0,0 +1,111 @@
+/*
+ This file is part of cpp-ethereum.
+
+ cpp-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ cpp-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with cpp-ethereum. If not, see .
+*/
+/**
+ * @file Assertions.h
+ * @author Christian
+ * @date 2015
+ *
+ * Assertion handling.
+ */
+
+#pragma once
+
+#include "Exceptions.h"
+#include "debugbreak.h"
+
+namespace dev
+{
+
+#if defined(_MSC_VER)
+#define ETH_FUNC __FUNCSIG__
+#elif defined(__GNUC__)
+#define ETH_FUNC __PRETTY_FUNCTION__
+#else
+#define ETH_FUNC __func__
+#endif
+
+#define asserts(A) ::dev::assertAux(A, #A, __LINE__, __FILE__, ETH_FUNC)
+#define assertsEqual(A, B) ::dev::assertEqualAux(A, B, #A, #B, __LINE__, __FILE__, ETH_FUNC)
+
+inline bool assertAux(bool _a, char const* _aStr, unsigned _line, char const* _file, char const* _func)
+{
+ bool ret = _a;
+ if (!ret)
+ {
+ std::cerr << "Assertion failed:" << _aStr << " [func=" << _func << ", line=" << _line << ", file=" << _file << "]" << std::endl;
+#if ETH_DEBUG
+ debug_break();
+#endif
+ }
+ return !ret;
+}
+
+template
+inline bool assertEqualAux(A const& _a, B const& _b, char const* _aStr, char const* _bStr, unsigned _line, char const* _file, char const* _func)
+{
+ bool ret = _a == _b;
+ if (!ret)
+ {
+ std::cerr << "Assertion failed: " << _aStr << " == " << _bStr << " [func=" << _func << ", line=" << _line << ", file=" << _file << "]" << std::endl;
+ std::cerr << " Fail equality: " << _a << "==" << _b << std::endl;
+#if ETH_DEBUG
+ debug_break();
+#endif
+ }
+ return !ret;
+}
+
+/// Assertion that throws an exception containing the given description if it is not met.
+/// Use it as assertThrow(1 == 1, ExceptionType, "Mathematics is wrong.");
+/// Do NOT supply an exception object as the second parameter.
+#define assertThrow(_condition, _ExceptionType, _description) \
+ ::dev::assertThrowAux<_ExceptionType>(_condition, _description, __LINE__, __FILE__, ETH_FUNC)
+
+using errinfo_comment = boost::error_info;
+
+template
+inline void assertThrowAux(
+ bool _condition,
+ ::std::string const& _errorDescription,
+ unsigned _line,
+ char const* _file,
+ char const* _function
+)
+{
+ if (!_condition)
+ ::boost::throw_exception(
+ _ExceptionType() <<
+ ::dev::errinfo_comment(_errorDescription) <<
+ ::boost::throw_function(_function) <<
+ ::boost::throw_file(_file) <<
+ ::boost::throw_line(_line)
+ );
+}
+
+template
+inline void assertThrowAux(
+ void const* _pointer,
+ ::std::string const& _errorDescription,
+ unsigned _line,
+ char const* _file,
+ char const* _function
+)
+{
+ assertThrowAux<_ExceptionType>(_pointer != nullptr, _errorDescription, _line, _file, _function);
+}
+
+}
diff --git a/libdevcore/Common.h b/libdevcore/Common.h
index bf9699b2f..5e778644d 100644
--- a/libdevcore/Common.h
+++ b/libdevcore/Common.h
@@ -44,7 +44,6 @@
#pragma warning(pop)
#pragma GCC diagnostic pop
#include "vector_ref.h"
-#include "debugbreak.h"
// CryptoPP defines byte in the global namespace, so must we.
using byte = uint8_t;
@@ -135,45 +134,4 @@ private:
std::function m_f;
};
-// Assertions...
-
-#if defined(_MSC_VER)
-#define ETH_FUNC __FUNCSIG__
-#elif defined(__GNUC__)
-#define ETH_FUNC __PRETTY_FUNCTION__
-#else
-#define ETH_FUNC __func__
-#endif
-
-#define asserts(A) ::dev::assertAux(A, #A, __LINE__, __FILE__, ETH_FUNC)
-#define assertsEqual(A, B) ::dev::assertEqualAux(A, B, #A, #B, __LINE__, __FILE__, ETH_FUNC)
-
-inline bool assertAux(bool _a, char const* _aStr, unsigned _line, char const* _file, char const* _func)
-{
- bool ret = _a;
- if (!ret)
- {
- std::cerr << "Assertion failed:" << _aStr << " [func=" << _func << ", line=" << _line << ", file=" << _file << "]" << std::endl;
-#if ETH_DEBUG
- debug_break();
-#endif
- }
- return !ret;
-}
-
-template
-inline bool assertEqualAux(A const& _a, B const& _b, char const* _aStr, char const* _bStr, unsigned _line, char const* _file, char const* _func)
-{
- bool ret = _a == _b;
- if (!ret)
- {
- std::cerr << "Assertion failed: " << _aStr << " == " << _bStr << " [func=" << _func << ", line=" << _line << ", file=" << _file << "]" << std::endl;
- std::cerr << " Fail equality: " << _a << "==" << _b << std::endl;
-#if ETH_DEBUG
- debug_break();
-#endif
- }
- return !ret;
-}
-
}
diff --git a/libdevcore/StructuredLogger.cpp b/libdevcore/StructuredLogger.cpp
index 5655b332d..f51ed310a 100644
--- a/libdevcore/StructuredLogger.cpp
+++ b/libdevcore/StructuredLogger.cpp
@@ -38,9 +38,10 @@ void StructuredLogger::outputJson(Json::Value const& _value, std::string const&
{
Json::Value event;
static Mutex s_lock;
+ Json::FastWriter fastWriter;
Guard l(s_lock);
event[_name] = _value;
- cout << event << endl << flush;
+ cout << fastWriter.write(event) << endl;
}
void StructuredLogger::starting(string const& _clientImpl, const char* _ethVersion)
diff --git a/libdevcrypto/CryptoPP.cpp b/libdevcrypto/CryptoPP.cpp
index 79fd62262..ff22b9b45 100644
--- a/libdevcrypto/CryptoPP.cpp
+++ b/libdevcrypto/CryptoPP.cpp
@@ -20,6 +20,7 @@
*/
#include
+#include
#include "ECDHE.h"
#include "CryptoPP.h"
diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp
index 76efc06a2..d26ac0260 100644
--- a/libethcore/Common.cpp
+++ b/libethcore/Common.cpp
@@ -22,6 +22,7 @@
#include "Common.h"
#include
#include
+#include "Ethasher.h"
#include "Exceptions.h"
using namespace std;
using namespace dev;
@@ -32,15 +33,16 @@ namespace dev
namespace eth
{
+const unsigned c_ethashVersion = c_ethashRevision;
const unsigned c_protocolVersion = 58;
const unsigned c_databaseBaseVersion = 8;
#if ETH_FATDB
-const unsigned c_databaseVersionModifier = 1000;
+const unsigned c_databaseVersionModifier = 1;
#else
const unsigned c_databaseVersionModifier = 0;
#endif
-const unsigned c_databaseVersion = c_databaseBaseVersion + c_databaseVersionModifier;
+const unsigned c_databaseVersion = c_databaseBaseVersion + (c_databaseVersionModifier << 8) + (c_ethashVersion << 9);
vector> const& units()
{
diff --git a/libethcore/Common.h b/libethcore/Common.h
index 80a253bdd..aabb59d25 100644
--- a/libethcore/Common.h
+++ b/libethcore/Common.h
@@ -38,6 +38,9 @@ extern const unsigned c_protocolVersion;
/// Current database version.
extern const unsigned c_databaseVersion;
+/// Current database version.
+extern const unsigned c_ethashVersion;
+
/// User-friendly string representation of the amount _b in wei.
std::string formatBalance(bigint const& _b);
diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp
index 54167f2ad..f80680f38 100644
--- a/libethereum/BlockChain.cpp
+++ b/libethereum/BlockChain.cpp
@@ -26,6 +26,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/libethereum/State.cpp b/libethereum/State.cpp
index 9bfc0c08c..638430c3b 100644
--- a/libethereum/State.cpp
+++ b/libethereum/State.cpp
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/libevm/VMFactory.cpp b/libevm/VMFactory.cpp
index 40f8a3500..1092906e4 100644
--- a/libevm/VMFactory.cpp
+++ b/libevm/VMFactory.cpp
@@ -16,6 +16,7 @@
*/
#include "VMFactory.h"
+#include
#include "VM.h"
#if ETH_EVMJIT
diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp
index 0a0611292..68f326bfd 100644
--- a/libevmcore/Assembly.cpp
+++ b/libevmcore/Assembly.cpp
@@ -47,9 +47,6 @@ unsigned AssemblyItem::bytesRequired(unsigned _addressLength) const
case PushData:
case PushSub:
return 1 + _addressLength;
- case NoOptimizeBegin:
- case NoOptimizeEnd:
- return 0;
default:
break;
}
@@ -61,7 +58,7 @@ int AssemblyItem::deposit() const
switch (m_type)
{
case Operation:
- return instructionInfo((Instruction)(byte)m_data).ret - instructionInfo((Instruction)(byte)m_data).args;
+ return instructionInfo(instruction()).ret - instructionInfo(instruction()).args;
case Push:
case PushString:
case PushTag:
@@ -91,6 +88,48 @@ string AssemblyItem::getJumpTypeAsString() const
}
}
+ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item)
+{
+ switch (_item.type())
+ {
+ case Operation:
+ _out << " " << instructionInfo(_item.instruction()).name;
+ if (_item.instruction() == eth::Instruction::JUMP || _item.instruction() == eth::Instruction::JUMPI)
+ _out << "\t" << _item.getJumpTypeAsString();
+ break;
+ case Push:
+ _out << " PUSH " << hex << _item.data();
+ break;
+ case PushString:
+ _out << " PushString" << hex << (unsigned)_item.data();
+ break;
+ case PushTag:
+ _out << " PushTag " << _item.data();
+ break;
+ case Tag:
+ _out << " Tag " << _item.data();
+ break;
+ case PushData:
+ _out << " PushData " << hex << (unsigned)_item.data();
+ break;
+ case PushSub:
+ _out << " PushSub " << hex << h256(_item.data()).abridged();
+ break;
+ case PushSubSize:
+ _out << " PushSubSize " << hex << h256(_item.data()).abridged();
+ break;
+ case PushProgramSize:
+ _out << " PushProgramSize";
+ break;
+ case UndefinedItem:
+ _out << " ???";
+ break;
+ default:
+ BOOST_THROW_EXCEPTION(InvalidOpcode());
+ }
+ return _out;
+}
+
unsigned Assembly::bytesRequired() const
{
for (unsigned br = 1;; ++br)
@@ -145,47 +184,7 @@ void Assembly::append(Assembly const& _a, int _deposit)
ostream& dev::eth::operator<<(ostream& _out, AssemblyItemsConstRef _i)
{
for (AssemblyItem const& i: _i)
- switch (i.type())
- {
- case Operation:
- _out << " " << instructionInfo((Instruction)(byte)i.data()).name;
- break;
- case Push:
- _out << " PUSH" << i.data();
- break;
- case PushString:
- _out << " PUSH'[" << hex << (unsigned)i.data() << "]";
- break;
- case PushTag:
- _out << " PUSH[tag" << i.data() << "]";
- break;
- case Tag:
- _out << " tag" << i.data() << ": JUMPDEST";
- break;
- case PushData:
- _out << " PUSH*[" << hex << (unsigned)i.data() << "]";
- break;
- case PushSub:
- _out << " PUSHs[" << hex << h256(i.data()).abridged() << "]";
- break;
- case PushSubSize:
- _out << " PUSHss[" << hex << h256(i.data()).abridged() << "]";
- break;
- case PushProgramSize:
- _out << " PUSHSIZE";
- break;
- case NoOptimizeBegin:
- _out << " DoNotOptimze{{";
- break;
- case NoOptimizeEnd:
- _out << " DoNotOptimze}}";
- break;
- case UndefinedItem:
- _out << " ???";
- break;
- default:
- BOOST_THROW_EXCEPTION(InvalidOpcode());
- }
+ _out << i;
return _out;
}
@@ -219,7 +218,7 @@ ostream& Assembly::stream(ostream& _out, string const& _prefix, StringMap const&
switch (i.m_type)
{
case Operation:
- _out << " " << instructionInfo((Instruction)(byte)i.m_data).name << "\t" << i.getJumpTypeAsString();
+ _out << " " << instructionInfo(i.instruction()).name << "\t" << i.getJumpTypeAsString();
break;
case Push:
_out << " PUSH " << i.m_data;
@@ -245,12 +244,6 @@ ostream& Assembly::stream(ostream& _out, string const& _prefix, StringMap const&
case PushData:
_out << " PUSH [" << hex << (unsigned)i.m_data << "]";
break;
- case NoOptimizeBegin:
- _out << "DoNotOptimze{{";
- break;
- case NoOptimizeEnd:
- _out << "DoNotOptimze}}";
- break;
default:
BOOST_THROW_EXCEPTION(InvalidOpcode());
}
@@ -384,7 +377,7 @@ Assembly& Assembly::optimise(bool _enable)
{
if (m[0].type() != Operation)
return m.toVector();
- Instruction instr = Instruction(byte(m[0].data()));
+ Instruction instr = m[0].instruction();
if (Instruction::DUP1 <= instr && instr <= Instruction::DUP16)
return {};
InstructionInfo info = instructionInfo(instr);
@@ -424,12 +417,6 @@ Assembly& Assembly::optimise(bool _enable)
count = 0;
for (unsigned i = 0; i < m_items.size(); ++i)
{
- if (m_items[i].type() == NoOptimizeBegin)
- {
- while (i < m_items.size() && m_items[i].type() != NoOptimizeEnd)
- ++i;
- continue;
- }
for (auto const& r: rules)
{
auto vr = AssemblyItemsConstRef(&m_items).cropped(i, r.first.size());
@@ -459,13 +446,11 @@ Assembly& Assembly::optimise(bool _enable)
}
}
}
- if (m_items[i].type() == Operation && m_items[i].data() == (byte)Instruction::JUMP)
+ if (m_items[i].type() == Operation && m_items[i].instruction() == Instruction::JUMP)
{
bool o = false;
while (m_items.size() > i + 1 && m_items[i + 1].type() != Tag)
{
- if (m_items[i + 1].type() == NoOptimizeBegin)
- break;
m_items.erase(m_items.begin() + i + 1);
o = true;
}
@@ -490,7 +475,7 @@ Assembly& Assembly::optimise(bool _enable)
{
auto t = *tags.begin();
unsigned i = t.second;
- if (i && m_items[i - 1].type() == Operation && m_items[i - 1].data() == (byte)Instruction::JUMP)
+ if (i && m_items[i - 1].type() == Operation && m_items[i - 1].instruction() == Instruction::JUMP)
while (i < m_items.size() && (m_items[i].type() != Tag || tags.count(m_items[i].data())))
{
if (m_items[i].type() == Tag && tags.count(m_items[i].data()))
@@ -599,9 +584,6 @@ bytes Assembly::assemble() const
tagPos[(unsigned)i.m_data] = ret.size();
ret.push_back((byte)Instruction::JUMPDEST);
break;
- case NoOptimizeBegin:
- case NoOptimizeEnd:
- break;
default:
BOOST_THROW_EXCEPTION(InvalidOpcode());
}
diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h
index 242f6f1ff..280a2e81c 100644
--- a/libevmcore/Assembly.h
+++ b/libevmcore/Assembly.h
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
#include
#include
#include "Exceptions.h"
@@ -33,7 +34,7 @@ namespace dev
namespace eth
{
-enum AssemblyItemType { UndefinedItem, Operation, Push, PushString, PushTag, PushSub, PushSubSize, PushProgramSize, Tag, PushData, NoOptimizeBegin, NoOptimizeEnd };
+enum AssemblyItemType { UndefinedItem, Operation, Push, PushString, PushTag, PushSub, PushSubSize, PushProgramSize, Tag, PushData };
class Assembly;
@@ -48,11 +49,17 @@ public:
AssemblyItem(Instruction _i): m_type(Operation), m_data((byte)_i) {}
AssemblyItem(AssemblyItemType _type, u256 _data = 0): m_type(_type), m_data(_data) {}
- AssemblyItem tag() const { if (asserts(m_type == PushTag || m_type == Tag)) BOOST_THROW_EXCEPTION(Exception()); return AssemblyItem(Tag, m_data); }
- AssemblyItem pushTag() const { if (asserts(m_type == PushTag || m_type == Tag)) BOOST_THROW_EXCEPTION(Exception()); return AssemblyItem(PushTag, m_data); }
+ AssemblyItem tag() const { assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); return AssemblyItem(Tag, m_data); }
+ AssemblyItem pushTag() const { assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); return AssemblyItem(PushTag, m_data); }
AssemblyItemType type() const { return m_type; }
- u256 data() const { return m_data; }
+ u256 const& data() const { return m_data; }
+ /// @returns the instruction of this item (only valid if type() == Operation)
+ Instruction instruction() const { return Instruction(byte(m_data)); }
+
+ /// @returns true iff the type and data of the items are equal.
+ bool operator==(AssemblyItem const& _other) const { return m_type == _other.m_type && m_data == _other.m_data; }
+ bool operator!=(AssemblyItem const& _other) const { return !operator==(_other); }
/// @returns an upper bound for the number of bytes required by this item, assuming that
/// the value of a jump tag takes @a _addressLength bytes.
@@ -77,6 +84,7 @@ private:
using AssemblyItems = std::vector;
using AssemblyItemsConstRef = vector_ref;
+std::ostream& operator<<(std::ostream& _out, AssemblyItem const& _item);
std::ostream& operator<<(std::ostream& _out, AssemblyItemsConstRef _i);
inline std::ostream& operator<<(std::ostream& _out, AssemblyItems const& _i) { return operator<<(_out, AssemblyItemsConstRef(&_i)); }
diff --git a/libevmcore/Instruction.h b/libevmcore/Instruction.h
index 9eab92713..07c7b52fd 100644
--- a/libevmcore/Instruction.h
+++ b/libevmcore/Instruction.h
@@ -22,6 +22,7 @@
#pragma once
#include
+#include
#include
namespace dev
@@ -194,32 +195,28 @@ inline unsigned getSwapNumber(Instruction _inst)
/// @returns the PUSH<_number> instruction
inline Instruction pushInstruction(unsigned _number)
{
- if (asserts(1 <= _number && _number <= 32))
- BOOST_THROW_EXCEPTION(InvalidOpcode() << errinfo_comment("Invalid PUSH instruction requested."));
+ assertThrow(1 <= _number && _number <= 32, InvalidOpcode, "Invalid PUSH instruction requested.");
return Instruction(unsigned(Instruction::PUSH1) + _number - 1);
}
/// @returns the DUP<_number> instruction
inline Instruction dupInstruction(unsigned _number)
{
- if (asserts(1 <= _number && _number <= 16))
- BOOST_THROW_EXCEPTION(InvalidOpcode() << errinfo_comment("Invalid DUP instruction requested."));
+ assertThrow(1 <= _number && _number <= 16, InvalidOpcode, "Invalid DUP instruction requested.");
return Instruction(unsigned(Instruction::DUP1) + _number - 1);
}
/// @returns the SWAP<_number> instruction
inline Instruction swapInstruction(unsigned _number)
{
- if (asserts(1 <= _number && _number <= 16))
- BOOST_THROW_EXCEPTION(InvalidOpcode() << errinfo_comment("Invalid SWAP instruction requested."));
+ assertThrow(1 <= _number && _number <= 16, InvalidOpcode, "Invalid SWAP instruction requested.");
return Instruction(unsigned(Instruction::SWAP1) + _number - 1);
}
/// @returns the LOG<_number> instruction
inline Instruction logInstruction(unsigned _number)
{
- if (asserts(_number <= 4))
- BOOST_THROW_EXCEPTION(InvalidOpcode() << errinfo_comment("Invalid LOG instruction requested."));
+ assertThrow(_number <= 4, InvalidOpcode, "Invalid LOG instruction requested.");
return Instruction(unsigned(Instruction::LOG0) + _number);
}
diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp
index 1d54f4afe..78a8232fd 100644
--- a/libp2p/Host.cpp
+++ b/libp2p/Host.cpp
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/libp2p/Network.cpp b/libp2p/Network.cpp
index d1e97fac6..bdd1f0108 100644
--- a/libp2p/Network.cpp
+++ b/libp2p/Network.cpp
@@ -29,6 +29,7 @@
#include
#include
+#include
#include
#include
#include "Common.h"
diff --git a/libp2p/RLPxFrameIO.cpp b/libp2p/RLPxFrameIO.cpp
index cb768bfeb..ac1a27bed 100644
--- a/libp2p/RLPxFrameIO.cpp
+++ b/libp2p/RLPxFrameIO.cpp
@@ -19,11 +19,13 @@
* @date 2015
*/
+#include "RLPxFrameIO.h"
+#include
#include "Host.h"
#include "Session.h"
#include "Peer.h"
#include "RLPxHandshake.h"
-#include "RLPxFrameIO.h"
+
using namespace std;
using namespace dev;
using namespace dev::p2p;
diff --git a/libsolidity/Utils.h b/libsolidity/Utils.h
index 1411f66b4..05c5fa6f0 100644
--- a/libsolidity/Utils.h
+++ b/libsolidity/Utils.h
@@ -22,34 +22,9 @@
#pragma once
-#include
-#include
-
-namespace dev
-{
-namespace solidity
-{
+#include
/// Assertion that throws an InternalCompilerError containing the given description if it is not met.
#define solAssert(CONDITION, DESCRIPTION) \
- ::dev::solidity::solAssertAux(CONDITION, DESCRIPTION, __LINE__, __FILE__, ETH_FUNC)
-
-inline void solAssertAux(bool _condition, std::string const& _errorDescription, unsigned _line,
- char const* _file, char const* _function)
-{
- if (!_condition)
- ::boost::throw_exception( InternalCompilerError()
- << errinfo_comment(_errorDescription)
- << ::boost::throw_function(_function)
- << ::boost::throw_file(_file)
- << ::boost::throw_line(_line));
-}
-
-inline void solAssertAux(void const* _pointer, std::string const& _errorDescription, unsigned _line,
- char const* _file, char const* _function)
-{
- solAssertAux(_pointer != nullptr, _errorDescription, _line, _file, _function);
-}
+ assertThrow(CONDITION, ::dev::solidity::InternalCompilerError, DESCRIPTION)
-}
-}
diff --git a/test/checkRandomStateTest.cpp b/test/checkRandomStateTest.cpp
index 17e785f60..8d73f872c 100644
--- a/test/checkRandomStateTest.cpp
+++ b/test/checkRandomStateTest.cpp
@@ -21,6 +21,7 @@
*/
#include
+#include
#include
#include
#include
diff --git a/test/checkRandomVMTest.cpp b/test/checkRandomVMTest.cpp
index c96357714..a40922577 100644
--- a/test/checkRandomVMTest.cpp
+++ b/test/checkRandomVMTest.cpp
@@ -21,6 +21,7 @@
*/
#include
+#include
#include
#include
#include
diff --git a/test/net.cpp b/test/net.cpp
index 831c283e2..3a69a627b 100644
--- a/test/net.cpp
+++ b/test/net.cpp
@@ -22,6 +22,7 @@
#include
#include
+#include
#include
#include
#include