Merge branch 'feature/SONs-base' into feature/SON-295

This commit is contained in:
Srdjan Obucina 2020-03-25 11:07:06 +01:00
commit b42aa51946
19 changed files with 130 additions and 84 deletions

View file

@ -197,7 +197,7 @@ std::set<son_id_type> database::get_sons_being_reported_down()
fc::optional<operation> database::create_son_deregister_proposal( son_id_type son_id, account_id_type paying_son )
{
son_delete_operation son_dereg_op;
son_dereg_op.payer = GRAPHENE_SON_ACCOUNT;
son_dereg_op.payer = get_global_properties().parameters.son_account();
son_dereg_op.son_id = son_id;
proposal_create_operation proposal_op;

View file

@ -458,16 +458,6 @@ void database::init_genesis(const genesis_state_type& genesis_state)
a.network_fee_percentage = 0;
a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT;
}).get_id() == GRAPHENE_RAKE_FEE_ACCOUNT_ID);
FC_ASSERT(create<account_object>([this](account_object& a) {
a.name = "son-account";
a.statistics = create<account_statistics_object>([&](account_statistics_object& s){s.owner = a.id;}).id;
a.owner.weight_threshold = 1;
a.active.weight_threshold = 0;
a.registrar = a.lifetime_referrer = a.referrer = GRAPHENE_SON_ACCOUNT;
a.membership_expiration_date = time_point_sec::maximum();
a.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT - GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
}).get_id() == GRAPHENE_SON_ACCOUNT);
// Create more special accounts
while( true )
{

View file

@ -138,7 +138,8 @@ void database::pay_sons()
if(s.txs_signed > 0){
auto son_params = get_global_properties().parameters;
share_type pay = (s.txs_signed * son_budget.value)/total_txs_signed;
// TODO: Remove me after QA
ilog( "pay ${p} to ${s} for ${t} transactions signed", ("p", pay.value)("s", s.id)("t",s.txs_signed) );
const auto& idx = get_index_type<son_index>().indices().get<by_id>();
auto son_obj = idx.find( s.owner );
modify( *son_obj, [&]( son_object& _son_obj)
@ -166,16 +167,30 @@ void database::pay_sons()
}
}
void database::update_son_metrics()
void database::update_son_metrics(const vector<son_info>& curr_active_sons)
{
vector<son_id_type> current_sons;
current_sons.reserve(curr_active_sons.size());
std::transform(curr_active_sons.begin(), curr_active_sons.end(),
std::inserter(current_sons, current_sons.end()),
[](const son_info &swi) {
return swi.son_id;
});
const auto& son_idx = get_index_type<son_index>().indices().get< by_id >();
for( auto& son : son_idx )
{
auto& stats = son.statistics(*this);
modify( stats, [&]( son_statistics_object& _stats)
bool is_active_son = (std::find(current_sons.begin(), current_sons.end(), son.id) != current_sons.end());
modify( stats, [&]( son_statistics_object& _stats )
{
_stats.total_downtime += _stats.current_interval_downtime;
_stats.current_interval_downtime = 0;
if(is_active_son)
{
_stats.total_voted_time = _stats.total_voted_time + get_global_properties().parameters.maintenance_interval;
}
});
}
}
@ -555,44 +570,48 @@ void database::update_active_sons()
}
// Update SON authority
modify( get(GRAPHENE_SON_ACCOUNT), [&]( account_object& a )
if( gpo.parameters.son_account() != GRAPHENE_NULL_ACCOUNT )
{
if( head_block_time() < HARDFORK_533_TIME )
modify( get(gpo.parameters.son_account()), [&]( account_object& a )
{
uint64_t total_votes = 0;
map<account_id_type, uint64_t> weights;
a.active.weight_threshold = 0;
a.active.account_auths.clear();
for( const son_object& son : sons )
if( head_block_time() < HARDFORK_533_TIME )
{
weights.emplace(son.son_account, _vote_tally_buffer[son.vote_id]);
total_votes += _vote_tally_buffer[son.vote_id];
}
uint64_t total_votes = 0;
map<account_id_type, uint64_t> weights;
a.active.weight_threshold = 0;
a.active.account_auths.clear();
// total_votes is 64 bits. Subtract the number of leading low bits from 64 to get the number of useful bits,
// then I want to keep the most significant 16 bits of what's left.
int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0);
for( const auto& weight : weights )
{
// Ensure that everyone has at least one vote. Zero weights aren't allowed.
uint16_t votes = std::max((weight.second >> bits_to_drop), uint64_t(1) );
a.active.account_auths[weight.first] += votes;
a.active.weight_threshold += votes;
for( const son_object& son : sons )
{
weights.emplace(son.son_account, _vote_tally_buffer[son.vote_id]);
total_votes += _vote_tally_buffer[son.vote_id];
}
// total_votes is 64 bits. Subtract the number of leading low bits from 64 to get the number of useful bits,
// then I want to keep the most significant 16 bits of what's left.
int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0);
for( const auto& weight : weights )
{
// Ensure that everyone has at least one vote. Zero weights aren't allowed.
uint16_t votes = std::max((weight.second >> bits_to_drop), uint64_t(1) );
a.active.account_auths[weight.first] += votes;
a.active.weight_threshold += votes;
}
a.active.weight_threshold *= 2;
a.active.weight_threshold /= 3;
a.active.weight_threshold += 1;
}
else
{
vote_counter vc;
for( const son_object& son : sons )
vc.add( son.son_account, std::max(_vote_tally_buffer[son.vote_id], UINT64_C(1)) );
vc.finish_2_3( a.active );
}
} );
}
a.active.weight_threshold *= 2;
a.active.weight_threshold /= 3;
a.active.weight_threshold += 1;
}
else
{
vote_counter vc;
for( const son_object& son : sons )
vc.add( son.son_account, std::max(_vote_tally_buffer[son.vote_id], UINT64_C(1)) );
vc.finish_2_3( a.active );
}
} );
// Compare current and to-be lists of active sons
auto cur_active_sons = gpo.active_sons;
@ -622,6 +641,9 @@ void database::update_active_sons()
update_son_statuses(cur_active_sons, new_active_sons);
}
// Update son performance metrics
update_son_metrics(cur_active_sons);
modify(gpo, [&]( global_property_object& gp ){
gp.active_sons.clear();
gp.active_sons.reserve(new_active_sons.size());
@ -640,9 +662,6 @@ void database::update_active_sons()
});
_sso.scheduler.update(active_sons);
});
update_son_metrics();
} FC_CAPTURE_AND_RETHROW() }
void database::initialize_budget_record( fc::time_point_sec now, budget_record& rec )const
@ -1558,6 +1577,30 @@ void process_dividend_assets(database& db)
}
} FC_CAPTURE_AND_RETHROW() }
void perform_son_tasks(database& db)
{
const global_property_object& gpo = db.get_global_properties();
if(gpo.parameters.son_account() == GRAPHENE_NULL_ACCOUNT && db.head_block_time() >= HARDFORK_SON_TIME)
{
const auto& son_account = db.create<account_object>([&](account_object& a) {
a.name = "son-account";
a.statistics = db.create<account_statistics_object>([&](account_statistics_object& s){s.owner = a.id;}).id;
a.owner.weight_threshold = 1;
a.active.weight_threshold = 0;
a.registrar = a.lifetime_referrer = a.referrer = a.id;
a.membership_expiration_date = time_point_sec::maximum();
a.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT - GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
});
db.modify( gpo, [&]( global_property_object& gpo ) {
gpo.parameters.extensions.value.son_account = son_account.get_id();
if( gpo.pending_parameters )
gpo.pending_parameters->extensions.value.son_account = son_account.get_id();
});
}
}
void database::perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props)
{ try {
const auto& gpo = get_global_properties();
@ -1566,6 +1609,7 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
create_buyback_orders(*this);
process_dividend_assets(*this);
perform_son_tasks(*this);
struct vote_tally_helper {
database& d;

View file

@ -110,7 +110,6 @@ fc::variant_object get_config()
result[ "GRAPHENE_TEMP_ACCOUNT" ] = fc::variant(GRAPHENE_TEMP_ACCOUNT, GRAPHENE_MAX_NESTED_OBJECTS);
result[ "GRAPHENE_PROXY_TO_SELF_ACCOUNT" ] = fc::variant(GRAPHENE_TEMP_ACCOUNT, GRAPHENE_MAX_NESTED_OBJECTS);
result[ "GRAPHENE_RAKE_FEE_ACCOUNT_ID" ] = fc::variant(GRAPHENE_TEMP_ACCOUNT, GRAPHENE_MAX_NESTED_OBJECTS);
result[ "GRAPHENE_SON_ACCOUNT" ] = fc::variant(GRAPHENE_TEMP_ACCOUNT, GRAPHENE_MAX_NESTED_OBJECTS);
result[ "GRAPHENE_NULL_WITNESS" ] = fc::variant(GRAPHENE_TEMP_ACCOUNT, GRAPHENE_MAX_NESTED_OBJECTS);
result[ "GRAPHENE_FBA_STEALTH_DESIGNATED_ASSET" ] = fc::variant(GRAPHENE_TEMP_ACCOUNT, GRAPHENE_MAX_NESTED_OBJECTS);
result[ "GRAPHENE_DEFAULT_RAKE_FEE_PERCENTAGE" ] = fc::variant(GRAPHENE_TEMP_ACCOUNT, GRAPHENE_MAX_NESTED_OBJECTS);

View file

@ -175,8 +175,6 @@
#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::chain::account_id_type(5))
///
#define GRAPHENE_RAKE_FEE_ACCOUNT_ID (graphene::chain::account_id_type(6))
///
#define GRAPHENE_SON_ACCOUNT (graphene::chain::account_id_type(7))
/// Sentinel value used in the scheduler.
#define GRAPHENE_NULL_WITNESS (graphene::chain::witness_id_type(0))
///@}

View file

@ -546,7 +546,7 @@ namespace graphene { namespace chain {
void perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props);
void update_active_witnesses();
void update_active_committee_members();
void update_son_metrics();
void update_son_metrics( const vector<son_info>& curr_active_sons );
void update_active_sons();
void remove_son_proposal( const proposal_object& proposal );
void remove_inactive_son_down_proposals( const vector<son_id_type>& son_ids_to_remove );

View file

@ -50,6 +50,7 @@ namespace graphene { namespace chain {
optional < uint32_t > son_deregister_time;
optional < uint32_t > son_heartbeat_frequency;
optional < uint32_t > son_down_time;
optional < account_id_type > son_account;
};
struct chain_parameters
@ -154,6 +155,9 @@ namespace graphene { namespace chain {
inline uint16_t son_down_time()const {
return extensions.value.son_down_time.valid() ? *extensions.value.son_down_time : SON_DOWN_TIME;
}
inline account_id_type son_account() const {
return extensions.value.son_account.valid() ? *extensions.value.son_account : GRAPHENE_NULL_ACCOUNT;
}
};
} } // graphene::chain
@ -175,6 +179,7 @@ FC_REFLECT( graphene::chain::parameter_extension,
(son_deregister_time)
(son_heartbeat_frequency)
(son_down_time)
(son_account)
)
FC_REFLECT( graphene::chain::chain_parameters,

View file

@ -34,6 +34,8 @@ namespace graphene { namespace chain {
uint64_t total_txs_signed = 0;
// Transactions signed since the last son payouts
uint64_t txs_signed = 0;
// Total Voted Active time i.e. duration selected as part of voted active SONs
uint64_t total_voted_time = 0;
// Total Downtime barring the current down time in seconds, used for stats to present to user
uint64_t total_downtime = 0;
// Current Interval Downtime since last maintenance
@ -117,6 +119,7 @@ FC_REFLECT_DERIVED( graphene::chain::son_statistics_object,
(owner)
(total_txs_signed)
(txs_signed)
(total_voted_time)
(total_downtime)
(current_interval_downtime)
(last_down_timestamp)

View file

@ -11,7 +11,7 @@ namespace graphene { namespace chain {
void_result sidechain_transaction_create_evaluator::do_evaluate(const sidechain_transaction_create_operation &op)
{ try {
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
FC_ASSERT((op.object_id.is<son_wallet_id_type>() || op.object_id.is<son_wallet_deposit_id_type>() || op.object_id.is<son_wallet_withdraw_id_type>()), "Invalid object id");

View file

@ -67,7 +67,7 @@ void_result delete_son_evaluator::do_evaluate(const son_delete_operation& op)
{ try {
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON_HARDFORK"); // can be removed after HF date pass
// Either owner can remove or consensus son account
FC_ASSERT(op.payer == db().get(op.son_id).son_account || (db().is_son_dereg_valid(op.son_id) && op.payer == GRAPHENE_SON_ACCOUNT));
FC_ASSERT(op.payer == db().get(op.son_id).son_account || (db().is_son_dereg_valid(op.son_id) && op.payer == db().get_global_properties().parameters.son_account()));
const auto& idx = db().get_index_type<son_index>().indices().get<by_id>();
FC_ASSERT( idx.find(op.son_id) != idx.end() );
return void_result();
@ -167,7 +167,7 @@ object_id_type son_heartbeat_evaluator::do_apply(const son_heartbeat_operation&
void_result son_report_down_evaluator::do_evaluate(const son_report_down_operation& op)
{ try {
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); // can be removed after HF date pass
FC_ASSERT(op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer.");
FC_ASSERT(op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer.");
const auto& idx = db().get_index_type<son_index>().indices().get<by_id>();
FC_ASSERT( idx.find(op.son_id) != idx.end() );
auto itr = idx.find(op.son_id);

View file

@ -10,7 +10,7 @@ namespace graphene { namespace chain {
void_result create_son_wallet_deposit_evaluator::do_evaluate(const son_wallet_deposit_create_operation& op)
{ try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
const auto &idx = db().get_index_type<son_stats_index>().indices().get<by_owner>();
FC_ASSERT(idx.find(op.son_id) != idx.end(), "Statistic object for a given SON ID does not exists");
@ -69,7 +69,7 @@ object_id_type create_son_wallet_deposit_evaluator::do_apply(const son_wallet_de
void_result process_son_wallet_deposit_evaluator::do_evaluate(const son_wallet_deposit_process_operation& op)
{ try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
const auto& idx = db().get_index_type<son_wallet_deposit_index>().indices().get<by_id>();
const auto& itr = idx.find(op.son_wallet_deposit_id);

View file

@ -8,7 +8,7 @@ namespace graphene { namespace chain {
void_result recreate_son_wallet_evaluator::do_evaluate(const son_wallet_recreate_operation& op)
{ try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
const auto& idx = db().get_index_type<son_wallet_index>().indices().get<by_id>();
auto itr = idx.rbegin();
@ -53,7 +53,7 @@ object_id_type recreate_son_wallet_evaluator::do_apply(const son_wallet_recreate
void_result update_son_wallet_evaluator::do_evaluate(const son_wallet_update_operation& op)
{ try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
const auto& idx = db().get_index_type<son_wallet_index>().indices().get<by_id>();
FC_ASSERT( idx.find(op.son_wallet_id) != idx.end() );

View file

@ -10,7 +10,7 @@ namespace graphene { namespace chain {
void_result create_son_wallet_withdraw_evaluator::do_evaluate(const son_wallet_withdraw_create_operation& op)
{ try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
const auto &idx = db().get_index_type<son_stats_index>().indices().get<by_owner>();
FC_ASSERT(idx.find(op.son_id) != idx.end(), "Statistic object for a given SON ID does not exists");
@ -68,7 +68,7 @@ object_id_type create_son_wallet_withdraw_evaluator::do_apply(const son_wallet_w
void_result process_son_wallet_withdraw_evaluator::do_evaluate(const son_wallet_withdraw_process_operation& op)
{ try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
FC_ASSERT( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
const auto& idx = db().get_index_type<son_wallet_withdraw_index>().indices().get<by_id>();
const auto& itr = idx.find(op.son_wallet_withdraw_id);

View file

@ -483,7 +483,7 @@ void peerplays_sidechain_plugin_impl::create_son_down_proposals() {
const chain::global_property_object &gpo = d.get_global_properties();
chain::son_report_down_operation son_down_op;
son_down_op.payer = GRAPHENE_SON_ACCOUNT;
son_down_op.payer = d.get_global_properties().parameters.son_account();
son_down_op.son_id = son_id;
son_down_op.down_ts = last_active_ts;

View file

@ -68,9 +68,9 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
const chain::global_property_object &gpo = database.get_global_properties();
// Deposit request
if ((sed.peerplays_to == GRAPHENE_SON_ACCOUNT) && (sed.sidechain_currency.compare("1.3.0") != 0)) {
if ((sed.peerplays_to == gpo.parameters.son_account()) && (sed.sidechain_currency.compare("1.3.0") != 0)) {
son_wallet_deposit_create_operation op;
op.payer = GRAPHENE_SON_ACCOUNT;
op.payer = gpo.parameters.son_account();
//op.son_id = ; // to be filled for each son
op.timestamp = sed.timestamp;
op.sidechain = sed.sidechain;
@ -109,7 +109,7 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
}
// Withdrawal request
if ((sed.peerplays_to == GRAPHENE_SON_ACCOUNT) && (sed.sidechain_currency.compare("1.3.0") == 0)) {
if ((sed.peerplays_to == gpo.parameters.son_account()) && (sed.sidechain_currency.compare("1.3.0") == 0)) {
// BTC Payout only (for now)
const auto &sidechain_addresses_idx = database.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
const auto &addr_itr = sidechain_addresses_idx.find(std::make_tuple(sed.peerplays_from, sidechain_type::bitcoin));
@ -117,7 +117,7 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
return;
son_wallet_withdraw_create_operation op;
op.payer = GRAPHENE_SON_ACCOUNT;
op.payer = gpo.parameters.son_account();
//op.son_id = ; // to be filled for each son
op.timestamp = sed.timestamp;
op.sidechain = sed.sidechain;
@ -174,12 +174,12 @@ void sidechain_net_handler::process_deposits() {
const chain::global_property_object &gpo = database.get_global_properties();
son_wallet_deposit_process_operation swdp_op;
swdp_op.payer = GRAPHENE_SON_ACCOUNT;
swdp_op.payer = gpo.parameters.son_account();
swdp_op.son_wallet_deposit_id = swdo.id;
transfer_operation t_op;
t_op.fee = asset(2000000);
t_op.from = swdo.peerplays_to; // GRAPHENE_SON_ACCOUNT
t_op.from = swdo.peerplays_to; // gpo.parameters.son_account()
t_op.to = swdo.peerplays_from;
t_op.amount = swdo.peerplays_asset;
@ -219,7 +219,7 @@ void sidechain_net_handler::process_withdrawals() {
const chain::global_property_object &gpo = database.get_global_properties();
son_wallet_withdraw_process_operation swwp_op;
swwp_op.payer = GRAPHENE_SON_ACCOUNT;
swwp_op.payer = gpo.parameters.son_account();
swwp_op.son_wallet_withdraw_id = swwo.id;
proposal_create_operation proposal_op;

View file

@ -837,7 +837,7 @@ void sidechain_net_handler_bitcoin::recreate_primary_wallet() {
boost::property_tree::json_parser::write_json(res, active_pw_pt.get_child("result"));
son_wallet_update_operation op;
op.payer = GRAPHENE_SON_ACCOUNT;
op.payer = gpo.parameters.son_account();
op.son_wallet_id = active_sw->id;
op.sidechain = sidechain_type::bitcoin;
op.address = res.str();
@ -908,7 +908,7 @@ void sidechain_net_handler_bitcoin::recreate_primary_wallet() {
}
sidechain_transaction_create_operation stc_op;
stc_op.payer = GRAPHENE_SON_ACCOUNT;
stc_op.payer = gpo.parameters.son_account();
stc_op.object_id = prev_sw->id;
stc_op.sidechain = sidechain;
stc_op.transaction = tx_str;
@ -984,7 +984,7 @@ bool sidechain_net_handler_bitcoin::process_deposit(const son_wallet_deposit_obj
}
sidechain_transaction_create_operation stc_op;
stc_op.payer = GRAPHENE_SON_ACCOUNT;
stc_op.payer = gpo.parameters.son_account();
stc_op.object_id = swdo.id;
stc_op.sidechain = sidechain;
stc_op.transaction = tx_str;
@ -1066,7 +1066,7 @@ bool sidechain_net_handler_bitcoin::process_withdrawal(const son_wallet_withdraw
}
sidechain_transaction_create_operation stc_op;
stc_op.payer = GRAPHENE_SON_ACCOUNT;
stc_op.payer = gpo.parameters.son_account();
stc_op.object_id = swwo.id;
stc_op.sidechain = sidechain;
stc_op.transaction = tx_str;
@ -1322,7 +1322,7 @@ void sidechain_net_handler_bitcoin::handle_event(const std::string &event_data)
sed.sidechain_currency = "BTC";
sed.sidechain_amount = v.out.amount;
sed.peerplays_from = addr_itr->sidechain_address_account;
sed.peerplays_to = GRAPHENE_SON_ACCOUNT;
sed.peerplays_to = database.get_global_properties().parameters.son_account();
sed.peerplays_asset = asset(sed.sidechain_amount / 1000); // For Bitcoin, the exchange rate is 1:1, for others, get the exchange rate from market
sidechain_event_data_received(sed);
}
@ -1399,6 +1399,13 @@ void sidechain_net_handler_bitcoin::on_changed_objects_cb(const vector<object_id
pw_redeem_script = pw_pt.get<std::string>("redeemScript");
bitcoin_client->importaddress(pw_redeem_script);
}
vector<string> son_pubkeys_bitcoin;
for (const son_info &si : swo->sons) {
son_pubkeys_bitcoin.push_back(si.sidechain_public_keys.at(sidechain_type::bitcoin));
}
uint32_t nrequired = son_pubkeys_bitcoin.size() * 2 / 3 + 1;
bitcoin_client->addmultisigaddress(nrequired, son_pubkeys_bitcoin);
}
}
}

View file

@ -57,7 +57,7 @@ void sidechain_net_handler_peerplays::on_applied_block(const signed_block &b) {
operation_index = operation_index + 1;
if (op.which() == operation::tag<transfer_operation>::value) {
transfer_operation transfer_op = op.get<transfer_operation>();
if (transfer_op.to != GRAPHENE_SON_ACCOUNT) {
if (transfer_op.to != plugin.database().get_global_properties().parameters.son_account()) {
continue;
}

View file

@ -220,7 +220,7 @@ try {
son_delete_operation op;
op.owner_account = alice_id;
op.son_id = son_id_type(0);
op.payer = GRAPHENE_SON_ACCOUNT;
op.payer = db.get_global_properties().parameters.son_account();
trx.operations.push_back(op);
sign(trx, bob_private_key);
@ -729,7 +729,7 @@ BOOST_AUTO_TEST_CASE( son_report_down_test ) {
generate_block();
// Send Report Down Operation for an active status SON
son_report_down_operation op;
op.payer = GRAPHENE_SON_ACCOUNT;
op.payer = db.get_global_properties().parameters.son_account();
op.son_id = son_id_type(0);
op.down_ts = fc::time_point_sec(son_stats_obj->last_active_timestamp - fc::seconds(1));
@ -742,7 +742,7 @@ BOOST_AUTO_TEST_CASE( son_report_down_test ) {
}
{
// Check that transaction fails if payer is not GRAPHENE_SON_ACCOUNT.
// Check that transaction fails if payer is not db.get_global_properties().parameters.son_account().
generate_block();
// Send Report Down Operation for an active status SON
son_report_down_operation op;
@ -759,11 +759,11 @@ BOOST_AUTO_TEST_CASE( son_report_down_test ) {
}
{
// Check that transaction succeeds after getting enough approvals on GRAPHENE_SON_ACCOUNT.
// Check that transaction succeeds after getting enough approvals on db.get_global_properties().parameters.son_account().
generate_block();
// Send Report Down Operation for an active status SON
son_report_down_operation op;
op.payer = GRAPHENE_SON_ACCOUNT;
op.payer = db.get_global_properties().parameters.son_account();
op.son_id = son_id_type(0);
op.down_ts = son_stats_obj->last_active_timestamp;
@ -783,7 +783,7 @@ BOOST_AUTO_TEST_CASE( son_report_down_test ) {
generate_block();
// Send Report Down Operation for an active status SON
son_report_down_operation op;
op.payer = GRAPHENE_SON_ACCOUNT;
op.payer = db.get_global_properties().parameters.son_account();
op.son_id = son_id_type(0);
op.down_ts = son_stats_obj->last_active_timestamp;

View file

@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE( son_wallet_recreate_test ) {
son_wallet_recreate_operation op;
op.payer = GRAPHENE_SON_ACCOUNT;
op.payer = db.get_global_properties().parameters.son_account();
{
son_info si;
@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE( son_wallet_update_test ) {
son_wallet_update_operation op;
op.payer = GRAPHENE_SON_ACCOUNT;
op.payer = db.get_global_properties().parameters.son_account();
op.son_wallet_id = son_wallet_id_type(0);
op.sidechain = graphene::peerplays_sidechain::sidechain_type::bitcoin;
op.address = "bitcoin address";