merge beatrice release delta changes into develop #603

Merged
sierra19XX merged 1 commit from feature/beatrice-changes-to-develop into develop 2021-06-18 09:09:02 +00:00
8 changed files with 16 additions and 141 deletions

View file

@ -248,9 +248,6 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
// Account Role
vector<account_role_object> get_account_roles_by_owner(account_id_type owner) const;
// rng
vector<uint64_t> get_random_number_ex(uint64_t minimum, uint64_t maximum, uint64_t selections, bool duplicates) const;
uint64_t get_random_number(uint64_t bound) const;
//private:
const account_object* get_account_from_string( const std::string& name_or_id,
@ -3192,31 +3189,6 @@ vector<account_role_object> database_api_impl::get_account_roles_by_owner(accoun
}
return result;
}
//////////////////////////////////////////////////////////////////////
// //
// Random numbers //
// //
//////////////////////////////////////////////////////////////////////
vector<uint64_t> database_api::get_random_number_ex(uint64_t minimum, uint64_t maximum, uint64_t selections, bool duplicates) const
{
return my->get_random_number_ex(minimum, maximum, selections, duplicates);
}
vector<uint64_t> database_api_impl::get_random_number_ex(uint64_t minimum, uint64_t maximum, uint64_t selections, bool duplicates) const
{
return _db.get_random_numbers(minimum, maximum, selections, duplicates);
}
uint64_t database_api::get_random_number(uint64_t bound) const
{
return my->get_random_number(bound);
}
uint64_t database_api_impl::get_random_number(uint64_t bound) const {
vector<uint64_t> v = get_random_number_ex(0, bound, 1, false);
return v.at(0);
}
//////////////////////////////////////////////////////////////////////
// //

View file

@ -943,26 +943,6 @@ class database_api
//////////////////
vector<account_role_object> get_account_roles_by_owner(account_id_type owner) const;
/////////////////////////////
// Random number generator //
/////////////////////////////
/**
* @brief Returns the random number
* @param minimum Lower bound of segment containing random number
* @param maximum Upper bound of segment containing random number
* @param selections Number of random numbers to return
* @param duplicates Allow duplicated numbers
* @return Vector containing random numbers from segment [minimum, maximum)
*/
vector<uint64_t> get_random_number_ex(uint64_t minimum, uint64_t maximum, uint64_t selections, bool duplicates) const;
/**
* @brief Returns the random number
* @param bound Upper bound of segment containing random number
* @return Random number from segment [0, bound)
*/
uint64_t get_random_number(uint64_t bound) const;
private:
std::shared_ptr< database_api_impl > my;
};
@ -1155,7 +1135,4 @@ FC_API(graphene::app::database_api,
// Account Roles
(get_account_roles_by_owner)
// rngs
(get_random_number_ex)
(get_random_number)
)

View file

