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

Cleanup config #206

Merged
merged 13 commits into from
Mar 4, 2024
Merged

Cleanup config #206

merged 13 commits into from
Mar 4, 2024

Conversation

cam-schultz
Copy link
Collaborator

Why this should be merged

Simplifies the relayer configuration by making the following changes:

  • Removes the network-id field, instead fetching it from the info API.
  • Add new info-api-url field instead of reusing p-chain-api-url. This removes the requirement that same node has both APIs enabled.
  • Removes endpoint construction entirely, instead requiring the RPC and WS endpoints to be fully specified in the configuration. The current approach of constructing endpoints from the provided host, port, and encryption connection was error prone and didn't give the user with any additional functionality that couldn't be attained by providing a fully specified endpoint.

How this works

  • Removes Config.NetworkID
  • Adds Config.InfoAPIURL
  • Removes Config.EncryptConnection
  • Removes SourceSubnet.EncryptConnection, SourceSubnet.APINodeHost, and SourceSubnet.APINodePort
  • Removes DestinationSubnet.EncryptConnection, DestinationSubnet.APINodeHost, and DestinationSubnet.APINodePort

How this was tested

CI

How is this documented

Updated README

geoff-vball
geoff-vball previously approved these changes Mar 4, 2024
- platform.getHeight
- platform.validatedBy
- platform.getValidatorsAt

`"encrypt-connection": boolean`
`"info-api-url": string`

Choose a reason for hiding this comment

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

i'm not too familiar with the info api nodes, is it common for the p chain api node to have info api enabled as well?

Choose a reason for hiding this comment

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

thinking if worth have more documentation about how to find their info api node, or whether to add a comment about testing with the p chain api node

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's entirely up to the node operator which APIs to support. The P-Chain and Info APIs are independent, so we shouldn't assume that they'll both be enabled on the same node here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The public APIs support both the info endpoints and most of the P-chain endpoints (with the exception of getValidatorsAt.

$ curl 'https://api.avax-test.network/ext/info' \
> --header 'Content-Type: application/json' \
> --data '{
>     "jsonrpc":"2.0",
>     "id"     :1,
>     "method" :"info.getNetworkID"
> }'
{"jsonrpc":"2.0","result":{"networkID":"5"},"id":1}

I probably would have gone the route of having a single avalancheAPIURL configuration option and adding the path extensions as needed in the application, but not opposed to having these split up in the event that the node used for the P-chain API (possibly private node) doesn't have the Info API enabled (all public APIs have the Info API available).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, in the case of the public API, both the info and P-chain API share the same base URL. That's not true in general though, so I think it's better to make as few assumptions here as we can.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, totally agree. Thanks for elaborating.

Choose a reason for hiding this comment

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

is there any additional comment/documentation we can add for finding the info api, or is this relatively understood/straightforward for node operators?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think this is the place to dive too deeply into API availability. We can add a note that the public API should support the required methods though.

Choose a reason for hiding this comment

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

makes sense, I agree

michaelkaplan13
michaelkaplan13 previously approved these changes Mar 4, 2024
Rename subnet -> blockchain in Config
geoff-vball
geoff-vball previously approved these changes Mar 4, 2024
if networkID != constants.MainnetID &&
networkID != constants.FujiID &&
len(APINodeURL) == 0 {
InfoAPINodeURL == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think InfoAPINodeURL being empty would cause an error above when it's used to get the network ID, so this case isn't possible. Do you know why it was required originally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, we will require this url be non-empty in all cases since it's used to fetch the network ID.

Looking at it again, this check is no longer valid. In an older release, the Avalanchego test network had a set of hard-coded node IDs for Fuji and mainnet, so we didn't need to explicitly connect to them here. That's no longer the case, so we need the info API to fetch the peers in all cases.

@@ -19,8 +19,13 @@ source "$RELAYER_PATH"/scripts/versions.sh
full_commit_hash="$(git --git-dir="$RELAYER_PATH/.git" rev-parse HEAD)"
commit_hash="${full_commit_hash::8}"

./scripts/build.sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this broken previously? Seems unrelated to the rest of this PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry meant to add a comment here explaining this. We removed the build stage from the Dockerfile here, in favor of goreleaser's approach which builds the binary outside of the image. This change should have been included in that PR.

geoff-vball
geoff-vball previously approved these changes Mar 4, 2024
@@ -145,7 +145,9 @@ func (r *messageRelayer) relayMessage(unsignedMessage *avalancheWarp.UnsignedMes
// will need to be accounted for here.
func (r *messageRelayer) createSignedMessage() (*avalancheWarp.Message, error) {
r.relayer.logger.Info("Fetching aggregate signature from the source chain validators via API")
warpClient, err := warpBackend.NewClient(r.relayer.apiNodeURI, r.relayer.sourceBlockchainID.String())
// TODO: To properly support this, we should provide a dedicated Warp API endpoint in the config
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you create an issue for this if it doesn't already exist?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, this is already captured here: #119

@cam-schultz cam-schultz merged commit b87be95 into main Mar 4, 2024
7 checks passed
@cam-schultz cam-schultz deleted the cleanup-cfg branch March 4, 2024 23:03
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.

4 participants