Merge branch 'develop' into feature/son-for-hive

This commit is contained in:
serkixenos 2021-07-01 16:02:35 +02:00
commit efe612b1bc
18 changed files with 222 additions and 149 deletions

View file

@ -29,6 +29,18 @@ build:
tags:
- builder
dockerize:
stage: build
script:
- docker build . -t $DOCKER_REPO:$CI_COMMIT_REF_NAME
- docker login -u $DOCKER_USER -p $DOCKER_PASS
- docker push $DOCKER_REPO:$CI_COMMIT_REF_NAME
- docker logout
tags:
- builder
when: manual
timeout: 3h
test:
stage: test
dependencies:

View file

@ -0,0 +1,10 @@
sonar.projectKey=peerplays-network_peerplays
sonar.organization=peerplays-network
# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=peerplays
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
sonar.sources=.
sonar.host.url=https://sonarcloud.io

View file

@ -141,7 +141,7 @@ namespace graphene { namespace app {
vector<optional<signed_block>> block_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to)const
{
FC_ASSERT( block_num_to >= block_num_from );
FC_ASSERT( block_num_to >= block_num_from && block_num_to - block_num_from <= 100, "Total blocks to be returned should be less than 100");
vector<optional<signed_block>> res;
for(uint32_t block_num=block_num_from; block_num<=block_num_to; block_num++) {
res.push_back(_db.fetch_block_by_number(block_num));

View file

@ -71,6 +71,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
optional<block_header> get_block_header(uint32_t block_num)const;
map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums)const;
optional<signed_block> get_block(uint32_t block_num)const;
vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to)const;
processed_transaction get_transaction( uint32_t block_num, uint32_t trx_in_block )const;
// Globals
@ -247,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,
@ -499,6 +497,21 @@ optional<signed_block> database_api_impl::get_block(uint32_t block_num)const
return _db.fetch_block_by_number(block_num);
}
vector<optional<signed_block>> database_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to)const
{
return my->get_blocks( block_num_from, block_num_to );
}
vector<optional<signed_block>> database_api_impl::get_blocks(uint32_t block_num_from, uint32_t block_num_to)const
{
FC_ASSERT( block_num_to >= block_num_from && block_num_to - block_num_from <= 100, "Total blocks to be returned should be less than 100");
vector<optional<signed_block>> res;
for(uint32_t block_num=block_num_from; block_num<=block_num_to; block_num++) {
res.push_back(_db.fetch_block_by_number(block_num));
}
return res;
}
processed_transaction database_api::get_transaction( uint32_t block_num, uint32_t trx_in_block )const
{
return my->get_transaction( block_num, trx_in_block );
@ -3176,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

@ -199,6 +199,14 @@ class database_api
*/
optional<signed_block> get_block(uint32_t block_num)const;
/**
* @brief Retrieve a list of signed blocks
* @param block_num_from start
* @param block_num_to end
* @return list of referenced blocks
*/
vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to)const;
/**
* @brief used to fetch an individual transaction.
*/
@ -935,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;
};
@ -985,6 +973,7 @@ FC_API(graphene::app::database_api,
(get_block_header)
(get_block_header_batch)
(get_block)
(get_blocks)
(get_transaction)
(get_recent_transaction_by_id)
@ -1146,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

@ -42,8 +42,7 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o
database& d = db();
if (d.head_block_time() < HARDFORK_SON_TIME)
FC_ASSERT(op.symbol != "BTC", "BTC asset creation before SON hardfork");
FC_ASSERT(d.is_asset_creation_allowed(op.symbol), "Asset creation not allowed at current time");
const auto& chain_parameters = d.get_global_properties().parameters;
FC_ASSERT( op.common_options.whitelist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );
@ -191,6 +190,8 @@ void_result lottery_asset_create_evaluator::do_evaluate( const lottery_asset_cre
database& d = db();
FC_ASSERT(d.is_asset_creation_allowed(op.symbol), "Lottery asset creation not allowed at current time");
const auto& chain_parameters = d.get_global_properties().parameters;
FC_ASSERT( op.common_options.whitelist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );
FC_ASSERT( op.common_options.blacklist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );

View file

@ -315,6 +315,27 @@ bool database::is_son_active( son_id_type son_id )
return (it_son != active_son_ids.end());
}
bool database::is_asset_creation_allowed(const string &symbol)
{
time_point_sec now = head_block_time();
std::unordered_set<std::string> post_son_hf_symbols = {"ETH", "USDT", "BNB", "ADA", "DOGE", "XRP", "USDC", "DOT", "UNI", "BUSD", "BCH", "LTC", "SOL", "LINK", "MATIC", "THETA",
"WBTC", "XLM", "ICP", "DAI", "VET", "ETC", "TRX", "FIL", "XMR", "EGR", "EOS", "SHIB", "AAVE", "CRO", "ALGO", "AMP", "BTCB",
"BSV", "KLAY", "CAKE", "FTT", "LEO", "XTZ", "TFUEL", "MIOTA", "LUNA", "NEO", "ATOM", "MKR", "FEI", "WBNB", "UST", "AVAX",
"STEEM", "HIVE", "HBD", "SBD", "BTS"};
if (symbol == "BTC")
{
if (now < HARDFORK_SON_TIME)
return false;
}
if (post_son_hf_symbols.find(symbol) != post_son_hf_symbols.end())
{
if (now >= HARDFORK_SON_TIME)
return false;
}
return true;
}
vector<uint64_t> database::get_random_numbers(uint64_t minimum, uint64_t maximum, uint64_t selections, bool duplicates)
{
FC_ASSERT( selections <= 100000 );

View file

@ -178,36 +178,52 @@ void database::update_worker_votes()
void database::pay_sons()
{
auto get_weight = []( uint64_t total_votes ) {
int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0);
uint16_t weight = std::max((total_votes >> bits_to_drop), uint64_t(1) );
return weight;
};
time_point_sec now = head_block_time();
const dynamic_global_property_object& dpo = get_dynamic_global_properties();
// 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 SON2 HF
uint64_t total_votes = 0;
for( const son_object& son : sons )
{
total_votes += _vote_tally_buffer[son.vote_id];
}
int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0);
auto get_weight = [&bits_to_drop]( uint64_t son_votes ) {
uint16_t weight = std::max((son_votes >> bits_to_drop), uint64_t(1) );
return weight;
};
// 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](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_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){
auto son_params = get_global_properties().parameters;
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)
{
_son_obj.pay_son_fee(pay, *this);
@ -2013,6 +2029,21 @@ void database::perform_son_tasks()
}
}
void update_son_asset(database& db)
{
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);
if( btc_asset.is_transfer_restricted() ) {
db.modify( btc_asset, []( asset_object& ao ) {
ao.options.flags = asset_issuer_permission_flags::charge_market_fee |
asset_issuer_permission_flags::override_authority;
});
}
}
}
void database::perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props)
{ try {
const auto& gpo = get_global_properties();
@ -2024,6 +2055,8 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
rolling_period_start(*this);
update_son_asset(*this);
struct vote_tally_helper {
database& d;
const global_property_object& props;

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

@ -164,7 +164,12 @@ namespace graphene { namespace chain {
template<class DB>
const asset_bitasset_data_object& bitasset_data(const DB& db)const
{ assert(bitasset_data_id); return db.get(*bitasset_data_id); }
{
FC_ASSERT( bitasset_data_id.valid(),
"Asset ${a} (${id}) is not a market issued asset.",
("a",this->symbol)("id",this->id) );
return db.get(*bitasset_data_id);
}
template<class DB>
const asset_dividend_data_object& dividend_data(const DB& db)const

View file

@ -312,6 +312,7 @@ namespace graphene { namespace chain {
signed_transaction create_signed_transaction( const fc::ecc::private_key& signing_private_key, const operation& op );
bool is_son_dereg_valid( son_id_type son_id );
bool is_son_active( son_id_type son_id );
bool is_asset_creation_allowed(const string& symbol);
time_point_sec head_block_time()const;
uint32_t head_block_num()const;

View file

@ -12,6 +12,20 @@ namespace detail {
class peerplays_sidechain_plugin_impl;
}
struct son_proposal_type {
son_proposal_type(int op, son_id_type son, object_id_type object) :
op_type(op),
son_id(son),
object_id(object) {
}
int op_type;
son_id_type son_id;
object_id_type object_id;
bool operator<(const son_proposal_type &other) const {
return std::tie(op_type, son_id, object_id) < std::tie(other.op_type, other.son_id, other.object_id);
}
};
class peerplays_sidechain_plugin : public graphene::app::plugin {
public:
peerplays_sidechain_plugin();
@ -35,6 +49,8 @@ public:
bool is_son_deregistered(son_id_type son_id);
fc::ecc::private_key get_private_key(son_id_type son_id);
fc::ecc::private_key get_private_key(chain::public_key_type public_key);
void log_son_proposal_retry(int op_type, object_id_type object_id);
bool can_son_participate(int op_type, object_id_type object_id);
};
}} // namespace graphene::peerplays_sidechain

View file

@ -42,6 +42,8 @@ public:
bool is_valid_son_proposal(const chain::proposal_object &proposal);
fc::ecc::private_key get_private_key(son_id_type son_id);
fc::ecc::private_key get_private_key(chain::public_key_type public_key);
void log_son_proposal_retry(int op_type, object_id_type object_id);
bool can_son_participate(int op_type, object_id_type object_id);
void schedule_heartbeat_loop();
void heartbeat_loop();
@ -83,6 +85,8 @@ private:
std::map<chain::public_key_type, fc::ecc::private_key> private_keys;
fc::future<void> _heartbeat_task;
fc::future<void> _son_processing_task;
std::map<son_proposal_type, uint16_t> son_retry_count;
uint16_t retries_threshold;
bool first_block_skipped;
void on_applied_block(const signed_block &b);
@ -136,6 +140,8 @@ void peerplays_sidechain_plugin_impl::plugin_set_program_options(
cli.add_options()("peerplays-private-key", bpo::value<vector<string>>()->composing()->multitoken()->DEFAULT_VALUE_VECTOR(std::make_pair(chain::public_key_type(default_priv_key.get_public_key()), graphene::utilities::key_to_wif(default_priv_key))),
"Tuple of [PublicKey, WIF private key] (may specify multiple times)");
cli.add_options()("sidechain-retry-threshold", bpo::value<uint16_t>()->default_value(150), "Sidechain retry throttling threshold");
cli.add_options()("bitcoin-sidechain-enabled", bpo::value<bool>()->default_value(false), "Bitcoin sidechain handler enabled");
cli.add_options()("bitcoin-node-ip", bpo::value<string>()->default_value("127.0.0.1"), "IP address of Bitcoin node");
cli.add_options()("bitcoin-node-zmq-port", bpo::value<uint32_t>()->default_value(11111), "ZMQ port of Bitcoin node");
@ -198,6 +204,8 @@ void peerplays_sidechain_plugin_impl::plugin_initialize(const boost::program_opt
}
config_ready_son = config_ready_son && !private_keys.empty();
}
retries_threshold = options.at("sidechain-retry-threshold").as<uint16_t>();
ilog("sidechain-retry-threshold: ${sidechain-retry-threshold}", ("sidechain-retry-threshold", retries_threshold));
}
if (!config_ready_son) {
wlog("Haven't set up SON parameters");
@ -509,6 +517,22 @@ bool peerplays_sidechain_plugin_impl::is_valid_son_proposal(const chain::proposa
return false;
}
void peerplays_sidechain_plugin_impl::log_son_proposal_retry(int op_type, object_id_type object_id) {
son_proposal_type prop_type(op_type, get_current_son_id(), object_id);
auto itr = son_retry_count.find(prop_type);
if (itr != son_retry_count.end()) {
itr->second++;
} else {
son_retry_count[prop_type] = 1;
}
}
bool peerplays_sidechain_plugin_impl::can_son_participate(int op_type, object_id_type object_id) {
son_proposal_type prop_type(op_type, get_current_son_id(), object_id);
auto itr = son_retry_count.find(prop_type);
return (itr == son_retry_count.end() || itr->second < retries_threshold);
}
void peerplays_sidechain_plugin_impl::approve_proposals() {
auto check_approve_proposal = [&](const chain::son_id_type &son_id, const chain::proposal_object &proposal) {
@ -761,4 +785,12 @@ fc::ecc::private_key peerplays_sidechain_plugin::get_private_key(chain::public_k
return my->get_private_key(public_key);
}
void peerplays_sidechain_plugin::log_son_proposal_retry(int op_type, object_id_type object_id) {
my->log_son_proposal_retry(op_type, object_id);
}
bool peerplays_sidechain_plugin::can_son_participate(int op_type, object_id_type object_id) {
return my->can_son_participate(op_type, object_id);
}
}} // namespace graphene::peerplays_sidechain

View file

@ -299,6 +299,7 @@ void sidechain_net_handler::process_proposals() {
int32_t op_idx_0 = -1;
chain::operation op_obj_idx_0;
object_id_type object_id;
if (po->proposed_transaction.operations.size() >= 1) {
op_idx_0 = po->proposed_transaction.operations[0].which();
@ -317,11 +318,13 @@ void sidechain_net_handler::process_proposals() {
switch (op_idx_0) {
case chain::operation::tag<chain::son_wallet_update_operation>::value: {
should_process = (op_obj_idx_0.get<son_wallet_update_operation>().sidechain == sidechain);
object_id = op_obj_idx_0.get<son_wallet_update_operation>().son_wallet_id;
break;
}
case chain::operation::tag<chain::son_wallet_deposit_process_operation>::value: {
son_wallet_deposit_id_type swdo_id = op_obj_idx_0.get<son_wallet_deposit_process_operation>().son_wallet_deposit_id;
object_id = swdo_id;
const auto &idx = database.get_index_type<son_wallet_deposit_index>().indices().get<by_id>();
const auto swdo = idx.find(swdo_id);
if (swdo != idx.end()) {
@ -332,6 +335,7 @@ void sidechain_net_handler::process_proposals() {
case chain::operation::tag<chain::son_wallet_withdraw_process_operation>::value: {
son_wallet_withdraw_id_type swwo_id = op_obj_idx_0.get<son_wallet_withdraw_process_operation>().son_wallet_withdraw_id;
object_id = swwo_id;
const auto &idx = database.get_index_type<son_wallet_withdraw_index>().indices().get<by_id>();
const auto swwo = idx.find(swwo_id);
if (swwo != idx.end()) {
@ -347,6 +351,7 @@ void sidechain_net_handler::process_proposals() {
const auto sto = idx.find(st_id);
if (sto != idx.end()) {
should_process = ((sto->sidechain == sidechain) && (sto->status == sidechain_transaction_status::valid) && signer_expected(*sto, signer));
object_id = sto->object_id;
}
break;
}
@ -357,6 +362,7 @@ void sidechain_net_handler::process_proposals() {
const auto sto = idx.find(st_id);
if (sto != idx.end()) {
should_process = (sto->sidechain == sidechain);
object_id = sto->object_id;
}
break;
}
@ -368,10 +374,14 @@ void sidechain_net_handler::process_proposals() {
elog("==================================================");
}
if (should_process) {
if (should_process && (op_idx_0 == chain::operation::tag<chain::sidechain_transaction_sign_operation>::value || plugin.can_son_participate(op_idx_0, object_id))) {
bool should_approve = process_proposal(*po);
if (should_approve) {
approve_proposal(po->id, plugin.get_current_son_id());
if (approve_proposal(po->id, plugin.get_current_son_id())) {
if (op_idx_0 != chain::operation::tag<chain::sidechain_transaction_sign_operation>::value) {
plugin.log_son_proposal_retry(op_idx_0, object_id);
}
}
}
}
}
@ -398,7 +408,7 @@ void sidechain_net_handler::process_deposits() {
const auto &idx_range = idx.equal_range(std::make_tuple(sidechain, true, false));
std::for_each(idx_range.first, idx_range.second, [&](const son_wallet_deposit_object &swdo) {
if (swdo.id == object_id_type(0, 0, 0)) {
if (swdo.id == object_id_type(0, 0, 0) || !plugin.can_son_participate(chain::operation::tag<chain::son_wallet_deposit_process_operation>::value, swdo.id)) {
return;
}
//Ignore the deposits which are not valid anymore, considered refunds.
@ -416,6 +426,7 @@ void sidechain_net_handler::process_deposits() {
wlog("Deposit not processed: ${swdo}", ("swdo", swdo));
return;
}
plugin.log_son_proposal_retry(chain::operation::tag<chain::son_wallet_deposit_process_operation>::value, swdo.id);
});
}
@ -428,7 +439,7 @@ void sidechain_net_handler::process_withdrawals() {
const auto &idx_range = idx.equal_range(std::make_tuple(sidechain, true, false));
std::for_each(idx_range.first, idx_range.second, [&](const son_wallet_withdraw_object &swwo) {
if (swwo.id == object_id_type(0, 0, 0)) {
if (swwo.id == object_id_type(0, 0, 0) || !plugin.can_son_participate(chain::operation::tag<chain::son_wallet_withdraw_process_operation>::value, swwo.id)) {
return;
}
@ -440,6 +451,7 @@ void sidechain_net_handler::process_withdrawals() {
wlog("Withdraw not processed: ${swwo}", ("swwo", swwo));
return;
}
plugin.log_son_proposal_retry(chain::operation::tag<chain::son_wallet_withdraw_process_operation>::value, swwo.id);
});
}
@ -538,6 +550,10 @@ void sidechain_net_handler::settle_sidechain_transactions() {
return;
}
if (!plugin.can_son_participate(chain::operation::tag<chain::sidechain_transaction_settle_operation>::value, sto.object_id)) {
return;
}
ilog("Sidechain transaction to settle: ${sto}", ("sto", sto.id));
asset settle_amount;
@ -585,6 +601,7 @@ void sidechain_net_handler::settle_sidechain_transactions() {
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
if (plugin.app().p2p_node())
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
plugin.log_son_proposal_retry(chain::operation::tag<chain::sidechain_transaction_settle_operation>::value, sto.object_id);
} catch (fc::exception &e) {
elog("Sending proposal for sidechain transaction settle operation failed with exception ${e}", ("e", e.what()));
}

View file

@ -1287,6 +1287,9 @@ void sidechain_net_handler_bitcoin::process_primary_wallet() {
boost::property_tree::ptree active_pw_pt;
boost::property_tree::read_json(active_pw_ss, active_pw_pt);
if (active_pw_pt.count("error") && active_pw_pt.get_child("error").empty()) {
if (!plugin.can_son_participate(chain::operation::tag<chain::son_wallet_update_operation>::value, active_sw->id)) {
return;
}
proposal_create_operation proposal_op;
proposal_op.fee_paying_account = plugin.get_current_son_object().son_account;
@ -1325,6 +1328,7 @@ void sidechain_net_handler_bitcoin::process_primary_wallet() {
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
if (plugin.app().p2p_node())
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
plugin.log_son_proposal_retry(chain::operation::tag<chain::son_wallet_update_operation>::value, active_sw->id);
} catch (fc::exception &e) {
elog("Sending proposal for son wallet update operation failed with exception ${e}", ("e", e.what()));
return;

View file

@ -312,6 +312,7 @@ class wallet_api
*/
variant_object about() const;
optional<signed_block_with_info> get_block( uint32_t num );
vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to)const;
/** Returns the number of accounts registered on the blockchain
* @returns the number of registered accounts
*/
@ -1969,35 +1970,6 @@ class wallet_api
bool broadcast /* = false */
);
/** Get random numbers
* @brief Returns the random number
* @param account The account paying the fee to get a 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 account The account paying the fee to get a random number
* @param bound Upper bound of segment containing random number
* @param broadcast true if you wish to broadcast the transaction
* @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);
@ -2674,6 +2646,7 @@ FC_API( graphene::wallet::wallet_api,
(get_account)
(get_account_id)
(get_block)
(get_blocks)
(get_account_count)
(get_account_history)
(get_relative_account_history)
@ -2700,8 +2673,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

@ -3868,38 +3868,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;
@ -4353,6 +4321,11 @@ optional<signed_block_with_info> wallet_api::get_block(uint32_t num)
return my->_remote_db->get_block(num);
}
vector<optional<signed_block>> wallet_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to) const
{
return my->_remote_db->get_blocks(block_num_from, block_num_to);
}
uint64_t wallet_api::get_account_count() const
{
return my->_remote_db->get_account_count();
@ -5442,23 +5415,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();

View file

@ -34,6 +34,7 @@
#include <fc/rpc/cli.hpp>
#include <fc/rpc/http_api.hpp>
#include <fc/rpc/websocket_api.hpp>
#include <fc/smart_ref_impl.hpp>
#include <graphene/app/api.hpp>
#include <graphene/chain/config.hpp>
@ -74,6 +75,7 @@ int main( int argc, char** argv )
boost::program_options::options_description opts;
opts.add_options()
("help,h", "Print this help message and exit.")
("version", "Display the version info and exit")
("server-rpc-endpoint,s", bpo::value<string>()->implicit_value("ws://127.0.0.1:8090"), "Server websocket RPC endpoint")
("server-rpc-user,u", bpo::value<string>(), "Server Username")
("server-rpc-password,p", bpo::value<string>(), "Server Password")
@ -95,6 +97,20 @@ int main( int argc, char** argv )
return 0;
}
if (options.count("version"))
{
std::string wallet_version(graphene::utilities::git_revision_description);
const size_t pos = wallet_version.find('/');
if( pos != std::string::npos && wallet_version.size() > pos )
wallet_version = wallet_version.substr( pos + 1 );
std::cerr << "Version: " << wallet_version << "\n";
std::cerr << "Git Revision: " << graphene::utilities::git_revision_sha << "\n";
std::cerr << "Built: " << __DATE__ " at " __TIME__ << "\n";
std::cout << "SSL: " << OPENSSL_VERSION_TEXT << "\n";
std::cout << "Boost: " << boost::replace_all_copy(std::string(BOOST_LIB_VERSION), "_", ".") << "\n";
return 0;
}
fc::path data_dir;
fc::logging_config cfg;
fc::path log_dir = data_dir / "logs";