Browse Source

Merge branch 'develop' into web3.js-v3.1

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
6aca61a3bd
  1. 2
      abi/main.cpp
  2. 2
      alethzero/NatspecHandler.cpp
  3. 2
      eth/main.cpp
  4. 14
      libdevcore/Log.h
  5. 23
      libdevcore/Worker.cpp
  6. 6
      libethereum/BlockChain.cpp
  7. 52
      libethereum/Client.cpp
  8. 4
      libethereum/ClientBase.cpp
  9. 2
      libethereum/EthereumHost.cpp
  10. 14
      libethereum/EthereumPeer.cpp
  11. 26
      libethereum/State.cpp
  12. 2
      libethereum/State.h
  13. 2
      libethereum/TransactionQueue.cpp
  14. 16
      libp2p/Host.cpp
  15. 2
      libp2p/Network.cpp
  16. 8
      libp2p/NodeTable.cpp
  17. 6
      libp2p/Session.cpp
  18. 6
      libweb3jsonrpc/WebThreeStubServerBase.cpp
  19. 106
      solc/CommandLineInterface.cpp
  20. 1
      solc/CommandLineInterface.h
  21. 6
      test/libdevcrypto/trie.cpp
  22. 10
      test/libwhisper/whisperTopic.cpp

2
abi/main.cpp

@ -43,7 +43,7 @@ void help()
<< " -h,--help Print this help message and exit." << endl
<< " -V,--version Show the version and exit." << endl
<< "Input options:" << endl
<< " -f,--format-prefix Require all input formats to be prefixed e.g. 0x for hex, . for decimal, @ for binary." << endl
<< " -f,--format-prefix Require all input formats to be prefixed e.g. 0x for hex, + for decimal, ' for binary." << endl
<< " -F,--no-format-prefix Require no input format to be prefixed." << endl
<< " -t,--typing Require all arguments to be typed e.g. b32: (bytes32), u64: (uint64), b[]: (byte[]), i: (int256)." << endl
<< " -T,--no-typing Require no arguments to be typed." << endl

2
alethzero/NatspecHandler.cpp

@ -58,7 +58,7 @@ string NatspecHandler::retrieve(dev::h256 const& _contractHash) const
{
string ret;
m_db->Get(m_readOptions, _contractHash.ref(), &ret);
cdebug << "Looking up NatSpec: " << _contractHash.abridged() << ret;
cdebug << "Looking up NatSpec: " << _contractHash << ret;
return ret;
}

2
eth/main.cpp

@ -517,7 +517,7 @@ int main(int argc, char** argv)
bool bootstrap = false;
/// Mining params
unsigned mining = ~(unsigned)0;
unsigned mining = 0;
bool forceMining = false;
KeyPair sigKey = KeyPair::create();
Secret sessionSecret;

14
libdevcore/Log.h

