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

refactor: move network validation to GetFullNodeAPIV1Curio #345

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Winter-Soren
Copy link

This PR implements network validation at the API connection level to prevent mismatched network connections early in the startup process.

Changes:

  1. Removed separate network validation function and use existing build.BuildTypeString()
  2. Moved network validation from run.go to GetFullNodeAPIV1Curio()
  3. Added validation for each chain node with proper error handling and logging
  4. Only proceeds if at least one compatible node is found

Fixes #340

Copy link
Contributor

@LexLuthr LexLuthr left a comment

Choose a reason for hiding this comment

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

I think cleanup from previous approach is pending.

build/params.go Outdated
NetworkTestnet = "testnet"
)

func CurrentNetwork() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this function or above constants

cmd/curio/run.go Outdated
@@ -135,7 +138,13 @@ var runCmd = &cli.Command{
return xerrors.Errorf("starting market RPCs: %w", err)
}

err = rpc.ListenAndServe(ctx, dependencies, shutdownChan) // Monitor for shutdown.
api, closer, err := lcli.GetFullNodeAPI(cctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

I though I already clarified that we don't need this in run in the original issue

deps/apiinfo.go Show resolved Hide resolved
deps/apiinfo.go Outdated
fullNodes = append(fullNodes, v1api)
closers = append(closers, closer)
}

if len(fullNodes) == 0 {
return nil, nil, xerrors.Errorf("failed to establish connection with all nodes")
return nil, nil, xerrors.Errorf("no compatible nodes found - all nodes had network mismatches or connection errors")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to change this message

Copy link
Contributor

@LexLuthr LexLuthr 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. Just need 1 last change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Revert this file to its original form. There is still unused code there.

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.

Refuse to start if binary network doesn't match chain node network
2 participants