Closed
Description
System information
Java-tron version: v4.7.2
OS & Version: Linux & macOS
Expected behavior
The getHeadBlockId
function should return the correct block header information.
Actual behavior
When synchronizing blocks, an abnormal block ID appears, as shown in the following log:
This ID: 00000000032b9cc50deb2777f7e751ade0245ace23c2cc8579d733af34401832
is composed of two parts, the number of block 53189829 and the hash of block 53189830. The reason for this phenomenon is that there is a concurrency problem in this function. The function definition is as follows:
public synchronized BlockId getHeadBlockId() {
return new BlockId(
dynamicPropertiesStore.getLatestBlockHeaderHash(),
dynamicPropertiesStore.getLatestBlockHeaderNumber());
}
When calling this function, if only the block hash is written at this time, and the block number has not been written in time, the above-mentioned situation will occur.