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

Map namespace between local name and remote name #895

Merged
merged 10 commits into from
Jul 13, 2022

Conversation

awrichar
Copy link
Contributor

@awrichar awrichar commented Jul 8, 2022

Part of FIR-12

Orchestrator is now aware of the namespace local name and remote name, as are some of the managers. Plugins are intentionally not aware of the mapping, but are passed the local or remote namespace names as appropriate.

The only two items which record a remote namespace name are Message and Group. These now have an additional localNamespace field, which will be populated with the local namespace, while the existing namespace field will be populated with the remote namespace (because it is part of the hash in both of these cases, it must remain the same for all members). In addition, Batch and Data items will be populated with the remote namespace name for network transit (but will be stored with the local namespace name only). Beyond these, every other existing object simply continues to populate its namespace with a local namespace name.

Some more notes on how the local namespace is filled for other items:

  • All definition types (datatypes, contract FFIs/APIs, identities, and token pools) are transmitted without a namespace filled. Each receiving node will map the definition based on the enclosing message's namespace, and then will fill in the local namespace name before storing the item.
  • Token transfers and approvals continue to inherit their namespace from the associated token pool.
  • Contract listeners are still local-only, and blockchain events tied to them will inherit their namespace.

awrichar added 9 commits July 8, 2022 16:19
Currently the local namespace name is still used everywhere, but this is the first
step in propagating both names further into the stack.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Note: many sanity checks on token namespaces were removed, as it became clear
that they were impossible to hit (cannot query database for one namespace and
somehow receive a result from another namespace).

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Operations deal only with local namespace names, while other plugin operations
use remote namespace names.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Do not transmit a namespace in the definition. Every receiver will fill in
a namespace based on the message containing the definition.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Batch manager (and therefore all processors) is specific to a single namespace.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
The namespaces on these items is not transmitted but is inferred from a
previously created local definition (a contract listener or token pool).
Therefore, all filtering is based on the local namespace name.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
@codecov-commenter
Copy link

codecov-commenter commented Jul 8, 2022

Codecov Report

Merging #895 (96d9e44) into main (6789f92) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 96d9e44 differs from pull request most recent head 074dee5. Consider uploading reports for the commit 074dee5 to get more accurate results

@@            Coverage Diff             @@
##             main     #895      +/-   ##
==========================================
+ Coverage   99.96%   99.97%   +0.01%     
==========================================
  Files         298      298              
  Lines       19405    19274     -131     
==========================================
- Hits        19399    19270     -129     
+ Misses          5        4       -1     
+ Partials        1        0       -1     
Impacted Files Coverage Δ
internal/definitions/sender.go 100.00% <ø> (ø)
pkg/core/data.go 100.00% <ø> (ø)
pkg/core/datatype.go 100.00% <ø> (ø)
pkg/core/group.go 100.00% <ø> (ø)
pkg/core/identity.go 100.00% <ø> (ø)
pkg/core/message.go 100.00% <ø> (ø)
pkg/core/namespace.go 100.00% <ø> (ø)
pkg/core/operation.go 100.00% <ø> (ø)
pkg/core/tokenpool.go 100.00% <ø> (ø)
internal/batch/batch_manager.go 100.00% <100.00%> (ø)
... and 62 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 ca1f963...074dee5. Read the comment docs.

@@ -34,14 +33,17 @@ func (bm *definitionSender) DefineFFI(ctx context.Context, ffi *fftypes.FFI, wai
}

if bm.multiparty {
ffi.Namespace = bm.namespace // TODO: change validation to not check namespace
Copy link
Member

Choose a reason for hiding this comment

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

Is this still a TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea... needs to be done in firefly-common. I'll add a card to the board.

msg, err := bm.sendDefinitionDefault(ctx, datatype, core.SystemTagDefineDatatype, waitConfirm)
if msg != nil {
datatype.Message = msg.Header.ID
}
datatype.Namespace = bm.namespace
Copy link
Member

Choose a reason for hiding this comment

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

Just for my own understanding, why do we set this right before returning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm trying to ensure it's set on everything sent to the database or in an HTTP response, but not in anything packed for sending over dataexchange/sharedstorage.

Copy link
Member

@shorsher shorsher left a comment

Choose a reason for hiding this comment

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

Looks good, but will defer to @peterbroadhurst.

Just noting here we did talk about different ways to handle unsetting the namespace other than *.namespace = ""

@awrichar awrichar merged commit 3e8f9cc into hyperledger:main Jul 13, 2022
@awrichar awrichar deleted the remotename branch July 13, 2022 19:06
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