Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Gh#4836 signals #4901

Merged
merged 10 commits into from Aug 8, 2018
Merged

Gh#4836 signals #4901

merged 10 commits into from Aug 8, 2018

Conversation

heifner
Copy link
Contributor

@heifner heifner commented Jul 27, 2018

Resolves #4836

Added new emit of signals:

  • emit accepted_transaction signal for implicit transaction onerror.
  • emit accepted_transaction signal for all scheduled transactions.
  • emit applied_transaction signal after onerror processing of scheduled transactions.
  • emit applied_transaction signal for expired scheduled transactions.

Added new implicit and scheduled flags to transaction_metadata so bnet and other plugins can explicitly distinguish transaction types. Updated the bnet_plugin to use the new flags.

heifner and others added 6 commits July 27, 2018 11:59
- emit accepted_transaction signal for all scheduled transactions.
- emit applied_transaction signal after onerror processing of scheduled transactions.
- emit applied_transaction signal for expired scheduled transactions.
@heifner heifner mentioned this pull request Aug 6, 2018
@@ -623,6 +635,8 @@ struct controller_impl {
trace = error_trace;
if( !trace->except_ptr ) {
undo_session.squash();
emit( self.accepted_transaction, trx );
emit( self.applied_transaction, trace );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apply_onerror would already emit an accepted_transaction signal for onerror transaction followed by an applied_transaction signal for the onerror transaction's trace (but without the inner deferred transaction trace).

These two lines would mean emitting the signals again in the case of soft_fail. Except that the accepted_transaction signal is emitted with the original transaction (not the on error) and the applied_transaction is emitted with the finalized, correct trace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me the correct thing here is to not emit in apply_onerror and instead handle all the exit conditions in push_scheduled_transaction.

@@ -1332,7 +1347,7 @@ void controller::push_confirmation( const header_confirmation& c ) {

transaction_trace_ptr controller::push_transaction( const transaction_metadata_ptr& trx, fc::time_point deadline, uint32_t billed_cpu_time_us ) {
validate_db_available_size();
return my->push_transaction(trx, deadline, false, billed_cpu_time_us, billed_cpu_time_us > 0 );
return my->push_transaction(trx, deadline, billed_cpu_time_us, billed_cpu_time_us > 0 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert that trx->implicit is false so that it does not become possible for outside callers to push a transaction that is treated as an implicit transaction by controller.

@@ -1084,7 +1084,7 @@ BOOST_FIXTURE_TEST_CASE(deferred_transaction_tests, TESTER) { try {
auto c = control->applied_transaction.connect([&]( const transaction_trace_ptr& t) { if (t && t->scheduled) { trace = t; } } );
CALL_TEST_FUNCTION(*this, "test_transaction", "send_deferred_transaction", {});
CALL_TEST_FUNCTION(*this, "test_transaction", "cancel_deferred_transaction_success", {});
produce_block( fc::seconds(2) );
produce_block( fc::seconds(3) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not necessary, I made it while debugging another issue.

trx->accepted = true;
emit( self.accepted_transaction, trx);
}

emit(self.applied_transaction, trace);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We emit the accepted_transaction and applied_transaction signals in push_transaction prior to squashing the undo sessions and canceling the scoped_exit to restore the block receipts, but we emit those signals after squashing the undo sessions in push_scheduled_transaction. It should be consistent.

The question is which one is more appropriate? You seem to have intentionally changed the point at which the existing signals were emitted to happen after. Was there a reason for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason was my first stab at this I used a scoped exit to call the emits. However, that failed on gcc. I think I will go with the previous emit before squash/undo.

@heifner heifner merged commit 79fd74c into develop Aug 8, 2018
@heifner heifner deleted the gh#4836-signals branch August 8, 2018 12:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants