diff options
-rw-r--r-- | contrib/epee/include/net/levin_protocol_handler_async.h | 2 | ||||
-rw-r--r-- | contrib/epee/include/net/net_helper.h | 1 | ||||
-rw-r--r-- | contrib/epee/include/serialization/keyvalue_serialization.h | 3 | ||||
-rw-r--r-- | contrib/epee/include/serialization/keyvalue_serialization_overloads.h | 3 | ||||
-rw-r--r-- | contrib/epee/src/mlog.cpp | 2 | ||||
-rw-r--r-- | src/cryptonote_basic/hardfork.cpp | 5 | ||||
-rw-r--r-- | src/cryptonote_core/tx_sanity_check.cpp | 4 | ||||
-rw-r--r-- | src/daemonizer/windows_daemonizer.inl | 10 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 8 | ||||
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 2 | ||||
-rw-r--r-- | src/wallet/wallet_rpc_server_commands_defs.h | 6 | ||||
-rwxr-xr-x | tests/functional_tests/blockchain.py | 7 | ||||
-rwxr-xr-x | tests/functional_tests/cold_signing.py | 7 | ||||
-rwxr-xr-x | tests/functional_tests/mining.py | 7 | ||||
-rwxr-xr-x | tests/functional_tests/multisig.py | 7 | ||||
-rwxr-xr-x | tests/functional_tests/proofs.py | 7 | ||||
-rwxr-xr-x | tests/functional_tests/transfer.py | 7 | ||||
-rwxr-xr-x | tests/functional_tests/txpool.py | 7 | ||||
-rwxr-xr-x | tests/functional_tests/wallet_address.py | 8 | ||||
-rw-r--r-- | tests/unit_tests/logging.cpp | 3 |
20 files changed, 94 insertions, 12 deletions
diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h index a1ea3e680..116b3ace1 100644 --- a/contrib/epee/include/net/levin_protocol_handler_async.h +++ b/contrib/epee/include/net/levin_protocol_handler_async.h @@ -266,7 +266,7 @@ public: m_pservice_endpoint(psnd_hndlr), m_config(config), m_connection_context(conn_context), - m_cache_in_buffer(256 * 1024), + m_cache_in_buffer(4 * 1024), m_state(stream_state_head) { m_close_called = 0; diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h index 89cef8134..6387c4c34 100644 --- a/contrib/epee/include/net/net_helper.h +++ b/contrib/epee/include/net/net_helper.h @@ -448,6 +448,7 @@ namespace net_utils { MTRACE("Connection err_code eof."); //connection closed there, empty + buff.clear(); return true; } diff --git a/contrib/epee/include/serialization/keyvalue_serialization.h b/contrib/epee/include/serialization/keyvalue_serialization.h index fc5a21851..5459c8409 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization.h +++ b/contrib/epee/include/serialization/keyvalue_serialization.h @@ -32,6 +32,9 @@ #include "enableable.h" #include "keyvalue_serialization_overloads.h" +#undef MONERO_DEFAULT_LOG_CATEGORY +#define MONERO_DEFAULT_LOG_CATEGORY "serialization" + namespace epee { /************************************************************************/ diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h index 15c95f07a..fc8b90a2c 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h +++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h @@ -33,6 +33,9 @@ #include <boost/mpl/vector.hpp> #include <boost/mpl/contains_fwd.hpp> +#undef MONERO_DEFAULT_LOG_CATEGORY +#define MONERO_DEFAULT_LOG_CATEGORY "serialization" + namespace epee { namespace diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index 9b6b832d1..a8bfd114d 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -100,7 +100,7 @@ static const char *get_default_categories(int level) switch (level) { case 0: - categories = "*:WARNING,net:FATAL,net.http:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,stacktrace:INFO,logging:INFO,msgwriter:INFO"; + categories = "*:WARNING,net:FATAL,net.http:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,serialization:FATAL,stacktrace:INFO,logging:INFO,msgwriter:INFO"; break; case 1: categories = "*:INFO,global:INFO,stacktrace:INFO,logging:INFO,msgwriter:INFO,perf.*:DEBUG"; diff --git a/src/cryptonote_basic/hardfork.cpp b/src/cryptonote_basic/hardfork.cpp index d5710f727..98158a513 100644 --- a/src/cryptonote_basic/hardfork.cpp +++ b/src/cryptonote_basic/hardfork.cpp @@ -292,8 +292,7 @@ void HardFork::on_block_popped(uint64_t nblocks) const uint64_t new_chain_height = db.height(); const uint64_t old_chain_height = new_chain_height + nblocks; uint8_t version; - uint64_t height; - for (height = old_chain_height - 1; height >= new_chain_height; --height) + for (uint64_t height = old_chain_height - 1; height >= new_chain_height; --height) { version = versions.back(); last_versions[version]--; @@ -305,7 +304,7 @@ void HardFork::on_block_popped(uint64_t nblocks) // does not take voting into account for (current_fork_index = heights.size() - 1; current_fork_index > 0; --current_fork_index) - if (height >= heights[current_fork_index].height) + if (new_chain_height >= heights[current_fork_index].height) break; } diff --git a/src/cryptonote_core/tx_sanity_check.cpp b/src/cryptonote_core/tx_sanity_check.cpp index d3b225f1c..10198a3d3 100644 --- a/src/cryptonote_core/tx_sanity_check.cpp +++ b/src/cryptonote_core/tx_sanity_check.cpp @@ -34,7 +34,7 @@ #include "tx_sanity_check.h" #undef MONERO_DEFAULT_LOG_CATEGORY -#define MONERO_DEFAULT_LOG_CATEGORY "txsanity" +#define MONERO_DEFAULT_LOG_CATEGORY "verify" namespace cryptonote { @@ -80,7 +80,7 @@ bool tx_sanity_check(Blockchain &blockchain, const cryptonote::blobdata &tx_blob if (n_available < 10000) return true; - if (rct_indices.size() < n_indices * 9 / 10) + if (rct_indices.size() < n_indices * 8 / 10) { MERROR("unique indices is only " << rct_indices.size() << "/" << n_indices); return false; diff --git a/src/daemonizer/windows_daemonizer.inl b/src/daemonizer/windows_daemonizer.inl index 701c098f6..c6cd474fd 100644 --- a/src/daemonizer/windows_daemonizer.inl +++ b/src/daemonizer/windows_daemonizer.inl @@ -61,6 +61,10 @@ namespace daemonizer "run-as-service" , "Hidden -- true if running as windows service" }; + const command_line::arg_descriptor<bool> arg_non_interactive = { + "non-interactive" + , "Run non-interactive" + }; std::string get_argument_string(int argc, char const * argv[]) { @@ -83,6 +87,7 @@ namespace daemonizer command_line::add_arg(normal_options, arg_start_service); command_line::add_arg(normal_options, arg_stop_service); command_line::add_arg(hidden_options, arg_is_service); + command_line::add_arg(hidden_options, arg_non_interactive); } inline boost::filesystem::path get_default_data_dir() @@ -177,7 +182,10 @@ namespace daemonizer else // interactive { //LOG_PRINT_L0("Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL); - return executor.run_interactive(vm); + if (command_line::has_arg(vm, arg_non_interactive)) + return executor.run_non_interactive(vm); + else + return executor.run_interactive(vm); } return false; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 831166d5f..6554ef7d5 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -221,6 +221,8 @@ namespace add_reason(reason, "fee too low"); if (res.not_rct) add_reason(reason, "tx is not ringct"); + if (res.sanity_check_failed) + add_reason(reason, "tx sanity check failed"); if (res.not_relayed) add_reason(reason, "tx was not relayed"); return reason; @@ -3129,6 +3131,7 @@ void wallet2::refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blo } }); + auto scope_exit_handler_hwdev = epee::misc_utils::create_scope_leave_handler([&](){hwdev.computing_key_images(false);}); bool first = true; while(m_run.load(std::memory_order_relaxed)) { @@ -3254,7 +3257,6 @@ void wallet2::refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blo LOG_PRINT_L1("Failed to check pending transactions"); } - hwdev.computing_key_images(false); m_first_refresh_done = true; LOG_PRINT_L1("Refresh done, blocks received: " << blocks_fetched << ", balance (all accounts): " << print_money(balance_all()) << ", unlocked: " << print_money(unlocked_balance_all())); @@ -9534,7 +9536,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp tx.ptx = test_ptx; tx.weight = get_transaction_weight(test_tx, txBlob.size()); tx.outs = outs; - tx.needed_fee = needed_fee; + tx.needed_fee = test_ptx.fee; accumulated_fee += test_ptx.fee; accumulated_change += test_ptx.change_dts.amount; adding_fee = false; @@ -9932,7 +9934,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton tx.ptx = test_ptx; tx.weight = get_transaction_weight(test_tx, txBlob.size()); tx.outs = outs; - tx.needed_fee = needed_fee; + tx.needed_fee = test_ptx.fee; accumulated_fee += test_ptx.fee; accumulated_change += test_ptx.change_dts.amount; if (!unused_transfers_indices.empty() || !unused_dust_indices.empty()) diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index aaad82bb7..4076ae957 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1848,6 +1848,8 @@ namespace tools rpc_transfers.tx_hash = epee::string_tools::pod_to_hex(td.m_txid); rpc_transfers.subaddr_index = {td.m_subaddr_index.major, td.m_subaddr_index.minor}; rpc_transfers.key_image = td.m_key_image_known ? epee::string_tools::pod_to_hex(td.m_key_image) : ""; + rpc_transfers.block_height = td.m_block_height; + rpc_transfers.frozen = td.m_frozen; rpc_transfers.unlocked = m_wallet->is_transfer_unlocked(td); res.transfers.push_back(rpc_transfers); } diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h index 604bc4175..4504ac752 100644 --- a/src/wallet/wallet_rpc_server_commands_defs.h +++ b/src/wallet/wallet_rpc_server_commands_defs.h @@ -47,7 +47,7 @@ // advance which version they will stop working with // Don't go over 32767 for any of these #define WALLET_RPC_VERSION_MAJOR 1 -#define WALLET_RPC_VERSION_MINOR 12 +#define WALLET_RPC_VERSION_MINOR 13 #define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor)) #define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR) namespace tools @@ -982,6 +982,8 @@ namespace wallet_rpc std::string tx_hash; cryptonote::subaddress_index subaddr_index; std::string key_image; + uint64_t block_height; + bool frozen; bool unlocked; BEGIN_KV_SERIALIZE_MAP() @@ -991,6 +993,8 @@ namespace wallet_rpc KV_SERIALIZE(tx_hash) KV_SERIALIZE(subaddr_index) KV_SERIALIZE(key_image) + KV_SERIALIZE(block_height) + KV_SERIALIZE(frozen) KV_SERIALIZE(unlocked) END_KV_SERIALIZE_MAP() }; diff --git a/tests/functional_tests/blockchain.py b/tests/functional_tests/blockchain.py index 56164600d..6376b86d0 100755 --- a/tests/functional_tests/blockchain.py +++ b/tests/functional_tests/blockchain.py @@ -45,9 +45,16 @@ from framework.daemon import Daemon class BlockchainTest(): def run_test(self): + self.reset() self._test_generateblocks(5) self._test_alt_chains() + def reset(self): + print 'Resetting blockchain' + daemon = Daemon() + daemon.pop_blocks(1000) + daemon.flush_txpool() + def _test_generateblocks(self, blocks): assert blocks >= 2 diff --git a/tests/functional_tests/cold_signing.py b/tests/functional_tests/cold_signing.py index e5430f87c..59a879e0a 100755 --- a/tests/functional_tests/cold_signing.py +++ b/tests/functional_tests/cold_signing.py @@ -38,10 +38,17 @@ from framework.wallet import Wallet class ColdSigningTest(): def run_test(self): + self.reset() self.create(0) self.mine() self.transfer() + def reset(self): + print 'Resetting blockchain' + daemon = Daemon() + daemon.pop_blocks(1000) + daemon.flush_txpool() + def create(self, idx): print 'Creating hot and cold wallet' diff --git a/tests/functional_tests/mining.py b/tests/functional_tests/mining.py index 1b189beb2..78dc68640 100755 --- a/tests/functional_tests/mining.py +++ b/tests/functional_tests/mining.py @@ -43,9 +43,16 @@ from framework.wallet import Wallet class MiningTest(): def run_test(self): + self.reset() self.create() self.mine() + def reset(self): + print 'Resetting blockchain' + daemon = Daemon() + daemon.pop_blocks(1000) + daemon.flush_txpool() + def create(self): print 'Creating wallet' wallet = Wallet() diff --git a/tests/functional_tests/multisig.py b/tests/functional_tests/multisig.py index a61f30001..476e3a02d 100755 --- a/tests/functional_tests/multisig.py +++ b/tests/functional_tests/multisig.py @@ -38,6 +38,7 @@ from framework.wallet import Wallet class MultisigTest(): def run_test(self): + self.reset() self.mine('493DsrfJPqiN3Suv9RcRDoZEbQtKZX1sNcGPA3GhkKYEEmivk8kjQrTdRdVc4ZbmzWJuE157z9NNUKmF2VDfdYDR3CziGMk', 5) self.mine('42jSRGmmKN96V2j3B8X2DbiNThBXW1tSi1rW1uwkqbyURenq3eC3yosNm8HEMdHuWwKMFGzMUB3RCTvcTaW9kHpdRPP7p5y', 5) self.mine('47fF32AdrmXG84FcPY697uZdd42pMMGiH5UpiTRTt3YX2pZC7t7wkzEMStEicxbQGRfrYvAAYxH6Fe8rnD56EaNwUgxRd53', 5) @@ -68,6 +69,12 @@ class MultisigTest(): self.import_multisig_info([0, 1, 2, 3], 6) self.check_transaction(txid) + def reset(self): + print 'Resetting blockchain' + daemon = Daemon() + daemon.pop_blocks(1000) + daemon.flush_txpool() + def mine(self, address, blocks): print("Mining some blocks") daemon = Daemon() diff --git a/tests/functional_tests/proofs.py b/tests/functional_tests/proofs.py index 0a0b6304d..844131095 100755 --- a/tests/functional_tests/proofs.py +++ b/tests/functional_tests/proofs.py @@ -38,6 +38,7 @@ from framework.wallet import Wallet class ProofsTest(): def run_test(self): + self.reset() self.mine('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 80) self.create_wallets() txid, tx_key, amount = self.transfer() @@ -45,6 +46,12 @@ class ProofsTest(): self.check_tx_proof(txid, amount) self.check_reserve_proof() + def reset(self): + print 'Resetting blockchain' + daemon = Daemon() + daemon.pop_blocks(1000) + daemon.flush_txpool() + def mine(self, address, blocks): print("Mining some blocks") daemon = Daemon() diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py index bc2f5472b..1ff641d1f 100755 --- a/tests/functional_tests/transfer.py +++ b/tests/functional_tests/transfer.py @@ -39,6 +39,7 @@ from framework.wallet import Wallet class TransferTest(): def run_test(self): + self.reset() self.create() self.mine() self.transfer() @@ -46,6 +47,12 @@ class TransferTest(): self.check_double_spend_detection() self.sweep_single() + def reset(self): + print 'Resetting blockchain' + daemon = Daemon() + daemon.pop_blocks(1000) + daemon.flush_txpool() + def create(self): print 'Creating wallets' seeds = [ diff --git a/tests/functional_tests/txpool.py b/tests/functional_tests/txpool.py index 71109c9e5..d74395f10 100755 --- a/tests/functional_tests/txpool.py +++ b/tests/functional_tests/txpool.py @@ -38,10 +38,17 @@ from framework.wallet import Wallet class TransferTest(): def run_test(self): + self.reset() self.create() self.mine() self.check_txpool() + def reset(self): + print 'Resetting blockchain' + daemon = Daemon() + daemon.pop_blocks(1000) + daemon.flush_txpool() + def create(self): print 'Creating wallet' wallet = Wallet() diff --git a/tests/functional_tests/wallet_address.py b/tests/functional_tests/wallet_address.py index cb9c52e7a..8a55521c6 100755 --- a/tests/functional_tests/wallet_address.py +++ b/tests/functional_tests/wallet_address.py @@ -39,9 +39,11 @@ Test the following RPCs: """ from framework.wallet import Wallet +from framework.daemon import Daemon class WalletAddressTest(): def run_test(self): + self.reset() self.create() self.check_main_address() self.check_keys() @@ -49,6 +51,12 @@ class WalletAddressTest(): self.open_close() self.languages() + def reset(self): + print 'Resetting blockchain' + daemon = Daemon() + daemon.pop_blocks(1000) + daemon.flush_txpool() + def create(self): print 'Creating wallet' wallet = Wallet() diff --git a/tests/unit_tests/logging.cpp b/tests/unit_tests/logging.cpp index 12d49e2fb..056eae604 100644 --- a/tests/unit_tests/logging.cpp +++ b/tests/unit_tests/logging.cpp @@ -44,7 +44,10 @@ static void init() static void cleanup() { + // windows does not let files be deleted if still in use, so leave droppings there +#ifndef _WIN32 boost::filesystem::remove(log_filename); +#endif } static size_t nlines(const std::string &str) |