-
Notifications
You must be signed in to change notification settings - Fork 4
Use the prev inner block hash of the last non simplex block #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,7 @@ var ( | |
| errNilBlock = errors.New("block is nil") | ||
| errInvalidPChainHeight = errors.New("invalid P-chain height") | ||
| errZeroBlockHasInnerBlock = errors.New("zero block must not have an inner block") | ||
| errZeroBlockInnerDigestMismatch = errors.New("zero block inner block digest does not match last non-Simplex inner block digest") | ||
| errZeroBlockPrevDigestMismatch = errors.New("zero block previous digest does not match last non-Simplex inner block digest") | ||
| errZeroBlockTimestampMismatch = errors.New("zero block timestamp does not match last non-Simplex inner block timestamp") | ||
| errPrevSealingBlockNotFinalized = errors.New("previous sealing block is not finalized") | ||
| errBlockDigestMismatch = errors.New("does not match proposed block digest") | ||
|
|
@@ -772,9 +772,8 @@ func (sm *StateMachine) buildBlockZero(parentBlock StateMachineBlock, simplexMet | |
| timestamp := sm.LastNonSimplexInnerBlock.Timestamp().UnixMilli() | ||
| simplexEpochInfo := constructSimplexZeroBlockSimplexEpochInfo(pChainHeight, validatorSet, prevVMBlockSeq) | ||
|
|
||
| md := simplexMetadata | ||
| md.Prev = sm.LastNonSimplexInnerBlock.Digest() | ||
| md.Seq = sm.LastNonSimplexInnerBlock.Height() | ||
| simplexMetadata.Prev = sm.LastNonSimplexInnerBlock.Digest() | ||
| simplexMetadata.Seq = sm.LastNonSimplexInnerBlock.Height() + 1 | ||
|
|
||
| // The zero block carries over the parent's ICM epoch unchanged, just as it carries over the | ||
| // timestamp. If the parent is a genesis block that predates ICM, the carried-over epoch is empty, | ||
|
|
@@ -849,8 +848,10 @@ func (sm *StateMachine) verifyBlockZero(block *StateMachineBlock, prevBlock Stat | |
| if block.InnerBlock != nil { | ||
| return errZeroBlockHasInnerBlock | ||
| } | ||
| if prevBlock.InnerBlock.Digest() != sm.LastNonSimplexInnerBlock.Digest() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how was this passing before? prevBlock.InnerBlock is supposed to be nil after the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think because |
||
| return errZeroBlockInnerDigestMismatch | ||
|
|
||
| // The zero block must build upon the last non-Simplex block | ||
| if block.Metadata.SimplexProtocolMetadata.Prev != sm.LastNonSimplexInnerBlock.Digest() { | ||
| return errZeroBlockPrevDigestMismatch | ||
| } | ||
|
|
||
| // The timestamp must equal the last non-Simplex inner block's timestamp. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.DigestThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the protocol metadata doesn't contain the hash though, and the hash is computed differently for pre-simplex blocks.