-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat(lib/babe): add check of types.ConfigData.SecondarySlots for disabling secondary verification #1910
feat(lib/babe): add check of types.ConfigData.SecondarySlots for disabling secondary verification #1910
Changes from 20 commits
c8b46b5
250986d
7d6f8cd
3692fd0
09e702c
d25c781
c26553d
4e2f925
4ef4652
ee0900d
1e221c3
b6930bb
83a4591
ac41b7a
2ae9e0f
b4f4fad
da13828
1c21820
73f08b5
1ee9ffc
1d70d13
fb16b0b
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 |
---|---|---|
|
@@ -31,9 +31,10 @@ import ( | |
// verifierInfo contains the information needed to verify blocks | ||
// it remains the same for an epoch | ||
type verifierInfo struct { | ||
authorities []types.Authority | ||
randomness Randomness | ||
threshold *common.Uint128 | ||
authorities []types.Authority | ||
randomness Randomness | ||
threshold *common.Uint128 | ||
secondarySlots bool | ||
} | ||
|
||
// onDisabledInfo contains information about an authority that's been disabled at a certain | ||
|
@@ -224,9 +225,10 @@ func (v *VerificationManager) getVerifierInfo(epoch uint64) (*verifierInfo, erro | |
} | ||
|
||
return &verifierInfo{ | ||
authorities: epochData.Authorities, | ||
randomness: epochData.Randomness, | ||
threshold: threshold, | ||
authorities: epochData.Authorities, | ||
randomness: epochData.Randomness, | ||
threshold: threshold, | ||
secondarySlots: configData.SecondarySlots > 0, | ||
}, nil | ||
} | ||
|
||
|
@@ -247,11 +249,12 @@ func (v *VerificationManager) getConfigData(epoch uint64) (*types.ConfigData, er | |
|
||
// verifier is a BABE verifier for a specific authority set, randomness, and threshold | ||
type verifier struct { | ||
blockState BlockState | ||
epoch uint64 | ||
authorities []types.Authority | ||
randomness Randomness | ||
threshold *common.Uint128 | ||
blockState BlockState | ||
epoch uint64 | ||
authorities []types.Authority | ||
randomness Randomness | ||
threshold *common.Uint128 | ||
secondarySlots bool | ||
} | ||
|
||
// newVerifier returns a Verifier for the epoch described by the given descriptor | ||
|
@@ -261,11 +264,12 @@ func newVerifier(blockState BlockState, epoch uint64, info *verifierInfo) (*veri | |
} | ||
|
||
return &verifier{ | ||
blockState: blockState, | ||
epoch: epoch, | ||
authorities: info.authorities, | ||
randomness: info.randomness, | ||
threshold: info.threshold, | ||
blockState: blockState, | ||
epoch: epoch, | ||
authorities: info.authorities, | ||
randomness: info.randomness, | ||
threshold: info.threshold, | ||
secondarySlots: info.secondarySlots, | ||
}, nil | ||
} | ||
|
||
|
@@ -409,15 +413,28 @@ func (b *verifier) verifyPreRuntimeDigest(digest *types.PreRuntimeDigest) (scale | |
case types.BabePrimaryPreDigest: | ||
ok, err = b.verifyPrimarySlotWinner(d.AuthorityIndex, d.SlotNumber, d.VRFOutput, d.VRFProof) | ||
case types.BabeSecondaryVRFPreDigest: | ||
if !b.secondarySlots { | ||
ok = false | ||
break | ||
} | ||
pub := b.authorities[d.AuthorityIndex].Key | ||
var pk *sr25519.PublicKey | ||
pk, err = sr25519.NewPublicKey(pub.Encode()) | ||
|
||
pk, err := sr25519.NewPublicKey(pub.Encode()) // nolint | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ok, err = verifySecondarySlotVRF(&d, pk, b.epoch, len(b.authorities), b.randomness) // nolint | ||
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. Same here, let's not use 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 removed //nolint tag completely, and linter no longer complains, has something changed? 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. Well yes, |
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ok, err = verifySecondarySlotVRF(&d, pk, b.epoch, len(b.authorities), b.randomness) | ||
case types.BabeSecondaryPlainPreDigest: | ||
if !b.secondarySlots { | ||
ok = false | ||
break | ||
} | ||
|
||
ok = true | ||
err = verifySecondarySlotPlain(d.AuthorityIndex, d.SlotNumber, len(b.authorities), b.randomness) | ||
} | ||
|
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.
Assuming this is because of govet's funny shadowing detection feature, use this instead:
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.
I removed //nolint tag completely, and linter no longer complains, has something changed?
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.
Well yes,
golangci-lint
version wasn't pinned in the CI (see #1979), so maybe that was a false positive back months ago and now it doesn't detect it anymore.