From 3af94b787847cbd9b547a6b1cd8b6be37bb2f917 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Mon, 4 Jan 2016 10:24:09 -0500 Subject: [PATCH 01/10] application.cpp: Handle exception in open() by re-indexing #492 --- libraries/app/application.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 0245ebcf..5be743a3 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -328,9 +328,27 @@ namespace detail { fc::read_file_contents( _data_dir / "db_version", version_str ); return (version_str != GRAPHENE_CURRENT_DB_VERSION); }; - if( !is_new() && is_outdated() ) + + bool need_reindex = (!is_new() && is_outdated()); + std::string reindex_reason = "version upgrade"; + + if( !need_reindex ) { - ilog("Replaying blockchain due to version upgrade"); + try + { + _chain_db->open(_data_dir / "blockchain", initial_state); + } + catch( const fc::exception& e ) + { + ilog( "caught exception ${e} in open()", ("e", e.to_detail_string()) ); + need_reindex = true; + reindex_reason = "exception in open()"; + } + } + + if( need_reindex ) + { + ilog("Replaying blockchain due to ${reason}", ("reason", reindex_reason) ); fc::remove_all( _data_dir / "db_version" ); _chain_db->reindex(_data_dir / "blockchain", initial_state()); @@ -346,8 +364,6 @@ namespace detail { db_version.write( version_string.c_str(), version_string.size() ); db_version.close(); } - } else { - _chain_db->open(_data_dir / "blockchain", initial_state); } } else { wlog("Detected unclean shutdown. Replaying blockchain..."); From 10a4dce501d4dd6a5ed7c9d07b3f5f5379401c61 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Thu, 28 Jan 2016 18:14:10 -0500 Subject: [PATCH 02/10] db_update.cpp: Don't update bitasset_data_object force_settled_volume every block unless needed #540 --- libraries/chain/db_update.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index 2b6ba2e7..8fc29dd2 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -357,9 +357,12 @@ void database::clear_expired_orders() break; } } - modify(mia, [settled](asset_bitasset_data_object& b) { - b.force_settled_volume = settled.amount; - }); + if( mia.force_settled_volume != settled.amount ) + { + modify(mia, [settled](asset_bitasset_data_object& b) { + b.force_settled_volume = settled.amount; + }); + } } } } From 10fca25acc6bb13b724bb31760df27afdad761b3 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Mon, 8 Feb 2016 01:23:01 -0500 Subject: [PATCH 03/10] database_fixture.cpp: Fix integer overflow bug waiting for zero blocks #559 --- tests/common/database_fixture.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index f7431f40..50c6ffcd 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -318,8 +318,10 @@ void database_fixture::generate_blocks(fc::time_point_sec timestamp, bool miss_i if( miss_intermediate_blocks ) { generate_block(); - auto slots_to_miss = db.get_slot_at_time(timestamp) - 1; - if( slots_to_miss <= 0 ) return; + auto slots_to_miss = db.get_slot_at_time(timestamp); + if( slots_to_miss <= 1 ) + return; + --slots_to_miss; generate_block(~0, init_account_priv_key, slots_to_miss); return; } From fe67b180657a7b79bd2b54ea21b2e89bc1ed4371 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Mon, 8 Feb 2016 15:28:39 -0500 Subject: [PATCH 04/10] js_operation_serializer: Add missing includes #466 #561 --- programs/js_operation_serializer/main.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index 9dec2f6b..8b9ca362 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -23,14 +23,19 @@ */ #include #include -#include -#include -#include -#include -#include + #include +#include #include #include +#include +#include +#include +#include +#include +#include +#include + #include #include From ba2f388f22ab8bbbacf1531ed2357e0c09eecebc Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 28 Jan 2016 11:20:43 +0100 Subject: [PATCH 05/10] Fix cancel_order: set fee after adding operation --- libraries/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 3858f4c1..eec7d840 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1914,8 +1914,8 @@ public: limit_order_cancel_operation op; op.fee_paying_account = get_object(order_id).seller; op.order = order_id; - set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); trx.operations = {op}; + set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); trx.validate(); return sign_transaction(trx, broadcast); From 8d2fa3863ee3eaa65b96ad8ef7cd825d62da0d5d Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 7 Feb 2016 16:58:29 +0100 Subject: [PATCH 06/10] Fix for #557: check BTC/PTS addresses on balance import including compressed/uncompressed versions --- libraries/wallet/wallet.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 3858f4c1..7e441e1a 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3356,7 +3356,17 @@ vector< signed_transaction > wallet_api_impl::import_balance( string name_or_id, { optional< private_key_type > key = wif_to_key( wif_key ); FC_ASSERT( key.valid(), "Invalid private key" ); - addrs.push_back( key->get_public_key() ); + fc::ecc::public_key pk = key->get_public_key(); + addrs.push_back( pk ); + keys[addrs.back()] = *key; + // see chain/balance_evaluator.cpp + addrs.push_back( pts_address( pk, false, 56 ) ); + keys[addrs.back()] = *key; + addrs.push_back( pts_address( pk, true, 56 ) ); + keys[addrs.back()] = *key; + addrs.push_back( pts_address( pk, false, 0 ) ); + keys[addrs.back()] = *key; + addrs.push_back( pts_address( pk, true, 0 ) ); keys[addrs.back()] = *key; } } From 19cf1b135b3cf74210ca57b7c7d34346f1efa7e0 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Tue, 9 Feb 2016 04:01:06 -0500 Subject: [PATCH 07/10] Fix withdraw_permission_object.hpp reflection #562 --- .../chain/include/graphene/chain/withdraw_permission_object.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp index 97ef23b4..172f4e28 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -93,4 +93,5 @@ FC_REFLECT_DERIVED( graphene::chain::withdraw_permission_object, (graphene::db:: (withdrawal_period_sec) (period_start_time) (expiration) + (claimed_this_period) ) From 3a968332e8c2922b5d14737ecf422b3a77ddda5e Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Tue, 9 Feb 2016 04:06:01 -0500 Subject: [PATCH 08/10] Remove active_witnesses from global_property_object #562 --- libraries/chain/db_init.cpp | 1 - libraries/chain/db_maint.cpp | 7 ------- .../include/graphene/chain/global_property_object.hpp | 1 - tests/tests/operation_tests.cpp | 5 +++-- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index ba2d07a6..2bb10b30 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -636,7 +636,6 @@ void database::init_genesis(const genesis_state_type& genesis_state) for( uint32_t i = 1; i <= genesis_state.initial_active_witnesses; ++i ) { p.active_witnesses.insert(i); - p.witness_accounts.insert(get(witness_id_type(i)).witness_account); } }); diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 807254a9..8403f181 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -213,13 +213,6 @@ void database::update_active_witnesses() [](const witness_object& w) { return w.id; }); - gp.witness_accounts.clear(); - gp.witness_accounts.reserve(wits.size()); - std::transform(wits.begin(), wits.end(), - std::inserter(gp.witness_accounts, gp.witness_accounts.end()), - [](const witness_object& w) { - return w.witness_account; - }); }); } FC_CAPTURE_AND_RETHROW() } diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index 61aecf97..6374b548 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -49,7 +49,6 @@ namespace graphene { namespace chain { vector active_committee_members; // updated once per maintenance interval flat_set active_witnesses; // updated once per maintenance interval // n.b. witness scheduling is done by witness_schedule object - flat_set witness_accounts; // updated once per maintenance interval }; /** diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index b85b3161..15f7e845 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -1137,8 +1137,9 @@ BOOST_AUTO_TEST_CASE( witness_feeds ) generate_block(); const asset_object& bit_usd = get_asset("USDBIT"); auto& global_props = db.get_global_properties(); - const vector active_witnesses(global_props.witness_accounts.begin(), - global_props.witness_accounts.end()); + vector active_witnesses; + for( const witness_id_type& wit_id : global_props.active_witnesses ) + active_witnesses.push_back( wit_id(db).witness_account ); BOOST_REQUIRE_EQUAL(active_witnesses.size(), 10); asset_publish_feed_operation op; From e8aeacc29331e7c301ce8a76c880dfe9153a179d Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Tue, 9 Feb 2016 04:36:41 -0500 Subject: [PATCH 09/10] operations.cpp: Remove unused ancient implementation of operation_get_required_authorities #537 --- libraries/chain/protocol/operations.cpp | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/libraries/chain/protocol/operations.cpp b/libraries/chain/protocol/operations.cpp index 26dbaaa1..366d62f7 100644 --- a/libraries/chain/protocol/operations.cpp +++ b/libraries/chain/protocol/operations.cpp @@ -35,29 +35,6 @@ void balance_claim_operation::validate()const FC_ASSERT( balance_owner_key != public_key_type() ); } -struct required_auth_visitor -{ - typedef void result_type; - - vector& result; - - required_auth_visitor( vector& r ):result(r){} - - /** for most operations this is a no-op */ - template - void operator()(const T& )const {} - - void operator()( const balance_claim_operation& o )const - { - result.push_back( authority( 1, o.balance_owner_key, 1 ) ); - } -}; - -void operation_get_required_authorities( const operation& op, vector& result ) -{ - op.visit( required_auth_visitor( result ) ); -} - /** * @brief Used to validate operations in a polymorphic manner */ From ababf24e694d1716d020250be603a003f10bb723 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Tue, 9 Feb 2016 07:59:22 -0500 Subject: [PATCH 10/10] Fix #523 relevant to #452 --- libraries/wallet/include/graphene/wallet/wallet.hpp | 2 +- libraries/wallet/wallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 952b1b33..c13bac9f 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -759,7 +759,7 @@ class wallet_api blind_confirmation transfer_to_blind( string from_account_id_or_name, string asset_symbol, /** map from key or label to amount */ - map to_amounts, + vector> to_amounts, bool broadcast = false ); /** diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 3858f4c1..aeebfa84 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3787,7 +3787,7 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name, string asset_symbol, /** map from key or label to amount */ - map to_amounts, + vector> to_amounts, bool broadcast ) { try { FC_ASSERT( !is_locked() );