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

API endpoint for manually relaying warp message #327

Merged
merged 62 commits into from
Jul 3, 2024
Merged

Conversation

geoff-vball
Copy link
Contributor

@geoff-vball geoff-vball commented Jun 10, 2024

Why this should be merged

Closes #314

How this works

Creates a global MessageCoordinator that contains maps to Source Clients, Application Relayers, and Message Handler Factories.

TODOs:

  • Make block number optional (implement iterative look-back for the message)
  • Flag to enable/disable the API?
  • Documentation around potential DOS vectors of the API should it be open to the public networking wise?
  • Should any authentication be required? Probably makes sense to recommend it is only an RPC available locally.
  • Currently we have no way to distinguish between the transaction being successfully sent and ShouldSendMessage() returning false.

How this was tested

E2E Test

How is this documented

TODO

main/main.go Fixed Show fixed Hide fixed
Copy link
Collaborator

@cam-schultz cam-schultz left a comment

Choose a reason for hiding this comment

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

I left a handful of comments and asks, and I'd like to think a bit more about the new MessageCoordinator type. But overall, the changes make sense and I'm a big fan of the trend of decoupling all of the components and coordinating them in main.

main/main.go Outdated Show resolved Hide resolved
main/main.go Outdated
"Created application relayers",
zap.String("blockchainID", sourceBlockchain.BlockchainID),
)
return relayer.ProcessManualWarpMessages(manualWarpMessages[sourceBlockchain.GetBlockchainID()])
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add deprecation notes for manual Warp messages in the config, and perhaps emit logs when they are provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I already removed the manual warp messages from the config. Do you think we should keep them in there for a few releases with a deprecation note? I can't imagine many people were using them already given the difficulty in having to add them to the nodes as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, we should deprecate features gracefully at this point, even though I agree that likely few people are using this particular feature. Apologies for not making that clear up front

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So a couple thoughts here. We don't initialize the logger for the application until after we finish parsing the config. So it would be a little hard to emit logs from here. Returning an error and failing validation seems a little too extreme here, is there some middle ground?

Do we still want to process the manual warp messages if they're included in the config? It should be easy enough to point the users to the new API.

relayer/listener.go Outdated Show resolved Hide resolved
relayer/relay_message_api_handler.go Outdated Show resolved Hide resolved
relayer/relay_message_api_handler.go Outdated Show resolved Hide resolved
relayer/relay_message_api_handler.go Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's document this endpoint in the top-level README

relayer/relay_message_api_handler.go Outdated Show resolved Hide resolved
main/main.go Outdated Show resolved Hide resolved
main/main.go Outdated Show resolved Hide resolved
main/main.go Outdated Show resolved Hide resolved
) (map[ids.ID]map[common.Address]messages.MessageHandlerFactory, error) {
messageHandlerFactories := make(map[ids.ID]map[common.Address]messages.MessageHandlerFactory)
for _, sourceBlockchain := range globalConfig.SourceBlockchains {
messageHandlerFactoriesForSource := make(map[common.Address]messages.MessageHandlerFactory)

Choose a reason for hiding this comment

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

nit: can we rename to messageProtocolHandlerFactory or simiilar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rename which?

Choose a reason for hiding this comment

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

messageHandlerFactoriesForSource

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
relayer/message_coordinator.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
api/relay_message.go Outdated Show resolved Hide resolved
api/relay_message.go Outdated Show resolved Hide resolved
api/relay_message.go Outdated Show resolved Hide resolved
api/relay_message.go Outdated Show resolved Hide resolved
geoff-vball and others added 9 commits July 2, 2024 11:02
Co-authored-by: F. Eugene Aumson <[email protected]>
Signed-off-by: Geoff Stuart <[email protected]>
Co-authored-by: F. Eugene Aumson <[email protected]>
Signed-off-by: Geoff Stuart <[email protected]>
Co-authored-by: F. Eugene Aumson <[email protected]>
Signed-off-by: Geoff Stuart <[email protected]>
Co-authored-by: cam-schultz <[email protected]>
Signed-off-by: Geoff Stuart <[email protected]>
Co-authored-by: cam-schultz <[email protected]>
Signed-off-by: Geoff Stuart <[email protected]>
Co-authored-by: cam-schultz <[email protected]>
Signed-off-by: Geoff Stuart <[email protected]>
Co-authored-by: cam-schultz <[email protected]>
Signed-off-by: Geoff Stuart <[email protected]>
Copy link
Collaborator

@cam-schultz cam-schultz left a comment

Choose a reason for hiding this comment

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

Two more final comments, then I think we're good to go

api/relay_message.go Outdated Show resolved Hide resolved
main/main.go Outdated Show resolved Hide resolved
error,
) {
// Check that the warp message is from a supported message protocol contract address.
messageHandlerFactory, supportedMessageProtocol := mc.messageHandlerFactories[warpMessageInfo.UnsignedMessage.SourceChainID][warpMessageInfo.SourceAddress]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: This line looks very long...I'm not too worried about it specifically but surprised we're not getting a linter error/warning in CI

Copy link
Collaborator

@cam-schultz cam-schultz Jul 2, 2024

Choose a reason for hiding this comment

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

It looks like this can be enabled with the lll linter: https://golangci-lint.run/usage/linters/#lll

Worth noting that the Go team has explicitly denied adding line length limits to gofmt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are a good number of lines that don't fit in the line length, so I'll make a separate ticket for this.

Copy link
Collaborator

@michaelkaplan13 michaelkaplan13 left a comment

Choose a reason for hiding this comment

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

Last few nits, but LGTM otherwise

Copy link
Collaborator

@cam-schultz cam-schultz left a comment

Choose a reason for hiding this comment

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

One last uber mega nit that I'm just noticing now - can we capitalize the first letters of the log message strings for consistency? I think the only files that need to be modified are health_check.go and relay_message.go

Copy link
Collaborator

@cam-schultz cam-schultz left a comment

Choose a reason for hiding this comment

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

LGTM! 🙏

Copy link
Contributor

@bernard-avalabs bernard-avalabs left a comment

Choose a reason for hiding this comment

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

LGTM

@geoff-vball geoff-vball merged commit e1d4d77 into main Jul 3, 2024
7 checks passed
@geoff-vball geoff-vball deleted the gstuart/api-relay branch July 3, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add API Handler for "relay message" requests
6 participants