Skip to content

Issue 683 Requirements

John M. Jones edited this page Mar 19, 2018 · 5 revisions

bitshares-core Issue 683 - Skip updating certain secondary indexes during replay

Issue can be found here: https://github.com/bitshares/bitshares-core/issues/683

Additional Details:

According to libraries/chain/db_init.cpp:

The account_index has 2 secondary indexes

  1. account_member_index
  2. account_referrer_index

The proposal_index has 1 secondary index

  1. required_approval_index

These indexes are kept updated during the replay process. These indexes should be generated from the current chain state, and not constantly updated during the replay process. Making this change will result in a faster replay process.

Changes required:

The system must be able to determine that a replay is in progress. Once determined, any updates should bypass updating the secondary indexes.

Once the replay process is complete, the secondary indexes can be generated.

It appears that the majority of the code changes will reside in libraries/chain/db_management.cpp. The reindex method is called when a replay is required.

The reindex method calls either apply_block or push_block, and passes the block as well as an or'd list of things to skip.

The apply_block (db_block.cpp) calls detail::with_skip_flags, and passes a lambda that will call _apply_block.

The with_skip_flags saves off the normal skip flags, and calls the lambda. The destruction of the restorer object at the end of the method restores the original skip flags.

the _apply_block method loops through the transactions of the block, and applies them. It then calls several methods that update summary data, data objects, optionally perform chain maintenance, etc.

These methods are:

  • update_global_dynamic_data
  • update_signing_witnesses
  • update_last_irreversible_block
  • (optionally) perform_chain_maintenance (does do stuff with account index in call to perform_account_maintenance)
  • create_block_summary
  • clear_expired_transactions
  • clear_expired_proposals
  • clear_expired_orders
  • update_expired_feeds
  • update_withdraw_permissions
  • update_maintenance_flag
  • update_witness_schedule
  • (optionally) apply_debug_updates

To research: Find out all areas where the secondary indexes are updated.

Clone this wiki locally