diff --git a/CMakeLists.txt b/CMakeLists.txt index f0b313164..55aefe335 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -527,8 +527,8 @@ endif () if (WIN32) # packaging stuff include(InstallRequiredSystemLibraries) - set(CPACK_PACKAGE_NAME "Ethereum (++)") - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Ethereum (++) Toolset") + set(CPACK_PACKAGE_NAME "Ethereum") + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Ethereum Toolset") set(CPACK_PACKAGE_VENDOR "ethereum.org") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") @@ -557,7 +557,7 @@ if (WIN32) set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") endif() - set(CPACK_NSIS_DISPLAY_NAME "Ethereum (++)") + set(CPACK_NSIS_DISPLAY_NAME "Ethereum") set(CPACK_NSIS_HELP_LINK "https://github.com/ethereum/cpp-ethereum") set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/ethereum/cpp-ethereum") set(CPACK_NSIS_CONTACT "ethereum.org") diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 49d1e8f34..223eee951 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -159,7 +159,7 @@ Main::Main(QWidget* _parent): QMessageBox::warning(nullptr, "Try again", "You entered two different passwords - please enter the same password twice.", QMessageBox::Ok); } m_keyManager.create(password.toStdString()); - m_keyManager.import(Secret::random(), "Default identity"); + m_keyManager.import(ICAP::createDirect(), "Default identity"); } #if ETH_DEBUG @@ -317,9 +317,7 @@ void Main::install(AccountNamer* _adopt) void Main::uninstall(AccountNamer* _kill) { - auto it = m_namers.find(_kill); - if (it != m_namers.end()) - m_namers.erase(it); + m_namers.erase(_kill); refreshAll(); } @@ -411,7 +409,7 @@ NetworkPreferences Main::netPrefs() const ret = NetworkPreferences(listenIP, ui->port->value(), ui->upnp->isChecked()); ret.discovery = m_privateChain.isEmpty() && !ui->hermitMode->isChecked(); - ret.pin = m_privateChain.isEmpty() || ui->hermitMode->isChecked(); + ret.pin = !ret.discovery; return ret; } diff --git a/eth/main.cpp b/eth/main.cpp index a3d4cbffb..d5128ba7b 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -38,7 +38,7 @@ #include #include #include - +#include #include #if ETH_JSCONSOLE || !ETH_TRUE #include @@ -68,58 +68,17 @@ using dev::eth::Instruction; static std::atomic g_silence = {false}; -void interactiveHelp() -{ - cout - << "Commands:" << endl - << " netstart Starts the network subsystem on a specific port." << endl - << " netstop Stops the network subsystem." << endl - << " connect Connects to a specific peer." << endl - << " verbosity () Gets or sets verbosity level." << endl - << " minestart Starts mining." << endl - << " minestop Stops mining." << endl - << " mineforce Forces mining, even when there are no transactions." << endl - << " block Gives the current block height." << endl - << " blockhashfromnumber Gives the block hash with the givne number." << endl - << " numberfromblockhash Gives the block number with the given hash." << endl - << " blockqueue Gives the current block queue status." << endl - << " findblock Searches for the block in the blockchain and blockqueue." << endl - << " firstunknown Gives the first unknown block from the blockqueue." << endl - << " retryunknown retries to import all unknown blocks from the blockqueue." << endl - << " accounts Gives information on all owned accounts (balances, mining beneficiary and default signer)." << endl - << " newaccount Creates a new account with the given name." << endl - << " transact Execute a given transaction." << endl - << " transactnonce Execute a given transaction with a specified nonce." << endl - << " txcreate Execute a given contract creation transaction." << endl - << " send Execute a given transaction with current secret." << endl - << " contract Create a new contract with current secret." << endl - << " peers List the peers that are connected" << endl -#if ETH_FATDB || !ETH_TRUE - << " listaccounts List the accounts on the network." << endl - << " listcontracts List the contracts on the network." << endl - << " balanceat
Gives the balance of the given account." << endl - << " balanceatblock
Gives the balance of the given account." << endl - << " storageat
Gives the storage of the given account." << endl - << " storageatblock
Gives the storahe of the given account at a given blocknumber." << endl - << " codeat
Gives the code of the given account." << endl -#endif - << " setsigningkey Set the address with which to sign transactions." << endl - << " setaddress Set the coinbase (mining payout) address." << endl - << " exportconfig Export the config (.RLP) to the path provided." << endl - << " importconfig Import the config (.RLP) from the path provided." << endl - << " inspect Dumps a contract to /.evm." << endl - << " reprocess Reprocess a given block." << endl - << " dumptrace Dumps a transaction trace" << endl << "to . should be one of pretty, standard, standard+." << endl - << " dumpreceipt Dumps a transation receipt." << endl - << " hashrate Print the current hashrate in hashes per second if the client is mining." << endl - << " exit Exits the application." << endl; -} - void help() { cout << "Usage eth [OPTIONS]" << endl << "Options:" << endl << endl + << "Operating mode (default is non-interactive node):" << endl +#if ETH_JSCONSOLE || !ETH_TRUE + << " console Enter interactive console mode (default: non-interactive)." << endl + << " import Import file as a concatenated series of blocks." << endl + << " export Export file as a concatenated series of blocks." << endl +#endif << "Client mode (default):" << endl << " --olympic Use the Olympic (0.9) protocol." << endl << " --frontier Use the Frontier (1.0) protocol." << endl @@ -127,9 +86,6 @@ void help() << " --genesis-json Import the genesis block information from the given json file." << endl << endl << " -o,--mode Start a full node or a peer node (default: full)." << endl -#if ETH_JSCONSOLE || !ETH_TRUE - << " -i,--interactive Enter interactive mode (default: non-interactive)." << endl -#endif << endl #if ETH_JSONRPC || !ETH_TRUE << " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl @@ -169,7 +125,8 @@ void help() << endl << "Client networking:" << endl << " --client-name Add a name to your client's version string (default: blank)." << endl - << " -b,--bootstrap Connect to the default Ethereum peerserver." << endl + << " --bootstrap Connect to the default Ethereum peerservers (default unless --no-discovery used)." << endl + << " --no-bootstrap Do not connect to the default Ethereum peerservers (default only when --no-discovery is used)." << endl << " -x,--peers Attempt to connect to given number of peers (default: 11)." << endl << " --peer-stretch Accepted connection multiplier (default: 7)." << endl @@ -187,7 +144,7 @@ void help() // << " trusted Keep connected at all times." << endl // << " --trust-peers Text list of publickeys." << endl - << " --no-discovery Disable Node discovery." << endl + << " --no-discovery Disable Node discovery, implies --no-bootstrap." << endl << " --pin Only accept or connect to trusted peers." << endl << " --hermit Equivalent to --no-discovery --pin." << endl << " --sociable Forces discovery and no pinning." << endl @@ -198,9 +155,8 @@ void help() << " --structured-logging Enable structured logging (default output to stdout)." << endl << " --structured-logging-format Set the structured logging time format." << endl << " --structured-logging-url Set the structured logging destination (currently only file:// supported)." << endl + << endl << "Import/export modes:" << endl - << " -I,--import Import file as a concatenated series of blocks and exit." << endl - << " -E,--export Export file as a concatenated series of blocks and exit." << endl << " --from Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'." << endl << " --to Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'." << endl << " --only Equivalent to --export-from n --export-to n." << endl @@ -310,13 +266,17 @@ void stopMiningAfterXBlocks(eth::Client* _c, unsigned _start, unsigned& io_minin this_thread::sleep_for(chrono::milliseconds(100)); } -void interactiveMode(eth::Client*, std::shared_ptr, WebThreeDirect&, KeyManager&, string&, string&, function, function, NetworkPreferences, Address, Address, TransactionPriority) {} - int main(int argc, char** argv) { // Init defaults Defaults::get(); +#if ETH_DEBUG + g_logVerbosity = 4; +#else + g_logVerbosity = 1; +#endif + /// Operating mode. OperationMode mode = OperationMode::Node; string dbPath; @@ -359,7 +319,7 @@ int main(int argc, char** argv) HostPeerPreferences hprefs; unsigned peers = hprefs.idealPeerCount; unsigned peerStretch = hprefs.stretchPeerCount; - bool bootstrap = false; + bool bootstrap = true; bool disableDiscovery = false; bool pinning = false; bool enableDiscovery = false; @@ -381,7 +341,7 @@ int main(int argc, char** argv) string structuredLoggingURL; /// Transaction params - TransactionPriority priority = TransactionPriority::Medium; +// TransactionPriority priority = TransactionPriority::Medium; // double etherPrice = 30.679; // double blockFees = 15.0; u256 askPrice = c_defaultGasPrice; @@ -444,14 +404,14 @@ int main(int argc, char** argv) passwordsToNote.push_back(argv[++i]); else if (arg == "--master" && i + 1 < argc) masterPassword = argv[++i]; - else if ((arg == "-I" || arg == "--import") && i + 1 < argc) + else if ((arg == "-I" || arg == "--import" || arg == "import") && i + 1 < argc) { mode = OperationMode::Import; filename = argv[++i]; } else if (arg == "--dont-check") safeImport = true; - else if ((arg == "-E" || arg == "--export") && i + 1 < argc) + else if ((arg == "-E" || arg == "--export" || arg == "export") && i + 1 < argc) { mode = OperationMode::Export; filename = argv[++i]; @@ -645,7 +605,7 @@ int main(int argc, char** argv) return -1; } } - else if ((arg == "-P" || arg == "--priority") && i + 1 < argc) +/* else if ((arg == "-P" || arg == "--priority") && i + 1 < argc) { string m = boost::to_lower_copy(string(argv[++i])); if (m == "lowest") @@ -666,7 +626,7 @@ int main(int argc, char** argv) cerr << "Unknown " << arg << " option: " << m << endl; return -1; } - } + }*/ else if ((arg == "-m" || arg == "--mining") && i + 1 < argc) { string m = argv[++i]; @@ -685,8 +645,13 @@ int main(int argc, char** argv) } else if (arg == "-b" || arg == "--bootstrap") bootstrap = true; + else if (arg == "--no-bootstrap") + bootstrap = false; else if (arg == "--no-discovery") + { disableDiscovery = true; + bootstrap = false; + } else if (arg == "--pin") pinning = true; else if (arg == "--hermit") @@ -708,7 +673,7 @@ int main(int argc, char** argv) jsonAdmin = argv[++i]; #endif #if ETH_JSCONSOLE || !ETH_TRUE - else if (arg == "-i" || arg == "--interactive" || arg == "--console") + else if (arg == "-i" || arg == "--interactive" || arg == "--console" || arg == "console") useConsole = true; #endif else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc) @@ -780,7 +745,7 @@ int main(int argc, char** argv) if (c_network == eth::Network::Olympic) cout << "Welcome to Olympic!" << endl; else if (c_network == eth::Network::Frontier) - cout << "Welcome to the " EthMaroonBold "Frontier" EthReset "!" << endl; + cout << "Beware. You're entering the " EthMaroonBold "Frontier" EthReset "!" << endl; } m.execute(); @@ -996,7 +961,7 @@ int main(int argc, char** argv) if (keyManager.accounts().empty()) { - h128 uuid = keyManager.import(Secret::random(), "Default key"); + h128 uuid = keyManager.import(ICAP::createDirect(), "Default key"); if (!beneficiary) beneficiary = keyManager.address(uuid); if (!signingKey) @@ -1022,8 +987,14 @@ int main(int argc, char** argv) c->setNetworkId(networkId); } - cout << "Transaction Signer: " << signingKey << endl; - cout << "Mining Benefactor: " << beneficiary << endl; + auto renderFullAddress = [&](Address const& _a) -> std::string + { + return ICAP(_a).encoded() + " (" + toUUID(keyManager.uuid(_a)) + " - " + toHex(_a.ref().cropped(0, 4)) + ")"; + }; + + cout << "Transaction Signer: " << renderFullAddress(signingKey) << endl; + cout << "Mining Beneficiary: " << renderFullAddress(beneficiary) << endl; + cout << "Foundation: " << renderFullAddress(Address("de0b295669a9fd93d5f28d9ec85e40f4cb697bae")) << endl; if (bootstrap || !remoteHost.empty() || disableDiscovery) { @@ -1031,7 +1002,7 @@ int main(int argc, char** argv) cout << "Node ID: " << web3.enode() << endl; } else - cout << "Networking disabled. To start, use netstart or pass -b or a remote host." << endl; + cout << "Networking disabled. To start, use netstart or pass --bootstrap or a remote host." << endl; if (useConsole && jsonRPCURL == -1) jsonRPCURL = SensibleHttpPort; @@ -1064,9 +1035,7 @@ int main(int argc, char** argv) signal(SIGTERM, &sighandler); signal(SIGINT, &sighandler); - if (interactive) - interactiveMode(c, gasPricer, web3, keyManager, logbuf, additional, getPassword, getAccountPassword, netPrefs, beneficiary, signingKey, priority); - else if (c) + if (c) { unsigned n = c->blockChain().details().number; if (mining) @@ -1078,11 +1047,8 @@ int main(int argc, char** argv) shared_ptr rpcServer = make_shared(*console.connector(), web3, make_shared([&](){ return web3.ethereum(); }, getAccountPassword, keyManager), vector(), keyManager, *gasPricer); string sessionKey = rpcServer->newSession(SessionPermissions{{Privilege::Admin}}); console.eval("web3.admin.setSessionKey('" + sessionKey + "')"); - while (!g_exit) - { - console.readExpression(); + while (console.readExpression()) stopMiningAfterXBlocks(c, n, mining); - } rpcServer->StopListening(); #endif } diff --git a/ethkey/KeyAux.h b/ethkey/KeyAux.h index 70b76d6c6..d40439e86 100644 --- a/ethkey/KeyAux.h +++ b/ethkey/KeyAux.h @@ -505,7 +505,7 @@ public: if (Address a = wallet.address(u)) { cout << toUUID(u) << " " << a.abridged(); - cout << " (Not ICAP) "; + cout << " " << ICAP(a).encoded(); cout << " " << wallet.accountName(a) << endl; } for (auto const& u: bare) diff --git a/libdevcore/Base64.h b/libdevcore/Base64.h index d99a29767..42f454a22 100644 --- a/libdevcore/Base64.h +++ b/libdevcore/Base64.h @@ -44,7 +44,10 @@ template inline std::string toBase36(FixedHash const& _h) typename FixedHash::Arith a = _h; std::string ret; for (; a > 0; a /= 36) - ret = c_alphabet[(unsigned)a % 36] + ret; + { + unsigned r = (unsigned)(a - a / 36 * 36); // boost's % is broken + ret = c_alphabet[r] + ret; + } return ret; } diff --git a/libdevcore/Common.h b/libdevcore/Common.h index b7eca90f6..ce637a2a6 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -92,7 +92,15 @@ public: explicit secure_vector(vector_ref _c): m_data(_c.data(), _c.data() + _c.size()) {} ~secure_vector() { ref().cleanse(); } - secure_vector& operator=(secure_vector const& _c) { ref().cleanse(); m_data = _c.m_data; return *this; } + secure_vector& operator=(secure_vector const& _c) + { + if (&_c == this) + return *this; + + ref().cleanse(); + m_data = _c.m_data; + return *this; + } std::vector& writable() { clear(); return m_data; } std::vector const& makeInsecure() const { return m_data; } diff --git a/libdevcore/Worker.h b/libdevcore/Worker.h index fbc4d7042..23c90ab78 100644 --- a/libdevcore/Worker.h +++ b/libdevcore/Worker.h @@ -54,7 +54,12 @@ protected: Worker(Worker&& _m) { std::swap(m_name, _m.m_name); } /// Move-assignment. - Worker& operator=(Worker&& _m) { std::swap(m_name, _m.m_name); return *this; } + Worker& operator=(Worker&& _m) + { + assert(&_m != this); + std::swap(m_name, _m.m_name); + return *this; + } virtual ~Worker() { terminate(); } diff --git a/libdevcrypto/Common.cpp b/libdevcrypto/Common.cpp index a2907d2ed..e1ea2d6ec 100644 --- a/libdevcrypto/Common.cpp +++ b/libdevcrypto/Common.cpp @@ -308,33 +308,14 @@ h256 crypto::kdf(Secret const& _priv, h256 const& _hash) return s; } -string const& Nonce::seedFilePath(string const& _filePath) -{ - static mutex x_seedFile; - static string s_seedFile; - - Guard l(x_seedFile); - if (s_seedFile.empty()) - s_seedFile = _filePath.empty() ? getDataDir() + "/seed" : _filePath; - return s_seedFile; -} - Secret Nonce::next() { Guard l(x_value); if (!m_value) { - bytesSec b = contentsSec(seedFilePath()); - if (b.size() == 32) - b.ref().populate(m_value.writable().ref()); - else - m_value = Secret::random(); + m_value = Secret::random(); if (!m_value) BOOST_THROW_EXCEPTION(InvalidState()); - - // prevent seed reuse if process terminates abnormally - // this might throw - writeFile(seedFilePath(), bytes()); } m_value = sha3Secure(m_value.ref()); return sha3(~m_value); diff --git a/libdevcrypto/Common.h b/libdevcrypto/Common.h index debeee8d6..22460e940 100644 --- a/libdevcrypto/Common.h +++ b/libdevcrypto/Common.h @@ -203,14 +203,8 @@ public: /// Returns the next nonce (might be read from a file). static Secret get() { static Nonce s; return s.next(); } - /// @returns path of the seed file. FOR TESTS ONLY: optionally set path to @_filePath. - static std::string const& seedFilePath(std::string const& _filePath = std::string()); - private: Nonce() = default; - - /// Destructor. IO operation may throw. - ~Nonce() { if (m_value && next()) dev::writeFile(seedFilePath(), m_value.ref()); } /// @returns the next nonce. Secret next(); diff --git a/libdevcrypto/WordList.cpp b/libdevcrypto/WordList.cpp index 405ec9dd2..09feacff5 100644 --- a/libdevcrypto/WordList.cpp +++ b/libdevcrypto/WordList.cpp @@ -35,7 +35,7 @@ strings const WordList = "have", "to", "it", - "I", + "i", "that", "for", "you", @@ -198,7 +198,7 @@ strings const WordList = "start", "hand", "might", - "American", + "american", "show", "part", "about", @@ -233,7 +233,7 @@ strings const WordList = "like", "night", "live", - "Mr", + "mr", "point", "believe", "hold", @@ -567,7 +567,7 @@ strings const WordList = "court", "produce", "eat", - "American", + "american", "teach", "oil", "half", @@ -617,7 +617,7 @@ strings const WordList = "attention", "draw", "film", - "Republican", + "republican", "tree", "source", "red", @@ -661,7 +661,7 @@ strings const WordList = "administration", "south", "husband", - "Congress", + "congress", "floor", "campaign", "material", @@ -819,7 +819,7 @@ strings const WordList = "region", "television", "box", - "TV", + "tv", "training", "pretty", "trade", @@ -849,7 +849,7 @@ strings const WordList = "answer", "skill", "sister", - "PM", + "pm", "professor", "operation", "financial", @@ -928,7 +928,7 @@ strings const WordList = "that", "spring", "firm", - "Democrat", + "democrat", "radio", "visit", "management", @@ -1060,7 +1060,7 @@ strings const WordList = "reality", "coach", "step", - "Mrs", + "mrs", "yard", "beat", "violence", @@ -1137,7 +1137,7 @@ strings const WordList = "forest", "video", "global", - "Senate", + "senate", "reform", "access", "restaurant", @@ -1209,7 +1209,7 @@ strings const WordList = "spirit", "experience", "replace", - "British", + "british", "encourage", "lot", "lot", @@ -1222,7 +1222,7 @@ strings const WordList = "brain", "feature", "afternoon", - "AM", + "am", "weekend", "dozen", "possibility", @@ -1233,7 +1233,7 @@ strings const WordList = "beginning", "date", "generally", - "African", + "african", "very", "sorry", "crisis", @@ -1248,7 +1248,7 @@ strings const WordList = "vision", "status", "normal", - "Chinese", + "chinese", "ship", "solution", "stone", @@ -1278,7 +1278,7 @@ strings const WordList = "tradition", "winter", "village", - "Soviet", + "soviet", "refuse", "sales", "roll", @@ -1295,16 +1295,16 @@ strings const WordList = "potential", "increase", "middle", - "European", + "european", "presence", "independent", "district", "shape", "reader", - "Ms", + "ms", "contract", "crowd", - "Christian", + "christian", "express", "apartment", "willing", @@ -1395,8 +1395,8 @@ strings const WordList = "insist", "failure", "annual", - "French", - "Christmas", + "french", + "christmas", "comment", "responsible", "affair", @@ -1467,7 +1467,7 @@ strings const WordList = "smile", "location", "clothes", - "Indian", + "indian", "quiet", "dress", "promise", @@ -1494,14 +1494,14 @@ strings const WordList = "dangerous", "remind", "moral", - "United", + "united", "category", "relatively", "victory", "key", "academic", "visit", - "Internet", + "internet", "healthy", "fire", "negative", @@ -1597,7 +1597,7 @@ strings const WordList = "leaf", "direct", "dry", - "Russian", + "russian", "instruction", "fight", "pool", @@ -1653,7 +1653,7 @@ strings const WordList = "presidential", "emotional", "commitment", - "Supreme", + "supreme", "bear", "pocket", "thin", @@ -1688,7 +1688,7 @@ strings const WordList = "organize", "jury", "breast", - "Iraqi", + "iraqi", "human", "acknowledge", "theme", @@ -1757,7 +1757,7 @@ strings const WordList = "prefer", "truly", "earth", - "Japanese", + "japanese", "chest", "search", "thick", @@ -1795,7 +1795,7 @@ strings const WordList = "sheet", "ought", "ensure", - "Catholic", + "catholic", "extremely", "extent", "component", @@ -1822,7 +1822,7 @@ strings const WordList = "guide", "circumstance", "snow", - "English", + "english", "politician", "steal", "pursue", @@ -1835,7 +1835,7 @@ strings const WordList = "influence", "surgery", "correct", - "Jewish", + "jewish", "blame", "estimate", "due", @@ -1863,7 +1863,7 @@ strings const WordList = "rating", "golden", "motion", - "German", + "german", "gender", "solve", "fee", @@ -1943,7 +1943,7 @@ strings const WordList = "clean", "except", "beer", - "English", + "english", "reference", "tear", "doubt", @@ -2047,8 +2047,8 @@ strings const WordList = "towards", "expose", "rural", - "AIDS", - "Jew", + "aids", + "jew", "narrow", "cream", "secretary", @@ -2128,7 +2128,7 @@ strings const WordList = "forever", "fun", "regard", - "Israeli", + "israeli", "association", "twenty", "knock", @@ -2247,11 +2247,11 @@ strings const WordList = "error", "release", "cop", - "Arab", + "arab", "double", "walk", "sand", - "Spanish", + "spanish", "rule", "hit", "print", @@ -2294,7 +2294,7 @@ strings const WordList = "present", "joke", "coat", - "Mexican", + "mexican", "symptom", "contact", "manufacturer", @@ -2366,7 +2366,7 @@ strings const WordList = "another", "attach", "for", - "Indian", + "indian", "disaster", "parking", "prospect", @@ -2397,7 +2397,7 @@ strings const WordList = "illustrate", "boot", "monitor", - "Asian", + "asian", "entertainment", "bean", "evaluation", @@ -2536,7 +2536,7 @@ strings const WordList = "occasionally", "mayor", "consideration", - "CEO", + "ceo", "secure", "pink", "smoke", @@ -2575,13 +2575,13 @@ strings const WordList = "quit", "absence", "roll", - "Latin", + "latin", "rapidly", "jail", "comment", "diversity", "honest", - "Palestinian", + "palestinian", "pace", "employment", "speaker", @@ -2641,11 +2641,11 @@ strings const WordList = "phrase", "ingredient", "stake", - "Muslim", + "muslim", "dream", "fiber", "activist", - "Islamic", + "islamic", "snap", "terrorism", "refugee", @@ -2686,8 +2686,8 @@ strings const WordList = "wonder", "clock", "chocolate", - "Italian", - "Canadian", + "italian", + "canadian", "ceiling", "sweep", "advertising", @@ -2786,13 +2786,13 @@ strings const WordList = "though", "expansion", "elite", - "Olympic", + "olympic", "dirt", "odd", "rice", "bullet", "tight", - "Bible", + "bible", "chart", "solar", "decline", @@ -2878,7 +2878,7 @@ strings const WordList = "assistant", "offense", "counter", - "DNA", + "dna", "smell", "potentially", "transfer", @@ -2981,7 +2981,7 @@ strings const WordList = "radical", "stress", "adapt", - "Irish", + "irish", "honey", "correspondent", "pale", @@ -3072,7 +3072,7 @@ strings const WordList = "fund", "ski", "limitation", - "OK", + "ok", "trace", "appointment", "preference", @@ -3105,7 +3105,7 @@ strings const WordList = "mall", "derive", "scandal", - "PC", + "pc", "helpful", "impress", "heel", @@ -3125,7 +3125,7 @@ strings const WordList = "examination", "publisher", "strengthen", - "French", + "french", "proposed", "myth", "sophisticated", @@ -3153,7 +3153,7 @@ strings const WordList = "narrative", "photographer", "helicopter", - "Catholic", + "catholic", "modest", "provider", "delay", @@ -3181,7 +3181,7 @@ strings const WordList = "assignment", "restriction", "across", - "Palestinian", + "palestinian", "laboratory", "workshop", "differently", @@ -3216,19 +3216,19 @@ strings const WordList = "versus", "manufacturing", "risk", - "Christian", + "christian", "complex", "absolute", "chef", "discrimination", "offensive", - "German", + "german", "suit", "boom", "register", "appoint", "heritage", - "God", + "god", "terrorist", "dominant", "successfully", @@ -3366,7 +3366,7 @@ strings const WordList = "rope", "concrete", "prescription", - "African-American", + "african-american", "chase", "document", "brick", @@ -3547,7 +3547,7 @@ strings const WordList = "cold", "classical", "estimated", - "T-shirt", + "t-shirt", "online", "unemployment", "civilization", @@ -3564,16 +3564,16 @@ strings const WordList = "reliable", "excitement", "beef", - "Islam", - "Roman", + "islam", + "roman", "stretch", "architecture", "occasional", "administrative", "elbow", "deadly", - "Muslim", - "Hispanic", + "muslim", + "hispanic", "allegation", "tip", "confuse", @@ -3581,7 +3581,7 @@ strings const WordList = "monthly", "duck", "dose", - "Korean", + "korean", "plead", "initiate", "lecture", @@ -3762,7 +3762,7 @@ strings const WordList = "freshman", "sweat", "outer", - "European", + "european", "drunk", "survey", "research", @@ -3837,7 +3837,7 @@ strings const WordList = "shame", "meaningful", "sidewalk", - "Olympics", + "olympics", "technological", "signature", "pleasant", @@ -3919,7 +3919,7 @@ strings const WordList = "pastor", "jazz", "opera", - "Japanese", + "japanese", "bite", "frame", "evil", @@ -3945,7 +3945,7 @@ strings const WordList = "gym", "oral", "clerk", - "Israeli", + "israeli", "envelope", "reporting", "destination", @@ -4027,7 +4027,7 @@ strings const WordList = "enroll", "diminish", "prevention", - "Arab", + "arab", "value", "minimize", "chop", @@ -4063,7 +4063,7 @@ strings const WordList = "representative", "content", "realistic", - "Russian", + "russian", "hidden", "command", "tender", @@ -4126,19 +4126,15 @@ strings const WordList = "cart", "oversee", "stem", - "o'clock", "elder", - "o'clock", - "o'clock", - "o'clock", "pro", "inspiration", - "Dutch", + "dutch", "quantity", "trailer", "mate", "o'clock", - "Greek", + "greek", "genius", "monument", "bid", @@ -4264,7 +4260,7 @@ strings const WordList = "rent", "calm", "jewelry", - "Cuban", + "cuban", "haul", "concede", "trace", @@ -4366,7 +4362,7 @@ strings const WordList = "breeze", "costly", "ambitious", - "Christianity", + "christianity", "presumably", "influential", "translation", @@ -4547,7 +4543,7 @@ strings const WordList = "ideal", "constitution", "trainer", - "Thanksgiving", + "thanksgiving", "scent", "stack", "eyebrow", @@ -4614,7 +4610,7 @@ strings const WordList = "dip", "likewise", "informal", - "Persian", + "persian", "feather", "sphere", "tighten", @@ -4689,7 +4685,6 @@ strings const WordList = "toll", "rim", "embarrassed", - "fucking", "cling", "isolated", "blink", diff --git a/libethcore/CommonJS.cpp b/libethcore/CommonJS.cpp index 167879db3..75cadb0ba 100644 --- a/libethcore/CommonJS.cpp +++ b/libethcore/CommonJS.cpp @@ -22,16 +22,27 @@ */ #include "CommonJS.h" +#include "ICAP.h" namespace dev { -Address toAddress(std::string const& _sn) +Address jsToAddress(std::string const& _s) { - if (_sn.size() == 40) - return Address(fromHex(_sn)); - else - return Address(); + try + { + eth::ICAP i = eth::ICAP::decoded(_s); + return i.direct(); + } + catch (eth::InvalidICAP&) {} + try + { + auto b = fromHex(_s.substr(0, 2) == "0x" ? _s.substr(2) : _s, WhenError::Throw); + if (b.size() == 20) + return Address(b); + } + catch (BadHexCharacter&) {} + BOOST_THROW_EXCEPTION(InvalidAddress()); } std::string prettyU256(u256 _n, bool _abridged) diff --git a/libethcore/CommonJS.h b/libethcore/CommonJS.h index fdd18d6e5..6beb7e8a2 100644 --- a/libethcore/CommonJS.h +++ b/libethcore/CommonJS.h @@ -33,8 +33,7 @@ namespace dev { -/// Strictly convert unprefixed hex string string to Address (h160). @returns empty address if (_a.size != 40). -Address toAddress(std::string const& _a); +DEV_SIMPLE_EXCEPTION(InvalidAddress); /// Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length. inline Public jsToPublic(std::string const& _s) { return jsToFixed(_s); } @@ -43,7 +42,7 @@ inline Public jsToPublic(std::string const& _s) { return jsToFixed(_s); Secret ret(d); d.ref().cleanse(); return ret; } /// Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length. -inline Address jsToAddress(std::string const& _s) { return jsToFixed(_s); } +Address jsToAddress(std::string const& _s); /// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256. std::string prettyU256(u256 _n, bool _abridged = true); diff --git a/libethcore/ICAP.cpp b/libethcore/ICAP.cpp index 12e8aed56..3303f7b3f 100644 --- a/libethcore/ICAP.cpp +++ b/libethcore/ICAP.cpp @@ -64,6 +64,17 @@ std::pair ICAP::fromIBAN(std::string _iban) return make_pair(c, d); } +Secret ICAP::createDirect() +{ + Secret ret; + while (true) + { + ret = Secret::random(); + if (!toAddress(ret)[0]) + return ret; + } +} + ICAP ICAP::decoded(std::string const& _encoded) { ICAP ret; @@ -72,7 +83,7 @@ ICAP ICAP::decoded(std::string const& _encoded) std::tie(country, data) = fromIBAN(_encoded); if (country != "XE") BOOST_THROW_EXCEPTION(InvalidICAP()); - if (data.size() == 30) + if (data.size() == 30 || data.size() == 31) { ret.m_type = Direct; // Direct ICAP @@ -100,10 +111,8 @@ std::string ICAP::encoded() const { if (m_type == Direct) { - if (!!m_direct[0]) - BOOST_THROW_EXCEPTION(InvalidICAP()); std::string d = toBase36(m_direct); - while (d.size() < 30) + while (d.size() < 30) // always 34, sometimes 35. d = "0" + d; return iban("XE", d); } diff --git a/libethcore/ICAP.h b/libethcore/ICAP.h index a2456bd40..91a95d6d8 100644 --- a/libethcore/ICAP.h +++ b/libethcore/ICAP.h @@ -36,7 +36,7 @@ namespace dev namespace eth { -struct InvalidICAP: virtual public dev::Exception {}; +DEV_SIMPLE_EXCEPTION(InvalidICAP); /** * @brief Encapsulation of an ICAP address. @@ -62,6 +62,9 @@ public: Indirect }; + /// Create a direct address for ICAP. + static Secret createDirect(); + /// @returns IBAN encoding of client and data. static std::string iban(std::string _c, std::string _d); /// @returns Client and data from given IBAN address. diff --git a/libethcore/KeyManager.h b/libethcore/KeyManager.h index 671355df9..ac242c5cf 100644 --- a/libethcore/KeyManager.h +++ b/libethcore/KeyManager.h @@ -36,7 +36,7 @@ class PasswordUnknown: public Exception {}; struct KeyInfo { KeyInfo() = default; - KeyInfo(h256 const& _passHash, std::string const& _accountName, std::string const& _passwordHint): passHash(_passHash), accountName(_accountName), passwordHint(_passwordHint) {} + KeyInfo(h256 const& _passHash, std::string const& _accountName, std::string const& _passwordHint = std::string()): passHash(_passHash), accountName(_accountName), passwordHint(_passwordHint) {} /// Hash of the password or h256() / UnknownPassword if unknown. h256 passHash; diff --git a/libethereum/Block.cpp b/libethereum/Block.cpp index a57ded73d..1c8dc1b21 100644 --- a/libethereum/Block.cpp +++ b/libethereum/Block.cpp @@ -80,6 +80,9 @@ Block::Block(Block const& _s): Block& Block::operator=(Block const& _s) { + if (&_s == this) + return *this; + m_state = _s.m_state; m_transactions = _s.m_transactions; m_receipts = _s.m_receipts; diff --git a/libethereum/BlockChainSync.cpp b/libethereum/BlockChainSync.cpp index e5717511d..1f0e2a535 100644 --- a/libethereum/BlockChainSync.cpp +++ b/libethereum/BlockChainSync.cpp @@ -833,7 +833,6 @@ void PV60Sync::abortSync() void PV60Sync::onPeerAborting() { RecursiveGuard l(x_sync); - DEV_INVARIANT_CHECK; // Can't check invariants here since the peers is already removed from the list and the state is not updated yet. if (m_syncer.expired() && m_state != SyncState::Idle) { diff --git a/libethereum/DownloadMan.cpp b/libethereum/DownloadMan.cpp index 84931def2..a7c1b57d3 100644 --- a/libethereum/DownloadMan.cpp +++ b/libethereum/DownloadMan.cpp @@ -44,6 +44,7 @@ DownloadSub::DownloadSub(DownloadMan& _man): m_man(&_man) DownloadSub::~DownloadSub() { + Guard fl(m_fetch); if (m_man) { WriteGuard l(m_man->x_subs); diff --git a/libethereum/DownloadMan.h b/libethereum/DownloadMan.h index b6ca58845..dff5ea256 100644 --- a/libethereum/DownloadMan.h +++ b/libethereum/DownloadMan.h @@ -93,7 +93,10 @@ public: ~DownloadMan() { for (auto i: m_subs) + { + Guard l(i->m_fetch); i->m_man = nullptr; + } } void appendToChain(h256s const& _hashes) diff --git a/libethereum/Executive.cpp b/libethereum/Executive.cpp index 839d69216..7eb37ff99 100644 --- a/libethereum/Executive.cpp +++ b/libethereum/Executive.cpp @@ -383,7 +383,7 @@ bool Executive::go(OnOpFunc const& _onOp) } catch (VMException const& _e) { - cnote/*clog(StateSafeExceptions)*/ << "Safe VM Exception. " << diagnostic_information(_e); + clog(StateSafeExceptions) << "Safe VM Exception. " << diagnostic_information(_e); m_gas = 0; m_excepted = toTransactionException(_e); m_ext->revert(); diff --git a/libethereum/State.cpp b/libethereum/State.cpp index bd5feacb0..5258e0668 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -136,6 +136,9 @@ void State::paranoia(std::string const& _when, bool _enforceRefs) const State& State::operator=(State const& _s) { + if (&_s == this) + return *this; + m_db = _s.m_db; m_state.open(&m_db, _s.m_state.root(), Verification::Skip); m_cache = _s.m_cache; diff --git a/libethereum/TransactionQueue.cpp b/libethereum/TransactionQueue.cpp index aeeb35214..bf8e14a27 100644 --- a/libethereum/TransactionQueue.cpp +++ b/libethereum/TransactionQueue.cpp @@ -402,4 +402,3 @@ void TransactionQueue::verifierBody() } } } - diff --git a/libethereum/TransactionQueue.h b/libethereum/TransactionQueue.h index 9c8283aa2..b7af75013 100644 --- a/libethereum/TransactionQueue.h +++ b/libethereum/TransactionQueue.h @@ -140,7 +140,14 @@ private: UnverifiedTransaction() {} UnverifiedTransaction(bytesConstRef const& _t, h512 const& _nodeId): transaction(_t.toBytes()), nodeId(_nodeId) {} UnverifiedTransaction(UnverifiedTransaction&& _t): transaction(std::move(_t.transaction)) {} - UnverifiedTransaction& operator=(UnverifiedTransaction&& _other) { transaction = std::move(_other.transaction); nodeId = std::move(_other.nodeId); return *this; } + UnverifiedTransaction& operator=(UnverifiedTransaction&& _other) + { + assert(&_other != this); + + transaction = std::move(_other.transaction); + nodeId = std::move(_other.nodeId); + return *this; + } UnverifiedTransaction(UnverifiedTransaction const&) = delete; UnverifiedTransaction& operator=(UnverifiedTransaction const&) = delete; diff --git a/libethereum/VerifiedBlock.h b/libethereum/VerifiedBlock.h index 8bac12f90..fb96c084c 100644 --- a/libethereum/VerifiedBlock.h +++ b/libethereum/VerifiedBlock.h @@ -58,6 +58,8 @@ struct VerifiedBlock VerifiedBlock& operator=(VerifiedBlock&& _other) { + assert(&_other != this); + verified = (std::move(_other.verified)); blockData = (std::move(_other.blockData)); return *this; diff --git a/libevmasm/SourceLocation.h b/libevmasm/SourceLocation.h index 35e3c0318..b8b57b609 100644 --- a/libevmasm/SourceLocation.h +++ b/libevmasm/SourceLocation.h @@ -41,8 +41,21 @@ struct SourceLocation SourceLocation(): start(-1), end(-1) { } SourceLocation(SourceLocation const& _other): - start(_other.start), end(_other.end), sourceName(_other.sourceName) {} - SourceLocation& operator=(SourceLocation const& _other) { start = _other.start; end = _other.end; sourceName = _other.sourceName; return *this;} + start(_other.start), + end(_other.end), + sourceName(_other.sourceName) + {} + + SourceLocation& operator=(SourceLocation const& _other) + { + if (&_other == this) + return *this; + + start = _other.start; + end = _other.end; + sourceName = _other.sourceName; + return *this; + } bool operator==(SourceLocation const& _other) const { return start == _other.start && end == _other.end;} bool operator!=(SourceLocation const& _other) const { return !operator==(_other); } diff --git a/libjsconsole/JSConsole.h b/libjsconsole/JSConsole.h index da045a6f8..393f7080f 100644 --- a/libjsconsole/JSConsole.h +++ b/libjsconsole/JSConsole.h @@ -41,7 +41,7 @@ public: JSConsole(): m_engine(Engine()), m_printer(Printer(m_engine)) {} ~JSConsole() {} - void readExpression() const + bool readExpression() const { std::string cmd = ""; g_logPost = [](std::string const& a, char const*) @@ -83,6 +83,9 @@ public: } } while (openBrackets > 0); + if (cmd == "quit") + return false; + if (!isEmpty) { #if ETH_READLINE @@ -92,6 +95,7 @@ public: std::string result = m_printer.prettyPrint(value).cstr(); std::cout << result << std::endl; } + return true; } void eval(std::string const& _expression) { m_engine.eval(_expression.c_str()); } diff --git a/libp2p/Common.h b/libp2p/Common.h index 1b65d4759..9caa9c4c7 100644 --- a/libp2p/Common.h +++ b/libp2p/Common.h @@ -78,9 +78,9 @@ struct InvalidPublicIPAddress: virtual dev::Exception {}; struct InvalidHostIPAddress: virtual dev::Exception {}; struct NetWarn: public LogChannel { static const char* name(); static const int verbosity = 0; }; -struct NetNote: public LogChannel { static const char* name(); static const int verbosity = 1; }; -struct NetImpolite: public LogChannel { static const char* name(); static const int verbosity = 2; }; -struct NetMessageSummary: public LogChannel { static const char* name(); static const int verbosity = 3; }; +struct NetNote: public LogChannel { static const char* name(); static const int verbosity = 2; }; +struct NetImpolite: public LogChannel { static const char* name(); static const int verbosity = 3; }; +struct NetMessageSummary: public LogChannel { static const char* name(); static const int verbosity = 4; }; struct NetConnect: public LogChannel { static const char* name(); static const int verbosity = 10; }; struct NetMessageDetail: public LogChannel { static const char* name(); static const int verbosity = 5; }; struct NetTriviaSummary: public LogChannel { static const char* name(); static const int verbosity = 10; }; @@ -224,7 +224,13 @@ class DeadlineOps ~DeadlineOp() {} DeadlineOp(DeadlineOp&& _s): m_timer(_s.m_timer.release()) {} - DeadlineOp& operator=(DeadlineOp&& _s) { m_timer.reset(_s.m_timer.release()); return *this; } + DeadlineOp& operator=(DeadlineOp&& _s) + { + assert(&_s != this); + + m_timer.reset(_s.m_timer.release()); + return *this; + } bool expired() { Guard l(x_timer); return m_timer->expires_from_now().total_nanoseconds() <= 0; } void wait() { Guard l(x_timer); m_timer->wait(); } diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index b3b3d5bf3..64d10b172 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -396,7 +396,7 @@ void Host::runAcceptor() clog(NetConnect) << "Listening on local port " << m_listenPort << " (public: " << m_tcpPublic << ")"; m_accepting = true; - auto socket = make_shared(new bi::tcp::socket(m_ioService)); + auto socket = make_shared(m_ioService); m_tcp4Acceptor.async_accept(socket->ref(), [=](boost::system::error_code ec) { m_accepting = false; @@ -552,7 +552,7 @@ void Host::connect(std::shared_ptr const& _p) bi::tcp::endpoint ep(_p->endpoint); clog(NetConnect) << "Attempting connection to node" << _p->id << "@" << ep << "from" << id(); - auto socket = make_shared(new bi::tcp::socket(m_ioService)); + auto socket = make_shared(m_ioService); socket->ref().async_connect(ep, [=](boost::system::error_code const& ec) { _p->m_lastAttempted = std::chrono::system_clock::now(); diff --git a/libp2p/RLPXSocket.h b/libp2p/RLPXSocket.h index 58613bf82..171a7b35b 100644 --- a/libp2p/RLPXSocket.h +++ b/libp2p/RLPXSocket.h @@ -39,8 +39,7 @@ namespace p2p class RLPXSocket: public std::enable_shared_from_this { public: - /// Constructor. Dereferences and takes ownership of _socket. - RLPXSocket(bi::tcp::socket* _socket): m_socket(std::move(*_socket)) {} + RLPXSocket(ba::io_service& _ioService): m_socket(_ioService) {} ~RLPXSocket() { close(); } bool isConnected() const { return m_socket.is_open(); } diff --git a/libsolidity/Token.h b/libsolidity/Token.h index 43a5b90b9..7c7b1c7ff 100644 --- a/libsolidity/Token.h +++ b/libsolidity/Token.h @@ -366,6 +366,7 @@ public: } static bool isBitOp(Value op) { return (BitOr <= op && op <= SHR) || op == BitNot; } + static bool isBooleanOp(Value op) { return (Or <= op && op <= And) || op == Not; } static bool isUnaryOp(Value op) { return (Not <= op && op <= Delete) || op == Add || op == Sub || op == After; } static bool isCountOp(Value op) { return op == Inc || op == Dec; } static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 744362fb7..bda683569 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -79,6 +79,8 @@ pair const* StorageOffsets::getOffset(size_t _index) const MemberList& MemberList::operator=(MemberList&& _other) { + assert(&_other != this); + m_memberTypes = std::move(_other.m_memberTypes); m_storageOffsets = std::move(_other.m_storageOffsets); return *this; @@ -311,6 +313,8 @@ TypePointer IntegerType::binaryOperatorResult(Token::Value _operator, TypePointe // All integer types can be compared if (Token::isCompareOp(_operator)) return commonType; + if (Token::isBooleanOp(_operator)) + return TypePointer(); // Nothing else can be done with addresses if (commonType->isAddress()) return TypePointer(); diff --git a/libsolidity/Types.h b/libsolidity/Types.h index bc499d595..c4992cfdf 100644 --- a/libsolidity/Types.h +++ b/libsolidity/Types.h @@ -409,6 +409,10 @@ public: DataLocation location() const { return m_location; } virtual TypePointer unaryOperatorResult(Token::Value _operator) const override; + virtual TypePointer binaryOperatorResult(Token::Value, TypePointer const&) const override + { + return TypePointer(); + } virtual unsigned memoryHeadSize() const override { return 32; } /// @returns a copy of this type with location (recursively) changed to @a _location, diff --git a/libweb3jsonrpc/JsonHelper.cpp b/libweb3jsonrpc/JsonHelper.cpp index ffb598dd2..3e758d892 100644 --- a/libweb3jsonrpc/JsonHelper.cpp +++ b/libweb3jsonrpc/JsonHelper.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include using namespace std; diff --git a/libweb3jsonrpc/JsonHelper.h b/libweb3jsonrpc/JsonHelper.h index 9be59bcab..33e51c0a9 100644 --- a/libweb3jsonrpc/JsonHelper.h +++ b/libweb3jsonrpc/JsonHelper.h @@ -69,6 +69,12 @@ TransactionSkeleton toTransactionSkeleton(Json::Value const& _json); LogFilter toLogFilter(Json::Value const& _json); LogFilter toLogFilter(Json::Value const& _json, Interface const& _client); // commented to avoid warning. Uncomment once in use @ PoC-7. +class AddressResolver +{ +public: + static Address fromJS(std::string const& _address); +}; + template Json::Value toJson(BlockHeaderPolished const& _bh) { diff --git a/libweb3jsonrpc/WebThreeStubServer.cpp b/libweb3jsonrpc/WebThreeStubServer.cpp index b5d8dc35f..5ead3175a 100644 --- a/libweb3jsonrpc/WebThreeStubServer.cpp +++ b/libweb3jsonrpc/WebThreeStubServer.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -189,7 +190,7 @@ Json::Value WebThreeStubServer::admin_eth_newAccount(Json::Value const& _info, s if (!_info.isMember("name")) throw jsonrpc::JsonRpcException("No member found: name"); string name = _info["name"].asString(); - auto s = Secret::random(); + auto s = ICAP::createDirect(); h128 uuid; if (_info.isMember("password")) { diff --git a/new.sh b/new.sh new file mode 100755 index 000000000..37f9d431d --- /dev/null +++ b/new.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +type="$1" +path="$2" +name="$3" + +if ! [[ -n $type ]] || ! [[ -n $path ]] || ! [[ -n $name ]]; then + echo "Usage new.sh " + echo "e.g. new.sh plugin alethzero MyPlugin" + exit +fi + +cd templates +for i in $type.*; do + n="../$path/${i/$type/$name}" + cp "$i" "$n" + perl -i -p -e "s/\\\$NAME/$name/gc" "$n" +done + + + diff --git a/templates/dockplugin.cpp b/templates/dockplugin.cpp new file mode 100644 index 000000000..479896f54 --- /dev/null +++ b/templates/dockplugin.cpp @@ -0,0 +1,41 @@ +/* + 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 $NAME.h + * @author Gav Wood + * @date 2015 + */ + +#include "$NAME.h" +#include +#include +#include "ui_$NAME.h" +using namespace std; +using namespace dev; +using namespace az; +using namespace eth; + +$NAME::$NAME(MainFace* _m): + Plugin(_m, "$NAME"), + m_ui(new Ui::$NAME) +{ + dock(Qt::RightDockWidgetArea, "$NAME")->setWidget(new QWidget()); + m_ui->setupUi(dock()->widget()); +} + +$NAME::~$NAME() +{ +} diff --git a/templates/dockplugin.h b/templates/dockplugin.h new file mode 100644 index 000000000..e47181436 --- /dev/null +++ b/templates/dockplugin.h @@ -0,0 +1,56 @@ +/* + 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 $NAME.h + * @author Gav Wood + * @date 2015 + */ + +#pragma once + +#include +#include +#include "MainFace.h" + +namespace Ui +{ +class $NAME; +} + +namespace dev +{ +namespace az +{ + +class $NAME: public QObject, public Plugin +{ + Q_OBJECT + +public: + AllAccounts(MainFace* _m); + ~AllAccounts(); + +private: + void onAllChange() override {} + void readSettings(QSettings const&) override {} + void writeSettings(QSettings&) override {} + +private: + Ui::$NAME* m_ui; +}; + +} +} diff --git a/templates/dockplugin.ui b/templates/dockplugin.ui new file mode 100644 index 000000000..5da527cbd --- /dev/null +++ b/templates/dockplugin.ui @@ -0,0 +1,36 @@ + + + $NAME + + + + 0 + 0 + 405 + 300 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/templates/plugin.cpp b/templates/plugin.cpp new file mode 100644 index 000000000..7c072aa2e --- /dev/null +++ b/templates/plugin.cpp @@ -0,0 +1,37 @@ +/* + 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 $NAME.h + * @author Gav Wood + * @date 2015 + */ + +#include "$NAME.h" +#include +#include +using namespace std; +using namespace dev; +using namespace az; +using namespace eth; + +$NAME::$NAME(MainFace* _m): + Plugin(_m, "$NAME") +{ +} + +$NAME::~$NAME() +{ +} diff --git a/templates/plugin.h b/templates/plugin.h new file mode 100644 index 000000000..ee360417c --- /dev/null +++ b/templates/plugin.h @@ -0,0 +1,46 @@ +/* + 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 $NAME.h + * @author Gav Wood + * @date 2015 + */ + +#pragma once + +#include "MainFace.h" + +namespace dev +{ +namespace az +{ + +class $NAME: public QObject, public Plugin +{ + Q_OBJECT + +public: + $NAME(MainFace* _m); + ~$NAME(); + +private: + void onAllChange() override {} + void readSettings(QSettings const&) override {} + void writeSettings(QSettings&) override {} +}; + +} +} diff --git a/test/TestUtils.cpp b/test/TestUtils.cpp index 0ec76386b..5e0619c0e 100644 --- a/test/TestUtils.cpp +++ b/test/TestUtils.cpp @@ -120,8 +120,3 @@ void ParallelClientBaseFixture::enumerateClients(std::function. +*/ +/** @file Base36.cpp + * @author Marek Kotewicz + * @date 2015 + */ + +#include +#include +#include + +using namespace std; +using namespace dev; +using namespace dev::eth; + +BOOST_AUTO_TEST_SUITE(Base36Tests) + +BOOST_AUTO_TEST_CASE(basicEncoding) +{ + FixedHash<2> value("0x0048"); + string encoded = toBase36<2>(value); + BOOST_CHECK_EQUAL(encoded, "20"); +} + +BOOST_AUTO_TEST_CASE(basicEncoding2) +{ + FixedHash<2> value("0x0072"); + string encoded = toBase36<2>(value); + BOOST_CHECK_EQUAL(encoded, "36"); +} + +BOOST_AUTO_TEST_CASE(basicEncoding3) +{ + FixedHash<2> value("0xffff"); + string encoded = toBase36<2>(value); + BOOST_CHECK_EQUAL(encoded, "1EKF"); +} + + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/libdevcrypto/SecretStore.cpp b/test/libdevcrypto/SecretStore.cpp index 272fa7422..32dcd3206 100644 --- a/test/libdevcrypto/SecretStore.cpp +++ b/test/libdevcrypto/SecretStore.cpp @@ -37,8 +37,6 @@ using namespace dev::test; namespace js = json_spirit; namespace fs = boost::filesystem; -BOOST_GLOBAL_FIXTURE( MoveNonceToTempDir ) - BOOST_AUTO_TEST_SUITE(KeyStore) BOOST_AUTO_TEST_CASE(basic_tests) diff --git a/test/libdevcrypto/crypto.cpp b/test/libdevcrypto/crypto.cpp index 84f15d7b2..f248b287e 100644 --- a/test/libdevcrypto/crypto.cpp +++ b/test/libdevcrypto/crypto.cpp @@ -40,8 +40,6 @@ using namespace dev::test; using namespace dev::crypto; using namespace CryptoPP; -BOOST_GLOBAL_FIXTURE( MoveNonceToTempDir ) - BOOST_AUTO_TEST_SUITE(devcrypto) static Secp256k1PP s_secp256k1; diff --git a/test/libethcore/icap.cpp b/test/libethcore/icap.cpp new file mode 100644 index 000000000..34d76e253 --- /dev/null +++ b/test/libethcore/icap.cpp @@ -0,0 +1,80 @@ +/* + 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 icap.cpp + * @author Marek Kotewicz + * @date 2015 + */ + +#include +#include + +using namespace std; +using namespace dev; +using namespace dev::eth; + +BOOST_AUTO_TEST_SUITE(IcapTests) + +BOOST_AUTO_TEST_CASE(addressEncoding) +{ + Address address("0x52dc504a422f0e2a9e7632a34a50f1a82f8224c7"); + ICAP icap(address); + BOOST_CHECK_EQUAL(icap.encoded(), "XE499OG1EH8ZZI0KXC6N83EKGT1BM97P2O7"); +} + +BOOST_AUTO_TEST_CASE(addressEncodingRandomString) +{ + Address address("0x11c5496aee77c1ba1f0854206a26dda82a81d6d8"); + ICAP icap(address); + BOOST_CHECK_EQUAL(icap.encoded(), "XE1222Q908LN1QBBU6XUQSO1OHWJIOS46OO"); +} + +BOOST_AUTO_TEST_CASE(addressEncodingWithZeroPrefix) +{ + Address address("0x00c5496aee77c1ba1f0854206a26dda82a81d6d8"); + ICAP icap(address); + BOOST_CHECK_EQUAL(icap.encoded(), "XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"); +} + +BOOST_AUTO_TEST_CASE(addressDecoding) +{ + Address address("0x52dc504a422f0e2a9e7632a34a50f1a82f8224c7"); + ICAP icap = ICAP::decoded("XE499OG1EH8ZZI0KXC6N83EKGT1BM97P2O7"); + BOOST_CHECK_EQUAL(icap.direct(), address); +} + +BOOST_AUTO_TEST_CASE(addressDecodingRandomString) +{ + Address address("0x11c5496aee77c1ba1f0854206a26dda82a81d6d8"); + ICAP icap = ICAP::decoded("XE1222Q908LN1QBBU6XUQSO1OHWJIOS46OO"); + BOOST_CHECK_EQUAL(icap.direct(), address); +} + +BOOST_AUTO_TEST_CASE(addressDecodingWithZeroPrefix) +{ + Address address("0x00c5496aee77c1ba1f0854206a26dda82a81d6d8"); + ICAP icap = ICAP::decoded("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"); + BOOST_CHECK_EQUAL(icap.direct(), address); +} + +BOOST_AUTO_TEST_CASE(addressDecodingAndEncoding) +{ + std::string encoded = "XE499OG1EH8ZZI0KXC6N83EKGT1BM97P2O7"; + ICAP icap = ICAP::decoded(encoded); + BOOST_CHECK_EQUAL(icap.encoded(), encoded); +} + +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 6b116f251..ba5a5a60f 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1883,6 +1883,34 @@ BOOST_AUTO_TEST_CASE(positive_integers_to_unsigned_out_of_bound) BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(integer_boolean_operators) +{ + char const* sourceCode1 = R"( + contract test { function() { uint x = 1; uint y = 2; x || y; } } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode1), TypeError); + char const* sourceCode2 = R"( + contract test { function() { uint x = 1; uint y = 2; x && y; } } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode2), TypeError); + char const* sourceCode3 = R"( + contract test { function() { uint x = 1; !x; } } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode3), TypeError); +} + +BOOST_AUTO_TEST_CASE(reference_compare_operators) +{ + char const* sourceCode1 = R"( + contract test { bytes a; bytes b; function() { a == b; } } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode1), TypeError); + char const* sourceCode2 = R"( + contract test { struct s {uint a;}; s x; s y; function() { x == y; } } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode2), TypeError); +} + BOOST_AUTO_TEST_CASE(overwrite_memory_location_external) { char const* sourceCode = R"(