@ -87,11 +87,12 @@ struct WarnChannel: public LogChannel { static const char* name(); static const
struct NoteChannel: public LogChannel { static const char* name(); };
struct DebugChannel: public LogChannel { static const char* name(); static const int verbosity = 0; };
enum LogTag
enum class LogTag
{
None,
url,
error
Url,
Error,
Special
};
class LogOutputStreamBase
@ -103,12 +104,13 @@ public:
{
switch (m_logTag)
{
case url: m_sstr << EthNavyUnder; break;
case error: m_sstr << EthRedBold; break;
case LogTag::Url: m_sstr << EthNavyUnder; break;
case LogTag::Error: m_sstr << EthRedBold; break;
case LogTag::Special: m_sstr << EthWhiteBold; break;
default:;
}
m_sstr << _t << EthReset;
m_logTag = None;
m_logTag = LogTag::None;
}
void append(unsigned long _t) { m_sstr << EthBlue << _t << EthReset; }

23
libdevcore/Worker.cpp

@ -29,18 +29,25 @@ using namespace dev;
void Worker::startWorking()
{
// cnote << "startWorking for thread" << m_name;
cnote << "startWorking for thread" << m_name;
Guard l(x_work);
m_state = WorkerState::Starting;
if (!m_work)
if (m_work)
{
WorkerState ex = WorkerState::Stopped;
m_state.compare_exchange_strong(ex, WorkerState::Starting);
}
else
{
m_state = WorkerState::Starting;
m_work.reset(new thread([&]()
{
setThreadName(m_name.c_str());
cnote << "Thread begins";
while (m_state != WorkerState::Killing)
{
WorkerState ex = WorkerState::Starting;
m_state.compare_exchange_strong(ex, WorkerState::Started);
bool ok = m_state.compare_exchange_strong(ex, WorkerState::Started);
cnote << "Trying to set Started: Thread was" << (unsigned)ex << "; " << ok;
startedWorking();
cnote << "Entering work loop...";
@ -52,22 +59,25 @@ void Worker::startWorking()
// m_state.compare_exchange_strong(ex, WorkerState::Stopped);
ex = m_state.exchange(WorkerState::Stopped);
if (ex == WorkerState::Killing)
cnote << "State: Stopped: Thread was" << (unsigned)ex;
if (ex == WorkerState::Killing || ex == WorkerState::Starting)
m_state.exchange(ex);
cnote << "Waiting until not Stopped...";
while (m_state == WorkerState::Stopped)
this_thread::sleep_for(chrono::milliseconds(20));
}
}));
cnote << "Spawning" << m_name;
}
cnote << "Waiting until Started...";
while (m_state != WorkerState::Started)
this_thread::sleep_for(chrono::microseconds(20));
}
void Worker::stopWorking()
{
// cnote << "stopWorking for thread" << m_name;
cnote << "stopWorking for thread" << m_name;
ETH_GUARDED(x_work)
if (m_work)
{
@ -75,6 +85,7 @@ void Worker::stopWorking()
WorkerState ex = WorkerState::Started;
m_state.compare_exchange_strong(ex, WorkerState::Stopping);
cnote << "Waiting until Stopped...";
while (m_state != WorkerState::Stopped)
this_thread::sleep_for(chrono::microseconds(20));
}

6
libethereum/BlockChain.cpp

@ -320,14 +320,14 @@ tuple<h256s, h256s, bool> BlockChain::sync(BlockQueue& _bq, OverlayDB const& _st
}
catch (dev::eth::UnknownParent)
{
cwarn << "ODD: Import queue contains block with unknown parent." << error << boost::current_exception_diagnostic_information();
cwarn << "ODD: Import queue contains block with unknown parent." << LogTag::Error << boost::current_exception_diagnostic_information();
// NOTE: don't reimport since the queue should guarantee everything in the right order.
// Can't continue - chain bad.
badBlocks.push_back(BlockInfo::headerHash(block));
}
catch (Exception const& _e)
{
cnote << "Exception while importing block. Someone (Jeff? That you?) seems to be giving us dodgy blocks!" << error << diagnostic_information(_e);
cnote << "Exception while importing block. Someone (Jeff? That you?) seems to be giving us dodgy blocks!" << LogTag::Error << diagnostic_information(_e);
// NOTE: don't reimport since the queue should guarantee everything in the right order.
// Can't continue - chain bad.
badBlocks.push_back(BlockInfo::headerHash(block));
@ -611,7 +611,7 @@ ImportRoute BlockChain::import(bytes const& _block, OverlayDB const& _db, Import
m_extrasDB->Put(m_writeOptions, ldb::Slice("best"), ldb::Slice((char const*)&(bi.hash()), 32));
}
clog(BlockChainNote) << " Imported and best" << td << " (#" << bi.number << "). Has" << (details(bi.parentHash).children.size() - 1) << "siblings. Route:" << toString(route);
clog(BlockChainNote) << " Imported and best" << td << " (#" << bi.number << "). Has" << (details(bi.parentHash).children.size() - 1) << "siblings. Route:" << route;
noteCanonChanged();
StructuredLogger::chainNewHead(

52
libethereum/Client.cpp

@ -237,9 +237,6 @@ void Client::doneWorking()
void Client::killChain()
{
WriteGuard l(x_postMine);
WriteGuard l2(x_preMine);
bool wasMining = isMining();
if (wasMining)
stopMining();
@ -248,18 +245,21 @@ void Client::killChain()
m_tq.clear();
m_bq.clear();
m_farm.stop();
m_preMine = State();
m_postMine = State();
// ETH_WRITE_GUARDED(x_stateDB) // no point doing this yet since we can't control where else it's open yet.
{
WriteGuard l(x_postMine);
WriteGuard l2(x_preMine);
m_preMine = State();
m_postMine = State();
m_stateDB = OverlayDB();
m_stateDB = State::openDB(Defaults::dbPath(), WithExisting::Kill);
}
m_bc.reopen(Defaults::dbPath(), WithExisting::Kill);
m_bc.reopen(Defaults::dbPath(), WithExisting::Kill);
m_preMine = State(m_stateDB);
m_postMine = State(m_stateDB);
m_preMine = State(m_stateDB, BaseState::CanonGenesis);
m_postMine = State(m_stateDB);
}
if (auto h = m_host.lock())
h->reset();
@ -291,24 +291,23 @@ void Client::clearPending()
noteChanged(changeds);
}
template <class T>
static string filtersToString(T const& _fs)
template <class S, class T>
static S& filtersStreamOut(S& _out, T const& _fs)
{
stringstream ret;
ret << "{";
_out << "{";
unsigned i = 0;
for (h256 const& f: _fs)
{
ret << (i++ ? ", " : "");
_out << (i++ ? ", " : "");
if (f == PendingChangedFilter)
ret << url << "pending";
_out << LogTag::Special << "pending";
else if (f == ChainChangedFilter)
ret << url << "chain";
_out << LogTag::Special << "chain";
else
ret << f;
_out << f;
}
ret << "}";
return ret.str();
_out << "}";
return _out;
}
void Client::appendFromNewPending(TransactionReceipt const& _receipt, h256Set& io_changed, h256 _transactionHash)
@ -572,16 +571,21 @@ void Client::noteChanged(h256Set const& _filters)
{
Guard l(x_filtersWatches);
if (_filters.size())
cnote << "noteChanged(" << filtersToString(_filters) << ")";
filtersStreamOut(cnote << "noteChanged:", _filters);
// accrue all changes left in each filter into the watches.
for (auto& w: m_watches)
if (_filters.count(w.second.id))
{
cwatch << "!!!" << w.first << (m_filters.count(w.second.id) ? w.second.id.abridged() : w.second.id == PendingChangedFilter ? "pending" : w.second.id == ChainChangedFilter ? "chain" : "???");
if (m_filters.count(w.second.id)) // Normal filtering watch
if (m_filters.count(w.second.id))
{
cwatch << "!!!" << w.first << w.second.id.abridged();
w.second.changes += m_filters.at(w.second.id).changes;
else // Special ('pending'/'latest') watch
}
else
{
cwatch << "!!!" << w.first << LogTag::Special << (w.second.id == PendingChangedFilter ? "pending" : w.second.id == ChainChangedFilter ? "chain" : "???");
w.second.changes.push_back(LocalisedLogEntry(SpecialLogEntry, 0));
}
}
// clear the filters now.
for (auto& i: m_filters)

4
libethereum/ClientBase.cpp

@ -226,7 +226,7 @@ unsigned ClientBase::installWatch(LogFilter const& _f, Reaping _r)
Guard l(x_filtersWatches);
if (!m_filters.count(h))
{
cwatch << "FFF" << _f << h.abridged();
cwatch << "FFF" << _f << h;
m_filters.insert(make_pair(h, _f));
}
}
@ -240,7 +240,7 @@ unsigned ClientBase::installWatch(h256 _h, Reaping _r)
Guard l(x_filtersWatches);
ret = m_watches.size() ? m_watches.rbegin()->first + 1 : 0;
m_watches[ret] = ClientWatch(_h, _r);
cwatch << "+++" << ret << _h.abridged();
cwatch << "+++" << ret << _h;
}
#if INITIAL_STATE_AS_CHANGES
auto ch = logs(ret);

2
libethereum/EthereumHost.cpp

@ -61,7 +61,7 @@ bool EthereumHost::ensureInitialised()
{
// First time - just initialise.
m_latestBlockSent = m_chain.currentHash();
clog(NetNote) << "Initialising: latest=" << m_latestBlockSent.abridged();
clog(NetNote) << "Initialising: latest=" << m_latestBlockSent;
for (auto const& i: m_tq.transactions())
m_transactionsSent.insert(i.first);

14
libethereum/EthereumPeer.cpp

@ -134,7 +134,7 @@ void EthereumPeer::transition(Asking _a, bool _force)
clog(NetWarn) << "Bad state: asking for Hashes yet not syncing!";
if (shouldGrabBlocks())
{
clog(NetNote) << "Difficulty of hashchain HIGHER. Grabbing" << m_syncingNeededBlocks.size() << "blocks [latest now" << m_syncingLatestHash.abridged() << ", was" << host()->m_latestBlockSent.abridged() << "]";
clog(NetNote) << "Difficulty of hashchain HIGHER. Grabbing" << m_syncingNeededBlocks.size() << "blocks [latest now" << m_syncingLatestHash << ", was" << host()->m_latestBlockSent << "]";
host()->m_man.resetToChain(m_syncingNeededBlocks);
// host()->m_latestBlockSent = m_syncingLatestHash;
@ -253,7 +253,7 @@ bool EthereumPeer::shouldGrabBlocks() const
if (m_syncingNeededBlocks.empty())
return false;
clog(NetNote) << "Should grab blocks? " << td << "vs" << ctd << ";" << m_syncingNeededBlocks.size() << " blocks, ends" << m_syncingNeededBlocks.back().abridged();
clog(NetNote) << "Should grab blocks? " << td << "vs" << ctd << ";" << m_syncingNeededBlocks.size() << " blocks, ends" << m_syncingNeededBlocks.back();
if (td < ctd || (td == ctd && host()->m_chain.currentHash() == lh))
return false;
@ -280,7 +280,7 @@ void EthereumPeer::attemptSync()
unsigned n = host()->m_chain.number();
u256 td = host()->m_chain.details().totalDifficulty;
clog(NetAllDetail) << "Attempt chain-grab? Latest:" << c.abridged() << ", number:" << n << ", TD:" << td << " versus " << m_totalDifficulty;
clog(NetAllDetail) << "Attempt chain-grab? Latest:" << c << ", number:" << n << ", TD:" << td << " versus " << m_totalDifficulty;
if (td >= m_totalDifficulty)
{
clog(NetAllDetail) << "No. Our chain is better.";
@ -310,7 +310,7 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
m_latestHash = _r[3].toHash<h256>();
auto genesisHash = _r[4].toHash<h256>();
clog(NetMessageSummary) << "Status:" << m_protocolVersion << "/" << m_networkId << "/" << genesisHash.abridged() << ", TD:" << m_totalDifficulty << "=" << m_latestHash.abridged();
clog(NetMessageSummary) << "Status:" << m_protocolVersion << "/" << m_networkId << "/" << genesisHash << ", TD:" << m_totalDifficulty << "=" << m_latestHash;
if (genesisHash != host()->m_chain.genesisHash())
disable("Invalid genesis hash");
@ -358,7 +358,7 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
{
h256 later = _r[0].toHash<h256>();
unsigned limit = _r[1].toInt<unsigned>();
clog(NetMessageSummary) << "GetBlockHashes (" << limit << "entries," << later.abridged() << ")";
clog(NetMessageSummary) << "GetBlockHashes (" << limit << "entries," << later << ")";
unsigned c = min<unsigned>(host()->m_chain.number(later), limit);
@ -413,7 +413,7 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
knowns++;
m_syncingLastReceivedHash = h;
}
clog(NetMessageSummary) << knowns << "knowns," << unknowns << "unknowns; now at" << m_syncingLastReceivedHash.abridged();
clog(NetMessageSummary) << knowns << "knowns," << unknowns << "unknowns; now at" << m_syncingLastReceivedHash;
// run through - ask for more.
transition(Asking::Hashes);
break;
@ -526,7 +526,7 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
case NewBlockPacket:
{
auto h = BlockInfo::headerHash(_r[0].data());
clog(NetMessageSummary) << "NewBlock: " << h.abridged();
clog(NetMessageSummary) << "NewBlock: " << h;
if (_r.itemCount() != 2)
disable("NewBlock without 2 data fields.");

26
libethereum/State.cpp

@ -329,7 +329,7 @@ bool State::sync(BlockChain const& _bc, h256 _block, BlockInfo const& _bi, Impor
if (m_db.lookup(bi.stateRoot).empty())
{
cwarn << "Unable to sync to" << bi.hash().abridged() << "; state root" << bi.stateRoot.abridged() << "not found in database.";
cwarn << "Unable to sync to" << bi.hash() << "; state root" << bi.stateRoot << "not found in database.";
cwarn << "Database corrupt: contains block without stateRoot:" << bi;
cwarn << "Bailing.";
exit(-1);
@ -500,7 +500,7 @@ pair<TransactionReceipts, bool> State::sync(BlockChain const& _bc, TransactionQu
else if (i.second.gasPrice() < _gp.ask(*this) * 9 / 10)
{
// less than 90% of our ask price for gas. drop.
cnote << i.first.abridged() << "Dropping El Cheapo transaction (<90% of ask price)";
cnote << i.first << "Dropping El Cheapo transaction (<90% of ask price)";
_tq.drop(i.first);
}
}
@ -512,13 +512,13 @@ pair<TransactionReceipts, bool> State::sync(BlockChain const& _bc, TransactionQu
if (req > got)
{
// too old
cnote << i.first.abridged() << "Dropping old transaction (nonce too low)";
cnote << i.first << "Dropping old transaction (nonce too low)";
_tq.drop(i.first);
}
else if (got > req + 5)
{
// too new
cnote << i.first.abridged() << "Dropping new transaction (> 5 nonces ahead)";
cnote << i.first << "Dropping new transaction (> 5 nonces ahead)";
_tq.drop(i.first);
}
else
@ -529,7 +529,7 @@ pair<TransactionReceipts, bool> State::sync(BlockChain const& _bc, TransactionQu
bigint const& got = *boost::get_error_info<errinfo_got>(e);
if (got > m_currentBlock.gasLimit)
{
cnote << i.first.abridged() << "Dropping over-gassy transaction (gas > block's gas limit)";
cnote << i.first << "Dropping over-gassy transaction (gas > block's gas limit)";
_tq.drop(i.first);
}
else
@ -538,14 +538,14 @@ pair<TransactionReceipts, bool> State::sync(BlockChain const& _bc, TransactionQu
catch (Exception const& _e)
{
// Something else went wrong - drop it.
cnote << i.first.abridged() << "Dropping invalid transaction:" << diagnostic_information(_e);
cnote << i.first << "Dropping invalid transaction:" << diagnostic_information(_e);
_tq.drop(i.first);
}
catch (std::exception const&)
{
// Something else went wrong - drop it.
_tq.drop(i.first);
cnote << i.first.abridged() << "Transaction caused low-level exception :(";
cnote << i.first << "Transaction caused low-level exception :(";
}
}
if (chrono::steady_clock::now() > deadline)
@ -709,15 +709,15 @@ void State::cleanup(bool _fullCommit)
paranoia("immediately before database commit", true);
// Commit the new trie to disk.
clog(StateTrace) << "Committing to disk: stateRoot" << m_currentBlock.stateRoot.abridged() << "=" << rootHash().abridged() << "=" << toHex(asBytes(m_db.lookup(rootHash())));
clog(StateTrace) << "Committing to disk: stateRoot" << m_currentBlock.stateRoot << "=" << rootHash() << "=" << toHex(asBytes(m_db.lookup(rootHash())));
m_db.commit();
clog(StateTrace) << "Committed: stateRoot" << m_currentBlock.stateRoot.abridged() << "=" << rootHash().abridged() << "=" << toHex(asBytes(m_db.lookup(rootHash())));
clog(StateTrace) << "Committed: stateRoot" << m_currentBlock.stateRoot << "=" << rootHash() << "=" << toHex(asBytes(m_db.lookup(rootHash())));
paranoia("immediately after database commit", true);
m_previousBlock = m_currentBlock;
m_currentBlock.populateFromParent(m_previousBlock);
clog(StateTrace) << "finalising enactment. current -> previous, hash is" << m_previousBlock.hash().abridged();
clog(StateTrace) << "finalising enactment. current -> previous, hash is" << m_previousBlock.hash();
}
else
m_db.rollback();
@ -789,7 +789,7 @@ void State::commitToMine(BlockChain const& _bc)
{
uncommitToMine();
// cnote << "Committing to mine on block" << m_previousBlock.hash.abridged();
// cnote << "Committing to mine on block" << m_previousBlock.hash;
#if ETH_PARANOIA && 0
commit();
cnote << "Pre-reward stateRoot:" << m_state.root();
@ -866,7 +866,7 @@ void State::commitToMine(BlockChain const& _bc)
// Commit any and all changes to the trie that are in the cache, then update the state root accordingly.
commit();
// cnote << "Post-reward stateRoot:" << m_state.root().abridged();
// cnote << "Post-reward stateRoot:" << m_state.root();
// cnote << m_state;
// cnote << *this;
@ -890,7 +890,7 @@ void State::completeMine()
ret.appendRaw(m_currentUncles);
ret.swapOut(m_currentBytes);
m_currentBlock.noteDirty();
cnote << "Mined " << m_currentBlock.hash().abridged() << "(parent: " << m_currentBlock.parentHash.abridged() << ")";
cnote << "Mined " << m_currentBlock.hash() << "(parent: " << m_currentBlock.parentHash << ")";
StructuredLogger::minedNewBlock(
m_currentBlock.hash().abridged(),
m_currentBlock.nonce.abridged(),

2
libethereum/State.h

@ -174,7 +174,7 @@ public:
PoW::assignResult(_result, m_currentBlock);
cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << PoW::verify(m_currentBlock);
cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce) << m_currentBlock.nonce << m_currentBlock.difficulty << PoW::verify(m_currentBlock);
completeMine();

2
libethereum/TransactionQueue.cpp

@ -57,7 +57,7 @@ ImportResult TransactionQueue::import(bytesConstRef _transactionRLP, ImportCallb
m_known.insert(h);
if (_cb)
m_callbacks[h] = _cb;
ctxq << "Queued vaguely legit-looking transaction" << h.abridged();
ctxq << "Queued vaguely legit-looking transaction" << h;
m_onReady();
}
catch (Exception const& _e)

16
libp2p/Host.cpp

@ -204,7 +204,7 @@ void Host::startPeerSession(Public const& _id, RLP const& _rlp, RLPXFrameIO* _io
stringstream capslog;
for (auto cap: caps)
capslog << "(" << cap.first << "," << dec << cap.second << ")";
clog(NetMessageSummary) << "Hello: " << clientVersion << "V[" << protocolVersion << "]" << _id.abridged() << showbase << capslog.str() << dec << listenPort;
clog(NetMessageSummary) << "Hello: " << clientVersion << "V[" << protocolVersion << "]" << _id << showbase << capslog.str() << dec << listenPort;
// create session so disconnects are managed
auto ps = make_shared<Session>(this, _io, p, PeerSessionInfo({_id, clientVersion, _endpoint.address().to_string(), listenPort, chrono::steady_clock::duration(), _rlp[2].toSet<CapDesc>(), 0, map<string, string>()}));
@ -221,7 +221,7 @@ void Host::startPeerSession(Public const& _id, RLP const& _rlp, RLPXFrameIO* _io
if(s->isConnected())
{
// Already connected.
clog(NetWarn) << "Session already exists for peer with id" << _id.abridged();
clog(NetWarn) << "Session already exists for peer with id" << _id;
ps->disconnect(DuplicatePeer);
return;
}
@ -238,7 +238,7 @@ void Host::startPeerSession(Public const& _id, RLP const& _rlp, RLPXFrameIO* _io
m_sessions[_id] = ps;
}
clog(NetNote) << "p2p.host.peer.register" << _id.abridged();
clog(NetNote) << "p2p.host.peer.register" << _id;
StructuredLogger::p2pConnected(_id.abridged(), ps->m_peer->endpoint, ps->m_peer->m_lastConnected, clientVersion, peerCount());
}
@ -466,7 +466,7 @@ void Host::connect(std::shared_ptr<Peer> const& _p)
}
bi::tcp::endpoint ep(_p->endpoint);
clog(NetConnect) << "Attempting connection to node" << _p->id.abridged() << "@" << ep << "from" << id().abridged();
clog(NetConnect) << "Attempting connection to node" << _p->id << "@" << ep << "from" << id();
auto socket = make_shared<RLPXSocket>(new bi::tcp::socket(m_ioService));
socket->ref().async_connect(ep, [=](boost::system::error_code const& ec)
{
@ -475,13 +475,13 @@ void Host::connect(std::shared_ptr<Peer> const& _p)
if (ec)
{
clog(NetConnect) << "Connection refused to node" << _p->id.abridged() << "@" << ep << "(" << ec.message() << ")";
clog(NetConnect) << "Connection refused to node" << _p->id << "@" << ep << "(" << ec.message() << ")";
// Manually set error (session not present)
_p->m_lastDisconnect = TCPError;
}
else
{
clog(NetConnect) << "Connecting to" << _p->id.abridged() << "@" << ep;
clog(NetConnect) << "Connecting to" << _p->id << "@" << ep;
auto handshake = make_shared<RLPXHandshake>(this, socket, _p->id);
{
Guard l(x_connecting);
@ -619,14 +619,14 @@ void Host::startedWorking()
runAcceptor();
}
else
clog(NetNote) << "p2p.start.notice id:" << id().abridged() << "TCP Listen port is invalid or unavailable.";
clog(NetNote) << "p2p.start.notice id:" << id() << "TCP Listen port is invalid or unavailable.";
shared_ptr<NodeTable> nodeTable(new NodeTable(m_ioService, m_alias, NodeIPEndpoint(bi::address::from_string(listenAddress()), listenPort(), listenPort())));
nodeTable->setEventHandler(new HostNodeTableHandler(*this));
m_nodeTable = nodeTable;
restoreNetwork(&m_restoreNetwork);
clog(NetNote) << "p2p.started id:" << id().abridged();
clog(NetNote) << "p2p.started id:" << id();
run(boost::system::error_code());
}

2
libp2p/Network.cpp

@ -228,7 +228,7 @@ bi::tcp::endpoint Network::resolveHost(string const& _addr)
bi::tcp::resolver r(s_resolverIoService);
auto it = r.resolve({split[0], toString(port)}, ec);
if (ec)
clog(NetWarn) << "Error resolving host address..." << url << _addr << ":" << error << ec.message();
clog(NetWarn) << "Error resolving host address..." << LogTag::Url << _addr << ":" << LogTag::Error << ec.message();
else
ep = *it;
}

8
libp2p/NodeTable.cpp

@ -87,7 +87,7 @@ shared_ptr<NodeEntry> NodeTable::addNode(Node const& _node)
// we handle when tcp endpoint is 0 below
if (_node.endpoint.address.to_string() == "0.0.0.0")
{
clog(NodeTableWarn) << "addNode Failed. Invalid UDP address" << url << "0.0.0.0" << "for" << _node.id;
clog(NodeTableWarn) << "addNode Failed. Invalid UDP address" << LogTag::Url << "0.0.0.0" << "for" << _node.id;
return move(shared_ptr<NodeEntry>());
}
@ -326,7 +326,7 @@ void NodeTable::noteActiveNode(Public const& _pubk, bi::udp::endpoint const& _en
shared_ptr<NodeEntry> node = nodeEntry(_pubk);
if (!!node && !node->pending)
{
clog(NodeTableConnect) << "Noting active node:" << _pubk.abridged() << _endpoint.address().to_string() << ":" << _endpoint.port();
clog(NodeTableConnect) << "Noting active node:" << _pubk << _endpoint.address().to_string() << ":" << _endpoint.port();
node->endpoint.address = _endpoint.address();
node->endpoint.udpPort = _endpoint.port();
@ -381,7 +381,7 @@ void NodeTable::dropNode(shared_ptr<NodeEntry> _n)
}
// notify host
clog(NodeTableUpdate) << "p2p.nodes.drop " << _n->id.abridged();
clog(NodeTableUpdate) << "p2p.nodes.drop " << _n->id;
if (m_nodeEventHandler)
m_nodeEventHandler->appendEvent(_n->id, NodeEntryDropped);
}
@ -464,7 +464,7 @@ void NodeTable::onReceived(UDPSocketFace*, bi::udp::endpoint const& _from, bytes
return; // unsolicited pong; don't note node as active
}
clog(NodeTableConnect) << "PONG from " << nodeid.abridged() << _from;
clog(NodeTableConnect) << "PONG from " << nodeid << _from;
break;
}

6
libp2p/Session.cpp

@ -138,7 +138,7 @@ void Session::serviceNodesRequest()
auto rs = randomSelection(peers, 10);
for (auto const& i: rs)
{
clog(NetTriviaDetail) << "Sending peer " << i.id.abridged() << i.endpoint;
clog(NetTriviaDetail) << "Sending peer " << i.id << i.endpoint;
if (i.endpoint.address.is_v4())
s.appendList(3) << bytesConstRef(i.endpoint.address.to_v4().to_bytes().data(), 4) << i.endpoint.tcpPort << i.id;
else// if (i.second.address().is_v6()) - assumed
@ -215,7 +215,7 @@ bool Session::interpret(PacketType _t, RLP const& _r)
auto ep = bi::tcp::endpoint(peerAddress, _r[i][1].toInt<short>());
NodeId id = _r[i][2].toHash<NodeId>();
clog(NetAllDetail) << "Checking: " << ep << "(" << id.abridged() << ")";
clog(NetAllDetail) << "Checking: " << ep << "(" << id << ")";
if (!isPublicAddress(peerAddress))
goto CONTINUE; // Private address. Ignore.
@ -238,7 +238,7 @@ bool Session::interpret(PacketType _t, RLP const& _r)
// OK passed all our checks. Assume it's good.
addRating(1000);
m_server->addNode(id, NodeIPEndpoint(ep.address(), ep.port(), ep.port()));
clog(NetTriviaDetail) << "New peer: " << ep << "(" << id .abridged()<< ")";
clog(NetTriviaDetail) << "New peer: " << ep << "(" << id << ")";
CONTINUE:;
LAMEPEER:;
}

6
libweb3jsonrpc/WebThreeStubServerBase.cpp

@ -848,7 +848,7 @@ bool WebThreeStubServerBase::shh_post(Json::Value const& _json)
Secret from;
if (m.from() && m_ids.count(m.from()))
{
cwarn << "Silently signing message from identity" << m.from().abridged() << ": User validation hook goes here.";
cwarn << "Silently signing message from identity" << m.from() << ": User validation hook goes here.";
// TODO: insert validification hook here.
from = m_ids[m.from()];
}
@ -940,7 +940,7 @@ Json::Value WebThreeStubServerBase::shh_getFilterChanges(string const& _filterId
shh::Message m;
if (pub)
{
cwarn << "Silently decrypting message from identity" << pub.abridged() << ": User validation hook goes here.";
cwarn << "Silently decrypting message from identity" << pub << ": User validation hook goes here.";
m = e.open(face()->fullTopic(id), m_ids[pub]);
}
else
@ -973,7 +973,7 @@ Json::Value WebThreeStubServerBase::shh_getMessages(string const& _filterId)
shh::Message m;
if (pub)
{
cwarn << "Silently decrypting message from identity" << pub.abridged() << ": User validation hook goes here.";
cwarn << "Silently decrypting message from identity" << pub << ": User validation hook goes here.";
m = e.open(face()->fullTopic(id), m_ids[pub]);
}
else

106
solc/CommandLineInterface.cpp

@ -27,6 +27,7 @@
#include <fstream>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include "BuildInfo.h"
#include <libdevcore/Common.h>
@ -64,6 +65,18 @@ static string const g_argNatspecDevStr = "natspec-dev";
static string const g_argNatspecUserStr = "natspec-user";
static string const g_argAddStandard = "add-std";
/// Possible arguments to for --combined-json
static set<string> const g_combinedJsonArgs{
"binary",
"opcodes",
"json-abi",
"sol-abi",
"asm",
"ast",
"natspec-user",
"natspec-dev"
};
static void version()
{
cout << "solc, the solidity compiler commandline interface " << dev::Version << endl
@ -72,24 +85,24 @@ static void version()
exit(0);
}
static inline bool argToStdout(po::variables_map const& _args, string const& _name)
static inline bool humanTargetedStdout(po::variables_map const& _args, string const& _name)
{
return _args.count(_name) && _args[_name].as<OutputType>() != OutputType::FILE;
}
static bool needStdout(po::variables_map const& _args)
static bool needsHumanTargetedStdout(po::variables_map const& _args)
{
return
argToStdout(_args, g_argAbiStr) ||
argToStdout(_args, g_argSolAbiStr) ||
argToStdout(_args, g_argNatspecUserStr) ||
argToStdout(_args, g_argAstJson) ||
argToStdout(_args, g_argNatspecDevStr) ||
argToStdout(_args, g_argAsmStr) ||
argToStdout(_args, g_argAsmJsonStr) ||
argToStdout(_args, g_argOpcodesStr) ||
argToStdout(_args, g_argBinaryStr);
humanTargetedStdout(_args, g_argAbiStr) ||
humanTargetedStdout(_args, g_argSolAbiStr) ||
humanTargetedStdout(_args, g_argNatspecUserStr) ||
humanTargetedStdout(_args, g_argAstJson) ||
humanTargetedStdout(_args, g_argNatspecDevStr) ||
humanTargetedStdout(_args, g_argAsmStr) ||
humanTargetedStdout(_args, g_argAsmJsonStr) ||
humanTargetedStdout(_args, g_argOpcodesStr) ||
humanTargetedStdout(_args, g_argBinaryStr);
}
static inline bool outputToFile(OutputType type)
@ -220,6 +233,11 @@ bool CommandLineInterface::parseArguments(int argc, char** argv)
("optimize", po::value<bool>()->default_value(false), "Optimize bytecode for size")
("add-std", po::value<bool>()->default_value(false), "Add standard contracts")
("input-file", po::value<vector<string>>(), "input file")
(
"combined-json",
po::value<string>()->value_name(boost::join(g_combinedJsonArgs, ",")),
"Output a single json document containing the specified information, can be combined."
)
(g_argAstStr.c_str(), po::value<OutputType>()->value_name("stdout|file|both"),
"Request to output the AST of the contract.")
(g_argAstJson.c_str(), po::value<OutputType>()->value_name("stdout|file|both"),
@ -252,9 +270,19 @@ bool CommandLineInterface::parseArguments(int argc, char** argv)
}
catch (po::error const& _exception)
{
cout << _exception.what() << endl;
cerr << _exception.what() << endl;
return false;
}
if (m_args.count("combined-json"))
{
vector<string> requests;
for (string const& item: boost::split(requests, m_args["combined-json"].as<string>(), boost::is_any_of(",")))
if (!g_combinedJsonArgs.count(item))
{
cerr << "Invalid option to --combined-json: " << item << endl;
return false;
}
}
po::notify(m_args);
if (m_args.count("help"))
@ -289,13 +317,13 @@ bool CommandLineInterface::processInput()
auto path = boost::filesystem::path(infile);
if (!boost::filesystem::exists(path))
{
cout << "Skipping non existant input file \"" << infile << "\"" << endl;
cerr << "Skipping non existant input file \"" << infile << "\"" << endl;
continue;
}
if (!boost::filesystem::is_regular_file(path))
{
cout << "\"" << infile << "\" is not a valid file. Skipping" << endl;
cerr << "\"" << infile << "\" is not a valid file. Skipping" << endl;
continue;
}
@ -350,6 +378,52 @@ bool CommandLineInterface::processInput()
return true;
}
void CommandLineInterface::handleCombinedJSON()
{
Json::Value output(Json::objectValue);
set<string> requests;
boost::split(requests, m_args["combined-json"].as<string>(), boost::is_any_of(","));
vector<string> contracts = m_compiler->getContractNames();
if (!contracts.empty())
output["contracts"] = Json::Value(Json::objectValue);
for (string const& contractName: contracts)
{
Json::Value contractData(Json::objectValue);
if (requests.count("sol-abi"))
contractData["sol-abi"] = m_compiler->getSolidityInterface(contractName);
if (requests.count("json-abi"))
contractData["json-abi"] = m_compiler->getInterface(contractName);
if (requests.count("binary"))
contractData["binary"] = toHex(m_compiler->getBytecode(contractName));
if (requests.count("opcodes"))
contractData["opcodes"] = eth::disassemble(m_compiler->getBytecode(contractName));
if (requests.count("asm"))
{
ostringstream unused;
contractData["asm"] = m_compiler->streamAssembly(unused, contractName, m_sourceCodes, true);
}
if (requests.count("natspec-dev"))
contractData["natspec-dev"] = m_compiler->getMetadata(contractName, DocumentationType::NatspecDev);
if (requests.count("natspec-user"))
contractData["natspec-user"] = m_compiler->getMetadata(contractName, DocumentationType::NatspecUser);
output["contracts"][contractName] = contractData;
}
if (requests.count("ast"))
{
output["sources"] = Json::Value(Json::objectValue);
for (auto const& sourceCode: m_sourceCodes)
{
ASTJsonConverter converter(m_compiler->getAST(sourceCode.first));
output["sources"][sourceCode.first] = Json::Value(Json::objectValue);
output["sources"][sourceCode.first]["AST"] = converter.json();
}
}
cout << Json::FastWriter().write(output) << endl;
}
void CommandLineInterface::handleAst(string const& _argStr)
{
string title;
@ -408,6 +482,8 @@ void CommandLineInterface::handleAst(string const& _argStr)
void CommandLineInterface::actOnInput()
{
handleCombinedJSON();
// do we need AST output?
handleAst(g_argAstStr);
handleAst(g_argAstJson);
@ -415,7 +491,7 @@ void CommandLineInterface::actOnInput()
vector<string> contracts = m_compiler->getContractNames();
for (string const& contract: contracts)
{
if (needStdout(m_args))
if (needsHumanTargetedStdout(m_args))
cout << endl << "======= " << contract << " =======" << endl;
// do we need EVM assembly?

1
solc/CommandLineInterface.h

@ -53,6 +53,7 @@ public:
void actOnInput();
private:
void handleCombinedJSON();
void handleAst(std::string const& _argStr);
void handleBinary(std::string const& _contract);
void handleOpcode(std::string const& _contract);

6
test/libdevcrypto/trie.cpp

@ -522,17 +522,17 @@ BOOST_AUTO_TEST_CASE(trieStess)
cwarn << "Good:" << d2.root();
// for (auto i: dm2.get())
// cwarn << i.first.abridged() << ": " << RLP(i.second);
// cwarn << i.first << ": " << RLP(i.second);
d2.debugStructure(cerr);
cwarn << "Broken:" << d.root(); // Leaves an extension -> extension (3c1... -> 742...)
// for (auto i: dm.get())
// cwarn << i.first.abridged() << ": " << RLP(i.second);
// cwarn << i.first << ": " << RLP(i.second);
d.debugStructure(cerr);
d2.insert(k, v);
cwarn << "Pres:" << d2.root();
// for (auto i: dm2.get())
// cwarn << i.first.abridged() << ": " << RLP(i.second);
// cwarn << i.first << ": " << RLP(i.second);
d2.debugStructure(cerr);
g_logVerbosity = 99;
d2.remove(k);

10
test/libwhisper/whisperTopic.cpp

@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(topic)
if (received.count(last))
continue;
received.insert(last);
cnote << "New message from:" << msg.from().abridged() << RLP(msg.payload()).toInt<unsigned>();
cnote << "New message from:" << msg.from() << RLP(msg.payload()).toInt<unsigned>();
result += last;
}
this_thread::sleep_for(chrono::milliseconds(50));
@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
{
Message msg = whost1->envelope(i).open(whost1->fullTopic(w));
unsigned last = RLP(msg.payload()).toInt<unsigned>();
cnote << "New message from:" << msg.from().abridged() << RLP(msg.payload()).toInt<unsigned>();
cnote << "New message from:" << msg.from() << RLP(msg.payload()).toInt<unsigned>();
result = last;
}
this_thread::sleep_for(chrono::milliseconds(50));
@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
for (auto i: whost2->checkWatch(w))
{
Message msg = whost2->envelope(i).open(whost2->fullTopic(w));
cnote << "New message from:" << msg.from().abridged() << RLP(msg.payload()).toInt<unsigned>();
cnote << "New message from:" << msg.from() << RLP(msg.payload()).toInt<unsigned>();
}
this_thread::sleep_for(chrono::milliseconds(50));
}
@ -239,7 +239,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
for (auto i: whost1->checkWatch(w))
{
Message msg = whost1->envelope(i).open(whost1->fullTopic(w));
cnote << "New message from:" << msg.from().abridged() << RLP(msg.payload()).toInt<unsigned>();
cnote << "New message from:" << msg.from() << RLP(msg.payload()).toInt<unsigned>();
}
this_thread::sleep_for(chrono::milliseconds(50));
}
@ -283,7 +283,7 @@ BOOST_AUTO_TEST_CASE(asyncforwarding)
{
Message msg = wh->envelope(i).open(wh->fullTopic(w));
unsigned last = RLP(msg.payload()).toInt<unsigned>();
cnote << "New message from:" << msg.from().abridged() << RLP(msg.payload()).toInt<unsigned>();
cnote << "New message from:" << msg.from() << RLP(msg.payload()).toInt<unsigned>();
result = last;
}
this_thread::sleep_for(chrono::milliseconds(50));

Loading…
Cancel
Save