Closed limemloh closed 9 months ago
The protocol version is accessible in most parts of the code, so it is easy to put pretty much anywhere in the block hash, but I think it should be very close to the top of the state hash, since the light client will need this to understand the remaining hashing structure. But it could also get the information from the node and then check it afterward without an issue.
Absolute and relative block height are not really available in the block state, since they live in the tree state, by suggestion is to introduce a node above the block state hash in the state hash, which includes this information and the block state hash as the first branch.
data BlockTreeStateHashInputs pv = BlockTreeStateHashInputs
{ blockStateHash :: BlockStateHash, -- What previously was the state hash.
relativeBlockHeight :: RelativeBlockHeight,
absoluteBlockHeight :: AbsoluteBlockHeight,
}
makeBlockTreeStateHashInputs :: BlockTreeStateHashInputs pv -> StateHash
makeBlockTreeStateHashInputs {..} =
if includesBlockheightAndPVInHashing pv then
StateHashV0 $
H.hashOfHashes
blockStateHash
(hash $ put (relativeBlockHeight, abosluteBlockheight, pv))
else
StateHashV0 blockStateHash
To me, the simplest solution seems to be to add a _finalizationCommitteeHash
field to PersistentEpochBakers
type where the information to derive this is already present.
Then of course have the hashing, loading and storing for this type branch on the protocol version.
The information is not as close to the root as it could be, but I think it is still reasonable.
Including the protocol version will be done as a separate task tracked here https://github.com/Concordium/concordium-node/issues/1106
To reduce the work needed for light client implementations, starting from Protocol version 7 the block hash should include more information: