Skip to content

Conversation

@nguyer
Copy link
Contributor

@nguyer nguyer commented Nov 1, 2021

Messages that use the ff_system namespace:

  • Org registration
  • Node registration
  • Namespace definition

Messages that use whatever namespace is specified in the API request path:

  • Everything else

eventType := fftypes.EventTypeMessageConfirmed
switch {
case msg.Header.Namespace == fftypes.SystemNamespace:
case msg.Header.Namespace == fftypes.SystemNamespace || msg.Header.Type == fftypes.MessageTypeDefinition:
Copy link
Contributor

Choose a reason for hiding this comment

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

Does syshandler now handle anything that is not a definition?

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 think it's only ever handled definitions

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it needs a different name 🙃

Copy link
Contributor

Choose a reason for hiding this comment

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

And maybe the first part of the if clause here is irrelevant...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly. Probably worth some input from @peterbroadhurst on this one. I'll try to chat with him when he gets a chance. The rest of the code, including the unit tests seem to be written in a way that assumes there could be system broadcasts that are not definitions. Maybe there is a case I'm not thinking about, possibly a future case. Or maybe the way the code was originally written is not relevant anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. I've approved since I think these changes are good - but probably need to have a chat about the future of what else may be on the ff_system namespace, and if "syshandler" is really the right name for the thing that is handling definitions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@peterbroadhurst I removed the first part of this case in the switch statement, which did change some failure code paths in the tests. I'll highlight those in the places that changed. But would appreciate your eyes on this to make sure the correct thing is still happening here.

@codecov-commenter
Copy link

codecov-commenter commented Nov 11, 2021

Codecov Report

Merging #312 (1ff29f8) into main (29fe427) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #312   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          232       234    +2     
  Lines        12720     12788   +68     
=========================================
+ Hits         12720     12788   +68     
Impacted Files Coverage Δ
internal/broadcast/manager.go 100.00% <ø> (ø)
internal/broadcast/datatype.go 100.00% <100.00%> (ø)
internal/broadcast/definition.go 100.00% <100.00%> (ø)
internal/broadcast/namespace.go 100.00% <100.00%> (ø)
internal/broadcast/tokenpool.go 100.00% <100.00%> (ø)
internal/definitions/definition_handler.go 100.00% <100.00%> (ø)
...nternal/definitions/definition_handler_datatype.go 100.00% <100.00%> (ø)
...ternal/definitions/definition_handler_namespace.go 100.00% <100.00%> (ø)
...nal/definitions/definition_handler_network_node.go 100.00% <100.00%> (ø)
...rnal/definitions/definition_handler_network_org.go 100.00% <100.00%> (ø)
... and 17 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 29fe427...1ff29f8. Read the comment docs.

Comment on lines 984 to 988
mdm.On("ValidateAll", ag.ctx, mock.Anything).Return(false, nil)

dbm := ag.database.(*databasemocks.Plugin)
dbm.On("UpdateMessage", ag.ctx, mock.Anything, mock.Anything).Return(nil)
dbm.On("InsertEvent", ag.ctx, mock.Anything).Return(errors.Errorf("pop"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@peterbroadhurst This is one of the tests I had to change

Comment on lines 939 to 944
msh := ag.syshandlers.(*syshandlersmocks.SystemHandlers)
msh.On("HandleSystemBroadcast", mock.Anything, mock.Anything, mock.Anything).Return(false, nil)

mdm := ag.data.(*datamocks.Manager)
mdm.On("GetMessageData", ag.ctx, mock.Anything, true).Return([]*fftypes.Data{}, true, nil)

mdm.On("ValidateAll", ag.ctx, mock.Anything).Return(false, nil)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@peterbroadhurst This is one of the tests I had to change

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to check, why wouldn't you just change msh := ag.syshandlers.(*syshandlersmocks.SystemHandlers) to be the DefinitionHandlers, and return false and set Header.Type on the message in attemptMessageDispatch?

e.g. so you're testing the same path.

eventType := fftypes.EventTypeMessageConfirmed
switch {
case msg.Header.Namespace == fftypes.SystemNamespace:
case msg.Header.Type == fftypes.MessageTypeDefinition:
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks right to me 👍
Think this is the substantial change, matching the package rename.
We went from "If it's on the system namespace, the system handlers handle it"...
To "If it's a definition, then the definition handlers handle it"

@nguyer
Copy link
Contributor Author

nguyer commented Nov 12, 2021

Re-running the build because it failed due to this bug: #265

1 similar comment
@nguyer
Copy link
Contributor Author

nguyer commented Nov 12, 2021

Re-running the build because it failed due to this bug: #265

return dh.handleTokenPoolBroadcast(ctx, msg, data)
default:
l.Warnf("Unknown topic '%s' for system broadcast ID '%s'", msg.Header.Tag, msg.Header.ID)
l.Debugf("Unknown topic '%s' for system broadcast or definition ID '%s'", msg.Header.Tag, msg.Header.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really only for definitions now, right? The "or" seems superfluous. Also we say "topic" but actually log the "tag".

switch {
case msg.Header.Namespace == fftypes.SystemNamespace:
case msg.Header.Type == fftypes.MessageTypeDefinition:
// We handle system events in-line on the aggregator, as it would be confusing for apps to be
Copy link
Contributor

Choose a reason for hiding this comment

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

"system events" is now more accurately "definition events"

Copy link
Contributor

@awrichar awrichar left a comment

Choose a reason for hiding this comment

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

New changes look great. Noted a few spelling items in logs/comments.

@awrichar
Copy link
Contributor

Looks good, thanks for making those adjustments.

@nguyer nguyer merged commit d03b868 into main Nov 24, 2021
@nguyer nguyer deleted the namespace-definition branch November 24, 2021 19:02
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.

5 participants