From 5d48052da31f24b356957e7e54810a33d37e30f3 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 2 Sep 2020 14:16:06 -0500 Subject: [PATCH] Ref #381: Fixes Build and logic fixes for Pull Request #381 --- .../graphene/chain/protocol/transaction.hpp | 2 +- libraries/chain/proposal_evaluator.cpp | 11 +++++----- libraries/chain/protocol/transaction.cpp | 4 ++-- tests/tests/authority_tests.cpp | 22 ++++++++++--------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/libraries/chain/include/graphene/chain/protocol/transaction.hpp b/libraries/chain/include/graphene/chain/protocol/transaction.hpp index f1bad900..5dbb7752 100644 --- a/libraries/chain/include/graphene/chain/protocol/transaction.hpp +++ b/libraries/chain/include/graphene/chain/protocol/transaction.hpp @@ -205,7 +205,7 @@ namespace graphene { namespace chain { const std::function(account_id_type, const operation&)>& get_custom, bool ignore_custom_operation_required_auths, uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH, - bool allow_committe = false, + bool allow_committee = false, const flat_set& active_aprovals = flat_set(), const flat_set& owner_approvals = flat_set() ); diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 3f56d913..2a378d5f 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -207,16 +207,17 @@ struct proposal_operation_hardfork_visitor void_result proposal_create_evaluator::do_evaluate( const proposal_create_operation& o ) { try { const database& d = db(); + auto block_time = d.head_block_time(); - proposal_operation_hardfork_visitor vtor( d.head_block_time() ); + proposal_operation_hardfork_visitor vtor( block_time ); vtor( o ); const auto& global_parameters = d.get_global_properties().parameters; - FC_ASSERT( o.expiration_time > d.head_block_time(), "Proposal has already expired on creation." ); - FC_ASSERT( o.expiration_time <= d.head_block_time() + global_parameters.maximum_proposal_lifetime, + FC_ASSERT( o.expiration_time > block_time, "Proposal has already expired on creation." ); + FC_ASSERT( o.expiration_time <= block_time + global_parameters.maximum_proposal_lifetime, "Proposal expiration time is too far in the future."); - FC_ASSERT( !o.review_period_seconds || fc::seconds(*o.review_period_seconds) < (o.expiration_time - d.head_block_time()), + FC_ASSERT( !o.review_period_seconds || fc::seconds(*o.review_period_seconds) < (o.expiration_time - block_time), "Proposal review period must be less than its overall lifetime." ); { @@ -276,7 +277,7 @@ object_id_type proposal_create_evaluator::do_apply( const proposal_create_operat // TODO: consider caching values from evaluate? for( auto& op : _proposed_trx.operations ) operation_get_required_authorities( op, required_active, proposal.required_owner_approvals, other, - MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(block_time) ); + MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(chain_time) ); //All accounts which must provide both owner and active authority should be omitted from the active authority set; //owner authority approval implies active authority approval. diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/chain/protocol/transaction.cpp index 1bbb0c0b..b31c6795 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/chain/protocol/transaction.cpp @@ -254,7 +254,7 @@ void verify_authority( const vector& ops, const flat_set(account_id_type, const operation&)>& get_custom, bool ignore_custom_operation_required_auths, uint32_t max_recursion_depth, - bool allow_committe, + bool allow_committee, const flat_set& active_aprovals, const flat_set& owner_approvals ) { try { @@ -416,7 +416,7 @@ set signed_transaction::minimize_required_signatures( uint32_t max_recursion ) const { - set< public_key_type > s = get_required_signatures( chain_id, available_keys, get_active, get_owner, + set< public_key_type > s = get_required_signatures( chain_id, available_keys, get_active, get_owner, get_custom, ignore_custom_operation_required_auths, max_recursion ); flat_set< public_key_type > result( s.begin(), s.end() ); diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index 87425e29..387036df 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -1205,9 +1205,9 @@ BOOST_FIXTURE_TEST_CASE( get_required_signatures_test, database_fixture ) { //wdump( (tx)(available_keys) ); set result_set = tx.get_required_signatures(db.get_chain_id(), available_keys, - get_active, get_owner, false, false); + get_active, get_owner, get_custom, false); set result_set2 = tx.get_required_signatures(db.get_chain_id(), available_keys, - get_active, get_owner, true, false); + get_active, get_owner, get_custom, true); //wdump( (result_set)(result_set2)(ref_set) ); return result_set == ref_set && result_set2 == ref_set; } ; @@ -1330,9 +1330,9 @@ BOOST_FIXTURE_TEST_CASE( nonminimal_sig_test, database_fixture ) { //wdump( (tx)(available_keys) ); set result_set = tx.get_required_signatures(db.get_chain_id(), available_keys, - get_active, get_owner, false, false); + get_active, get_owner, get_custom, false); set result_set2 = tx.get_required_signatures(db.get_chain_id(), available_keys, - get_active, get_owner, true, false); + get_active, get_owner, get_custom, true); //wdump( (result_set)(result_set2)(ref_set) ); return result_set == ref_set && result_set2 == ref_set; } ; @@ -1345,9 +1345,9 @@ BOOST_FIXTURE_TEST_CASE( nonminimal_sig_test, database_fixture ) { //wdump( (tx)(available_keys) ); set result_set = tx.minimize_required_signatures(db.get_chain_id(), available_keys, - get_active, get_owner, false, false); + get_active, get_owner, get_custom, false); set result_set2 = tx.minimize_required_signatures(db.get_chain_id(), available_keys, - get_active, get_owner, true, false); + get_active, get_owner, get_custom, true); //wdump( (result_set)(result_set2)(ref_set) ); return result_set == ref_set && result_set2 == ref_set; } ; @@ -1366,11 +1366,13 @@ BOOST_FIXTURE_TEST_CASE( nonminimal_sig_test, database_fixture ) BOOST_CHECK( chk( tx, { alice_public_key, bob_public_key }, { alice_public_key, bob_public_key } ) ); BOOST_CHECK( chk_min( tx, { alice_public_key, bob_public_key }, { alice_public_key } ) ); - GRAPHENE_REQUIRE_THROW( tx.verify_authority( db.get_chain_id(), get_active, get_owner, false, false ), fc::exception ); - GRAPHENE_REQUIRE_THROW( tx.verify_authority( db.get_chain_id(), get_active, get_owner, true, false ), fc::exception ); + GRAPHENE_REQUIRE_THROW( tx.verify_authority( db.get_chain_id(), get_active, get_owner, get_custom, false ), + fc::exception ); + GRAPHENE_REQUIRE_THROW( tx.verify_authority( db.get_chain_id(), get_active, get_owner, get_custom, true ), + fc::exception ); sign( tx, alice_private_key ); - tx.verify_authority( db.get_chain_id(), get_active, get_owner, false, false ); - tx.verify_authority( db.get_chain_id(), get_active, get_owner, true, false ); + tx.verify_authority( db.get_chain_id(), get_active, get_owner, get_custom, false ); + tx.verify_authority( db.get_chain_id(), get_active, get_owner, get_custom, true ); } catch(fc::exception& e) {