Open abitmore opened 6 years ago
Proposed solution: Add new properties in addition to head_block_time and head_block_num called current_block_time and current_block_num. These will be set to head_block_time and head_block_num unless you are processing a block. They should also be rolled back in the case of an exception that stops block processing.
Transaction and other processing that can happen within a block should use the new fields. Anything outside that process can continue to use headblock???
Note: This can mean some metadata within things like transactions can change. i.e. a transaction being moved from pending to within a block will have their block time and number changed. I have not researched the implications of this, but believe it to be okay, as there are no guarantees that pending transactions will end up in a particular block.
there are no guarantees that pending transactions will end up in a particular block, and there can be different reasons, not only due time, but also due to size.
Don't forget block generation. That currently uses head_block_time of the block that it is building upon.
I agree that the current implementation is not nice and may lead to surprising results sometimes, but it doesn't hurt very much in practice. Changing it requires significant effort and will forever pollute our codebase with a hardfork.
I agree that the current implementation is not nice and may lead to surprising results sometimes, but it doesn't hurt very much in practice. Changing it requires significant effort and will forever pollute our codebase with a hardfork.
After examining the issue, I must agree with @pmconrad. If all agree, we will mark this as a wontfix.
Won't fix.
Bug Description When processing a block, we usually use
database::head_block_time()
akadynamic_global_properties.time
to indicate "now". We also usedatabase::head_block_num()
. However, these variables are updated in the middle of the process, specifically, indatabase::update_global_dynamic_data()
, after processed transactions: https://github.com/bitshares/bitshares-core/blob/44a7c47a3c063033f535ee039cfd6b55088dce2a/libraries/chain/db_block.cpp#L520-L524It means when processing transactions, we're using the time and block number of last block. Technically it is not a big deal, but it has brought some confusions, for example:
Impacts Describe which portion(s) of BitShares Core may be impacted by this bug. Please tick at least one box.
Expected Behavior Block time and block number should be consistent when processing a block.
Additional Context (optional) This change requires a consensus upgrade. Do we need to correct/update old data after the upgrade?
CORE TEAM TASK LIST