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

change private key loading logic #3621

Merged
merged 3 commits into from
Sep 2, 2022
Merged

change private key loading logic #3621

merged 3 commits into from
Sep 2, 2022

Conversation

CoderZhi
Copy link
Collaborator

@CoderZhi CoderZhi commented Sep 1, 2022

  1. Merge PrivateKeyConfigFile and ProducerPrivKey
  2. Move PrivateKeyConfigFileMethod to blockchain.Config and rename it to ProducerPrivKeySchema
  3. Load ProducerPrivKey according to ProducerPrivKeySchema
  4. Add sync.Once to prevent blockchain.SetProducerPrivKey being called multiple times.

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@CoderZhi CoderZhi requested a review from a team as a code owner September 1, 2022 21:50
@@ -25,6 +26,7 @@ import (
type (
// Config is the config struct for blockchain package
Config struct {
producerPrivKeyLoader sync.Once
Copy link
Member

Choose a reason for hiding this comment

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

defined but not used?
also, this can be outside of the Config struct?

@codecov
Copy link

codecov bot commented Sep 2, 2022

Codecov Report

Merging #3621 (106a43d) into master (a20e489) will decrease coverage by 1.03%.
The diff coverage is 71.24%.

@@            Coverage Diff             @@
##           master    #3621      +/-   ##
==========================================
- Coverage   75.43%   74.39%   -1.04%     
==========================================
  Files         247      260      +13     
  Lines       22845    23581     +736     
==========================================
+ Hits        17233    17543     +310     
- Misses       4685     5109     +424     
- Partials      927      929       +2     
Impacted Files Coverage Δ
action/action_deserializer.go 57.14% <ø> (ø)
action/protocol/poll/nativestaking.go 41.08% <0.00%> (-0.65%) ⬇️
action/protocol/poll/staking_command.go 10.71% <0.00%> (ø)
action/protocol/staking/read_state.go 15.38% <0.00%> (ø)
action/protocol/vote/probationlist.go 87.50% <ø> (ø)
api/blocklistener.go 70.73% <0.00%> (ø)
api/websocket.go 5.17% <0.00%> (-0.19%) ⬇️
blockchain/block/block_deserializer.go 71.15% <ø> (ø)
blockchain/blockchain.go 0.89% <0.00%> (ø)
blockchain/filedao/filedao_legacy.go 85.80% <ø> (ø)
... and 107 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

case "hashiCorpVault":
cli, err := newVaultClient(&pc.VaultConfig)
yaml, err := config.NewYAML(config.Expand(os.LookupEnv), config.File(cfg.ProducerPrivKey))
Copy link
Member

Choose a reason for hiding this comment

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

nit: cfg.ProducerPrivKey can be a private key text (hex-string) or a filename (like "/var/data/vault.config", which could be a little confusing

@sonarcloud
Copy link

sonarcloud bot commented Sep 2, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dustinxie dustinxie merged commit ba84d70 into master Sep 2, 2022
@dustinxie dustinxie deleted the private_key_loading branch September 2, 2022 03:32
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.

3 participants