diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bc2737be..f8ff07ca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,14 +11,17 @@ build: - rm -rf .git/modules/* ./docs ./libraries/fc - git submodule sync - git submodule update --init --recursive - - cmake . + - rm -rf build + - mkdir build + - cd build + - cmake .. - make -j$(nproc) artifacts: untracked: true paths: - - libraries/ - - programs/ - - tests/ + - build/libraries/ + - build/programs/ + - build/tests/ tags: - builder @@ -27,9 +30,9 @@ test: dependencies: - build script: - - ./tests/betting_test --log_level=message - - ./tests/chain_test --log_level=message - - ./tests/cli_test --log_level=message + - ./build/tests/betting_test --log_level=message + - ./build/tests/chain_test --log_level=message + - ./build/tests/cli_test --log_level=message tags: - builder diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 68f0e11d..5fa27338 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -1844,7 +1844,10 @@ void perform_son_tasks(database& db) { const auto& son_account = db.create([&](account_object& a) { a.name = "son-account"; - a.statistics = db.create([&](account_statistics_object& s){s.owner = a.id;}).id; + a.statistics = db.create([&a](account_statistics_object& s){ + s.owner = a.id; + s.name = a.name; + }).id; a.owner.weight_threshold = 1; a.active.weight_threshold = 0; a.registrar = a.lifetime_referrer = a.referrer = a.id; diff --git a/libraries/chain/hardfork.d/GPOS.hf b/libraries/chain/hardfork.d/GPOS.hf index 8e93f80f..991c35ac 100644 --- a/libraries/chain/hardfork.d/GPOS.hf +++ b/libraries/chain/hardfork.d/GPOS.hf @@ -1,4 +1,5 @@ -// GPOS HARDFORK Monday, 31 Dec 2019 00:00:00 GMT +// GPOS HARDFORK Monday, 31 Dec 2019 00:00:00 GMT - 1577750400 +// GPOS HARDFORK Monday, March 30, 2020 2:00:00 PM - 1585569600 #ifndef HARDFORK_GPOS_TIME -#define HARDFORK_GPOS_TIME (fc::time_point_sec( 1577750400 )) +#define HARDFORK_GPOS_TIME (fc::time_point_sec( 1585569600 )) #endif diff --git a/libraries/chain/hardfork.d/SON.hf b/libraries/chain/hardfork.d/SON.hf index 5c4e1e76..b3947a75 100644 --- a/libraries/chain/hardfork.d/SON.hf +++ b/libraries/chain/hardfork.d/SON.hf @@ -1,6 +1,7 @@ // SON HARDFORK Wednesday, January 1, 2020 12:00:00 AM - 1577836800 +// SON HARDFORK Monday, March 30, 2020 3:00:00 PM - 1585573200 // SON HARDFORK Monday, September 21, 2020 1:43:11 PM - 1600695791 #ifndef HARDFORK_SON_TIME #include -#define HARDFORK_SON_TIME (fc::time_point_sec( 1577836800 )) +#define HARDFORK_SON_TIME (fc::time_point_sec( 1585573200 )) #endif diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index ac7796e1..df4bfc3c 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -1339,6 +1339,25 @@ class wallet_api flat_map sidechain_public_keys, bool broadcast = false); + /** Creates a SON object owned by the given account. + * + * Tries to create a SON object owned by the given account using + * existing vesting balances, fails if can't quess matching + * vesting balance objects. If several vesting balance objects matches + * this function uses the recent one. + * + * @param owner_account the name or id of the account which is creating the SON + * @param url a URL to include in the SON record in the blockchain. Clients may + * display this when showing a list of SONs. May be blank. + * @param sidechain_public_keys The new set of sidechain public keys. + * @param broadcast true to broadcast the transaction on the network + * @returns the signed transaction registering a SON + */ + signed_transaction try_create_son(string owner_account, + string url, + flat_map sidechain_public_keys, + bool broadcast = false); + /** * Update a SON object owned by the given account. * @@ -2298,6 +2317,7 @@ FC_API( graphene::wallet::wallet_api, (list_witnesses) (list_committee_members) (create_son) + (try_create_son) (update_son) (delete_son) (list_sons) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 112afc1a..e6cd6291 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -4727,6 +4727,37 @@ signed_transaction wallet_api::create_son(string owner_account, return my->create_son(owner_account, url, deposit_id, pay_vb_id, sidechain_public_keys, broadcast); } +signed_transaction wallet_api::try_create_son(string owner_account, + string url, + flat_map sidechain_public_keys, + bool broadcast /* = false */) +{ + vesting_balance_id_type deposit_id; + bool deposit_found = false; + vesting_balance_id_type pay_vb_id; + bool pay_vb_found = false; + vector vbs = get_vesting_balances(owner_account); + for(const auto& vb: vbs) + { + if ((vb.balance_type == vesting_balance_type::son) && + (vb.get_asset_amount() >= my->get_global_properties().parameters.son_vesting_amount()) && + (vb.policy.which() == vesting_policy::tag::value)) + { + deposit_found = true; + deposit_id = vb.id; + } + if ((vb.balance_type == vesting_balance_type::normal) && + (vb.policy.which() == vesting_policy::tag::value)) + { + pay_vb_found = true; + pay_vb_id = vb.id; + } + } + if (!deposit_found || !pay_vb_found) + FC_THROW("Failed to find vesting balance objects"); + return my->create_son(owner_account, url, deposit_id, pay_vb_id, sidechain_public_keys, broadcast); +} + signed_transaction wallet_api::update_son(string owner_account, string url, string block_signing_key, diff --git a/tests/cli/son.cpp b/tests/cli/son.cpp index f640a1d7..d8eabf7d 100644 --- a/tests/cli/son.cpp +++ b/tests/cli/son.cpp @@ -205,8 +205,8 @@ BOOST_AUTO_TEST_CASE( son_voting ) son_object son2_obj; signed_transaction vote_son1_tx; signed_transaction vote_son2_tx; - int son1_start_votes, son1_end_votes; - int son2_start_votes, son2_end_votes; + uint64_t son1_start_votes, son1_end_votes; + uint64_t son2_start_votes, son2_end_votes; son1_obj = con.wallet_api_ptr->get_son("son1account"); son1_start_votes = son1_obj.total_votes; @@ -436,8 +436,8 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test ) son_object son1_obj; son_object son2_obj; - int son1_start_votes, son1_end_votes; - int son2_start_votes, son2_end_votes; + uint64_t son1_start_votes, son1_end_votes; + uint64_t son2_start_votes, son2_end_votes; // Get votes at start son1_obj = con.wallet_api_ptr->get_son("son1account"); @@ -488,7 +488,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test ) son2_obj = con.wallet_api_ptr->get_son("son2account"); // voice distribution changed, SON2 now has all voices son2_end_votes = son2_obj.total_votes; - BOOST_CHECK(son2_end_votes > son2_start_votes); + BOOST_CHECK((son2_end_votes > 0) && (son2_end_votes <= son2_start_votes)); // nathan spent funds for vb, it has different voting power son2_start_votes = son2_end_votes; // Try to reject incorrect SON