Use the prev inner block hash of the last non simplex block - #479
Conversation
5241c87 to
b7ea146
Compare
Previously to this commit, when building the first ever simplex block, simplex was using the previous block hash of the protocol metadata, which is computed differently and incorrectly because the block previous to the first ever simplex block is not a simplex block.
| if block.InnerBlock != nil { | ||
| return errZeroBlockHasInnerBlock | ||
| } | ||
| if prevBlock.InnerBlock.Digest() != sm.LastNonSimplexInnerBlock.Digest() { |
There was a problem hiding this comment.
how was this passing before? prevBlock.InnerBlock is supposed to be nil after the if
There was a problem hiding this comment.
I think because prevBlock.InnerBlock is sm.LastNonSimplexInnerBlock
| Seq: 43, | ||
| Epoch: 43, | ||
| Prev: preSimplexParent.Digest(), | ||
| Prev: preSimplexParent.InnerBlock.Digest(), |
There was a problem hiding this comment.
but we are calling StateMachine.Digest which encodes the inner blocks digest. So with this change this says the last non-simplex block is no longer wrapped in simplex protocol metadata?
There was a problem hiding this comment.
we're building on top of the pre-simplex parent, so its digest is computed with the inner block.
The outer block doesn't exist for the pre-simplex parent, it's just a facade because we encode the ICMEpochInfo in the test outside of it.
| parsedBlock := &ParsedBlock{ | ||
| msm: e.msm, | ||
| StateMachineBlock: block, | ||
| legacyBlock: seq <= e.lastNonSimplexHeight, |
There was a problem hiding this comment.
wouldn't it be easier to just wrap any non-simplex blocks in the default protocol metadata? this way we wouldn't need the legacy block fields and wouldn't need to use inner.Digest
There was a problem hiding this comment.
the protocol metadata doesn't contain the hash though, and the hash is computed differently for pre-simplex blocks.
Previously to this commit, when building the first ever simplex block, simplex was using the previous block hash of the protocol metadata, which is computed differently and incorrectly because the block previous to the first ever simplex block is not a simplex block.