Compare commits

...

45 commits

Author SHA1 Message Date
Milos Milosevic
4647044ab3 Fix issue with wrong image name 2023-07-11 12:15:56 +02:00
Milos Milosevic
a73ba73aaf Add force to delete 2023-07-11 12:15:56 +02:00
Milos Milosevic
b6b5893979 Move shutting down to after_script 2023-07-11 12:15:56 +02:00
Milos Milosevic
c5953c542c Again without 2023-07-11 12:15:56 +02:00
Milos Milosevic
1e84ce51de Call docker properly 2023-07-11 12:15:56 +02:00
Milos Milosevic
902f76a093 Do not remove too many images 2023-07-11 12:15:56 +02:00
Milos Milosevic
24dbcc628e Rerun without docker-compose build 2023-07-11 12:15:56 +02:00
Vlad Dobromyslov
e24de4f199 Merge branch 'feature/552-son-eth-hf-time' into 'develop'
#552 - NEW HARDFORK TIME FOR SON ETH

See merge request PBSA/peerplays!237
2023-07-06 15:32:52 +00:00
Vlad Dobromyslov
15ebbfe6bb #552 - NEW HARDFORK TIME FOR SON ETH 2023-07-06 15:38:20 +03:00
Vlad Dobromyslov
917e09a80b Merge branch 'bug/551-son-account-operations-count' into 'develop'
#551 - fix is_son_dereg_valid funtion

See merge request PBSA/peerplays!236
2023-07-03 19:50:59 +00:00
Vlad Dobromyslov
646b421308 #551 - fix is_son_dereg_valid funtion 2023-07-03 18:37:54 +03:00
Vlad Dobromyslov
dd2a531364 Merge branch 'bug/548-balance-discrepancies-blind-transfer' into 'develop'
#548 - Fix blind_transfer before and after ETH HARDFORK

See merge request PBSA/peerplays!234
2023-07-01 11:51:01 +00:00
Vlad Dobromyslov
ae0a895daf #548 - Fix blind_transfer before and after ETH HARDFORK 2023-07-01 11:51:01 +00:00
Vlad Dobromyslov
8530228189 Merge branch 'feature/remove-image-e2e-tests' into 'develop'
Remove unneeded docker images at the end of the pipeline

See merge request PBSA/peerplays!233
2023-06-30 18:33:26 +00:00
Milo M
85fb3fee67 Remove unneeded docker images at the end of the pipeline 2023-06-30 18:33:26 +00:00
Vlad Dobromyslov
2c9fd332d4 Merge branch 'bug/548-balance-discrepancies' into 'develop'
Fix balance discrepancies

See merge request PBSA/peerplays!231
2023-06-19 09:58:13 +00:00
Vlad Dobromyslov
fb01043e55 Fix balance discrepancies 2023-06-19 09:58:12 +00:00
Vlad Dobromyslov
a1186372d2 Merge branch 'bug/550-son_schedule_object' into 'develop'
#550 - update schedule for sidechain type

See merge request PBSA/peerplays!229
2023-06-08 05:28:30 +00:00
Vlad Dobromyslov
3a51723e51 #550 - update schedule for sidechain type 2023-06-08 05:28:30 +00:00
Vlad Dobromyslov
f23244cde0 Merge branch 'bug/549-testnet-sync' into 'develop'
Fix #549 testnet sync

See merge request PBSA/peerplays!228
2023-06-05 09:24:05 +00:00
Vlad Dobromyslov
fee7bc99fa Fix #549 testnet sync 2023-06-05 09:24:04 +00:00
Vlad Dobromyslov
6cf31b1075 Add develop branch to build target 2023-06-05 12:22:54 +03:00
Vlad Dobromyslov
97eaf4575a Merge branch 'beatrice' into develop
Conflicts are resolved:
	.gitlab-ci.yml
2023-06-05 09:32:07 +03:00
Vlad Dobromyslov
d367c308b8 Merge branch 'feature/python-e2e-tests-jm' into 'develop'
Python e2e test

See merge request PBSA/peerplays!221
2023-05-15 10:53:07 +00:00
Milos Milosevic
838a9820f1 Right order of the steps 2023-04-26 13:22:19 +02:00
Vlad Dobromyslov
3e1f38d972 Merge branch 'bug/530-eth-deposit_address' into 'develop'
#530 - fix ETH deposit_address

See merge request PBSA/peerplays!222
2023-04-21 07:15:16 +00:00
Vlad Dobromyslov
dfd3dfae09 #530 - fix ETH deposit_address 2023-04-21 09:21:17 +03:00
Milos Milosevic
1f72b4fbd6 Remove symbolic-ref call 2023-04-21 00:35:02 +02:00
Milos Milosevic
3ee2439d5b Revert changes on Dockerfile 2023-04-20 14:15:30 +02:00
Milos Milosevic
cfecfb457b Pull propper image 2023-04-19 00:23:54 +02:00
Milos Milosevic
25bbacaa88 Add docker prune before run 2023-04-18 16:17:48 +02:00
Milos Milosevic
0175a7d0ec Try the full flow 2023-04-18 13:27:00 +02:00
Milos Milosevic
fd492ca196 Run tests in the end 2023-04-18 12:53:12 +02:00
Milos Milosevic
2a6c917e4c Try through python 2023-04-18 11:14:20 +02:00
Milos Milosevic
6fe15f27b0 Try with rename 2023-04-18 09:47:10 +02:00
Milos Milosevic
d2374aeed9 Try via command line again 2023-04-18 08:13:20 +02:00
Milos Milosevic
6f792db52d Passing locally 2023-04-18 00:22:26 +02:00
Milos Milosevic
1b61016693 docker login still needed 2023-04-17 22:45:05 +02:00
Milos Milosevic
0f375777c2 Quick exec 2023-04-17 22:37:26 +02:00
Milos Milosevic
a2ce65e1ef Add pull image 2023-04-17 08:52:41 +02:00
Milos Milosevic
432876a677 Try different approach 2023-04-16 23:49:51 +02:00
Vlad Dobromyslov
948e7dd5e4 Merge branch 'bug/524-eth-mainnet-tr' into 'develop'
Bug/524-eth-mainnet-tr

See merge request PBSA/peerplays!219
2023-03-29 09:38:55 +00:00
Vlad Dobromyslov
b21f9c4282 Bug/524-eth-mainnet-tr 2023-03-29 09:38:54 +00:00
Vlad Dobromyslov
1586531e13 Merge branch 'bug/develop-518-last_voting_time' into 'develop'
#518 - update update_vote_time when voting for SON

See merge request PBSA/peerplays!217
2023-03-17 09:31:24 +00:00
Vlad Dobromyslov
8e0e20eb6f #518 - update update_vote_time when voting for SON 2023-03-17 11:33:33 +03:00
14 changed files with 396 additions and 210 deletions

View file

@ -29,8 +29,6 @@ build-mainnet:
- build/libraries/ - build/libraries/
- build/programs/ - build/programs/
- build/tests/ - build/tests/
rules:
- if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "beatrice" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "beatrice" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
tags: tags:
- builder - builder
@ -81,8 +79,6 @@ build-testnet:
- build/libraries/ - build/libraries/
- build/programs/ - build/programs/
- build/tests/ - build/tests/
rules:
- if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "beatrice" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "beatrice" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
when: manual when: manual
tags: tags:
- builder - builder
@ -155,7 +151,7 @@ test-e2e:
- python3 -m venv venv - python3 -m venv venv
- source venv/bin/activate - source venv/bin/activate
- pip3 install -r requirements.txt - pip3 install -r requirements.txt
- python3 main.py --stop - docker-compose down --remove-orphans
- docker ps -a - docker ps -a
- docker pull $IMAGE - docker pull $IMAGE
- docker tag $IMAGE peerplays-base:latest - docker tag $IMAGE peerplays-base:latest
@ -163,8 +159,11 @@ test-e2e:
- python3 main.py --start all - python3 main.py --start all
- docker ps -a - docker ps -a
- python3 -m pytest test_btc_init_state.py test_hive_inital_state.py test_pp_inital_state.py - python3 -m pytest test_btc_init_state.py test_hive_inital_state.py test_pp_inital_state.py
- python3 main.py --stop
- deactivate - deactivate
- docker ps -a - docker ps -a
after_script:
- cd peerplays-utils/peerplays-qa-environment/e2e-tests
- docker-compose down
- docker rmi -f $(docker images -a | grep -v 'hive-for-peerplays\|ethereum-for-peerplays\|bitcoin-for-peerplays\|ubuntu-for-peerplays\|peerplays-base\|IMAGE' | awk '{print $3}')
tags: tags:
- python-tests - python-tests

View file

