Add assertions for block log data sizes
This MR adds assertions for head block raw data size
Example error before:
3236251ms block_log.cpp:158 open ] Opening blocklog /storage1/kristupas/hive/hived_data_dir/./blockchain/block_log
3236251ms block_log.cpp:187 open ] block_log_size: 621687762944
3236251ms block_log.cpp:480 read_head ] 13 St9bad_alloc: std::bad_alloc
rethrow std::bad_alloc:
{"what":"std::bad_alloc"}
block_log.cpp:480 read_head
3236251ms database.cpp:154 open ] 13 St9bad_alloc: std::bad_alloc
rethrow std::bad_alloc:
{"what":"std::bad_alloc"}
block_log.cpp:480 read_head
3236251ms database.cpp:154 open ] args.data_dir: /storage1/kristupas/hive/hived_data_dir/./blockchain args.shared_mem_dir: /storage1/kristupas/hive/hived_data_dir/./blockchain args.shared_file_size: 57982058496
3236251ms chain_plugin.cpp:634 open ] Error opening database. If the binary or configuration has changed, replay the blockchain explicitly using `--force-replay`.
3236251ms chain_plugin.cpp:635 open ] If you know what you are doing you can skip this check and force open the database using `--force-open`.
3236251ms chain_plugin.cpp:636 open ] WARNING: THIS MAY CORRUPT YOUR DATABASE. FORCE OPEN AT YOUR OWN RISK.
3236251ms chain_plugin.cpp:637 open ] Error: {"code":13,"name":"St9bad_alloc","message":"std::bad_alloc","stack":[{"context":{"level":"warn","file":"block_log.cpp","line":480,"method":"read_head","hostname":"","timestamp":"2022-08-02T08:53:56"},"format":"rethrow ${what}: ","data":{"what":"std::bad_alloc"}},{"context":{"level":"warn","file":"database.cpp","line":154,"method":"open","hostname":"","timestamp":"2022-08-02T08:53:56"},"format":"rethrow","data":{"args.data_dir":"/storage1/kristupas/hive/hived_data_dir/./blockchain","args.shared_mem_dir":"/storage1/kristupas/hive/hived_data_dir/./blockchain","args.shared_file_size":"57982058496"}}]}
After adding assertion:
748848ms block_log.cpp:621 read_head ] 10 assert_exception: Assert Exception
(size_t)(block_log_size) > ( head_block_offset - sizeof(head_block_offset) ):
{}
block_log.cpp:601 read_raw_head_block
748848ms database.cpp:155 open ] 10 assert_exception: Assert Exception
(size_t)(block_log_size) > ( head_block_offset - sizeof(head_block_offset) ):
{}
block_log.cpp:601 read_raw_head_block
rethrow
{}
block_log.cpp:621 read_head
748848ms database.cpp:155 open ] args.data_dir: /storage1/kristupas/hive/hived_data_dir/./blockchain args.shared_mem_dir: /storage1/kristupas/hive/hived_data_dir/./blockchain args.shared_file_size: 21474836480