eos icon indicating copy to clipboard operation
eos copied to clipboard

replay after block skips removing deferred transactions

Open wanderingbort opened this issue 8 years ago • 4 comments

description

Given 2 producers (A and B) where B has speculatively executed at least 1 deferred transaction and A produces a block.

B will roll back the speculatively applied deferred TX B will apply the block from A B will replay its speculative transactions which includes the deferred transaction B will not remove this transaction from the generated transaction index which means subsequent calls to push_deferred_transactions will attempt to replay the transaction and (hopefully) fail due to duplicate IDs

This is due to the way we are determining what to try to replay after a newly appended block.

We store off the pointer to the _pending_transaction_metas: https://github.com/EOSIO/eos/blob/459165e/libraries/chain/include/eosio/chain/chain_controller.hpp#L204

then after pushing the block, we re-apply the transactions that were not applied in that block: https://github.com/EOSIO/eos/blob/459165e/libraries/chain/include/eosio/chain/chain_controller.hpp#L212-L213

This calls _push_transaction directly but proper pruning of the generated transaction index is done in push_deferred_transactions: https://github.com/EOSIO/eos/blob/459165e/libraries/chain/chain_controller.cpp#L1765-L1766

However, all transactions including implicit and deferred are added to this list: https://github.com/EOSIO/eos/blob/459165e/libraries/chain/chain_controller.cpp#L370

This means that we will re-push those transactions after a block. This is inefficient for implicit transactions like on-block and deferred transactions. The former is guaranteed to be a duplicate and the latter will leave entries in the generated transaction index and potentially attempt to replay them.

Thoughts on solution

It is probably worthwhile to add a discriminating field to transaction_metadata which would allow without_pending_transactions to properly filter out deferred and implicit transactions for replay, or allows pushing properly cleanup into the common code path.

wanderingbort avatar Mar 29 '18 13:03 wanderingbort

@moskvanaft is this done?

andriantolie avatar Jul 03 '18 09:07 andriantolie

@andriantolie , this hasn't been done. Not sure if it's still relevant.

moskvanaft avatar Jul 03 '18 13:07 moskvanaft

Thanks for the confirmation!

andriantolie avatar Jul 04 '18 01:07 andriantolie

@wanderingbort @heifner I am presuming this is no longer relevant. If I don't hear anything I will presume that it is.

brianjohnson5972 avatar Oct 30 '18 16:10 brianjohnson5972