Skip to content
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

Merged
merged 22 commits into from
Nov 4, 2021
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c8b46b5
add check for types.ConfigData.SecondarySlots
edwardmack Oct 19, 2021
250986d
Merge branch 'development' into ed/use_types_configdata_secondarySlots
edwardmack Oct 20, 2021
7d6f8cd
Update lib/babe/verify.go
edwardmack Oct 22, 2021
3692fd0
Merge branch 'development' into ed/use_types_configdata_secondarySlots
edwardmack Oct 22, 2021
09e702c
Merge branch 'development' into ed/use_types_configdata_secondarySlots
edwardmack Oct 25, 2021
d25c781
update ok = false if !b.secondarySlots
edwardmack Oct 25, 2021
c26553d
Merge branch 'development' into ed/use_types_configdata_secondarySlots
edwardmack Oct 26, 2021
4e2f925
Merge branch 'development' into ed/use_types_configdata_secondarySlots
edwardmack Oct 26, 2021
4ef4652
stub test for secondary verification
edwardmack Oct 27, 2021
ee0900d
add test to verify secondary digest
edwardmack Oct 27, 2021
1e221c3
Merge branch 'development' into ed/use_types_configdata_secondarySlots
edwardmack Oct 29, 2021
b6930bb
address PR comments
edwardmack Oct 29, 2021
83a4591
add err check
edwardmack Oct 29, 2021
ac41b7a
update pointers to fix tests
edwardmack Nov 1, 2021
2ae9e0f
Merge branch 'development' into ed/use_types_configdata_secondarySlots
edwardmack Nov 1, 2021
b4f4fad
add tests for decoding
edwardmack Nov 1, 2021
da13828
my wip
timwu20 Nov 2, 2021
1c21820
fix VRF encoding
edwardmack Nov 2, 2021
73f08b5
Merge branch 'development' into ed/use_types_configdata_secondarySlots
edwardmack Nov 2, 2021
1ee9ffc
Merge branch 'development' into ed/use_types_configdata_secondarySlots
edwardmack Nov 3, 2021
1d70d13
update linter tags
edwardmack Nov 3, 2021
fb16b0b
Merge branch 'development' into ed/use_types_configdata_secondarySlots
edwardmack Nov 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions lib/babe/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,17 +388,18 @@ func (b *verifier) verifyPreRuntimeDigest(digest *types.PreRuntimeDigest) (types
case *types.BabePrimaryPreDigest:
ok, err = b.verifyPrimarySlotWinner(d.AuthorityIndex(), d.SlotNumber(), d.VrfOutput(), d.VrfProof())
case *types.BabeSecondaryVRFPreDigest:
if b.secondarySlots {
pub := b.authorities[d.AuthorityIndex()].Key
var pk *sr25519.PublicKey
pk, err = sr25519.NewPublicKey(pub.Encode())
if err != nil {
return nil, err
}

ok, err = verifySecondarySlotVRF(d, pk, b.epoch, len(b.authorities), b.randomness)
} else {
if !b.secondarySlots {
ok = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there's a secondary slot digest but b.secondarySlots == false then this should be ok = false, as the digest would be invalid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

break
}
pub := b.authorities[d.AuthorityIndex()].Key
var pk *sr25519.PublicKey
pk, err = sr25519.NewPublicKey(pub.Encode())
if err != nil {
qdm12 marked this conversation as resolved.
Show resolved Hide resolved
return nil, err
}

ok, err = verifySecondarySlotVRF(d, pk, b.epoch, len(b.authorities), b.randomness)
}

case *types.BabeSecondaryPlainPreDigest:
Expand Down