From 525d69ef54238034519e43292348bea217962cbc Mon Sep 17 00:00:00 2001 From: subtly Date: Thu, 6 Aug 2015 12:56:43 +0200 Subject: [PATCH 01/20] defs for 32-bit secp256k1 --- secp256k1/libsecp256k1-config.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/secp256k1/libsecp256k1-config.h b/secp256k1/libsecp256k1-config.h index d23fee837..ac590cee7 100644 --- a/secp256k1/libsecp256k1-config.h +++ b/secp256k1/libsecp256k1-config.h @@ -51,7 +51,9 @@ #define HAVE_UNISTD_H 1 /* Define to 1 if the system has the type `__int128'. */ +#if defined(__x86_64__) || defined(_M_X64) #define HAVE___INT128 1 +#endif /* Define to the sub-directory where libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" @@ -81,16 +83,18 @@ #define STDC_HEADERS 1 /* Define this symbol to enable x86_64 assembly optimizations */ -/* #undef USE_ASM_X86_64 */ +// #if defined(__APPLE__) || defined(__GNUC__) +// #defined USE_ASM_X86_64 1 +// #endif /* Define this symbol to use endomorphism optimization */ /* #undef USE_ENDOMORPHISM */ -/* Define this symbol to use the FIELD_10X26 implementation */ -/* #undef USE_FIELD_10X26 */ - -/* Define this symbol to use the FIELD_5X52 implementation */ +#if defined(__x86_64__) || defined(_M_X64) #define USE_FIELD_5X52 1 +#elif defined(__i386) || defined(_M_IX86) +#define USE_FIELD_10X26 1 +#endif /* Define this symbol to use the native field inverse implementation */ /* #undef USE_FIELD_INV_BUILTIN */ @@ -104,11 +108,11 @@ /* Define this symbol to use no num implementation */ /* #undef USE_NUM_NONE */ -/* Define this symbol to use the 4x64 scalar implementation */ +#if defined(__x86_64__) || defined(_M_X64) #define USE_SCALAR_4X64 1 - -/* Define this symbol to use the 8x32 scalar implementation */ -/* #undef USE_SCALAR_8X32 */ +#elif defined(__i386) || defined(_M_IX86) +#define USE_SCALAR_8X32 1 +#endif /* Define this symbol to use the native scalar inverse implementation */ /* #undef USE_SCALAR_INV_BUILTIN */ From e737e5252cd039582072b320cd101ce6bad1caf2 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Wed, 5 Aug 2015 17:07:02 +0200 Subject: [PATCH 02/20] tests for whisper api --- test/libwhisper/shhrpc.cpp | 266 +++++++++++++++++++++++++++++++++++-- 1 file changed, 256 insertions(+), 10 deletions(-) diff --git a/test/libwhisper/shhrpc.cpp b/test/libwhisper/shhrpc.cpp index 5d3fea641..ea02f2e1c 100644 --- a/test/libwhisper/shhrpc.cpp +++ b/test/libwhisper/shhrpc.cpp @@ -44,7 +44,9 @@ namespace js = json_spirit; WebThreeDirect* web3; unique_ptr jsonrpcServer; unique_ptr jsonrpcClient; -static uint16_t const web3port = 30333; +static uint16_t const g_web3port = 30333; +static string const g_version("shhrpc-web3"); +static unsigned const g_ttl = 777000; struct Setup { @@ -56,10 +58,9 @@ struct Setup if (!setup) { setup = true; - NetworkPreferences nprefs(std::string(), web3port, false); - web3 = new WebThreeDirect("shhrpc-web3", "", WithExisting::Trust, {"eth", "shh"}, nprefs); + NetworkPreferences nprefs(std::string(), g_web3port, false); + web3 = new WebThreeDirect(g_version, "", WithExisting::Trust, {"shh"}, nprefs); web3->setIdealPeerCount(1); - web3->ethereum()->setForceMining(false); auto server = new jsonrpc::HttpServer(8080); vector v; KeyManager keyMan; @@ -78,6 +79,27 @@ struct Setup } }; +Json::Value createMessage(string const& _from, string const& _to, string const& _topic = "", string _payload = "") +{ + Json::Value msg; + msg["from"] = _from; + msg["to"] = _to; + msg["ttl"] = toJS(g_ttl); + + if (_payload.empty()) + _payload = string("0x") + h256::random().hex(); + + msg["payload"] = _payload; + + if (!_topic.empty()) + { + Json::Value t(Json::arrayValue); + t.append(_topic); + msg["topics"] = t; + } + + return msg; +} BOOST_FIXTURE_TEST_SUITE(shhrpc, Setup) @@ -109,7 +131,7 @@ BOOST_AUTO_TEST_CASE(basic) for (unsigned i = 0; i < 3000 && (!web3->peerCount() || !host2.peerCount()); i += step) this_thread::sleep_for(chrono::milliseconds(step)); - BOOST_REQUIRE_EQUAL(host2.peerCount(), 1); + BOOST_REQUIRE_EQUAL(host2.peerCount(), 1); BOOST_REQUIRE_EQUAL(web3->peerCount(), 1); vector vpeers = web3->peers(); @@ -149,9 +171,9 @@ BOOST_AUTO_TEST_CASE(send) { setThreadName("listener"); ready = true; - auto w = whost2->installWatch(BuildTopicMask("odd")); + auto w = whost2->installWatch(BuildTopicMask("odd")); set received; - for (unsigned x = 0; x < 9000 && !sent; x += step) + for (unsigned x = 0; x < 7000 && !sent; x += step) this_thread::sleep_for(chrono::milliseconds(step)); for (unsigned x = 0, last = 0; x < 100 && received.size() < messageCount; ++x) @@ -219,7 +241,7 @@ BOOST_AUTO_TEST_CASE(receive) auto w = web3->whisper()->installWatch(BuildTopicMask("odd")); set received; - for (unsigned x = 0; x < 9000 && !sent; x += step) + for (unsigned x = 0; x < 7000 && !sent; x += step) this_thread::sleep_for(chrono::milliseconds(step)); for (unsigned x = 0, last = 0; x < 100 && received.size() < messageCount; ++x) @@ -233,6 +255,8 @@ BOOST_AUTO_TEST_CASE(receive) result += last; } } + + web3->whisper()->uninstallWatch(w); }); for (unsigned i = 0; i < 2000 && (!host2.haveNetwork() || !web3->haveNetwork()); i += step) @@ -241,7 +265,7 @@ BOOST_AUTO_TEST_CASE(receive) BOOST_REQUIRE(host2.haveNetwork()); BOOST_REQUIRE(web3->haveNetwork()); - host2.addNode(web3->id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), web3port, web3port)); + host2.addNode(web3->id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), g_web3port, g_web3port)); for (unsigned i = 0; i < 3000 && (!web3->peerCount() || !host2.peerCount()); i += step) this_thread::sleep_for(chrono::milliseconds(step)); @@ -252,7 +276,7 @@ BOOST_AUTO_TEST_CASE(receive) KeyPair us = KeyPair::create(); for (unsigned i = 0; i < messageCount; ++i) { - web3->whisper()->post(us.sec(), RLPStream().append(i * i * i).out(), BuildTopic(i)(i % 2 ? "odd" : "even"), 777000, 1); + web3->whisper()->post(us.sec(), RLPStream().append(i * i * i).out(), BuildTopic(i)(i % 2 ? "odd" : "even"), g_ttl, 1); this_thread::sleep_for(chrono::milliseconds(50)); } @@ -261,4 +285,226 @@ BOOST_AUTO_TEST_CASE(receive) BOOST_REQUIRE_EQUAL(result, 1 + 27 + 125); } +BOOST_AUTO_TEST_CASE(serverBasic) +{ + cnote << "Testing basic jsonrpc server..."; + + string s = jsonrpcServer->web3_clientVersion(); + BOOST_REQUIRE_EQUAL(s, g_version); + + s = jsonrpcServer->net_version(); + BOOST_REQUIRE(s.empty()); + + s = jsonrpcServer->web3_sha3("some pseudo-random string here"); + BOOST_REQUIRE_EQUAL(s.size(), h256::size * 2 + 2); + BOOST_REQUIRE('0' == s[0] && 'x' == s[1]); + + s = jsonrpcServer->net_peerCount(); + BOOST_REQUIRE_EQUAL(s, "0x0"); + + KeyPair src = KeyPair::create(); + KeyPair dst = KeyPair::create(); + Json::Value t1 = createMessage(toJS(src.address()), toJS(dst.address())); + bool b = jsonrpcServer->shh_post(t1); + BOOST_REQUIRE(b); + + string const id = jsonrpcServer->shh_newIdentity(); + BOOST_REQUIRE_EQUAL(id.size(), 130); + BOOST_REQUIRE('0' == id[0] && 'x' == id[1]); + + b = jsonrpcServer->shh_hasIdentity(id); + BOOST_REQUIRE(b); + + Json::Value t2 = createMessage(id, id); + b = jsonrpcServer->shh_post(t2); + BOOST_REQUIRE(b); +} + +BOOST_AUTO_TEST_CASE(server) +{ + cnote << "Testing server functionality..."; + + bool b; + string s; + Json::Value j; + SessionPermissions permissions; + permissions.privileges.insert(Privilege::Admin); + string const text = string("0x") + h256::random().hex(); // message must be in raw form + + string sess1 = jsonrpcServer->newSession(permissions); + string sess2("session number two"); + jsonrpcServer->addSession(sess2, permissions); + + b = jsonrpcServer->admin_web3_setVerbosity(5, sess1); + BOOST_REQUIRE(b); + + b = jsonrpcServer->admin_net_start(sess1); + BOOST_REQUIRE(b); + + unsigned const step = 10; + for (unsigned i = 0; i < 3000 && !jsonrpcServer->net_listening(); i += step) + this_thread::sleep_for(chrono::milliseconds(step)); + + b = jsonrpcServer->net_listening(); + BOOST_REQUIRE(b); + + b = jsonrpcServer->admin_net_stop(sess1); + BOOST_REQUIRE(b); + + b = jsonrpcServer->net_listening(); + BOOST_REQUIRE(!b); + + j = jsonrpcServer->admin_net_peers(sess1); + BOOST_REQUIRE(j.empty()); + + j = jsonrpcServer->admin_net_nodeInfo(sess2); + BOOST_REQUIRE_EQUAL(j["id"].asString(), web3->id().hex()); + BOOST_REQUIRE_EQUAL(j["port"].asUInt(), g_web3port); + + uint16_t port2 = 30339; + Host host2("shhrpc-host2", NetworkPreferences("127.0.0.1", port2, false)); + host2.setIdealPeerCount(1); + auto whost2 = host2.registerCapability(new WhisperHost()); + host2.start(); + + b = jsonrpcServer->admin_net_start(sess2); + BOOST_REQUIRE(b); + + for (unsigned i = 0; i < 2000 && !host2.haveNetwork(); i += step) + this_thread::sleep_for(chrono::milliseconds(step)); + + for (unsigned i = 0; i < 2000 && !jsonrpcServer->net_listening(); i += step) + this_thread::sleep_for(chrono::milliseconds(step)); + + BOOST_REQUIRE(host2.haveNetwork()); + BOOST_REQUIRE(jsonrpcServer->net_listening()); + + string node("enode://"); + node += host2.id().hex(); + node += "@"; + node += "127.0.0.1:30339"; + b = jsonrpcServer->admin_net_connect(node, sess2); + + for (unsigned i = 0; i < 3000 && !host2.peerCount(); i += step) + this_thread::sleep_for(chrono::milliseconds(step)); + + BOOST_REQUIRE_EQUAL(host2.peerCount(), 1); + this_thread::sleep_for(chrono::milliseconds(step)); + + j = jsonrpcServer->admin_net_peers(sess2); + BOOST_REQUIRE_EQUAL(j.size(), 1); + Json::Value peer = j[0]; + s = peer["id"].asString(); + BOOST_REQUIRE_EQUAL(s, host2.id().hex()); + BOOST_REQUIRE_EQUAL(peer["port"].asUInt(), port2); + + s = jsonrpcServer->net_peerCount(); + BOOST_REQUIRE_EQUAL(s, "0x1"); + + KeyPair src = KeyPair::create(); + KeyPair dst = KeyPair::create(); + + Json::Value t1 = createMessage(toJS(src.address()), toJS(dst.address())); + b = jsonrpcServer->shh_post(t1); + BOOST_REQUIRE(b); + + string const id = jsonrpcServer->shh_newIdentity(); + BOOST_REQUIRE_EQUAL(id.size(), 130); + BOOST_REQUIRE(jsonrpcServer->shh_hasIdentity(id)); + + Json::Value t2 = createMessage(id, id); + b = jsonrpcServer->shh_post(t2); + BOOST_REQUIRE(b); + + string const nonexistent = "123456789"; + b = jsonrpcServer->shh_uninstallFilter(nonexistent); + BOOST_REQUIRE(b); + + j = jsonrpcServer->shh_getMessages(nonexistent); + BOOST_REQUIRE(j.empty()); + + string const topic = "unicorns"; + Json::Value t(Json::arrayValue); + t.append(topic); + Json::Value f; + f["to"] = id; + f["topics"] = t; + string const filter = jsonrpcServer->shh_newFilter(f); + + j = jsonrpcServer->shh_getFilterChanges(filter); + BOOST_REQUIRE(j.empty()); + + j = jsonrpcServer->shh_getMessages(filter); + BOOST_REQUIRE(j.empty()); + + Json::Value msg = createMessage(id, id, topic, text); + b = jsonrpcServer->shh_post(msg); + BOOST_REQUIRE(b); + this_thread::sleep_for(chrono::milliseconds(50)); + + j = jsonrpcServer->shh_getFilterChanges(filter); + BOOST_REQUIRE(!j.empty()); + Json::Value m1 = j[0]; + BOOST_REQUIRE_EQUAL(m1["ttl"], toJS(g_ttl)); + BOOST_REQUIRE_EQUAL(m1["from"], id); + BOOST_REQUIRE_EQUAL(m1["to"], id); + BOOST_REQUIRE_EQUAL(m1["payload"], text); + + j = jsonrpcServer->shh_getMessages(filter); + BOOST_REQUIRE(!j.empty()); + Json::Value m2 = j[0]; + BOOST_REQUIRE_EQUAL(m2["ttl"], toJS(g_ttl)); + BOOST_REQUIRE_EQUAL(m2["from"], id); + BOOST_REQUIRE_EQUAL(m2["to"], id); + BOOST_REQUIRE_EQUAL(m2["payload"], text); + + j = jsonrpcServer->shh_getFilterChanges(filter); + BOOST_REQUIRE(j.empty()); + + j = jsonrpcServer->shh_getMessages(filter); + BOOST_REQUIRE(!j.empty()); + m1 = j[0]; + BOOST_REQUIRE_EQUAL(m1["ttl"], toJS(g_ttl)); + BOOST_REQUIRE_EQUAL(m1["from"], id); + BOOST_REQUIRE_EQUAL(m1["to"], id); + BOOST_REQUIRE_EQUAL(m1["payload"], text); + + msg = createMessage(id, id, topic); + b = jsonrpcServer->shh_post(msg); + BOOST_REQUIRE(b); + this_thread::sleep_for(chrono::milliseconds(50)); + + j = jsonrpcServer->shh_getFilterChanges(filter); + BOOST_REQUIRE_EQUAL(j.size(), 1); + + j = jsonrpcServer->shh_getMessages(filter); + BOOST_REQUIRE_EQUAL(j.size(), 2); + + b = jsonrpcServer->shh_uninstallFilter(filter); + BOOST_REQUIRE(b); + + j = jsonrpcServer->shh_getFilterChanges(filter); + BOOST_REQUIRE(j.empty()); + + j = jsonrpcServer->shh_getMessages(filter); + BOOST_REQUIRE(j.empty()); + + msg = createMessage(id, id, topic); + b = jsonrpcServer->shh_post(msg); + BOOST_REQUIRE(b); + this_thread::sleep_for(chrono::milliseconds(50)); + + j = jsonrpcServer->shh_getFilterChanges(filter); + BOOST_REQUIRE(j.empty()); + + j = jsonrpcServer->shh_getMessages(filter); + BOOST_REQUIRE(j.empty()); + + b = jsonrpcServer->admin_net_stop(sess2); + BOOST_REQUIRE(b); + + b = jsonrpcServer->net_listening(); + BOOST_REQUIRE(!b); +} + BOOST_AUTO_TEST_SUITE_END() From 09c8fa4fafe01647d9ef2bcea7829950ab6d79c3 Mon Sep 17 00:00:00 2001 From: subtly Date: Thu, 6 Aug 2015 19:39:25 +0100 Subject: [PATCH 03/20] fix build --- secp256k1/libsecp256k1-config.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/secp256k1/libsecp256k1-config.h b/secp256k1/libsecp256k1-config.h index ac590cee7..0cbbc2434 100644 --- a/secp256k1/libsecp256k1-config.h +++ b/secp256k1/libsecp256k1-config.h @@ -83,9 +83,7 @@ #define STDC_HEADERS 1 /* Define this symbol to enable x86_64 assembly optimizations */ -// #if defined(__APPLE__) || defined(__GNUC__) -// #defined USE_ASM_X86_64 1 -// #endif +/* #undef USE_ASM_X86_64 */ /* Define this symbol to use endomorphism optimization */ /* #undef USE_ENDOMORPHISM */ From cc3aec606dfbaee80161c2f39bc5fe86fcdba03e Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 7 Aug 2015 09:24:50 +0200 Subject: [PATCH 04/20] set 50 shannon as default gasPrice --- alethzero/MainWin.cpp | 4 ++-- eth/main.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 35752680e..2451c1a64 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -860,8 +860,8 @@ void Main::readSettings(bool _skipGeometry) p->readSettings(s); }); - static_cast(ethereum()->gasPricer().get())->setAsk(u256(s.value("askPrice", "500000000000").toString().toStdString())); - static_cast(ethereum()->gasPricer().get())->setBid(u256(s.value("bidPrice", "500000000000").toString().toStdString())); + static_cast(ethereum()->gasPricer().get())->setAsk(u256(s.value("askPrice", "50000000000").toString().toStdString())); + static_cast(ethereum()->gasPricer().get())->setBid(u256(s.value("bidPrice", "50000000000").toString().toStdString())); ui->upnp->setChecked(s.value("upnp", true).toBool()); ui->forcePublicIP->setText(s.value("forceAddress", "").toString()); diff --git a/eth/main.cpp b/eth/main.cpp index 021a3c462..3d193b9be 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -153,8 +153,8 @@ void help() /*<< " -B,--block-fees Set the block fee profit in the reference unit e.g. ¢ (default: 15)." << endl << " -e,--ether-price Set the ether price in the reference unit e.g. ¢ (default: 30.679)." << endl << " -P,--priority <0 - 100> Default % priority of a transaction (default: 50)." << endl*/ - << " --ask Set the minimum ask gas price under which no transactions will be mined (default 500000000000)." << endl - << " --bid Set the bid gas price for to pay for transactions (default 500000000000)." << endl + << " --ask Set the minimum ask gas price under which no transactions will be mined (default 50000000000)." << endl + << " --bid Set the bid gas price for to pay for transactions (default 50000000000)." << endl << endl << "Client mining:" << endl << " -a,--address Set the coinbase (mining payout) address to addr (default: auto)." << endl @@ -373,8 +373,8 @@ int main(int argc, char** argv) TransactionPriority priority = TransactionPriority::Medium; // double etherPrice = 30.679; // double blockFees = 15.0; - u256 askPrice("500000000000"); - u256 bidPrice("500000000000"); + u256 askPrice = c_defaultGasPrice; + u256 bidPrice = c_defaultGasPrice; // javascript console bool useConsole = false; From 73a40ec96ffc30132bab18b9491a26b4c0a98c4a Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 7 Aug 2015 10:48:02 +0200 Subject: [PATCH 05/20] avoid using hard coded constants --- alethzero/MainWin.cpp | 5 ++--- eth/main.cpp | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 2451c1a64..a98ba6578 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -859,9 +859,8 @@ void Main::readSettings(bool _skipGeometry) { p->readSettings(s); }); - - static_cast(ethereum()->gasPricer().get())->setAsk(u256(s.value("askPrice", "50000000000").toString().toStdString())); - static_cast(ethereum()->gasPricer().get())->setBid(u256(s.value("bidPrice", "50000000000").toString().toStdString())); + static_cast(ethereum()->gasPricer().get())->setAsk(u256(s.value("askPrice", QString::fromStdString(boost::lexical_cast(c_defaultGasPrice))).toString().toStdString())); + static_cast(ethereum()->gasPricer().get())->setBid(u256(s.value("bidPrice", QString::fromStdString(boost::lexical_cast(c_defaultGasPrice))).toString().toStdString())); ui->upnp->setChecked(s.value("upnp", true).toBool()); ui->forcePublicIP->setText(s.value("forceAddress", "").toString()); diff --git a/eth/main.cpp b/eth/main.cpp index 3d193b9be..865f8caa7 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -153,8 +153,8 @@ void help() /*<< " -B,--block-fees Set the block fee profit in the reference unit e.g. ¢ (default: 15)." << endl << " -e,--ether-price Set the ether price in the reference unit e.g. ¢ (default: 30.679)." << endl << " -P,--priority <0 - 100> Default % priority of a transaction (default: 50)." << endl*/ - << " --ask Set the minimum ask gas price under which no transactions will be mined (default 50000000000)." << endl - << " --bid Set the bid gas price for to pay for transactions (default 50000000000)." << endl + << " --ask Set the minimum ask gas price under which no transactions will be mined (default " << boost::lexical_cast(c_defaultGasPrice) << " )." << endl + << " --bid Set the bid gas price for to pay for transactions (default " << boost::lexical_cast(c_defaultGasPrice) << " )." << endl << endl << "Client mining:" << endl << " -a,--address Set the coinbase (mining payout) address to addr (default: auto)." << endl From 46b706a6ef9d8b2e90fd72cddeba2ce36610c54f Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 7 Aug 2015 12:47:08 +0200 Subject: [PATCH 06/20] replace boost::lexical_cast with toString --- alethzero/MainWin.cpp | 4 ++-- eth/main.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index a98ba6578..c606a1d20 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -859,8 +859,8 @@ void Main::readSettings(bool _skipGeometry) { p->readSettings(s); }); - static_cast(ethereum()->gasPricer().get())->setAsk(u256(s.value("askPrice", QString::fromStdString(boost::lexical_cast(c_defaultGasPrice))).toString().toStdString())); - static_cast(ethereum()->gasPricer().get())->setBid(u256(s.value("bidPrice", QString::fromStdString(boost::lexical_cast(c_defaultGasPrice))).toString().toStdString())); + static_cast(ethereum()->gasPricer().get())->setAsk(u256(s.value("askPrice", QString::fromStdString(toString(c_defaultGasPrice))).toString().toStdString())); + static_cast(ethereum()->gasPricer().get())->setBid(u256(s.value("bidPrice", QString::fromStdString(toString(c_defaultGasPrice))).toString().toStdString())); ui->upnp->setChecked(s.value("upnp", true).toBool()); ui->forcePublicIP->setText(s.value("forceAddress", "").toString()); diff --git a/eth/main.cpp b/eth/main.cpp index 865f8caa7..4057e9303 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -153,8 +153,8 @@ void help() /*<< " -B,--block-fees Set the block fee profit in the reference unit e.g. ¢ (default: 15)." << endl << " -e,--ether-price Set the ether price in the reference unit e.g. ¢ (default: 30.679)." << endl << " -P,--priority <0 - 100> Default % priority of a transaction (default: 50)." << endl*/ - << " --ask Set the minimum ask gas price under which no transactions will be mined (default " << boost::lexical_cast(c_defaultGasPrice) << " )." << endl - << " --bid Set the bid gas price for to pay for transactions (default " << boost::lexical_cast(c_defaultGasPrice) << " )." << endl + << " --ask Set the minimum ask gas price under which no transactions will be mined (default " << toString(c_defaultGasPrice) << " )." << endl + << " --bid Set the bid gas price for to pay for transactions (default " << toString(c_defaultGasPrice) << " )." << endl << endl << "Client mining:" << endl << " -a,--address Set the coinbase (mining payout) address to addr (default: auto)." << endl From 1a4371e97d5ea99250578f2ea542a9e690d74f1c Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Fri, 7 Aug 2015 13:33:56 +0200 Subject: [PATCH 07/20] style update --- test/libwhisper/shhrpc.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/libwhisper/shhrpc.cpp b/test/libwhisper/shhrpc.cpp index ea02f2e1c..7729ec855 100644 --- a/test/libwhisper/shhrpc.cpp +++ b/test/libwhisper/shhrpc.cpp @@ -44,9 +44,9 @@ namespace js = json_spirit; WebThreeDirect* web3; unique_ptr jsonrpcServer; unique_ptr jsonrpcClient; -static uint16_t const g_web3port = 30333; -static string const g_version("shhrpc-web3"); -static unsigned const g_ttl = 777000; +static uint16_t const c_web3port = 30333; +static string const c_version("shhrpc-web3"); +static unsigned const c_ttl = 777000; struct Setup { @@ -58,8 +58,8 @@ struct Setup if (!setup) { setup = true; - NetworkPreferences nprefs(std::string(), g_web3port, false); - web3 = new WebThreeDirect(g_version, "", WithExisting::Trust, {"shh"}, nprefs); + NetworkPreferences nprefs(std::string(), c_web3port, false); + web3 = new WebThreeDirect(c_version, "", WithExisting::Trust, {"shh"}, nprefs); web3->setIdealPeerCount(1); auto server = new jsonrpc::HttpServer(8080); vector v; @@ -84,7 +84,7 @@ Json::Value createMessage(string const& _from, string const& _to, string const& Json::Value msg; msg["from"] = _from; msg["to"] = _to; - msg["ttl"] = toJS(g_ttl); + msg["ttl"] = toJS(c_ttl); if (_payload.empty()) _payload = string("0x") + h256::random().hex(); @@ -265,7 +265,7 @@ BOOST_AUTO_TEST_CASE(receive) BOOST_REQUIRE(host2.haveNetwork()); BOOST_REQUIRE(web3->haveNetwork()); - host2.addNode(web3->id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), g_web3port, g_web3port)); + host2.addNode(web3->id(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), c_web3port, c_web3port)); for (unsigned i = 0; i < 3000 && (!web3->peerCount() || !host2.peerCount()); i += step) this_thread::sleep_for(chrono::milliseconds(step)); @@ -276,7 +276,7 @@ BOOST_AUTO_TEST_CASE(receive) KeyPair us = KeyPair::create(); for (unsigned i = 0; i < messageCount; ++i) { - web3->whisper()->post(us.sec(), RLPStream().append(i * i * i).out(), BuildTopic(i)(i % 2 ? "odd" : "even"), g_ttl, 1); + web3->whisper()->post(us.sec(), RLPStream().append(i * i * i).out(), BuildTopic(i)(i % 2 ? "odd" : "even"), c_ttl, 1); this_thread::sleep_for(chrono::milliseconds(50)); } @@ -290,7 +290,7 @@ BOOST_AUTO_TEST_CASE(serverBasic) cnote << "Testing basic jsonrpc server..."; string s = jsonrpcServer->web3_clientVersion(); - BOOST_REQUIRE_EQUAL(s, g_version); + BOOST_REQUIRE_EQUAL(s, c_version); s = jsonrpcServer->net_version(); BOOST_REQUIRE(s.empty()); @@ -359,7 +359,7 @@ BOOST_AUTO_TEST_CASE(server) j = jsonrpcServer->admin_net_nodeInfo(sess2); BOOST_REQUIRE_EQUAL(j["id"].asString(), web3->id().hex()); - BOOST_REQUIRE_EQUAL(j["port"].asUInt(), g_web3port); + BOOST_REQUIRE_EQUAL(j["port"].asUInt(), c_web3port); uint16_t port2 = 30339; Host host2("shhrpc-host2", NetworkPreferences("127.0.0.1", port2, false)); @@ -445,7 +445,7 @@ BOOST_AUTO_TEST_CASE(server) j = jsonrpcServer->shh_getFilterChanges(filter); BOOST_REQUIRE(!j.empty()); Json::Value m1 = j[0]; - BOOST_REQUIRE_EQUAL(m1["ttl"], toJS(g_ttl)); + BOOST_REQUIRE_EQUAL(m1["ttl"], toJS(c_ttl)); BOOST_REQUIRE_EQUAL(m1["from"], id); BOOST_REQUIRE_EQUAL(m1["to"], id); BOOST_REQUIRE_EQUAL(m1["payload"], text); @@ -453,7 +453,7 @@ BOOST_AUTO_TEST_CASE(server) j = jsonrpcServer->shh_getMessages(filter); BOOST_REQUIRE(!j.empty()); Json::Value m2 = j[0]; - BOOST_REQUIRE_EQUAL(m2["ttl"], toJS(g_ttl)); + BOOST_REQUIRE_EQUAL(m2["ttl"], toJS(c_ttl)); BOOST_REQUIRE_EQUAL(m2["from"], id); BOOST_REQUIRE_EQUAL(m2["to"], id); BOOST_REQUIRE_EQUAL(m2["payload"], text); @@ -464,7 +464,7 @@ BOOST_AUTO_TEST_CASE(server) j = jsonrpcServer->shh_getMessages(filter); BOOST_REQUIRE(!j.empty()); m1 = j[0]; - BOOST_REQUIRE_EQUAL(m1["ttl"], toJS(g_ttl)); + BOOST_REQUIRE_EQUAL(m1["ttl"], toJS(c_ttl)); BOOST_REQUIRE_EQUAL(m1["from"], id); BOOST_REQUIRE_EQUAL(m1["to"], id); BOOST_REQUIRE_EQUAL(m1["payload"], text); From d75f8595dece344be508eecd66417c2344a8ed08 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 7 Aug 2015 14:31:27 +0200 Subject: [PATCH 08/20] Copy map before looping over it because it might be modified. --- libdevcore/CommonData.h | 18 ++++++++++++++++++ libethcore/Common.h | 12 ++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index 0faba8e8e..0556dc086 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -349,6 +349,24 @@ std::vector keysOf(std::unordered_map const& _m) return ret; } +template +std::vector valuesOf(std::map const& _m) +{ + std::vector ret(_m.size()); + for (auto const& i: _m) + ret.push_back(i.second); + return ret; +} + +template +std::vector valuesOf(std::unordered_map const& _m) +{ + std::vector ret(_m.size()); + for (auto const& i: _m) + ret.push_back(i.second); + return ret; +} + template bool contains(T const& _t, V const& _v) { diff --git a/libethcore/Common.h b/libethcore/Common.h index 883a14e9b..621a893f1 100644 --- a/libethcore/Common.h +++ b/libethcore/Common.h @@ -154,9 +154,9 @@ public: friend class Signal; public: - ~HandlerAux() { if (m_s) m_s->m_fire.erase(m_i); m_s = nullptr; } + ~HandlerAux() { if (m_s) m_s->m_fire.erase(m_i); } void reset() { m_s = nullptr; } - void fire(Args&&... _args) { m_h(std::forward(_args)...); } + void fire(Args const&... _args) { m_h(_args...); } private: HandlerAux(unsigned _i, Signal* _s, Callback const& _h): m_i(_i), m_s(_s), m_h(_h) {} @@ -181,11 +181,11 @@ public: return h; } - void operator()(Args&... _args) + void operator()(Args const&... _args) { - for (auto const& f: m_fire) - if (auto h = f.second.lock()) - h->fire(std::forward(_args)...); + for (auto const& f: valuesOf(m_fire)) + if (auto h = f.lock()) + h->fire(_args...); } private: From 958e5bcc9831fca36339edce850b3f89ea521031 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 6 Aug 2015 16:42:26 +0200 Subject: [PATCH 09/20] Ignore override warnings in Qt. --- libethereum/State.cpp | 2 -- libnatspec/NatspecExpressionEvaluator.h | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 955646f04..8329ff485 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -47,8 +47,6 @@ namespace fs = boost::filesystem; #define ctrace clog(StateTrace) #define ETH_TIMED_ENACTMENTS 0 -static const unsigned c_maxSyncTransactions = 256; - const char* StateSafeExceptions::name() { return EthViolet "⚙" EthBlue " ℹ"; } const char* StateDetail::name() { return EthViolet "⚙" EthWhite " ◌"; } const char* StateTrace::name() { return EthViolet "⚙" EthGray " ◎"; } diff --git a/libnatspec/NatspecExpressionEvaluator.h b/libnatspec/NatspecExpressionEvaluator.h index f7984f6e8..91d12399c 100644 --- a/libnatspec/NatspecExpressionEvaluator.h +++ b/libnatspec/NatspecExpressionEvaluator.h @@ -20,9 +20,11 @@ */ #pragma once - +#pragma warning(push) +#pragma clang diagnostic ignored "-Winconsistent-missing-override" #include #include +#pragma warning(pop) /** * Should be used to evaluate natspec expression. From 053c2989ea73fffd56e2e2cf24613aaf029fa642 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 7 Aug 2015 15:40:59 +0200 Subject: [PATCH 10/20] disable whisper tests which need networking --- test/libwhisper/whisperDB.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/libwhisper/whisperDB.cpp b/test/libwhisper/whisperDB.cpp index a62539bfd..e9f9b9e2a 100644 --- a/test/libwhisper/whisperDB.cpp +++ b/test/libwhisper/whisperDB.cpp @@ -130,6 +130,9 @@ BOOST_AUTO_TEST_CASE(persistence) BOOST_AUTO_TEST_CASE(messages) { + if (test::Options::get().nonetwork) + return; + cnote << "Testing load/save Whisper messages..."; VerbosityHolder setTemporaryLevel(2); unsigned const TestSize = 3; @@ -185,6 +188,9 @@ BOOST_AUTO_TEST_CASE(messages) BOOST_AUTO_TEST_CASE(corruptedData) { + if (test::Options::get().nonetwork) + return; + cnote << "Testing corrupted data..."; VerbosityHolder setTemporaryLevel(2); map m; @@ -211,6 +217,9 @@ BOOST_AUTO_TEST_CASE(corruptedData) BOOST_AUTO_TEST_CASE(filters) { + if (test::Options::get().nonetwork) + return; + cnote << "Testing filters saving..."; VerbosityHolder setTemporaryLevel(2); h256 persistID(0xC0FFEE); From 46f52550a23b5dffe651775f90b703999806292a Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Fri, 7 Aug 2015 15:43:07 +0200 Subject: [PATCH 11/20] Fixed self-overwriteing during assignment of secureFixedHash --- libdevcore/FixedHash.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index e0125b005..973bc174e 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -238,7 +238,14 @@ public: explicit SecureFixedHash(bytes const* _d, ConstructFromPointerType _t): FixedHash(_d, _t) {} ~SecureFixedHash() { ref().cleanse(); } - SecureFixedHash& operator=(SecureFixedHash const& _c) { ref().cleanse(); FixedHash::operator=(static_cast const&>(_c)); return *this; } + SecureFixedHash& operator=(SecureFixedHash const& _c) + { + if (&_c == this) + return *this; + ref().cleanse(); + FixedHash::operator=(static_cast const&>(_c)); + return *this; + } using FixedHash::size; From 534af4b802f230a0cf60316bf76b27bc2df23bab Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 7 Aug 2015 15:22:50 +0200 Subject: [PATCH 12/20] Reserve correctly. --- libdevcore/CommonData.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index 0556dc086..5f4b0a39e 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -352,7 +352,8 @@ std::vector keysOf(std::unordered_map const& _m) template std::vector valuesOf(std::map const& _m) { - std::vector ret(_m.size()); + std::vector ret; + ret.reserve(_m.size()); for (auto const& i: _m) ret.push_back(i.second); return ret; @@ -361,7 +362,8 @@ std::vector valuesOf(std::map const& _m) template std::vector valuesOf(std::unordered_map const& _m) { - std::vector ret(_m.size()); + std::vector ret; + ret.reserve(_m.size()); for (auto const& i: _m) ret.push_back(i.second); return ret; From 7f04b43595584e7dbbb3b0578e9599f98f1d4c94 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Fri, 7 Aug 2015 16:11:06 +0200 Subject: [PATCH 13/20] nonetwork check added --- test/libwhisper/shhrpc.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/libwhisper/shhrpc.cpp b/test/libwhisper/shhrpc.cpp index 7729ec855..05b769fc4 100644 --- a/test/libwhisper/shhrpc.cpp +++ b/test/libwhisper/shhrpc.cpp @@ -105,6 +105,9 @@ BOOST_FIXTURE_TEST_SUITE(shhrpc, Setup) BOOST_AUTO_TEST_CASE(basic) { + if (test::Options::get().nonetwork) + return; + cnote << "Testing web3 basic functionality..."; web3->startNetwork(); @@ -152,6 +155,9 @@ BOOST_AUTO_TEST_CASE(basic) BOOST_AUTO_TEST_CASE(send) { + if (test::Options::get().nonetwork) + return; + cnote << "Testing web3 send..."; bool sent = false; @@ -220,6 +226,9 @@ BOOST_AUTO_TEST_CASE(send) BOOST_AUTO_TEST_CASE(receive) { + if (test::Options::get().nonetwork) + return; + cnote << "Testing web3 receive..."; bool sent = false; @@ -287,6 +296,9 @@ BOOST_AUTO_TEST_CASE(receive) BOOST_AUTO_TEST_CASE(serverBasic) { + if (test::Options::get().nonetwork) + return; + cnote << "Testing basic jsonrpc server..."; string s = jsonrpcServer->web3_clientVersion(); @@ -322,6 +334,9 @@ BOOST_AUTO_TEST_CASE(serverBasic) BOOST_AUTO_TEST_CASE(server) { + if (test::Options::get().nonetwork) + return; + cnote << "Testing server functionality..."; bool b; From 80abbd491b47a5c686c9de436a62976fad188085 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 7 Aug 2015 16:24:28 +0200 Subject: [PATCH 14/20] compile fix, missing include --- test/libwhisper/whisperDB.cpp | 1 + test/libwhisper/whisperTopic.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/test/libwhisper/whisperDB.cpp b/test/libwhisper/whisperDB.cpp index e9f9b9e2a..892714393 100644 --- a/test/libwhisper/whisperDB.cpp +++ b/test/libwhisper/whisperDB.cpp @@ -24,6 +24,7 @@ along with cpp-ethereum. If not, see . #include #include #include +#include using namespace std; using namespace dev; diff --git a/test/libwhisper/whisperTopic.cpp b/test/libwhisper/whisperTopic.cpp index 6ee5076c4..39728fb17 100644 --- a/test/libwhisper/whisperTopic.cpp +++ b/test/libwhisper/whisperTopic.cpp @@ -389,6 +389,9 @@ BOOST_AUTO_TEST_CASE(topicAdvertising) BOOST_AUTO_TEST_CASE(selfAddressed) { + if (test::Options::get().nonetwork) + return; + VerbosityHolder setTemporaryLevel(10); cnote << "Testing self-addressed messaging with bloom filter matching..."; From 5dc39af3ac1f815cf067005fd3f30ba31020bae0 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Fri, 7 Aug 2015 16:54:01 +0200 Subject: [PATCH 15/20] nonetwork check added --- test/libp2p/net.cpp | 2 +- test/libwhisper/whisperDB.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/libp2p/net.cpp b/test/libp2p/net.cpp index 7ab8d00cc..f26907cf5 100644 --- a/test/libp2p/net.cpp +++ b/test/libp2p/net.cpp @@ -339,7 +339,7 @@ BOOST_AUTO_TEST_SUITE(netTypes) BOOST_AUTO_TEST_CASE(deadlineTimer) { - if (test::Options::get().nonetwork) + //if (test::Options::get().nonetwork) return; ba::io_service io; diff --git a/test/libwhisper/whisperDB.cpp b/test/libwhisper/whisperDB.cpp index a62539bfd..fb1fa2917 100644 --- a/test/libwhisper/whisperDB.cpp +++ b/test/libwhisper/whisperDB.cpp @@ -24,6 +24,7 @@ along with cpp-ethereum. If not, see . #include #include #include +#include using namespace std; using namespace dev; @@ -130,6 +131,9 @@ BOOST_AUTO_TEST_CASE(persistence) BOOST_AUTO_TEST_CASE(messages) { + if (test::Options::get().nonetwork) + return; + cnote << "Testing load/save Whisper messages..."; VerbosityHolder setTemporaryLevel(2); unsigned const TestSize = 3; @@ -211,6 +215,9 @@ BOOST_AUTO_TEST_CASE(corruptedData) BOOST_AUTO_TEST_CASE(filters) { + if (test::Options::get().nonetwork) + return; + cnote << "Testing filters saving..."; VerbosityHolder setTemporaryLevel(2); h256 persistID(0xC0FFEE); From bcabff431fadd6c5bcb73b0018aae58a34c0f63a Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Fri, 7 Aug 2015 17:03:58 +0200 Subject: [PATCH 16/20] a small update --- test/libwhisper/shhrpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libwhisper/shhrpc.cpp b/test/libwhisper/shhrpc.cpp index 05b769fc4..f14aea6b2 100644 --- a/test/libwhisper/shhrpc.cpp +++ b/test/libwhisper/shhrpc.cpp @@ -55,7 +55,7 @@ struct Setup dev::p2p::NodeIPEndpoint::test_allowLocal = true; static bool setup = false; - if (!setup) + if (!setup && !test::Options::get().nonetwork) { setup = true; NetworkPreferences nprefs(std::string(), c_web3port, false); From 3a0f5a7fc8333b0e463e6eecb3f46d646e0a7036 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Fri, 7 Aug 2015 17:07:56 +0200 Subject: [PATCH 17/20] bugfix --- test/libp2p/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libp2p/net.cpp b/test/libp2p/net.cpp index f26907cf5..7ab8d00cc 100644 --- a/test/libp2p/net.cpp +++ b/test/libp2p/net.cpp @@ -339,7 +339,7 @@ BOOST_AUTO_TEST_SUITE(netTypes) BOOST_AUTO_TEST_CASE(deadlineTimer) { - //if (test::Options::get().nonetwork) + if (test::Options::get().nonetwork) return; ba::io_service io; From 47cd2cfbfad12130bb81cf7df32844d255560951 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 7 Aug 2015 17:46:51 +0200 Subject: [PATCH 18/20] Don't trip up when can't change parent directory's permissions to the ideal. Don't show accounts that we don't have the keys for in AZ. --- alethzero/NatspecHandler.cpp | 2 +- libdevcore/CommonIO.cpp | 2 +- libdevcore/TransientDirectory.cpp | 2 +- libdevcrypto/SecretStore.cpp | 4 ++-- libdevcrypto/SecretStore.h | 3 +++ libethcore/KeyManager.cpp | 7 +++++-- libethereum/BlockChain.cpp | 2 +- libethereum/State.cpp | 4 +--- libethereum/Utility.cpp | 4 ++-- libweb3jsonrpc/WebThreeStubServer.cpp | 2 +- libwhisper/WhisperDB.cpp | 2 +- 11 files changed, 19 insertions(+), 15 deletions(-) diff --git a/alethzero/NatspecHandler.cpp b/alethzero/NatspecHandler.cpp index 6ed9f2b10..dc4a219ab 100644 --- a/alethzero/NatspecHandler.cpp +++ b/alethzero/NatspecHandler.cpp @@ -38,7 +38,7 @@ NatspecHandler::NatspecHandler() { string path = Defaults::dbPath(); fs::create_directories(path); - fs::permissions(path, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(path, fs::owner_all)); ldb::Options o; o.create_if_missing = true; ldb::DB::Open(o, path + "/natspec", &m_db); diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index 5c501fde7..3c3b08845 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -128,7 +128,7 @@ void dev::writeFile(std::string const& _file, bytesConstRef _data, bool _writeDe s.write(reinterpret_cast(_data.data()), _data.size()); if (!s) BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + _file)); - fs::permissions(_file, fs::owner_read|fs::owner_write); + DEV_IGNORE_EXCEPTIONS(fs::permissions(_file, fs::owner_read|fs::owner_write)); } } diff --git a/libdevcore/TransientDirectory.cpp b/libdevcore/TransientDirectory.cpp index 31a826c24..cd91bd0e4 100644 --- a/libdevcore/TransientDirectory.cpp +++ b/libdevcore/TransientDirectory.cpp @@ -41,7 +41,7 @@ TransientDirectory::TransientDirectory(std::string const& _path): BOOST_THROW_EXCEPTION(FileError()); fs::create_directories(m_path); - fs::permissions(m_path, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(m_path, fs::owner_all)); } TransientDirectory::~TransientDirectory() diff --git a/libdevcrypto/SecretStore.cpp b/libdevcrypto/SecretStore.cpp index 266f3735a..39f421f3e 100644 --- a/libdevcrypto/SecretStore.cpp +++ b/libdevcrypto/SecretStore.cpp @@ -148,7 +148,7 @@ void SecretStore::save(string const& _keysPath) { fs::path p(_keysPath); fs::create_directories(p); - fs::permissions(p, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(p, fs::owner_all)); for (auto& k: m_keys) { string uuid = toUUID(k.first); @@ -170,7 +170,7 @@ void SecretStore::load(string const& _keysPath) { fs::path p(_keysPath); fs::create_directories(p); - fs::permissions(p, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(p, fs::owner_all)); for (fs::directory_iterator it(p); it != fs::directory_iterator(); ++it) if (fs::is_regular_file(it->path())) readKey(it->path().string(), true); diff --git a/libdevcrypto/SecretStore.h b/libdevcrypto/SecretStore.h index fbc4c0bec..0fcb18734 100644 --- a/libdevcrypto/SecretStore.h +++ b/libdevcrypto/SecretStore.h @@ -70,6 +70,9 @@ public: /// Returns the uuids of all stored keys. std::vector keys() const { return keysOf(m_keys); } + /// @returns true iff we have the given key stored. + bool contains(h128 const& _k) const { return m_keys.count(_k); } + /// Clears all cached decrypted keys. The passwords have to be supplied in order to retrieve /// secrets again after calling this function. void clearCache() const; diff --git a/libethcore/KeyManager.cpp b/libethcore/KeyManager.cpp index 08892e453..8f3cd5e85 100644 --- a/libethcore/KeyManager.cpp +++ b/libethcore/KeyManager.cpp @@ -95,8 +95,11 @@ bool KeyManager::load(string const& _pass) { h128 uuid(i[1]); Address addr(i[0]); - m_addrLookup[addr] = uuid; - m_keyInfo[uuid] = KeyInfo(h256(i[2]), string(i[3])); + if (m_store.contains(uuid)) + { + m_addrLookup[addr] = uuid; + m_keyInfo[uuid] = KeyInfo(h256(i[2]), string(i[3])); + } // cdebug << toString(addr) << toString(uuid) << toString((h256)i[2]) << (string)i[3]; } diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 230eb39eb..b38db9c8b 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -180,7 +180,7 @@ unsigned BlockChain::openDatabase(std::string const& _path, WithExisting _we) string extrasPath = chainPath + "/" + toString(c_databaseVersion); fs::create_directories(extrasPath); - fs::permissions(extrasPath, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(extrasPath, fs::owner_all)); bytes status = contents(extrasPath + "/minor"); unsigned lastMinor = c_minorProtocolVersion; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 955646f04..b7367a64f 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -47,8 +47,6 @@ namespace fs = boost::filesystem; #define ctrace clog(StateTrace) #define ETH_TIMED_ENACTMENTS 0 -static const unsigned c_maxSyncTransactions = 256; - const char* StateSafeExceptions::name() { return EthViolet "⚙" EthBlue " ℹ"; } const char* StateDetail::name() { return EthViolet "⚙" EthWhite " ◌"; } const char* StateTrace::name() { return EthViolet "⚙" EthGray " ◎"; } @@ -85,7 +83,7 @@ OverlayDB State::openDB(std::string const& _basePath, h256 const& _genesisHash, path += "/" + toHex(_genesisHash.ref().cropped(0, 4)) + "/" + toString(c_databaseVersion); boost::filesystem::create_directories(path); - fs::permissions(path, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(path, fs::owner_all)); ldb::Options o; o.max_open_files = 256; diff --git a/libethereum/Utility.cpp b/libethereum/Utility.cpp index f34f66463..ac407999c 100644 --- a/libethereum/Utility.cpp +++ b/libethereum/Utility.cpp @@ -114,13 +114,13 @@ void dev::eth::upgradeDatabase(std::string const& _basePath, h256 const& _genesi if (!fs::exists(chainPath + "/blocks")) { fs::create_directories(chainPath); - fs::permissions(chainPath, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(chainPath, fs::owner_all)); fs::rename(path + "/blocks", chainPath + "/blocks"); if (!fs::exists(extrasPath + "/extras")) { fs::create_directories(extrasPath); - fs::permissions(extrasPath, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(extrasPath, fs::owner_all)); fs::rename(path + "/details", extrasPath + "/extras"); fs::rename(path + "/state", extrasPath + "/state"); writeFile(extrasPath + "/minor", rlp(minorProtocolVersion)); diff --git a/libweb3jsonrpc/WebThreeStubServer.cpp b/libweb3jsonrpc/WebThreeStubServer.cpp index 627f18d38..b5d8dc35f 100644 --- a/libweb3jsonrpc/WebThreeStubServer.cpp +++ b/libweb3jsonrpc/WebThreeStubServer.cpp @@ -59,7 +59,7 @@ WebThreeStubServer::WebThreeStubServer(jsonrpc::AbstractServerConnector& _conn, { auto path = getDataDir() + "/.web3"; fs::create_directories(path); - fs::permissions(path, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(path, fs::owner_all)); ldb::Options o; o.create_if_missing = true; ldb::DB::Open(o, path, &m_db); diff --git a/libwhisper/WhisperDB.cpp b/libwhisper/WhisperDB.cpp index 39d0629a7..ba3691a26 100644 --- a/libwhisper/WhisperDB.cpp +++ b/libwhisper/WhisperDB.cpp @@ -34,7 +34,7 @@ WhisperDB::WhisperDB(string const& _type) m_readOptions.verify_checksums = true; string path = dev::getDataDir("shh"); fs::create_directories(path); - fs::permissions(path, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(path, fs::owner_all)); path += "/" + _type; leveldb::Options op; op.create_if_missing = true; From bfc66d99063bddda14f0d76f5fea9225b7783af7 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 7 Aug 2015 18:05:29 +0200 Subject: [PATCH 19/20] Version bump. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d49bd76a3..f0b313164 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # cmake global cmake_minimum_required(VERSION 2.8.12) -set(PROJECT_VERSION "0.9.39") +set(PROJECT_VERSION "0.9.40") if (${CMAKE_VERSION} VERSION_GREATER 3.0) cmake_policy(SET CMP0042 OLD) # fix MACOSX_RPATH cmake_policy(SET CMP0048 NEW) # allow VERSION argument in project() From f07cd202f9e67ba88c14b67fa2f004e6e9d7a6c5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 7 Aug 2015 18:52:08 +0200 Subject: [PATCH 20/20] Fix for connecting to host without colon. --- libp2p/Network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libp2p/Network.cpp b/libp2p/Network.cpp index 7a3b50385..b44ac1e0a 100644 --- a/libp2p/Network.cpp +++ b/libp2p/Network.cpp @@ -216,7 +216,7 @@ bi::tcp::endpoint Network::resolveHost(string const& _addr) int givenPort; try { - givenPort = stoi(split[1]); + givenPort = stoi(split.at(1)); } catch (...) {