Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default limits for get_full_accounts API #2190

Merged
merged 6 commits into from Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions docker/default_config.ini
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions libraries/app/application.cpp
Expand Up @@ -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<uint64_t>()->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<uint64_t>()->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<uint64_t>()->default_value(100),
"For database_api_impl::get_full_accounts to set max limit value")
("api-limit-get-full-accounts",boost::program_options::value<uint64_t>()->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<uint64_t>()->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<uint64_t>()->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<uint64_t>()->default_value(300),
Expand Down
4 changes: 2 additions & 2 deletions libraries/app/include/graphene/app/application.hpp
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tests/common/database_fixture.cpp
Expand Up @@ -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") {
Expand Down
86 changes: 58 additions & 28 deletions tests/tests/api_limit_tests.cpp
Expand Up @@ -76,46 +76,52 @@ 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<string> 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);
abitmore marked this conversation as resolved.
Show resolved Hide resolved

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());
accounts.push_back("nosuchaccount");

// 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()));
Expand Down Expand Up @@ -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<string> 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;
Expand Down
2 changes: 0 additions & 2 deletions tests/tests/database_api_tests.cpp
Expand Up @@ -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) );
Expand Down