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

New endpoint /node/loaded-keys #5943

Merged
merged 4 commits into from Feb 13, 2024
Merged

New endpoint /node/loaded-keys #5943

merged 4 commits into from Feb 13, 2024

Conversation

sstanculeanu
Copy link
Contributor

@sstanculeanu sstanculeanu commented Feb 9, 2024

Reasoning behind the pull request

  • new enpoint needed for all the keys loaded by a node

Proposed changes

  • added new endpoint
    image

Testing procedure

  • standard system test + multi key test and check /node/loaded-keys on both single key(validator and observer) and multi key

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

Copy link

codecov bot commented Feb 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (9c4a906) 80.15% compared to head (a5c3bca) 80.17%.

Additional details and impacted files
@@                Coverage Diff                @@
##           rc/v1.6.next1    #5943      +/-   ##
=================================================
+ Coverage          80.15%   80.17%   +0.02%     
=================================================
  Files                709      709              
  Lines              94135    94172      +37     
=================================================
+ Hits               75456    75506      +50     
+ Misses             13331    13317      -14     
- Partials            5348     5349       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -36,7 +36,8 @@ import (
const DefaultRestInterface = "localhost:8080"

// DefaultRestPortOff is the default value that should be passed if it is desired
// to start the node without a REST endpoint available
//
Copy link
Contributor

Choose a reason for hiding this comment

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

indenting went wrong here and on L167

func (nar *nodeApiResolver) GetManagedKeys() []string {
managedKeys := nar.managedPeersMonitor.GetManagedKeys()
return nar.parseKeys(managedKeys)
}

// GetLoadedKeys returns all keys that were loaded and will be managed by this node
func (nar *nodeApiResolver) GetLoadedKeys() []string {
loadedKeys := nar.managedPeersMonitor.GetLoadedKeys()
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: should we append the main BLS key from crypto components to this list? Reason: maybe we are using the node in single key mode, not multikey and this route should return the main BLS key.
Or return that single key if the list returned by the managedPeersMonitor is empty. I guess this will be better as the multikey list won't be polluted by an observer BLS key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pushed

it will also return the public key for single key observers


args := createMockArgsManagedPeersHolder()
holder, _ := keysManagement.NewManagedPeersHolder(args)
_ = holder.AddManagedPeer(skBytes1)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 testing out the sort call

@sstanculeanu sstanculeanu changed the title New route /node/loaded-keys New endpoint /node/loaded-keys Feb 12, 2024
@ssd04 ssd04 self-requested a review February 12, 2024 08:30
Comment on lines +308 to +315
allLoadedKeys := make([][]byte, 0, len(holder.data))
for pk := range holder.data {
allLoadedKeys = append(allLoadedKeys, []byte(pk))
}

sort.Slice(allLoadedKeys, func(i, j int) bool {
return string(allLoadedKeys[i]) < string(allLoadedKeys[j])
})
Copy link
Contributor

Choose a reason for hiding this comment

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

extract this logic into a separate func and used in ManagedKeysByCurrentNode and remove sorting logic from managePeersMonitor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ManagedKeysByCurrentNode has an extra check than GetLoadedKeysByCurrentNode, the one for validators.. thus the common code is just the sorting which can be done separate

Copy link
Collaborator

@gabi-vuls gabi-vuls left a comment

Choose a reason for hiding this comment

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

  • allin ✅
  • scenario ✅
  • on multikey nodes the route prins all keys , and on single key nodes the route prints that one specific key ✅

Normal allin test: v1.6.15-dev-config-eb2e06c06d -> loaded-keys-ebeaab4359

--- Specific errors ---

block hash does not match 399
wrong nonce in block 295
miniblocks does not match 0
num miniblocks does not match 0
miniblock hash does not match 0
block bodies does not match 0
receipts hash missmatch 0

/------/

--- Statistics ---

Nr. of all ERRORS: 1
Nr. of all WARNS: 258
Nr. of new ERRORS: 1
Nr. of new WARNS: 23
Nr. of PANICS: 0

/------/

--- ERRORS ---

/------/

@gabi-vuls gabi-vuls merged commit 452bf4b into rc/v1.6.next1 Feb 13, 2024
8 checks passed
@gabi-vuls gabi-vuls deleted the loaded-keys branch February 13, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants