From 4dbc566a14c7fff2c3a2b498afef5db16c13f513 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 3 Nov 2014 12:14:06 +0100 Subject: [PATCH 1/4] Bugfix: Swap before mod and div. --- libsolidity/Compiler.cpp | 2 ++ test/solidityCompiler.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libsolidity/Compiler.cpp b/libsolidity/Compiler.cpp index f19dd3f7f..ba1dcfb6b 100644 --- a/libsolidity/Compiler.cpp +++ b/libsolidity/Compiler.cpp @@ -336,9 +336,11 @@ void ExpressionCompiler::appendArithmeticOperatorCode(Token::Value _operator, Ty append(eth::Instruction::MUL); break; case Token::DIV: + append(eth::Instruction::SWAP1); append(isSigned ? eth::Instruction::SDIV : eth::Instruction::DIV); break; case Token::MOD: + append(eth::Instruction::SWAP1); append(isSigned ? eth::Instruction::SMOD : eth::Instruction::MOD); break; default: diff --git a/test/solidityCompiler.cpp b/test/solidityCompiler.cpp index e08605110..e024043e4 100644 --- a/test/solidityCompiler.cpp +++ b/test/solidityCompiler.cpp @@ -193,7 +193,9 @@ BOOST_AUTO_TEST_CASE(arithmetics) byte(eth::Instruction::SWAP1), byte(eth::Instruction::SUB), byte(eth::Instruction::ADD), + byte(eth::Instruction::SWAP1), byte(eth::Instruction::MOD), + byte(eth::Instruction::SWAP1), byte(eth::Instruction::DIV), byte(eth::Instruction::MUL)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); From 4bbeb479af67c3efa300e7202dcc0df2f0dcb42a Mon Sep 17 00:00:00 2001 From: Joris Bontje Date: Fri, 31 Oct 2014 17:08:12 +0100 Subject: [PATCH 2/4] update Dockerfile with cryptopp and jsonrpc dependencies, fixes #423 --- docker/Dockerfile | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1bd690cbb..c183f03b9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,17 +4,30 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get update RUN apt-get upgrade -y -RUN apt-get install -qy wget -RUN apt-get install -qy build-essential g++-4.8 automake libtool unzip git cmake -RUN apt-get install -qy libncurses5-dev libgmp-dev libgmp3-dev libboost-all-dev libleveldb-dev yasm libminiupnpc-dev -RUN apt-get install -qy qtbase5-dev qt5-default qtdeclarative5-dev libqt5webkit5-dev +# Ethereum dependencies +RUN apt-get install -qy build-essential g++-4.8 git cmake libboost-all-dev libcurl4-openssl-dev wget +RUN apt-get install -qy automake unzip libgmp-dev libtool libleveldb-dev yasm libminiupnpc-dev libreadline-dev scons -RUN mkdir /cryptopp562 -RUN cd /cryptopp562 && wget http://www.cryptopp.com/cryptopp562.zip && unzip cryptopp562.zip -RUN cd /cryptopp562 && make -j $(cat /proc/cpuinfo | grep processor | wc -l) && make install +# NCurses based GUI (not optional though for a succesful compilation, see https://github.com/ethereum/cpp-ethereum/issues/452 ) +RUN apt-get install -qy libncurses5-dev +# Qt-based GUI +# RUN apt-get install -qy qtbase5-dev qt5-default qtdeclarative5-dev libqt5webkit5-dev + +# Cryptopp +RUN git clone --depth=1 https://github.com/mmoss/cryptopp.git +RUN cd cryptopp && scons --shared --prefix=/usr + +# JSONRPC (version 0.2.1, see https://github.com/ethereum/cpp-ethereum/issues/453 ) +RUN apt-get install -qy libjsoncpp-dev libargtable2-dev +RUN git clone --depth=1 --branch=0.2.1 https://github.com/cinemast/libjson-rpc-cpp.git +RUN mkdir -p libjson-rpc-cpp/build +RUN cd libjson-rpc-cpp/build && cmake .. && make && make install + +# Build Ethereum (HEADLESS) RUN git clone --depth=1 https://github.com/ethereum/cpp-ethereum -RUN mkdir cpp-ethereum/build -RUN cd cpp-ethereum/build && cmake .. -DCMAKE_BUILD_TYPE=Release && make -j $(cat /proc/cpuinfo | grep processor | wc -l) && make install +RUN mkdir -p cpp-ethereum/build +RUN cd cpp-ethereum/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DHEADLESS=1 && make -j $(cat /proc/cpuinfo | grep processor | wc -l) && make install +RUN ldconfig ENTRYPOINT ["/usr/local/bin/eth"] From 5149609e159b6fa82caa606f3b117954a36e7994 Mon Sep 17 00:00:00 2001 From: nicksavers Date: Mon, 3 Nov 2014 22:45:40 +0100 Subject: [PATCH 3/4] Fix empty unclesHash for Genesis --- libdevcrypto/SHA3.cpp | 1 + libdevcrypto/SHA3.h | 2 ++ libethcore/BlockInfo.cpp | 2 -- libethereum/BlockChain.cpp | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libdevcrypto/SHA3.cpp b/libdevcrypto/SHA3.cpp index 7c2cc01a3..4a0cd469e 100644 --- a/libdevcrypto/SHA3.cpp +++ b/libdevcrypto/SHA3.cpp @@ -30,6 +30,7 @@ namespace dev { h256 EmptySHA3 = sha3(bytesConstRef()); +h256 EmptyListSHA3 = sha3(RLPEmptyList); std::string sha3(std::string const& _input, bool _hex) { diff --git a/libdevcrypto/SHA3.h b/libdevcrypto/SHA3.h index fc2cfcfc3..1575ab29c 100644 --- a/libdevcrypto/SHA3.h +++ b/libdevcrypto/SHA3.h @@ -58,6 +58,8 @@ inline h256 sha3(std::string const& _input) { return sha3(bytesConstRef(_input)) extern h256 EmptySHA3; +extern h256 EmptyListSHA3; + // Other crypto convenience routines bytes aesDecrypt(bytesConstRef _cipher, std::string const& _password, unsigned _rounds = 2000, bytesConstRef _salt = bytesConstRef()); diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index d87e6f5df..44da9603c 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -56,8 +56,6 @@ h256 BlockInfo::headerHashWithoutNonce() const return sha3(s.out()); } -auto static const c_sha3EmptyList = sha3(RLPEmptyList); - void BlockInfo::streamRLP(RLPStream& _s, bool _nonce) const { _s.appendList(_nonce ? 15 : 14) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 710f17214..3ba1bb801 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -103,7 +103,7 @@ bytes BlockChain::createGenesisBlock() block.appendList(15) // TODO: maybe make logbloom correct? - << h256() << EmptySHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 0 << 1000000 << 0 << (unsigned)0 << string() << sha3(bytes(1, 42)); + << h256() << EmptyListSHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 0 << 1000000 << 0 << (unsigned)0 << string() << sha3(bytes(1, 42)); block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList); return block.out(); From e166a5a88113f617e32e48dd6da6411dac6deff9 Mon Sep 17 00:00:00 2001 From: arkpar Date: Mon, 3 Nov 2014 22:37:51 -0800 Subject: [PATCH 4/4] fixed crashes on shutdown --- alethzero/MainWin.h | 2 +- libp2p/Host.cpp | 40 +++++++++++++++++++++++----------------- libp2p/Host.h | 4 ++-- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index ba2592491..0ea072a93 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -255,7 +255,7 @@ private: QString m_logHistory; bool m_logChanged = true; - std::unique_ptr m_server; QWebThreeConnector m_qwebConnector; + std::unique_ptr m_server; QWebThree* m_qweb = nullptr; }; diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index 020c7e420..bf8d96506 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -62,8 +62,8 @@ Host::Host(std::string const& _clientVersion, NetworkPreferences const& _n, bool m_clientVersion(_clientVersion), m_netPrefs(_n), m_ioService(new ba::io_service), - m_acceptor(*m_ioService), - m_socket(*m_ioService), + m_acceptor(new bi::tcp::acceptor(*m_ioService)), + m_socket(new bi::tcp::socket(*m_ioService)), m_key(KeyPair::create()) { populateAddresses(); @@ -91,11 +91,11 @@ void Host::start() bi::tcp::endpoint endpoint(bi::tcp::v4(), i ? 0 : m_netPrefs.listenPort); try { - m_acceptor.open(endpoint.protocol()); - m_acceptor.set_option(ba::socket_base::reuse_address(true)); - m_acceptor.bind(endpoint); - m_acceptor.listen(); - m_listenPort = i ? m_acceptor.local_endpoint().port() : m_netPrefs.listenPort; + m_acceptor->open(endpoint.protocol()); + m_acceptor->set_option(ba::socket_base::reuse_address(true)); + m_acceptor->bind(endpoint); + m_acceptor->listen(); + m_listenPort = i ? m_acceptor->local_endpoint().port() : m_netPrefs.listenPort; break; } catch (...) @@ -105,7 +105,7 @@ void Host::start() cwarn << "Couldn't start accepting connections on host. Something very wrong with network?\n" << boost::current_exception_diagnostic_information(); return; } - m_acceptor.close(); + m_acceptor->close(); continue; } } @@ -118,20 +118,24 @@ void Host::start() void Host::stop() { + // if there's no ioService, it means we've had quit() called - bomb out - we're not allowed in here. + if (!m_ioService) + return; + for (auto const& h: m_capabilities) h.second->onStopping(); stopWorking(); - if (m_acceptor.is_open()) + if (m_acceptor->is_open()) { if (m_accepting) - m_acceptor.cancel(); - m_acceptor.close(); + m_acceptor->cancel(); + m_acceptor->close(); m_accepting = false; } - if (m_socket.is_open()) - m_socket.close(); + if (m_socket->is_open()) + m_socket->close(); disconnectPeers(); if (!!m_ioService) @@ -147,6 +151,8 @@ void Host::quit() // such tasks may involve socket reads from Capabilities that maintain references // to resources we're about to free. stop(); + m_acceptor.reset(); + m_socket.reset(); m_ioService.reset(); // m_acceptor & m_socket are DANGEROUS now. } @@ -463,18 +469,18 @@ void Host::ensureAccepting() { clog(NetConnect) << "Listening on local port " << m_listenPort << " (public: " << m_public << ")"; m_accepting = true; - m_acceptor.async_accept(m_socket, [=](boost::system::error_code ec) + m_acceptor->async_accept(*m_socket, [=](boost::system::error_code ec) { if (!ec) { try { try { - clog(NetConnect) << "Accepted connection from " << m_socket.remote_endpoint(); + clog(NetConnect) << "Accepted connection from " << m_socket->remote_endpoint(); } catch (...){} - bi::address remoteAddress = m_socket.remote_endpoint().address(); + bi::address remoteAddress = m_socket->remote_endpoint().address(); // Port defaults to 0 - we let the hello tell us which port the peer listens to - auto p = std::make_shared(this, std::move(m_socket), bi::tcp::endpoint(remoteAddress, 0)); + auto p = std::make_shared(this, std::move(*m_socket), bi::tcp::endpoint(remoteAddress, 0)); p->start(); } catch (Exception const& _e) diff --git a/libp2p/Host.h b/libp2p/Host.h index 6e60b915e..7722905ab 100644 --- a/libp2p/Host.h +++ b/libp2p/Host.h @@ -214,8 +214,8 @@ private: int m_listenPort = NetworkStopped; ///< What port are we listening on? std::unique_ptr m_ioService; ///< IOService for network stuff. - bi::tcp::acceptor m_acceptor; ///< Listening acceptor. - bi::tcp::socket m_socket; ///< Listening socket. + std::unique_ptr m_acceptor; ///< Listening acceptor. + std::unique_ptr m_socket; ///< Listening socket. UPnP* m_upnp = nullptr; ///< UPnP helper. bi::tcp::endpoint m_public; ///< Our public listening endpoint.