Skip to content

Lightweight version of optimization based on storing transacion invariants.

Andrzej Lisak requested to merge abw_tx_invariants into develop

This MR contains some small fixes and additions:

  • eliminated some compilation warnings
  • changed when 200ms execution limit does not apply (now only in testnet debug)
  • fixed pack of asset_symbol (it was broken for SMTs)
  • added log messages for (hopefully impossible) case of failure to reapply new block and for transactions skipped during block production
  • fixed value of database::_current_trx_id for post-apply transaction handler and in case of exceptions

The main purpose of this MR is introduction of storage for transaction invariants, that is, result of their operation validation and calculation of public keys from signatures. Since these don't depend on state, they can be calculated once and next time they are needed we can reuse results of previous calculation.

Current version only stores invariants for solo transactions - if transaction comes with a block and was not previously seen by the node, it computes its invariants normally, but does not store them (which means f.e. that forking is not going to be optimized). If we wanted to extend the mechanism, it would require more complicated management of lifetime for invariant objects. Now they disappear when transaction is dropped from pending (at the end of pending reapplication process each pending has corresponding invariant object).

The optimization in current version speeds up mainly creation of new blocks (since new blocks are made entirely out of pending transactions, block producer does not need to recompute any invariants; also reapplication of newly created block is fully optimized). Blocks coming from P2P will be processed faster in part that shares transactions with list of pending - transactions from block that were previously observed by the node will reuse stored invariants.

Merge request reports