@ -33,45 +33,163 @@ namespace graphene { namespace chain {
void_result transfer_to_blind_evaluator::do_evaluate( const transfer_to_blind_operation& o ) void_result transfer_to_blind_evaluator::do_evaluate( const transfer_to_blind_operation& o )
{ try { { try {
const auto& d = db();
if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME )
{
const auto& atype = o.amount.asset_id(d);
FC_ASSERT( atype.allow_confidential() );
FC_ASSERT( !atype.is_transfer_restricted() );
FC_ASSERT( !(atype.options.flags & white_list) );
for( const auto& out : o.outputs )
{
for( const auto& a : out.owner.account_auths )
a.first(d); // verify all accounts exist and are valid
}
}
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void_result transfer_to_blind_evaluator::do_apply( const transfer_to_blind_operation& o ) void_result transfer_to_blind_evaluator::do_apply( const transfer_to_blind_operation& o )
{ try { { try {
if( db().head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
db().adjust_balance(o.from, -o.amount);
const auto &add = o.amount.asset_id(db()).dynamic_asset_data_id(db()); // verify fee is a legit asset
db().modify(add, [&](asset_dynamic_data_object &obj) {
obj.confidential_supply += o.amount.amount;
FC_ASSERT(obj.confidential_supply >= 0);
});
for (const auto &out : o.outputs) {
db().create<blinded_balance_object>([&](blinded_balance_object &obj) {
obj.asset_id = o.amount.asset_id;
obj.owner = out.owner;
obj.commitment = out.commitment;
});
}
}
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void transfer_to_blind_evaluator::pay_fee() void transfer_to_blind_evaluator::pay_fee()
{ {
const auto& d = db();
if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
if (d.head_block_time() >= HARDFORK_563_TIME)
pay_fba_fee(fba_accumulator_id_transfer_to_blind);
else
generic_evaluator::pay_fee();
}
} }
void_result transfer_from_blind_evaluator::do_evaluate( const transfer_from_blind_operation& o ) void_result transfer_from_blind_evaluator::do_evaluate( const transfer_from_blind_operation& o )
{ try { { try {
const auto& d = db();
if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
o.fee.asset_id(d); // verify fee is a legit asset
const auto &bbi = d.get_index_type<blinded_balance_index>();
const auto &cidx = bbi.indices().get<by_commitment>();
for (const auto &in : o.inputs) {
auto itr = cidx.find(in.commitment);
FC_ASSERT(itr != cidx.end());
FC_ASSERT(itr->asset_id == o.fee.asset_id);
FC_ASSERT(itr->owner == in.owner);
}
}
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void_result transfer_from_blind_evaluator::do_apply( const transfer_from_blind_operation& o ) void_result transfer_from_blind_evaluator::do_apply( const transfer_from_blind_operation& o )
{ try { { try {
if( db().head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
db().adjust_balance(o.fee_payer(), o.fee);
db().adjust_balance(o.to, o.amount);
const auto &bbi = db().get_index_type<blinded_balance_index>();
const auto &cidx = bbi.indices().get<by_commitment>();
for (const auto &in : o.inputs) {
auto itr = cidx.find(in.commitment);
FC_ASSERT(itr != cidx.end());
db().remove(*itr);
}
const auto &add = o.amount.asset_id(db()).dynamic_asset_data_id(db()); // verify fee is a legit asset
db().modify(add, [&](asset_dynamic_data_object &obj) {
obj.confidential_supply -= o.amount.amount + o.fee.amount;
FC_ASSERT(obj.confidential_supply >= 0);
});
}
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void transfer_from_blind_evaluator::pay_fee() void transfer_from_blind_evaluator::pay_fee()
{ {
const auto& d = db();
if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
if (d.head_block_time() >= HARDFORK_563_TIME)
pay_fba_fee(fba_accumulator_id_transfer_from_blind);
else
generic_evaluator::pay_fee();
}
} }
void_result blind_transfer_evaluator::do_evaluate( const blind_transfer_operation& o ) void_result blind_transfer_evaluator::do_evaluate( const blind_transfer_operation& o )
{ try { { try {
const auto& d = db();
if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
o.fee.asset_id(d); // verify fee is a legit asset
const auto &bbi = d.get_index_type<blinded_balance_index>();
const auto &cidx = bbi.indices().get<by_commitment>();
for (const auto &out : o.outputs) {
for (const auto &a : out.owner.account_auths)
a.first(d); // verify all accounts exist and are valid
}
for (const auto &in : o.inputs) {
auto itr = cidx.find(in.commitment);
GRAPHENE_ASSERT(itr != cidx.end(), blind_transfer_unknown_commitment, "", ("commitment", in.commitment));
FC_ASSERT(itr->asset_id == o.fee.asset_id);
FC_ASSERT(itr->owner == in.owner);
}
}
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void_result blind_transfer_evaluator::do_apply( const blind_transfer_operation& o ) void_result blind_transfer_evaluator::do_apply( const blind_transfer_operation& o )
{ try { { try {
if( db().head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
db().adjust_balance(o.fee_payer(), o.fee); // deposit the fee to the temp account
const auto &bbi = db().get_index_type<blinded_balance_index>();
const auto &cidx = bbi.indices().get<by_commitment>();
for (const auto &in : o.inputs) {
auto itr = cidx.find(in.commitment);
GRAPHENE_ASSERT(itr != cidx.end(), blind_transfer_unknown_commitment, "", ("commitment", in.commitment));
db().remove(*itr);
}
for (const auto &out : o.outputs) {
db().create<blinded_balance_object>([&](blinded_balance_object &obj) {
obj.asset_id = o.fee.asset_id;
obj.owner = out.owner;
obj.commitment = out.commitment;
});
}
const auto &add = o.fee.asset_id(db()).dynamic_asset_data_id(db());
db().modify(add, [&](asset_dynamic_data_object &obj) {
obj.confidential_supply -= o.fee.amount;
FC_ASSERT(obj.confidential_supply >= 0);
});
}
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void blind_transfer_evaluator::pay_fee() void blind_transfer_evaluator::pay_fee()
{ {
const auto& d = db();
if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
if (d.head_block_time() >= HARDFORK_563_TIME)
pay_fba_fee(fba_accumulator_id_blind_transfer);
else
generic_evaluator::pay_fee();
}
} }
} } // graphene::chain } } // graphene::chain

View file

@ -739,13 +739,11 @@ void database::_apply_block( const signed_block& next_block )
if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) { if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) {
update_witness_schedule(next_block); update_witness_schedule(next_block);
bool need_to_update_son_schedule = false;
for(const auto& active_sons : global_props.active_sons) { for(const auto& active_sons : global_props.active_sons) {
if(!active_sons.second.empty()) if(!active_sons.second.empty()) {
need_to_update_son_schedule = true; update_son_schedule(active_sons.first, next_block);
} }
if(need_to_update_son_schedule) {
update_son_schedule(next_block);
} }
} }
@ -783,15 +781,11 @@ void database::_apply_block( const signed_block& next_block )
if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM) { if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM) {
update_witness_schedule(); update_witness_schedule();
bool need_update_son_schedule = false;
for(const auto& active_sidechain_type : active_sidechain_types(dynamic_global_props.time)) { for(const auto& active_sidechain_type : active_sidechain_types(dynamic_global_props.time)) {
if(global_props.active_sons.at(active_sidechain_type).size() > 0) { if(global_props.active_sons.at(active_sidechain_type).size() > 0) {
need_update_son_schedule = true; update_son_schedule(active_sidechain_type);
} }
} }
if(need_update_son_schedule) {
update_son_schedule();
}
} }
if( !_node_property_object.debug_updates.empty() ) if( !_node_property_object.debug_updates.empty() )

View file

@ -305,16 +305,14 @@ bool database::is_son_dereg_valid( son_id_type son_id )
} }
bool status_son_dereg_valid = true; bool status_son_dereg_valid = true;
for(const auto& status : son->statuses) for (const auto &active_sidechain_type : active_sidechain_types(head_block_time())) {
{ if(son->statuses.at(active_sidechain_type) != son_status::in_maintenance)
const auto& sidechain = status.first;
if(status.second != son_status::in_maintenance)
status_son_dereg_valid = false; status_son_dereg_valid = false;
if(status_son_dereg_valid) if(status_son_dereg_valid)
{ {
if(son->statistics(*this).last_active_timestamp.contains(sidechain)) { if(son->statistics(*this).last_active_timestamp.contains(active_sidechain_type)) {
if (head_block_time() - son->statistics(*this).last_active_timestamp.at(sidechain) < fc::seconds(get_global_properties().parameters.son_deregister_time())) { if (head_block_time() - son->statistics(*this).last_active_timestamp.at(active_sidechain_type) < fc::seconds(get_global_properties().parameters.son_deregister_time())) {
status_son_dereg_valid = false; status_son_dereg_valid = false;
} }
} }

View file

@ -185,13 +185,109 @@ void database::update_worker_votes()
} }
} }
void database::pay_sons() void database::pay_sons_before_hf_ethereum()
{
const auto 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())))
{
const sidechain_type st = sidechain_type::bitcoin;
const auto sons = sort_votable_objects<son_index>(st, get_global_properties().parameters.maximum_son_count());
// After SON2 HF
uint64_t total_votes = 0;
for( const son_object& son : sons )
{
FC_ASSERT(son.get_sidechain_vote_id(st).valid(), "Invalid vote id, sidechain: ${sidechain}, son: ${son}", ("sidechain", st)("son", son));
total_votes += _vote_tally_buffer[*son.get_sidechain_vote_id(st)];
}
const 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 ) {
const 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 ) {
const int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(son_votes)) - 15, 0);
const uint16_t weight = std::max((son_votes >> bits_to_drop), uint64_t(1) );
return weight;
};
uint64_t weighted_total_txs_signed = 0;
const 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_before_son2_hf, &st](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>();
const auto son_obj = idx.find( s.owner );
uint16_t son_weight = 0;
FC_ASSERT(son_obj->get_sidechain_vote_id(st).valid(), "Invalid vote id, sidechain: ${sidechain}, son: ${son}", ("sidechain", st)("son", *son_obj));
if( now >= HARDFORK_SON2_TIME ) {
son_weight += get_weight(_vote_tally_buffer[*son_obj->get_sidechain_vote_id(st)]);
}
else {
son_weight += get_weight_before_son2_hf(_vote_tally_buffer[*son_obj->get_sidechain_vote_id(st)]);
}
const uint64_t txs_signed_bitcoin = s.txs_signed.contains(sidechain_type::bitcoin) ? s.txs_signed.at(sidechain_type::bitcoin) : 0;
const uint64_t txs_signed_hive = s.txs_signed.contains(sidechain_type::hive) ? s.txs_signed.at(sidechain_type::hive) : 0;
weighted_total_txs_signed += ((txs_signed_bitcoin + txs_signed_hive) * 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, &get_weight_before_son2_hf, &now, &st](const object& o) {
const son_statistics_object& s = static_cast<const son_statistics_object&>(o);
const uint64_t txs_signed_bitcoin = s.txs_signed.contains(sidechain_type::bitcoin) ? s.txs_signed.at(sidechain_type::bitcoin) : 0;
const uint64_t txs_signed_hive = s.txs_signed.contains(sidechain_type::hive) ? s.txs_signed.at(sidechain_type::hive) : 0;
if(txs_signed_bitcoin > 0 || txs_signed_hive > 0) {
const auto& idx = get_index_type<son_index>().indices().get<by_id>();
auto son_obj = idx.find( s.owner );
uint16_t son_weight = 0;
FC_ASSERT(son_obj->get_sidechain_vote_id(st).valid(), "Invalid vote id, sidechain: ${sidechain}, son: ${son}", ("sidechain", st)("son", *son_obj));
if( now >= HARDFORK_SON2_TIME ) {
son_weight += get_weight(_vote_tally_buffer[*son_obj->get_sidechain_vote_id(st)]);
}
else {
son_weight += get_weight_before_son2_hf(_vote_tally_buffer[*son_obj->get_sidechain_vote_id(st)]);
}
const share_type pay = ((txs_signed_bitcoin + txs_signed_hive) * son_weight * son_budget.value)/weighted_total_txs_signed;
modify( *son_obj, [&]( son_object& _son_obj)
{
_son_obj.pay_son_fee(pay, *this);
});
//Remove the amount paid out to SON from global SON Budget
modify( dpo, [&]( dynamic_global_property_object& _dpo )
{
_dpo.son_budget -= pay;
} );
//Reset the tx counter in each son statistics object
modify( s, [&]( son_statistics_object& _s)
{
if(_s.txs_signed.contains(sidechain_type::bitcoin))
_s.txs_signed.at(sidechain_type::bitcoin) = 0;
if(_s.txs_signed.contains(sidechain_type::hive))
_s.txs_signed.at(sidechain_type::hive) = 0;
});
}
});
//Note the last son pay out time
modify( dpo, [&]( dynamic_global_property_object& _dpo )
{
_dpo.last_son_payout_time = now;
});
}
}
void database::pay_sons_after_hf_ethereum()
{ {
const time_point_sec now = head_block_time(); const time_point_sec now = head_block_time();
const dynamic_global_property_object& dpo = get_dynamic_global_properties(); 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 // 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()))) if( dpo.son_budget.value > 0 && ((now - dpo.last_son_payout_time) >= fc::seconds(get_global_properties().parameters.son_pay_time())))
{ {
flat_map<sidechain_type, int8_t> bits_to_drop;
for(const auto& active_sidechain_type : active_sidechain_types(now)) for(const auto& active_sidechain_type : active_sidechain_types(now))
{ {
assert( _son_count_histogram_buffer.at(active_sidechain_type).size() > 0 ); assert( _son_count_histogram_buffer.at(active_sidechain_type).size() > 0 );
@ -209,87 +305,67 @@ void database::pay_sons()
} }
} }
const sidechain_type st = [&now, &active_sidechain_type]{ const auto sons = sort_votable_objects<son_index>(active_sidechain_type, (std::max(son_count*2+1, (size_t)get_chain_properties().immutable_parameters.min_son_count)));
if( now < HARDFORK_SON_FOR_ETHEREUM_TIME )
return sidechain_type::bitcoin;
else
return active_sidechain_type;
}();
const auto sons = sort_votable_objects<son_index>(st,
(std::max(son_count*2+1, (size_t)get_chain_properties().immutable_parameters.min_son_count))
);
// After SON2 HF // After SON2 HF
uint64_t total_votes = 0; uint64_t total_votes = 0;
for( const son_object& son : sons ) for( const son_object& son : sons )
{ {
FC_ASSERT(son.get_sidechain_vote_id(st).valid(), "Invalid vote id, sidechain: ${sidechain}, son: ${son}", ("sidechain", st)("son", son)); FC_ASSERT(son.get_sidechain_vote_id(active_sidechain_type).valid(), "Invalid vote id, sidechain: ${sidechain}, son: ${son}", ("sidechain", active_sidechain_type)("son", son));
total_votes += _vote_tally_buffer[*son.get_sidechain_vote_id(st)]; total_votes += _vote_tally_buffer[*son.get_sidechain_vote_id(active_sidechain_type)];
} }
const int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0); bits_to_drop[active_sidechain_type] = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0);
auto get_weight = [&bits_to_drop]( uint64_t son_votes ) { }
const uint16_t weight = std::max((son_votes >> bits_to_drop), uint64_t(1) );
return weight; auto get_weight = [&bits_to_drop]( sidechain_type sidechain, uint64_t son_votes ) {
}; const uint16_t weight = std::max((son_votes >> bits_to_drop.at(sidechain)), uint64_t(1) );
// Before SON2 HF
auto get_weight_before_son2_hf = []( uint64_t son_votes ) {
const int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(son_votes)) - 15, 0);
const uint16_t weight = std::max((son_votes >> bits_to_drop), uint64_t(1) );
return weight; return weight;
}; };
// Calculate weighted_total_txs_signed
uint64_t weighted_total_txs_signed = 0; uint64_t weighted_total_txs_signed = 0;
const share_type son_budget = dpo.son_budget; get_index_type<son_stats_index>().inspect_all_objects([this, &weighted_total_txs_signed, &get_weight, &now](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, &active_sidechain_type, &st](const object& o) { for(const auto& active_sidechain_type : active_sidechain_types(now)) {
const son_statistics_object &s = static_cast<const son_statistics_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>(); const auto &idx = get_index_type<son_index>().indices().get<by_id>();
const auto son_obj = idx.find(s.owner); const auto son_obj = idx.find(s.owner);
uint16_t son_weight = 0; FC_ASSERT(son_obj->get_sidechain_vote_id(active_sidechain_type).valid(), "Invalid vote id, sidechain: ${sidechain}, son: ${son}", ("sidechain", active_sidechain_type)("son", *son_obj));
FC_ASSERT(son_obj->get_sidechain_vote_id(st).valid(), "Invalid vote id, sidechain: ${sidechain}, son: ${son}", ("sidechain", st)("son", *son_obj)); const uint16_t son_weight = get_weight(active_sidechain_type, _vote_tally_buffer[*son_obj->get_sidechain_vote_id(active_sidechain_type)]);
if( now >= HARDFORK_SON2_TIME ) {
son_weight += get_weight(_vote_tally_buffer[*son_obj->get_sidechain_vote_id(st)]);
}
else {
son_weight += get_weight_before_son2_hf(_vote_tally_buffer[*son_obj->get_sidechain_vote_id(st)]);
}
const uint64_t txs_signed = s.txs_signed.contains(active_sidechain_type) ? s.txs_signed.at(active_sidechain_type) : 0; const uint64_t txs_signed = s.txs_signed.contains(active_sidechain_type) ? s.txs_signed.at(active_sidechain_type) : 0;
weighted_total_txs_signed += (txs_signed * son_weight); weighted_total_txs_signed += (txs_signed * son_weight);
}
}); });
// Now pay off each SON proportional to the number of transactions signed. // 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, &get_weight_before_son2_hf, &now, &active_sidechain_type, &st](const object& o) { const share_type son_budget = dpo.son_budget;
get_index_type<son_stats_index>().inspect_all_objects([this, &now, &get_weight, &weighted_total_txs_signed, &dpo, &son_budget](const object& o) {
for(const auto& active_sidechain_type : active_sidechain_types(now)) {
const son_statistics_object &s = static_cast<const son_statistics_object &>(o); const son_statistics_object &s = static_cast<const son_statistics_object &>(o);
const uint64_t txs_signed = s.txs_signed.contains(active_sidechain_type) ? s.txs_signed.at(active_sidechain_type) : 0;
const uint64_t txs_signed = s.txs_signed.contains(active_sidechain_type) ? s.txs_signed.at(active_sidechain_type) : 0;
if (txs_signed > 0) { if (txs_signed > 0) {
const auto &idx = get_index_type<son_index>().indices().get<by_id>(); const auto &idx = get_index_type<son_index>().indices().get<by_id>();
auto son_obj = idx.find(s.owner); auto son_obj = idx.find(s.owner);
uint16_t son_weight = 0; uint16_t son_weight = 0;
FC_ASSERT(son_obj->get_sidechain_vote_id(st).valid(), "Invalid vote id, sidechain: ${sidechain}, son: ${son}", ("sidechain", st)("son", *son_obj)); FC_ASSERT(son_obj->get_sidechain_vote_id(active_sidechain_type).valid(), "Invalid vote id, sidechain: ${sidechain}, son: ${son}", ("sidechain", active_sidechain_type)("son", *son_obj));
if( now >= HARDFORK_SON2_TIME ) { son_weight += get_weight(active_sidechain_type, _vote_tally_buffer[*son_obj->get_sidechain_vote_id(active_sidechain_type)]);
son_weight += get_weight(_vote_tally_buffer[*son_obj->get_sidechain_vote_id(st)]);
}
else {
son_weight += get_weight_before_son2_hf(_vote_tally_buffer[*son_obj->get_sidechain_vote_id(st)]);
}
const share_type pay = (txs_signed * son_weight * son_budget.value) / weighted_total_txs_signed; const share_type pay = (txs_signed * son_weight * son_budget.value) / weighted_total_txs_signed;
modify( *son_obj, [&]( son_object& _son_obj) modify(*son_obj, [&](son_object &_son_obj) {
{
_son_obj.pay_son_fee(pay, *this); _son_obj.pay_son_fee(pay, *this);
}); });
// Remove the amount paid out to SON from global SON Budget // Remove the amount paid out to SON from global SON Budget
modify( dpo, [&]( dynamic_global_property_object& _dpo ) modify(dpo, [&](dynamic_global_property_object &_dpo) {
{
_dpo.son_budget -= pay; _dpo.son_budget -= pay;
}); });
// Reset the tx counter in each son statistics object // Reset the tx counter in each son statistics object
modify( s, [&]( son_statistics_object& _s) modify(s, [&](son_statistics_object &_s) {
{
if (_s.txs_signed.contains(active_sidechain_type)) if (_s.txs_signed.contains(active_sidechain_type))
_s.txs_signed.at(active_sidechain_type) = 0; _s.txs_signed.at(active_sidechain_type) = 0;
}); });
} }
}
}); });
//Note the last son pay out time //Note the last son pay out time
modify( dpo, [&]( dynamic_global_property_object& _dpo ) modify( dpo, [&]( dynamic_global_property_object& _dpo )
{ {
@ -297,7 +373,6 @@ void database::pay_sons()
}); });
} }
} }
}
void database::update_son_metrics(const flat_map<sidechain_type, vector<son_sidechain_info> >& curr_active_sons) void database::update_son_metrics(const flat_map<sidechain_type, vector<son_sidechain_info> >& curr_active_sons)
{ {
@ -2192,7 +2267,10 @@ void database::perform_son_tasks()
// Before making a budget we should pay out SONs // Before making a budget we should pay out SONs
// This function should check if its time to pay sons // This function should check if its time to pay sons
// and modify the global son funds accordingly, whatever is left is passed on to next budget // and modify the global son funds accordingly, whatever is left is passed on to next budget
pay_sons(); if(head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME)
pay_sons_before_hf_ethereum();
else
pay_sons_after_hf_ethereum();
} }
// Split vote_ids // Split vote_ids

View file

@ -200,22 +200,20 @@ void database::update_witness_schedule()
} }
} }
void database::update_son_schedule() void database::update_son_schedule(sidechain_type type)
{ {
const global_property_object& gpo = get_global_properties(); const global_property_object& gpo = get_global_properties();
for(const auto& active_sidechain_type : active_sidechain_types(head_block_time())) const son_schedule_object& sidechain_sso = get(son_schedule_id_type(get_son_schedule_id(type)));
{ if( gpo.active_sons.at(type).size() != 0 &&
const son_schedule_object& sidechain_sso = get(son_schedule_id_type(get_son_schedule_id(active_sidechain_type))); head_block_num() % gpo.active_sons.at(type).size() == 0)
if( gpo.active_sons.at(active_sidechain_type).size() != 0 &&
head_block_num() % gpo.active_sons.at(active_sidechain_type).size() == 0)
{ {
modify( sidechain_sso, [&]( son_schedule_object& _sso ) modify( sidechain_sso, [&]( son_schedule_object& _sso )
{ {
_sso.current_shuffled_sons.clear(); _sso.current_shuffled_sons.clear();
_sso.current_shuffled_sons.reserve( gpo.active_sons.at(active_sidechain_type).size() ); _sso.current_shuffled_sons.reserve( gpo.active_sons.at(type).size() );
for ( const auto &w : gpo.active_sons.at(active_sidechain_type) ) { for ( const auto &w : gpo.active_sons.at(type) ) {
_sso.current_shuffled_sons.push_back(w.son_id); _sso.current_shuffled_sons.push_back(w.son_id);
} }
@ -239,7 +237,6 @@ void database::update_son_schedule()
}); });
} }
} }
}
vector<witness_id_type> database::get_near_witness_schedule()const vector<witness_id_type> database::get_near_witness_schedule()const
{ {
@ -321,23 +318,15 @@ void database::update_witness_schedule(const signed_block& next_block)
idump( ( double(total_time/1000000.0)/calls) ); idump( ( double(total_time/1000000.0)/calls) );
} }
void database::update_son_schedule(const signed_block& next_block) void database::update_son_schedule(sidechain_type type, const signed_block& next_block)
{ {
auto start = fc::time_point::now(); auto start = fc::time_point::now();
#ifndef NDEBUG #ifndef NDEBUG
const son_schedule_object& sso = get(son_schedule_id_type()); const son_schedule_object& sso = get(son_schedule_id_type());
#endif #endif
const global_property_object& gpo = get_global_properties(); const global_property_object& gpo = get_global_properties();
const flat_map<sidechain_type, uint32_t> schedule_needs_filled = [&gpo]() const uint32_t schedule_needs_filled = gpo.active_sons.at(type).size();
{ const uint32_t schedule_slot = get_slot_at_time(next_block.timestamp);
flat_map<sidechain_type, uint32_t> schedule_needs_filled;
for(const auto& sidechain_active_sons : gpo.active_sons)
{
schedule_needs_filled[sidechain_active_sons.first] = sidechain_active_sons.second.size();
}
return schedule_needs_filled;
}();
uint32_t schedule_slot = get_slot_at_time(next_block.timestamp);
// We shouldn't be able to generate _pending_block with timestamp // We shouldn't be able to generate _pending_block with timestamp
// in the past, and incoming blocks from the network with timestamp // in the past, and incoming blocks from the network with timestamp
@ -351,9 +340,7 @@ void database::update_son_schedule(const signed_block& next_block)
assert( dpo.random.data_size() == witness_scheduler_rng::seed_length ); assert( dpo.random.data_size() == witness_scheduler_rng::seed_length );
assert( witness_scheduler_rng::seed_length == sso.rng_seed.size() ); assert( witness_scheduler_rng::seed_length == sso.rng_seed.size() );
for(const auto& active_sidechain_type : active_sidechain_types(head_block_time())) const son_schedule_object& sidechain_sso = get(son_schedule_id_type(get_son_schedule_id(type)));
{
const son_schedule_object& sidechain_sso = get(son_schedule_id_type(get_son_schedule_id(active_sidechain_type)));
son_id_type first_son; son_id_type first_son;
bool slot_is_near = sidechain_sso.scheduler.get_slot( schedule_slot-1, first_son ); bool slot_is_near = sidechain_sso.scheduler.get_slot( schedule_slot-1, first_son );
son_id_type son_id; son_id_type son_id;
@ -363,7 +350,7 @@ void database::update_son_schedule(const signed_block& next_block)
_sso.slots_since_genesis += schedule_slot; _sso.slots_since_genesis += schedule_slot;
witness_scheduler_rng rng(_sso.rng_seed.data, _sso.slots_since_genesis); witness_scheduler_rng rng(_sso.rng_seed.data, _sso.slots_since_genesis);
_sso.scheduler._min_token_count = std::max(int(gpo.active_sons.at(active_sidechain_type).size()) / 2, 1); _sso.scheduler._min_token_count = std::max(int(gpo.active_sons.at(type).size()) / 2, 1);
if( slot_is_near ) if( slot_is_near )
{ {
@ -380,7 +367,7 @@ void database::update_son_schedule(const signed_block& next_block)
{ {
_sso.scheduler.reset_schedule( first_son ); _sso.scheduler.reset_schedule( first_son );
} }
while( !_sso.scheduler.get_slot(schedule_needs_filled.at(active_sidechain_type), son_id) ) while( !_sso.scheduler.get_slot(schedule_needs_filled, son_id) )
{ {
if( _sso.scheduler.produce_schedule(rng) & emit_turn ) if( _sso.scheduler.produce_schedule(rng) & emit_turn )
memcpy(_sso.rng_seed.begin(), dpo.random.data(), dpo.random.data_size()); memcpy(_sso.rng_seed.begin(), dpo.random.data(), dpo.random.data_size());
@ -390,7 +377,6 @@ void database::update_son_schedule(const signed_block& next_block)
(_sso.recent_slots_filled << 1) (_sso.recent_slots_filled << 1)
+ 1) << (schedule_slot - 1); + 1) << (schedule_slot - 1);
}); });
}
auto end = fc::time_point::now(); auto end = fc::time_point::now();
static uint64_t total_time = 0; static uint64_t total_time = 0;

View file

@ -1,7 +1,7 @@
#ifndef HARDFORK_SON_FOR_ETHEREUM_TIME #ifndef HARDFORK_SON_FOR_ETHEREUM_TIME
#ifdef BUILD_PEERPLAYS_TESTNET #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_SON_FOR_ETHEREUM_TIME (fc::time_point_sec::from_iso_string("2023-06-05T12:00:00")) #define HARDFORK_SON_FOR_ETHEREUM_TIME (fc::time_point_sec::from_iso_string("2023-07-17T12:00:00"))
#else #else
#define HARDFORK_SON_FOR_ETHEREUM_TIME (fc::time_point_sec::from_iso_string("2023-07-05T12:00:00")) #define HARDFORK_SON_FOR_ETHEREUM_TIME (fc::time_point_sec::from_iso_string("2023-07-31T12:00:00"))
#endif #endif
#endif #endif

View file

@ -292,8 +292,8 @@ namespace graphene { namespace chain {
vector<witness_id_type> get_near_witness_schedule()const; vector<witness_id_type> get_near_witness_schedule()const;
void update_witness_schedule(); void update_witness_schedule();
void update_witness_schedule(const signed_block& next_block); void update_witness_schedule(const signed_block& next_block);
void update_son_schedule(); void update_son_schedule(sidechain_type type);
void update_son_schedule(const signed_block& next_block); void update_son_schedule(sidechain_type type, const signed_block& next_block);
void check_lottery_end_by_participants( asset_id_type asset_id ); void check_lottery_end_by_participants( asset_id_type asset_id );
void check_ending_lotteries(); void check_ending_lotteries();
@ -579,7 +579,8 @@ namespace graphene { namespace chain {
void initialize_budget_record( fc::time_point_sec now, budget_record& rec )const; void initialize_budget_record( fc::time_point_sec now, budget_record& rec )const;
void process_budget(); void process_budget();
void pay_workers( share_type& budget ); void pay_workers( share_type& budget );
void pay_sons(); void pay_sons_before_hf_ethereum();
void pay_sons_after_hf_ethereum();
void perform_son_tasks(); void perform_son_tasks();
void perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props); void perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props);
void update_active_witnesses(); void update_active_witnesses();

View file

@ -182,6 +182,9 @@ namespace graphene { namespace chain {
GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( override_transfer ); GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( override_transfer );
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( not_permitted, override_transfer, 1, "not permitted" ) GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( not_permitted, override_transfer, 1, "not permitted" )
GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( blind_transfer );
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1, "Attempting to claim an unknown prior commitment" );
/* /*
FC_DECLARE_DERIVED_EXCEPTION( addition_overflow, graphene::chain::chain_exception, 30002, "addition overflow" ) FC_DECLARE_DERIVED_EXCEPTION( addition_overflow, graphene::chain::chain_exception, 30002, "addition overflow" )
FC_DECLARE_DERIVED_EXCEPTION( subtraction_overflow, graphene::chain::chain_exception, 30003, "subtraction overflow" ) FC_DECLARE_DERIVED_EXCEPTION( subtraction_overflow, graphene::chain::chain_exception, 30003, "subtraction overflow" )

View file

@ -158,9 +158,7 @@ struct transfer_to_blind_operation : public base_operation
blind_factor_type blinding_factor; blind_factor_type blinding_factor;
vector<blind_output> outputs; vector<blind_output> outputs;
account_id_type fee_payer()const { return account_id_type{}; } account_id_type fee_payer()const { return from; }
//account_id_type fee_payer()const { return from; }
//void validate()const; //void validate()const;
//share_type calculate_fee(const fee_parameters_type& )const; //share_type calculate_fee(const fee_parameters_type& )const;
}; };
@ -181,9 +179,7 @@ struct transfer_from_blind_operation : public base_operation
blind_factor_type blinding_factor; blind_factor_type blinding_factor;
vector<blind_input> inputs; vector<blind_input> inputs;
account_id_type fee_payer()const { return account_id_type{}; } account_id_type fee_payer()const { return GRAPHENE_TEMP_ACCOUNT; }
//account_id_type fee_payer()const { return GRAPHENE_TEMP_ACCOUNT; }
//void validate()const; //void validate()const;
//void get_required_authorities( vector<authority>& a )const //void get_required_authorities( vector<authority>& a )const
//{ //{
@ -246,10 +242,8 @@ struct blind_transfer_operation : public base_operation
vector<blind_input> inputs; vector<blind_input> inputs;
vector<blind_output> outputs; vector<blind_output> outputs;
account_id_type fee_payer()const { return account_id_type{}; }
/** graphene TEMP account */ /** graphene TEMP account */
//account_id_type fee_payer()const; account_id_type fee_payer()const { return GRAPHENE_TEMP_ACCOUNT; }
//void validate()const; //void validate()const;
//share_type calculate_fee( const fee_parameters_type& k )const; //share_type calculate_fee( const fee_parameters_type& k )const;
//void get_required_authorities( vector<authority>& a )const //void get_required_authorities( vector<authority>& a )const

View file

@ -97,10 +97,18 @@ void_result update_son_wallet_evaluator::do_evaluate(const son_wallet_update_ope
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT( op.payer == db().get_global_properties().parameters.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>(); const son_wallet_id_type son_wallet_id = [&]{
if(db().head_block_time() >= HARDFORK_SON_FOR_ETHEREUM_TIME)
{
const auto ast = active_sidechain_types(db().head_block_time()); const auto ast = active_sidechain_types(db().head_block_time());
const auto id = (op.son_wallet_id.instance.value - std::distance(ast.begin(), ast.find(op.sidechain))) / ast.size(); const auto id = (op.son_wallet_id.instance.value - std::distance(ast.begin(), ast.find(op.sidechain))) / ast.size();
const son_wallet_id_type son_wallet_id{ id }; return son_wallet_id_type{ id };
}
return op.son_wallet_id;
}();
const auto& idx = db().get_index_type<son_wallet_index>().indices().get<by_id>();
FC_ASSERT( idx.find(son_wallet_id) != idx.end() ); FC_ASSERT( idx.find(son_wallet_id) != idx.end() );
//auto itr = idx.find(op.son_wallet_id); //auto itr = idx.find(op.son_wallet_id);
//FC_ASSERT( itr->addresses.find(op.sidechain) == itr->addresses.end() || //FC_ASSERT( itr->addresses.find(op.sidechain) == itr->addresses.end() ||
@ -110,10 +118,18 @@ void_result update_son_wallet_evaluator::do_evaluate(const son_wallet_update_ope
object_id_type update_son_wallet_evaluator::do_apply(const son_wallet_update_operation& op) object_id_type update_son_wallet_evaluator::do_apply(const son_wallet_update_operation& op)
{ try { { try {
const auto& idx = db().get_index_type<son_wallet_index>().indices().get<by_id>(); const son_wallet_id_type son_wallet_id = [&]{
if(db().head_block_time() >= HARDFORK_SON_FOR_ETHEREUM_TIME)
{
const auto ast = active_sidechain_types(db().head_block_time()); const auto ast = active_sidechain_types(db().head_block_time());
const auto id = (op.son_wallet_id.instance.value - std::distance(ast.begin(), ast.find(op.sidechain))) / ast.size(); const auto id = (op.son_wallet_id.instance.value - std::distance(ast.begin(), ast.find(op.sidechain))) / ast.size();
const son_wallet_id_type son_wallet_id{ id }; return son_wallet_id_type{ id };
}
return op.son_wallet_id;
}();
const auto& idx = db().get_index_type<son_wallet_index>().indices().get<by_id>();
auto itr = idx.find(son_wallet_id); auto itr = idx.find(son_wallet_id);
if (itr != idx.end()) if (itr != idx.end())
{ {

View file

@ -680,8 +680,7 @@ void sidechain_net_handler::on_applied_block(const signed_block &b) {
const bool is_tracked_asset = const bool is_tracked_asset =
((sidechain == sidechain_type::bitcoin) && (transfer_op.amount.asset_id == gpo.parameters.btc_asset())) || ((sidechain == sidechain_type::bitcoin) && (transfer_op.amount.asset_id == gpo.parameters.btc_asset())) ||
((sidechain == sidechain_type::ethereum) && (transfer_op.amount.asset_id == gpo.parameters.eth_asset())) || ((sidechain == sidechain_type::ethereum) && (transfer_op.amount.asset_id == gpo.parameters.eth_asset())) ||
((sidechain == sidechain_type::ethereum) && (transfer_op.amount.asset_id != gpo.parameters.btc_asset()) ((sidechain == sidechain_type::ethereum) && (transfer_op.amount.asset_id != gpo.parameters.btc_asset()) && (transfer_op.amount.asset_id != gpo.parameters.hbd_asset()) && (transfer_op.amount.asset_id != gpo.parameters.hive_asset())) ||
&& (transfer_op.amount.asset_id != gpo.parameters.hbd_asset()) && (transfer_op.amount.asset_id != gpo.parameters.hive_asset())) ||
((sidechain == sidechain_type::hive) && (transfer_op.amount.asset_id == gpo.parameters.hbd_asset())) || ((sidechain == sidechain_type::hive) && (transfer_op.amount.asset_id == gpo.parameters.hbd_asset())) ||
((sidechain == sidechain_type::hive) && (transfer_op.amount.asset_id == gpo.parameters.hive_asset())); ((sidechain == sidechain_type::hive) && (transfer_op.amount.asset_id == gpo.parameters.hive_asset()));

View file

@ -574,7 +574,7 @@ BOOST_AUTO_TEST_CASE( son_pay_test )
BOOST_REQUIRE_EQUAL(son_stats_obj2->total_sidechain_txs_reported.at(sidechain_type::hive), 12); BOOST_REQUIRE_EQUAL(son_stats_obj2->total_sidechain_txs_reported.at(sidechain_type::hive), 12);
BOOST_REQUIRE_EQUAL(son_stats_obj2->total_sidechain_txs_reported.at(sidechain_type::ethereum), 18); BOOST_REQUIRE_EQUAL(son_stats_obj2->total_sidechain_txs_reported.at(sidechain_type::ethereum), 18);
// Check that Alice and Bob are paid for signing the transactions in the previous day/cycle // Check that Alice and Bob are paid for signing the transactions in the previous day/cycle
BOOST_REQUIRE_EQUAL(db.get_balance(obj1->son_account, asset_id_type()).amount.value, 80+obj1_balance); BOOST_REQUIRE_EQUAL(db.get_balance(obj1->son_account, asset_id_type()).amount.value, 79+obj1_balance);
BOOST_REQUIRE_EQUAL(db.get_balance(obj2->son_account, asset_id_type()).amount.value, 120+obj2_balance); BOOST_REQUIRE_EQUAL(db.get_balance(obj2->son_account, asset_id_type()).amount.value, 120+obj2_balance);
// Check the SON Budget is again allocated after maintenance // Check the SON Budget is again allocated after maintenance
BOOST_CHECK( dpo.son_budget.value == 200); BOOST_CHECK( dpo.son_budget.value == 200);