diff --git a/docker/default_config.ini b/docker/default_config.ini index 53aa03bcfc..922fa6ea19 100644 --- a/docker/default_config.ini +++ b/docker/default_config.ini @@ -64,11 +64,11 @@ rpc-endpoint = 0.0.0.0:8090 # For database_api_impl::get_htlc_by_from and get_htlc_by_to to set max limit value # api-limit-get-htlc-by = 100 -# For database_api_impl::get_full_accounts to set max limit value -# api-limit-get-full-accounts = 10 +# For database_api_impl::get_full_accounts to set max accounts to query at once +# api-limit-get-full-accounts = 50 -# For database_api_impl::get_full_accounts to set max limit value -# api-limit-get-full-accounts-lists = 100 +# For database_api_impl::get_full_accounts to set max items to return in the lists +# api-limit-get-full-accounts-lists = 500 # For database_api_impl::get_call_orders and get_call_orders_by_account to set max limit value # api-limit-get-call-orders = 300 diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 6263ab1ec8..dd34e274bc 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -999,10 +999,10 @@ void application::set_program_options(boost::program_options::options_descriptio "For database_api_impl::get_key_references to set max limit value") ("api-limit-get-htlc-by",boost::program_options::value()->default_value(100), "For database_api_impl::get_htlc_by_from and get_htlc_by_to to set max limit value") - ("api-limit-get-full-accounts",boost::program_options::value()->default_value(10), - "For database_api_impl::get_full_accounts to set max limit value") - ("api-limit-get-full-accounts-lists",boost::program_options::value()->default_value(100), - "For database_api_impl::get_full_accounts to set max limit value") + ("api-limit-get-full-accounts",boost::program_options::value()->default_value(50), + "For database_api_impl::get_full_accounts to set max accounts to query at once") + ("api-limit-get-full-accounts-lists",boost::program_options::value()->default_value(500), + "For database_api_impl::get_full_accounts to set max items to return in the lists") ("api-limit-get-call-orders",boost::program_options::value()->default_value(300), "For database_api_impl::get_call_orders and get_call_orders_by_account to set max limit value") ("api-limit-get-settle-orders",boost::program_options::value()->default_value(300), diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 96e2d431ec..6446d3b70d 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -51,8 +51,8 @@ namespace graphene { namespace app { uint64_t api_limit_get_asset_holders = 100; uint64_t api_limit_get_key_references = 100; uint64_t api_limit_get_htlc_by = 100; - uint64_t api_limit_get_full_accounts = 10; - uint64_t api_limit_get_full_accounts_lists = 100; + uint64_t api_limit_get_full_accounts = 50; + uint64_t api_limit_get_full_accounts_lists = 500; uint64_t api_limit_get_call_orders = 300; uint64_t api_limit_get_settle_orders = 300; uint64_t api_limit_get_assets = 101; diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 9a0fe1759c..23f490b310 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -264,6 +264,8 @@ database_fixture::database_fixture(const fc::time_point_sec &initial_timestamp) { options.insert(std::make_pair("api-limit-get-full-accounts", boost::program_options::variable_value ((uint64_t)200, false))); + options.insert(std::make_pair("api-limit-get-full-accounts-lists", boost::program_options::variable_value + ((uint64_t)120, false))); } // add account tracking for ahplugin for special test case with track-account enabled if( !options.count("track-account") && current_test_name == "track_account") { diff --git a/tests/tests/api_limit_tests.cpp b/tests/tests/api_limit_tests.cpp index 5c332322a8..855d281d3d 100644 --- a/tests/tests/api_limit_tests.cpp +++ b/tests/tests/api_limit_tests.cpp @@ -76,38 +76,44 @@ BOOST_AUTO_TEST_CASE( api_limit_get_key_references ){ BOOST_AUTO_TEST_CASE( api_limit_get_full_accounts ) { try { - graphene::app::database_api db_api(db, &(this->app.get_options())); - - const account_object& alice = create_account("alice"); - const account_object& bob = create_account("bob"); - const account_object& carl = create_account("carl"); - const account_object& dan = create_account("dan"); - const account_object& fred = create_account("fred"); - const account_object& henry = create_account("henry"); - const account_object& kevin = create_account("kevin"); - const account_object& laura = create_account("laura"); - const account_object& lucy = create_account("lucy"); - const account_object& martin = create_account("martin"); - const account_object& patty = create_account("patty"); + ACTOR(alice); + + graphene::app::application_options opt = app.get_options(); + opt.has_api_helper_indexes_plugin = true; + graphene::app::database_api db_api( db, &opt ); vector accounts; - accounts.push_back(alice.name); - accounts.push_back(bob.name); - accounts.push_back(carl.name); - accounts.push_back(dan.name); - accounts.push_back(fred.name); - accounts.push_back(henry.name); - accounts.push_back(kevin.name); - accounts.push_back(laura.name); - accounts.push_back(lucy.name); - accounts.push_back(martin.name); - accounts.push_back(patty.name); + for( size_t i = 0; i < 50; ++i ) + { + string account_name = "testaccount" + fc::to_string(i); + create_account( account_name ); + accounts.push_back( account_name ); + } + accounts.push_back( "alice" ); + + transfer_operation op; + op.from = alice_id; + op.amount = asset(1); + for( size_t i = 0; i < 501; ++i ) + { + propose( op, alice_id ); + } + + // Too many accounts GRAPHENE_CHECK_THROW(db_api.get_full_accounts(accounts, false), fc::exception); accounts.erase(accounts.begin()); auto full_accounts = db_api.get_full_accounts(accounts, false); - BOOST_CHECK(full_accounts.size() == 10); + BOOST_CHECK(full_accounts.size() == 50); + + // The default max list size is 500 + BOOST_REQUIRE( full_accounts.find("alice") != full_accounts.end() ); + BOOST_CHECK_EQUAL( full_accounts["alice"].proposals.size(), 500u ); + BOOST_CHECK( full_accounts["alice"].more_data_available.proposals ); + BOOST_REQUIRE( full_accounts.find("testaccount9") != full_accounts.end() ); + BOOST_CHECK_EQUAL( full_accounts["testaccount9"].proposals.size(), 0 ); + BOOST_CHECK( !full_accounts["testaccount9"].more_data_available.proposals ); // not an account accounts.erase(accounts.begin()); @@ -115,7 +121,7 @@ BOOST_AUTO_TEST_CASE( api_limit_get_full_accounts ) { // non existing accounts will be ignored in the results full_accounts = db_api.get_full_accounts(accounts, false); - BOOST_CHECK(full_accounts.size() == 9); + BOOST_CHECK(full_accounts.size() == 49); } catch (fc::exception& e) { edump((e.to_detail_string())); @@ -262,17 +268,41 @@ BOOST_AUTO_TEST_CASE( api_limit_lookup_witness_accounts ) { BOOST_AUTO_TEST_CASE( api_limit_get_full_accounts2 ) { try { - graphene::app::database_api db_api(db, &(this->app.get_options())); + ACTOR(alice); + + graphene::app::application_options opt = app.get_options(); + opt.has_api_helper_indexes_plugin = true; + graphene::app::database_api db_api( db, &opt ); + vector accounts; - for (int i=0; i<201; i++) { + for (int i=0; i<200; i++) { std::string acct_name = "mytempacct" + std::to_string(i); const account_object& account_name=create_account(acct_name); accounts.push_back(account_name.name); } + accounts.push_back( "alice" ); + + transfer_operation op; + op.from = alice_id; + op.amount = asset(1); + for( size_t i = 0; i < 501; ++i ) + { + propose( op, alice_id ); + } + GRAPHENE_CHECK_THROW(db_api.get_full_accounts(accounts, false), fc::exception); accounts.erase(accounts.begin()); auto full_accounts = db_api.get_full_accounts(accounts, false); BOOST_REQUIRE_EQUAL(full_accounts.size(), 200u); + + // The updated max list size is 120 + BOOST_REQUIRE( full_accounts.find("alice") != full_accounts.end() ); + BOOST_CHECK_EQUAL( full_accounts["alice"].proposals.size(), 120u ); + BOOST_CHECK( full_accounts["alice"].more_data_available.proposals ); + BOOST_REQUIRE( full_accounts.find("mytempacct9") != full_accounts.end() ); + BOOST_CHECK_EQUAL( full_accounts["mytempacct9"].proposals.size(), 0 ); + BOOST_CHECK( !full_accounts["mytempacct9"].more_data_available.proposals ); + } catch (fc::exception& e) { edump((e.to_detail_string())); throw; diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 41f17216f0..7dbf2f73b2 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -1854,9 +1854,7 @@ BOOST_AUTO_TEST_CASE( get_trade_history ) ACTORS((bob)(alice)); const auto& eur = create_user_issued_asset("EUR"); - asset_id_type eur_id = eur.id; const auto& usd = create_user_issued_asset("USD"); - asset_id_type usd_id = usd.id; issue_uia( bob_id, usd.amount(1000000) ); issue_uia( alice_id, eur.amount(1000000) );