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 namespace from identity manager, network map, and group manager calls #862

Merged
merged 2 commits into from
Jun 20, 2022

Conversation

awrichar
Copy link
Contributor

@awrichar awrichar commented Jun 14, 2022

Part of FIR-12

Each manager is initialized for a single namespace and can assume all calls are scoped within that namespace This PR tackles identity manager, network manager, and group manager so they store and use that single namespace.

The one exception is for "network version 1", where identities may have been registered on the legacy "ff_system" namespace. In this case, the identity manager will query "ff_system" instead of its assigned namespace (noting that this will only work if "ff_system" shares a database with that namespace).

The manager is initialized for a single namespace and can assume all calls
are scoped within that namespace.

The one exception is for "network version 1", where identities may have been
registered on the legacy "ff_system" namespace. In this case, the identity
manager will query "ff_system" instead of its assigned namespace (noting that
this will only work if "ff_system" shares a database with that namespace).

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Also add namespace as a param to all database queries on identities,
verifiers, and groups.

Switch group manager to go via identity manager for identity lookups,
instead of going directly to the database (to preserve fallback
resolutions on ff_system).

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
@awrichar awrichar changed the title Remove namespace from identity manager calls Remove namespace from identity manager, network map, and group manager calls Jun 14, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 14, 2022

Codecov Report

Merging #862 (40e5c70) into main (362f721) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #862      +/-   ##
==========================================
- Coverage   99.96%   99.96%   -0.01%     
==========================================
  Files         300      300              
  Lines       19655    19610      -45     
==========================================
- Hits        19649    19604      -45     
  Misses          5        5              
  Partials        1        1              
Impacted Files Coverage Δ
internal/apiserver/route_get_groups.go 100.00% <100.00%> (ø)
internal/apiserver/route_get_identities.go 100.00% <100.00%> (ø)
internal/apiserver/route_get_identity_by_did.go 100.00% <100.00%> (ø)
internal/apiserver/route_get_identity_by_id.go 100.00% <100.00%> (ø)
internal/apiserver/route_get_identity_did.go 100.00% <100.00%> (ø)
internal/apiserver/route_get_identity_verifiers.go 100.00% <100.00%> (ø)
internal/apiserver/route_get_net_did.go 100.00% <100.00%> (ø)
internal/apiserver/route_get_net_diddoc.go 100.00% <100.00%> (ø)
internal/apiserver/route_get_net_identities.go 100.00% <100.00%> (ø)
internal/apiserver/route_get_net_node.go 100.00% <100.00%> (ø)
... and 45 more

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 362f721...40e5c70. Read the comment docs.

@@ -389,12 +388,13 @@ func (im *identityManager) cachedIdentityLookupByVerifierRef(ctx context.Context
return nil, err
} else if verifier == nil {
if namespace != core.LegacySystemNamespace && im.blockchain.NetworkVersion() == 1 {
// For V1 networks, fall back to SystemNamespace for looking up identities
// For V1 networks, fall back to LegacySystemNamespace for looking up identities
// This assumes that the system namespace shares a database with this manager's namespace!
return im.cachedIdentityLookupByVerifierRef(ctx, core.LegacySystemNamespace, verifierRef)
Copy link
Contributor Author

@awrichar awrichar Jun 15, 2022

Choose a reason for hiding this comment

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

This is the one location where a manager is performing a lookup across namespaces to something other than the one to which it is scoped. As noted, it will only work if the database plugin is shared between this manager's namespace and the ff_system namespace. Side note: ff_system (when enabled) always uses the same set of plugins as the default namespace.

The alternative I considered was giving some sort of global access to the ff_system orchestrator and identity manager, so that other identity managers could specifically query them... but it seemed heavyweight for what is a soon-to-be deprecated behavior.

Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

👍 - logic makes sense to me on the ff_system cross-ns identity lookup.

@peterbroadhurst peterbroadhurst merged commit 90ac27e into hyperledger:main Jun 20, 2022
@peterbroadhurst peterbroadhurst deleted the identity branch June 20, 2022 12:58
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