@ -183,7 +183,7 @@ void database::pay_sons()
// Current requirement is that we have to pay every 24 hours, so the following check
if( dpo.son_budget.value > 0 && ((now - dpo.last_son_payout_time) >= fc::seconds(get_global_properties().parameters.son_pay_time()))) {
auto sons = sort_votable_objects<son_index>(get_global_properties().parameters.maximum_son_count());
// After NEXT HF
// After SON2 HF
uint64_t total_votes = 0;
for( const son_object& son : sons )
{
@ -194,32 +194,35 @@ void database::pay_sons()
uint16_t weight = std::max((son_votes >> bits_to_drop), uint64_t(1) );
return weight;
};
// Before NEXT HF
auto get_weight_next_hf = []( uint64_t son_votes ) {
// Before SON2 HF
auto get_weight_before_son2_hf = []( uint64_t son_votes ) {
int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(son_votes)) - 15, 0);
uint16_t weight = std::max((son_votes >> bits_to_drop), uint64_t(1) );
return weight;
};
uint64_t weighted_total_txs_signed = 0;
share_type son_budget = dpo.son_budget;
get_index_type<son_stats_index>().inspect_all_objects([this, &weighted_total_txs_signed, &get_weight, &now, &get_weight_next_hf](const object& o) {
get_index_type<son_stats_index>().inspect_all_objects([this, &weighted_total_txs_signed, &get_weight, &now, &get_weight_before_son2_hf](const object& o) {
const son_statistics_object& s = static_cast<const son_statistics_object&>(o);
const auto& idx = get_index_type<son_index>().indices().get<by_id>();
auto son_obj = idx.find( s.owner );
auto son_weight = get_weight(_vote_tally_buffer[son_obj->vote_id]);
if( now < HARDFORK_NEXT_TIME ) {
son_weight = get_weight_next_hf(_vote_tally_buffer[son_obj->vote_id]);
if( now < HARDFORK_SON2_TIME ) {
son_weight = get_weight_before_son2_hf(_vote_tally_buffer[son_obj->vote_id]);
}
weighted_total_txs_signed += (s.txs_signed * son_weight);
});
// Now pay off each SON proportional to the number of transactions signed.
get_index_type<son_stats_index>().inspect_all_objects([this, &weighted_total_txs_signed, &dpo, &son_budget, &get_weight](const object& o) {
get_index_type<son_stats_index>().inspect_all_objects([this, &weighted_total_txs_signed, &dpo, &son_budget, &get_weight, &get_weight_before_son2_hf, &now](const object& o) {
const son_statistics_object& s = static_cast<const son_statistics_object&>(o);
if(s.txs_signed > 0){
const auto& idx = get_index_type<son_index>().indices().get<by_id>();
auto son_obj = idx.find( s.owner );
auto son_weight = get_weight(_vote_tally_buffer[son_obj->vote_id]);
if( now < HARDFORK_SON2_TIME ) {
son_weight = get_weight_before_son2_hf(_vote_tally_buffer[son_obj->vote_id]);
}
share_type pay = (s.txs_signed * son_weight * son_budget.value)/weighted_total_txs_signed;
modify( *son_obj, [&]( son_object& _son_obj)
{
@ -1954,7 +1957,7 @@ void database::perform_son_tasks()
void update_son_asset(database& db)
{
if( db.head_block_time() >= HARDFORK_NEXT_TIME )
if( db.head_block_time() >= HARDFORK_SON2_TIME )
{
const auto& gpo = db.get_global_properties();
const asset_object& btc_asset = gpo.parameters.btc_asset()(db);

View file

@ -1,4 +0,0 @@
// NEXT HARDFORK Wednesday, March 17, 2021 23:00:00 GMT
#ifndef HARDFORK_NEXT_TIME
#define HARDFORK_NEXT_TIME (fc::time_point_sec( 1615982400 ))
#endif

View file

@ -0,0 +1,4 @@
// SON2 HARDFORK Friday, June 11, 2021 00:00:00 GMT
#ifndef HARDFORK_SON2_TIME
#define HARDFORK_SON2_TIME (fc::time_point_sec( 1623369600 ))
#endif

View file

@ -134,7 +134,7 @@ void peerplays_sidechain_plugin_impl::plugin_set_program_options(
cli.add_options()("bitcoin-wallet-password", bpo::value<string>(), "Bitcoin wallet password");
cli.add_options()("bitcoin-private-key", bpo::value<vector<string>>()->composing()->multitoken()->DEFAULT_VALUE_VECTOR(std::make_pair("02d0f137e717fb3aab7aff99904001d49a0a636c5e1342f8927a4ba2eaee8e9772", "cVN31uC9sTEr392DLVUEjrtMgLA8Yb3fpYmTRj7bomTm6nn2ANPr")),
"Tuple of [Bitcoin public key, Bitcoin private key] (may specify multiple times)");
cli.add_options()("sidechain-retry-threshold", bpo::value<uint16_t>()->default_value(15), "Sidechain retry throttling threshold");
cli.add_options()("sidechain-retry-threshold", bpo::value<uint16_t>()->default_value(150), "Sidechain retry throttling threshold");
cfg.add(cli);
}

View file

@ -1957,32 +1957,6 @@ class wallet_api
bool broadcast /* = false */
);
/** Get random numbers
* @brief Returns the random number
* @param minimum Lower bound of segment containing random number
* @param maximum Upper bound of segment containing random number
* @param selections Number of random numbers to return
* @param duplicates Allow duplicated numbers
* @param broadcast true if you wish to broadcast the transaction
* @return the signed version of the transaction
* @return Vector containing random numbers from segment [minimum, maximum)
*/
vector<uint64_t> get_random_number_ex(string account,
uint64_t minimum,
uint64_t maximum,
uint64_t selections,
bool duplicates,
bool broadcast);
/** Get random number
* @brief Returns the random number
* @param bound Upper bound of segment containing random number
* @return Random number from segment [0, bound)
*/
uint64_t get_random_number(string account,
uint64_t bound,
bool broadcast);
order_book get_order_book( const string& base, const string& quote, unsigned limit = 50);
asset get_total_matched_bet_amount_for_betting_market_group(betting_market_group_id_type group_id);
@ -2680,8 +2654,6 @@ FC_API( graphene::wallet::wallet_api,
(propose_fee_change)
(propose_dividend_asset_update)
(approve_proposal)
(get_random_number_ex)
(get_random_number)
(dbg_make_uia)
(dbg_make_mia)
(dbg_push_blocks)

View file

@ -3866,38 +3866,6 @@ public:
return _remote_db->get_active_custom_account_authorities_by_operation(get_account(owner).id, operation_type);
}
vector<uint64_t> get_random_number_ex(string account,
uint64_t minimum,
uint64_t maximum,
uint64_t selections,
bool duplicates,
bool broadcast)
{
vector<uint64_t> v = _remote_db->get_random_number_ex(minimum, maximum, selections, duplicates);
random_number_store_operation op;
op.account = get_account(account).id;
op.random_number = v;
op.data = "";
signed_transaction trx;
trx.operations.push_back(op);
set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees );
trx.validate();
sign_transaction( trx, broadcast );
return v;
}
uint64_t get_random_number(string account,
uint64_t bound,
bool broadcast)
{
vector<uint64_t> v = get_random_number_ex(account, 0, bound, 1, false, broadcast);
return v.at(0);
}
void dbg_make_uia(string creator, string symbol)
{
asset_options opts;
@ -5444,23 +5412,6 @@ vector<authority> wallet_api::get_active_custom_account_authorities_by_operation
return my->get_active_custom_account_authorities_by_operation(owner, operation_type);
}
vector<uint64_t> wallet_api::get_random_number_ex(string account,
uint64_t minimum,
uint64_t maximum,
uint64_t selections,
bool duplicates,
bool broadcast)
{
return my->get_random_number_ex( account, minimum, maximum, selections, duplicates, broadcast );
}
uint64_t wallet_api::get_random_number(string account,
uint64_t bound,
bool broadcast)
{
return my->get_random_number( account, bound, broadcast );
}
global_property_object wallet_api::get_global_properties() const
{
return my->get_global_properties();