-
Notifications
You must be signed in to change notification settings - Fork 689
Extra null check for V1 genesis #11533
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: master
Are you sure you want to change the base?
Changes from 1 commit
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 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -237,7 +237,7 @@ public void Initialize(XdcBlockHeader current) | |||||||||||
| { | ||||||||||||
| IXdcReleaseSpec spec = _specProvider.GetXdcSpec(current); | ||||||||||||
| QuorumCertificate latestQc; | ||||||||||||
| if (current.Number == spec.SwitchBlock) | ||||||||||||
| if (current.Number == spec.SwitchBlock || current.ExtraConsensusData is null) | ||||||||||||
|
Contributor
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. The null guard is correct and prevents the NRE in the
Suggested change
|
||||||||||||
| { | ||||||||||||
| latestQc = new QuorumCertificate(new BlockRoundInfo(current.Hash, 0, current.Number), Array.Empty<Signature>(), | ||||||||||||
| (ulong)Math.Max(0, current.Number - spec.Gap)); | ||||||||||||
|
|
||||||||||||
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.
Medium — Silent fallback without a warning log
When
current.ExtraConsensusData is nullon a block that is not the switch block,Initializesilently treats it as a genesis block: round is reset to 1 and a synthetic zero-round QC is constructed. This is the correct action to avoid an NPE (the original bug), but it is inconsistent with how the rest of the file handles the same condition —CommitBlockat line 95 logs a warning and returns an error for the same missing-data scenario ("Chain might be corrupt!").Without a warning log here, chain corruption or a deserialization bug that leaves
ExtraConsensusDatanull on a mid-chain block will produce no observable signal; the node will just silently restart consensus from round 1.Suggested fix — add a warn log inside the branch when it isn't the switch block:
Fix this →