From fee7bc99faabf6779f9f2177d052b7318253500c Mon Sep 17 00:00:00 2001 From: Vlad Dobromyslov Date: Mon, 5 Jun 2023 09:24:04 +0000 Subject: [PATCH] Fix #549 testnet sync --- .gitlab-ci.yml | 4 ++-- libraries/chain/son_wallet_evaluator.cpp | 28 +++++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c443fe98..80c8fb23 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ build-mainnet: - build/programs/ - 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" + - if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "beatrice" || $CI_COMMIT_BRANCH == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "beatrice" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" tags: - builder @@ -82,7 +82,7 @@ build-testnet: - build/programs/ - 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" + - if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "beatrice" || $CI_COMMIT_BRANCH == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "beatrice" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" when: manual tags: - builder diff --git a/libraries/chain/son_wallet_evaluator.cpp b/libraries/chain/son_wallet_evaluator.cpp index 138f8e57..03e2edc1 100644 --- a/libraries/chain/son_wallet_evaluator.cpp +++ b/libraries/chain/son_wallet_evaluator.cpp @@ -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( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." ); + 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 id = (op.son_wallet_id.instance.value - std::distance(ast.begin(), ast.find(op.sidechain))) / ast.size(); + return son_wallet_id_type{ id }; + } + + return op.son_wallet_id; + }(); + const auto& idx = db().get_index_type().indices().get(); - 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 son_wallet_id_type son_wallet_id{ id }; FC_ASSERT( idx.find(son_wallet_id) != idx.end() ); //auto itr = idx.find(op.son_wallet_id); //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) { try { + 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 id = (op.son_wallet_id.instance.value - std::distance(ast.begin(), ast.find(op.sidechain))) / ast.size(); + return son_wallet_id_type{ id }; + } + + return op.son_wallet_id; + }(); + const auto& idx = db().get_index_type().indices().get(); - 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 son_wallet_id_type son_wallet_id{ id }; auto itr = idx.find(son_wallet_id); if (itr != idx.end()) {