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

remove redundant key generation code #1469

Merged
merged 5 commits into from Oct 12, 2021
Merged

remove redundant key generation code #1469

merged 5 commits into from Oct 12, 2021

Conversation

kc1116
Copy link
Contributor

@kc1116 kc1116 commented Oct 8, 2021

Small PR to remove some redundant key generation code flagged in a separate PR .

Copy link
Member

@jordanschalm jordanschalm left a comment

Choose a reason for hiding this comment

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

👌 Thanks for the clean-up

sk, err := crypto.GeneratePrivateKey(crypto.BLSBLS12381, seed)
return sk, err
func StakingKey() crypto.PrivateKey {
return BLS12381Key()
}

func StakingKeys(n int) ([]crypto.PrivateKey, error) {
Copy link
Member

Choose a reason for hiding this comment

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

We can remove the error return here as well

Comment on lines 235 to 236
stakingAccountKey = unittest.ECDSAP256Key()
networkingKey = unittest.ECDSAP256Key()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
stakingAccountKey = unittest.ECDSAP256Key()
networkingKey = unittest.ECDSAP256Key()
stakingAccountKey = unittest.ECDSAP256Key()
networkingKey = unittest.NetworkingKey()

Naming suggestion: operatorAccountKey rather than stakingAccountKey (for the reasons we've discussed of the confusion between stakingKey and stakingAccountKey)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

Thanks for tackling the late comments:

  • ECDSAKey, BLSKey can be replaced everywhere with PrivateKeyFixture(crypto.ECDSAP256, crypto.KeyGenSeedMinLenECDSAP256), PrivateKeyFixture(crypto.BLSBLS12381, crypto.KeyGenSeedMinLenBLSBLS12381). I don't need we need the level of indirection
  • we manipulate a ton of stakingKey, networkingKey, variables, etc. A way to manage the confusion is to make the function names more clear about what's going on in fixtures: RandomStakingPrivKey, RandomNetworkingPrivKey ...

@kc1116
Copy link
Contributor Author

kc1116 commented Oct 11, 2021

Thanks for tackling the late comments:

  • ECDSAKey, BLSKey can be replaced everywhere with PrivateKeyFixture(crypto.ECDSAP256, crypto.KeyGenSeedMinLenECDSAP256), PrivateKeyFixture(crypto.BLSBLS12381, crypto.KeyGenSeedMinLenBLSBLS12381). I don't need we need the level of indirection
  • we manipulate a ton of stakingKey, networkingKey, variables, etc. A way to manage the confusion is to make the function names more clear about what's going on in fixtures: RandomStakingPrivKey, RandomNetworkingPrivKey ...

803b9e5

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@kc1116
Copy link
Contributor Author

kc1116 commented Oct 12, 2021

bors merge

@codecov-commenter
Copy link

Codecov Report

Merging #1469 (f5193e7) into master (361ba2d) will increase coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1469   +/-   ##
=======================================
  Coverage   55.11%   55.12%           
=======================================
  Files         517      517           
  Lines       32334    32330    -4     
=======================================
+ Hits        17821    17822    +1     
+ Misses      12121    12114    -7     
- Partials     2392     2394    +2     
Flag Coverage Δ
unittests 55.12% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/bootstrap/utils/node_info.go 0.00% <0.00%> (ø)
engine/collection/synchronization/engine.go 62.90% <0.00%> (-1.08%) ⬇️
...sus/approvals/assignment_collector_statemachine.go 45.19% <0.00%> (+2.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 361ba2d...f5193e7. Read the comment docs.

@bors
Copy link
Contributor

bors bot commented Oct 12, 2021

@bors bors bot merged commit 9fb36b1 into master Oct 12, 2021
@bors bors bot deleted the khalil/refactor-key-funcs branch October 12, 2021 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants