From b619815077c0be1d11136a67cec84b89016b63a8 Mon Sep 17 00:00:00 2001 From: serkixenos Date: Thu, 16 Dec 2021 17:37:51 -0400 Subject: [PATCH 1/6] Revert change to a son_update_operation --- libraries/app/application.cpp | 4 ++-- libraries/chain/include/graphene/chain/protocol/son.hpp | 3 +-- libraries/chain/son_evaluator.cpp | 5 +---- libraries/wallet/wallet.cpp | 1 - 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 713a204a..1ecdd8f7 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -859,11 +859,11 @@ application::~application() { void application::set_program_options(boost::program_options::options_description &cli, boost::program_options::options_description &cfg) const { - cfg.add_options()("p2p-endpoint", bpo::value(), "Endpoint for P2P node to listen on"); + cfg.add_options()("p2p-endpoint", bpo::value()->default_value("0.0.0.0:9777"), "Endpoint for P2P node to listen on"); cfg.add_options()("seed-node,s", bpo::value>()->composing(), "P2P nodes to connect to on startup (may specify multiple times)"); cfg.add_options()("seed-nodes", bpo::value()->composing(), "JSON array of P2P nodes to connect to on startup"); cfg.add_options()("checkpoint,c", bpo::value>()->composing(), "Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints."); - cfg.add_options()("rpc-endpoint", bpo::value()->implicit_value("127.0.0.1:8090"), "Endpoint for websocket RPC to listen on"); + cfg.add_options()("rpc-endpoint", bpo::value()->default_value("127.0.0.1:8090"), "Endpoint for websocket RPC to listen on"); cfg.add_options()("rpc-tls-endpoint", bpo::value()->implicit_value("127.0.0.1:8089"), "Endpoint for TLS websocket RPC to listen on"); cfg.add_options()("server-pem,p", bpo::value()->implicit_value("server.pem"), "The TLS certificate file for this server"); cfg.add_options()("server-pem-password,P", bpo::value()->implicit_value(""), "Password for this certificate"); diff --git a/libraries/chain/include/graphene/chain/protocol/son.hpp b/libraries/chain/include/graphene/chain/protocol/son.hpp index 42ead5b6..9d6ef653 100644 --- a/libraries/chain/include/graphene/chain/protocol/son.hpp +++ b/libraries/chain/include/graphene/chain/protocol/son.hpp @@ -33,7 +33,6 @@ namespace graphene { namespace chain { optional new_signing_key; optional> new_sidechain_public_keys; optional new_pay_vb; - optional new_status; account_id_type fee_payer()const { return owner_account; } share_type calculate_fee(const fee_parameters_type& k)const { return 0; } @@ -105,7 +104,7 @@ FC_REFLECT(graphene::chain::son_create_operation, (fee)(owner_account)(url)(depo FC_REFLECT(graphene::chain::son_update_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_update_operation, (fee)(son_id)(owner_account)(new_url)(new_deposit) - (new_signing_key)(new_sidechain_public_keys)(new_pay_vb)(new_status) ) + (new_signing_key)(new_sidechain_public_keys)(new_pay_vb) ) FC_REFLECT(graphene::chain::son_deregister_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_deregister_operation, (fee)(son_id)(payer) ) diff --git a/libraries/chain/son_evaluator.cpp b/libraries/chain/son_evaluator.cpp index e732c145..776eb065 100644 --- a/libraries/chain/son_evaluator.cpp +++ b/libraries/chain/son_evaluator.cpp @@ -79,9 +79,6 @@ void_result update_son_evaluator::do_evaluate(const son_update_operation& op) FC_ASSERT(vbo.policy.which() == vesting_policy::tag::value, "Payment balance must have linear vesting policy"); } - if(op.new_status.valid()) { - FC_ASSERT(db().get(op.son_id).status == son_status::deregistered, "SON must be in deregistered state"); - } return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } @@ -97,7 +94,7 @@ object_id_type update_son_evaluator::do_apply(const son_update_operation& op) if(op.new_signing_key.valid()) so.signing_key = *op.new_signing_key; if(op.new_sidechain_public_keys.valid()) so.sidechain_public_keys = *op.new_sidechain_public_keys; if(op.new_pay_vb.valid()) so.pay_vb = *op.new_pay_vb; - if(op.new_status.valid()) so.status = son_status::inactive; + if(so.status == son_status::deregistered) so.status = son_status::inactive; }); } return op.son_id; diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index cc013736..8edfbd65 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2122,7 +2122,6 @@ public: son_update_operation son_update_op; son_update_op.son_id = son.id; son_update_op.owner_account = son.son_account; - son_update_op.new_status = son_status::inactive; signed_transaction tx; tx.operations.push_back( son_update_op ); set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); From 0dca13ea7ee5206abbd6756cf0d305d69e58439b Mon Sep 17 00:00:00 2001 From: serkixenos Date: Thu, 16 Dec 2021 17:37:51 -0400 Subject: [PATCH 2/6] Revert change to a son_update_operation --- libraries/app/application.cpp | 4 ++-- libraries/chain/include/graphene/chain/protocol/son.hpp | 3 +-- libraries/chain/son_evaluator.cpp | 5 +---- libraries/wallet/wallet.cpp | 1 - 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 713a204a..1ecdd8f7 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -859,11 +859,11 @@ application::~application() { void application::set_program_options(boost::program_options::options_description &cli, boost::program_options::options_description &cfg) const { - cfg.add_options()("p2p-endpoint", bpo::value(), "Endpoint for P2P node to listen on"); + cfg.add_options()("p2p-endpoint", bpo::value()->default_value("0.0.0.0:9777"), "Endpoint for P2P node to listen on"); cfg.add_options()("seed-node,s", bpo::value>()->composing(), "P2P nodes to connect to on startup (may specify multiple times)"); cfg.add_options()("seed-nodes", bpo::value()->composing(), "JSON array of P2P nodes to connect to on startup"); cfg.add_options()("checkpoint,c", bpo::value>()->composing(), "Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints."); - cfg.add_options()("rpc-endpoint", bpo::value()->implicit_value("127.0.0.1:8090"), "Endpoint for websocket RPC to listen on"); + cfg.add_options()("rpc-endpoint", bpo::value()->default_value("127.0.0.1:8090"), "Endpoint for websocket RPC to listen on"); cfg.add_options()("rpc-tls-endpoint", bpo::value()->implicit_value("127.0.0.1:8089"), "Endpoint for TLS websocket RPC to listen on"); cfg.add_options()("server-pem,p", bpo::value()->implicit_value("server.pem"), "The TLS certificate file for this server"); cfg.add_options()("server-pem-password,P", bpo::value()->implicit_value(""), "Password for this certificate"); diff --git a/libraries/chain/include/graphene/chain/protocol/son.hpp b/libraries/chain/include/graphene/chain/protocol/son.hpp index 42ead5b6..9d6ef653 100644 --- a/libraries/chain/include/graphene/chain/protocol/son.hpp +++ b/libraries/chain/include/graphene/chain/protocol/son.hpp @@ -33,7 +33,6 @@ namespace graphene { namespace chain { optional new_signing_key; optional> new_sidechain_public_keys; optional new_pay_vb; - optional new_status; account_id_type fee_payer()const { return owner_account; } share_type calculate_fee(const fee_parameters_type& k)const { return 0; } @@ -105,7 +104,7 @@ FC_REFLECT(graphene::chain::son_create_operation, (fee)(owner_account)(url)(depo FC_REFLECT(graphene::chain::son_update_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_update_operation, (fee)(son_id)(owner_account)(new_url)(new_deposit) - (new_signing_key)(new_sidechain_public_keys)(new_pay_vb)(new_status) ) + (new_signing_key)(new_sidechain_public_keys)(new_pay_vb) ) FC_REFLECT(graphene::chain::son_deregister_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_deregister_operation, (fee)(son_id)(payer) ) diff --git a/libraries/chain/son_evaluator.cpp b/libraries/chain/son_evaluator.cpp index e732c145..776eb065 100644 --- a/libraries/chain/son_evaluator.cpp +++ b/libraries/chain/son_evaluator.cpp @@ -79,9 +79,6 @@ void_result update_son_evaluator::do_evaluate(const son_update_operation& op) FC_ASSERT(vbo.policy.which() == vesting_policy::tag::value, "Payment balance must have linear vesting policy"); } - if(op.new_status.valid()) { - FC_ASSERT(db().get(op.son_id).status == son_status::deregistered, "SON must be in deregistered state"); - } return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } @@ -97,7 +94,7 @@ object_id_type update_son_evaluator::do_apply(const son_update_operation& op) if(op.new_signing_key.valid()) so.signing_key = *op.new_signing_key; if(op.new_sidechain_public_keys.valid()) so.sidechain_public_keys = *op.new_sidechain_public_keys; if(op.new_pay_vb.valid()) so.pay_vb = *op.new_pay_vb; - if(op.new_status.valid()) so.status = son_status::inactive; + if(so.status == son_status::deregistered) so.status = son_status::inactive; }); } return op.son_id; diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index cc013736..8edfbd65 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2122,7 +2122,6 @@ public: son_update_operation son_update_op; son_update_op.son_id = son.id; son_update_op.owner_account = son.son_account; - son_update_op.new_status = son_status::inactive; signed_transaction tx; tx.operations.push_back( son_update_op ); set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); From f9a40c647ea444af14057333e3ba6ffec08e2fc9 Mon Sep 17 00:00:00 2001 From: serkixenos Date: Thu, 16 Dec 2021 22:27:34 -0400 Subject: [PATCH 3/6] Increase replay's writing to database threshold --- libraries/chain/db_management.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index cbf7f018..2ca49c4c 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -123,7 +123,7 @@ void database::reindex( fc::path data_dir ) } for( uint32_t i = head_block_num() + 1; i <= last_block_num; ++i ) { - if( i % 10000 == 0 ) + if( i % 1000000 == 0 ) { ilog( "Writing database to disk at block ${i}", ("i",i) ); flush(); From 5e85079281d3142391d90af33529a28c0bfee880 Mon Sep 17 00:00:00 2001 From: serkixenos Date: Mon, 27 Dec 2021 00:28:29 -0400 Subject: [PATCH 4/6] Fix cli wallet memo displaying --- libraries/wallet/wallet.cpp | 44 +++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 8edfbd65..ed069ebe 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -4184,27 +4184,33 @@ string operation_printer::operator()(const transfer_operation& op) const std::string memo; if( op.memo ) { - if( wallet.is_locked() ) - { - out << " -- Unlock wallet to see memo."; - } else { - try { - FC_ASSERT(wallet._keys.count(op.memo->to) || wallet._keys.count(op.memo->from), "Memo is encrypted to a key ${to} or ${from} not in this wallet.", ("to", op.memo->to)("from",op.memo->from)); - if( wallet._keys.count(op.memo->to) ) { - auto my_key = wif_to_key(wallet._keys.at(op.memo->to)); - FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted."); - memo = op.memo->get_message(*my_key, op.memo->from); - out << " -- Memo: " << memo; - } else { - auto my_key = wif_to_key(wallet._keys.at(op.memo->from)); - FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted."); - memo = op.memo->get_message(*my_key, op.memo->to); - out << " -- Memo: " << memo; + bool is_encrypted = ((op.memo->from != public_key_type()) && (op.memo->to != public_key_type())); + if (is_encrypted) { + if( wallet.is_locked() ) + { + out << " -- Unlock wallet to see memo."; + } else { + try { + FC_ASSERT(wallet._keys.count(op.memo->to) || wallet._keys.count(op.memo->from), "Memo is encrypted to a key ${to} or ${from} not in this wallet.", ("to", op.memo->to)("from",op.memo->from)); + if( wallet._keys.count(op.memo->to) ) { + auto my_key = wif_to_key(wallet._keys.at(op.memo->to)); + FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted."); + memo = op.memo->get_message(*my_key, op.memo->from); + out << " -- Memo: " << memo; + } else { + auto my_key = wif_to_key(wallet._keys.at(op.memo->from)); + FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted."); + memo = op.memo->get_message(*my_key, op.memo->to); + out << " -- Memo: " << memo; + } + } catch (const fc::exception& e) { + out << " -- could not decrypt memo"; + elog("Error when decrypting memo: ${e}", ("e", e.to_detail_string())); } - } catch (const fc::exception& e) { - out << " -- could not decrypt memo"; - elog("Error when decrypting memo: ${e}", ("e", e.to_detail_string())); } + } else { + memo = op.memo->get_message(private_key_type(), public_key_type()); + out << " -- Memo: " << memo; } } fee(op.fee); From 0bcb0487a797935d40c6cec13d6320a5e9491d87 Mon Sep 17 00:00:00 2001 From: serkixenos Date: Fri, 21 Jan 2022 12:17:13 -0400 Subject: [PATCH 5/6] Fix list_active_son command output on deregistered SONs --- libraries/wallet/wallet.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index ed069ebe..ae8b350e 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2202,11 +2202,8 @@ public: vector owners; for(auto obj: son_objects) { - if (obj) - { - std::string acc_id = account_id_to_string(obj->son_account); - owners.push_back(acc_id); - } + std::string acc_id = account_id_to_string(obj->son_account); + owners.push_back(acc_id); } vector< optional< account_object> > accs = _remote_db->get_accounts(owners); std::remove_if(son_objects.begin(), son_objects.end(), @@ -2216,9 +2213,7 @@ public: std::inserter(result, result.end()), [](fc::optional& acct, fc::optional son) { FC_ASSERT(acct, "Invalid active SONs list in global properties."); - if (son.valid() && son->status != son_status::deregistered) - return std::make_pair(string(acct->name), std::move(son->id)); - return std::make_pair(string(acct->name), std::move(son_id_type())); + return std::make_pair(string(acct->name), std::move(son->id)); }); return result; } FC_CAPTURE_AND_RETHROW() } From 8c3a424bb6942459281b53afabe395b720f67fe1 Mon Sep 17 00:00:00 2001 From: Vlad Dobromyslov Date: Fri, 28 Jan 2022 15:05:49 +0000 Subject: [PATCH 6/6] bug #267 Fix error in chain_test in gitlab autobuild --- libraries/db/include/graphene/db/undo_database.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/db/include/graphene/db/undo_database.hpp b/libraries/db/include/graphene/db/undo_database.hpp index 4b727372..0eb00f55 100644 --- a/libraries/db/include/graphene/db/undo_database.hpp +++ b/libraries/db/include/graphene/db/undo_database.hpp @@ -34,10 +34,10 @@ namespace graphene { namespace db { struct undo_state { - unordered_map > old_values; - unordered_map old_index_next_ids; - std::unordered_set new_ids; - unordered_map > removed; + unordered_map > old_values; + unordered_map old_index_next_ids; + std::set > new_ids; + unordered_map > removed; };