Skip to content

Bunch of changes related to block log

Piotr Batko requested to merge pbatko/block-log-fixes into master

Related: hive!731 (merged), haf!179 (merged)

Changes:

  • Block log index was replaced with block log artifacts.
    • No more following warnings at CI: UserWarning: Block log with following path is missing: InitNode0/blockchain/block_log.index.
  • Block log artifacts during replay are treated as optional.
    • Previously if were missing, warning was generated, and flag include_artifacts=False had to be used.
    • Now artifacts are used if provided. If are missing, then everything is OK. Replay is performed without them.
  • BlockLog.copy_to now returns copied block log object.
  • During copying block log, artifacts can be treated as required, optional or excluded.
    • Are excluded by default, to simplify use case, where user generates block log for tests and copy it to predefined location.
    • Removed specifying how artifacts are treated during copying from block log's initializer (because it's unneeded, way of copying artifacts is specified during copying with BlockLog.copy_to artifacts parameter).
    • Valid values of artifacts parameter are suggested with type annotations and enforced in runtime.
  • Following members are now @properties:
    • Block log can be get from node with syntax node.block_log (previously was node.get_block_log()).
    • Path of block log can be get with syntax block_log.path (previously was block_log.get_path()).
    • So now, to get path of node's block log syntax was simplified from node.get_block_log().get_path() to node.block_log.path.
  • Fix bug, which caused error when node was replayed from renamed block log.
  • Fix bug, which caused that name of requested output block log was ignored during block log truncation (in BlockLog.truncate method).
  • Add documentation of BlockLog.truncate method.
  • Add block log artifacts path getter (with @property, consistently with path of block log).
  • Prevent copying block log files partially when error occurs (previously artifacts could be copied, when block log was missing).

Minor changes:

  • "Block log" (instead of "blocklog", as single word) is consistenly written in whole project.
  • Member variable __owner was removed from BlockLog.
    • So owner do not have to be passed in initializer. It simplifies block log creation (from BlockLog(None, path) to BlockLog(path)).
  • Fixed error message for missing artifacts in given path (previous error message was about block log, not artifacts).
  • Add type annotations for path parameters (Union[Path, str]).
  • Minor refactors:
    • Method Snapshot.copy_to was simplified with helper method __copy_file.
    • Remove unneeded local variable block_log_artifacts_file_name.

Please review: @kmochocki @mzebrak

Edited by Mateusz Żebrak

Merge request reports