You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Blocks that have not been committed yet could be seen as finalized.
If the Commit struct stored in _commitSlots is uninitialized, commitSlot.timestamp will default to zero and the boolean expression indicating whether a block is finalized given the commit’s timestamp will evaluate to true.
Figure 2.1: The finalized function in fuel-v2-contracts/contracts/fuelchain/FuelChainState.sol
101/// @notice Checks if a given block is finalized102/// @param blockHash The hash of the block to check103/// @param blockHeight The height of the block to check104/// @return true if the block is finalized105function finalized(bytes32blockHash, uint256blockHeight) externalview
whenNotPaused returns (bool) {
106uint256 commitHeight = blockHeight / BLOCKS_PER_COMMIT_INTERVAL;
107 Commit storage commitSlot = _commitSlots[commitHeight % NUM_COMMIT_SLOTS];
108require(commitSlot.blockHash == blockHash, "Unknown block");
109110returnblock.timestamp>=uint256(commitSlot.timestamp) +111 }
However, in this case, the provided blockHash parameter must equal the default value of Commit.blockHash (bytes32(0)) for the function to pass the require-check on line 108.
Recommendations
Short term, include a check that returns false when commitSlot.timestamp equals zero.
Long term, carefully consider all edge cases, such as when checking for a finalized block when it has not been committed yet.
The text was updated successfully, but these errors were encountered:
Description
Blocks that have not been committed yet could be seen as finalized.
If the Commit struct stored in _commitSlots is uninitialized, commitSlot.timestamp will default to zero and the boolean expression indicating whether a block is finalized given the commit’s timestamp will evaluate to true.
Figure 2.1: The finalized function in fuel-v2-contracts/contracts/fuelchain/FuelChainState.sol
However, in this case, the provided blockHash parameter must equal the default value of Commit.blockHash (bytes32(0)) for the function to pass the require-check on line 108.
Recommendations
Short term, include a check that returns false when commitSlot.timestamp equals zero.
Long term, carefully consider all edge cases, such as when checking for a finalized block when it has not been committed yet.
The text was updated successfully, but these errors were encountered: