Merge branch 'feature/SONs-base' into feature/SON-307
This commit is contained in:
commit
d773dcb100
7 changed files with 75 additions and 16 deletions
|
|
@ -11,14 +11,17 @@ build:
|
||||||
- rm -rf .git/modules/* ./docs ./libraries/fc
|
- rm -rf .git/modules/* ./docs ./libraries/fc
|
||||||
- git submodule sync
|
- git submodule sync
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
- cmake .
|
- rm -rf build
|
||||||
|
- mkdir build
|
||||||
|
- cd build
|
||||||
|
- cmake ..
|
||||||
- make -j$(nproc)
|
- make -j$(nproc)
|
||||||
artifacts:
|
artifacts:
|
||||||
untracked: true
|
untracked: true
|
||||||
paths:
|
paths:
|
||||||
- libraries/
|
- build/libraries/
|
||||||
- programs/
|
- build/programs/
|
||||||
- tests/
|
- build/tests/
|
||||||
tags:
|
tags:
|
||||||
- builder
|
- builder
|
||||||
|
|
||||||
|
|
@ -27,9 +30,9 @@ test:
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build
|
||||||
script:
|
script:
|
||||||
- ./tests/betting_test --log_level=message
|
- ./build/tests/betting_test --log_level=message
|
||||||
- ./tests/chain_test --log_level=message
|
- ./build/tests/chain_test --log_level=message
|
||||||
- ./tests/cli_test --log_level=message
|
- ./build/tests/cli_test --log_level=message
|
||||||
tags:
|
tags:
|
||||||
- builder
|
- builder
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1844,7 +1844,10 @@ void perform_son_tasks(database& db)
|
||||||
{
|
{
|
||||||
const auto& son_account = db.create<account_object>([&](account_object& a) {
|
const auto& son_account = db.create<account_object>([&](account_object& a) {
|
||||||
a.name = "son-account";
|
a.name = "son-account";
|
||||||
a.statistics = db.create<account_statistics_object>([&](account_statistics_object& s){s.owner = a.id;}).id;
|
a.statistics = db.create<account_statistics_object>([&a](account_statistics_object& s){
|
||||||
|
s.owner = a.id;
|
||||||
|
s.name = a.name;
|
||||||
|
}).id;
|
||||||
a.owner.weight_threshold = 1;
|
a.owner.weight_threshold = 1;
|
||||||
a.active.weight_threshold = 0;
|
a.active.weight_threshold = 0;
|
||||||
a.registrar = a.lifetime_referrer = a.referrer = a.id;
|
a.registrar = a.lifetime_referrer = a.referrer = a.id;
|
||||||
|
|
|
||||||
|
|
@ -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
|
#ifndef HARDFORK_GPOS_TIME
|
||||||
#define HARDFORK_GPOS_TIME (fc::time_point_sec( 1577750400 ))
|
#define HARDFORK_GPOS_TIME (fc::time_point_sec( 1585569600 ))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// SON HARDFORK Wednesday, January 1, 2020 12:00:00 AM - 1577836800
|
// 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
|
// SON HARDFORK Monday, September 21, 2020 1:43:11 PM - 1600695791
|
||||||
#ifndef HARDFORK_SON_TIME
|
#ifndef HARDFORK_SON_TIME
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#define HARDFORK_SON_TIME (fc::time_point_sec( 1577836800 ))
|
#define HARDFORK_SON_TIME (fc::time_point_sec( 1585573200 ))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1339,6 +1339,25 @@ class wallet_api
|
||||||
flat_map<sidechain_type, string> sidechain_public_keys,
|
flat_map<sidechain_type, string> sidechain_public_keys,
|
||||||
bool broadcast = false);
|
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_type, string> sidechain_public_keys,
|
||||||
|
bool broadcast = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a SON object owned by the given account.
|
* Update a SON object owned by the given account.
|
||||||
*
|
*
|
||||||
|
|
@ -2298,6 +2317,7 @@ FC_API( graphene::wallet::wallet_api,
|
||||||
(list_witnesses)
|
(list_witnesses)
|
||||||
(list_committee_members)
|
(list_committee_members)
|
||||||
(create_son)
|
(create_son)
|
||||||
|
(try_create_son)
|
||||||
(update_son)
|
(update_son)
|
||||||
(delete_son)
|
(delete_son)
|
||||||
(list_sons)
|
(list_sons)
|
||||||
|
|
|
||||||
|
|
@ -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);
|
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_type, string> 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<vesting_balance_object_with_info> 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<dormant_vesting_policy>::value))
|
||||||
|
{
|
||||||
|
deposit_found = true;
|
||||||
|
deposit_id = vb.id;
|
||||||
|
}
|
||||||
|
if ((vb.balance_type == vesting_balance_type::normal) &&
|
||||||
|
(vb.policy.which() == vesting_policy::tag<linear_vesting_policy>::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,
|
signed_transaction wallet_api::update_son(string owner_account,
|
||||||
string url,
|
string url,
|
||||||
string block_signing_key,
|
string block_signing_key,
|
||||||
|
|
|
||||||
|
|
@ -205,8 +205,8 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
||||||
son_object son2_obj;
|
son_object son2_obj;
|
||||||
signed_transaction vote_son1_tx;
|
signed_transaction vote_son1_tx;
|
||||||
signed_transaction vote_son2_tx;
|
signed_transaction vote_son2_tx;
|
||||||
int son1_start_votes, son1_end_votes;
|
uint64_t son1_start_votes, son1_end_votes;
|
||||||
int son2_start_votes, son2_end_votes;
|
uint64_t son2_start_votes, son2_end_votes;
|
||||||
|
|
||||||
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
son1_start_votes = son1_obj.total_votes;
|
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 son1_obj;
|
||||||
son_object son2_obj;
|
son_object son2_obj;
|
||||||
int son1_start_votes, son1_end_votes;
|
uint64_t son1_start_votes, son1_end_votes;
|
||||||
int son2_start_votes, son2_end_votes;
|
uint64_t son2_start_votes, son2_end_votes;
|
||||||
|
|
||||||
// Get votes at start
|
// Get votes at start
|
||||||
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
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");
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
||||||
// voice distribution changed, SON2 now has all voices
|
// voice distribution changed, SON2 now has all voices
|
||||||
son2_end_votes = son2_obj.total_votes;
|
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;
|
son2_start_votes = son2_end_votes;
|
||||||
|
|
||||||
// Try to reject incorrect SON
|
// Try to reject incorrect SON
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue