From ce9e480ef90859c2c6fbc6afc4a115ab5ffef8bc Mon Sep 17 00:00:00 2001 From: abitmore Date: Fri, 5 Nov 2021 20:50:05 +0000 Subject: [PATCH 1/2] Add tests to reproduce operation_results issue The broadcast_transaction_with_callback API returns an empty operation_results --- tests/tests/network_broadcast_api_tests.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/tests/network_broadcast_api_tests.cpp b/tests/tests/network_broadcast_api_tests.cpp index 9a4a264492..17dd7e8857 100644 --- a/tests/tests/network_broadcast_api_tests.cpp +++ b/tests/tests/network_broadcast_api_tests.cpp @@ -43,6 +43,9 @@ BOOST_AUTO_TEST_CASE( broadcast_transaction_with_callback_test ) { auto callback = [&]( const variant& v ) { ++called; + idump((v)); + auto callback_obj = v.as(200); + BOOST_CHECK_EQUAL( callback_obj.trx.operations.size(), callback_obj.trx.operation_results.size() ); }; fc::ecc::private_key cid_key = fc::ecc::private_key::regenerate( fc::digest("key") ); From f812666bb3bb884f6e8e5e7e669dc0050d3f3a69 Mon Sep 17 00:00:00 2001 From: abitmore Date: Fri, 5 Nov 2021 20:58:22 +0000 Subject: [PATCH 2/2] Notify on_block listeners with processed block... ... so that the listeners know the operation results --- libraries/chain/db_block.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 0c54dbf0f9..7dab0b27d6 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -613,7 +613,8 @@ void database::_apply_block( const signed_block& next_block ) _issue_453_affected_assets.clear(); - for( const auto& trx : next_block.transactions ) + signed_block processed_block( next_block ); // make a copy + for( auto& trx : processed_block.transactions ) { /* We do not need to push the undo state for each transaction * because they either all apply and are valid or the @@ -621,7 +622,7 @@ void database::_apply_block( const signed_block& next_block ) * for transactions when validating broadcast transactions or * when building a block. */ - apply_transaction( trx, skip ); + trx.operation_results = apply_transaction( trx, skip ).operation_results; ++_current_trx_in_block; } @@ -661,7 +662,7 @@ void database::_apply_block( const signed_block& next_block ) apply_debug_updates(); // notify observers that the block has been applied - notify_applied_block( next_block ); //emit + notify_applied_block( processed_block ); //emit _applied_ops.clear(); notify_changed_objects();