diff --git a/build/params.go b/build/params.go index 22badfaca..df9ebd059 100644 --- a/build/params.go +++ b/build/params.go @@ -9,4 +9,4 @@ func SetAddressNetwork(n address.Network) { address.CurrentNetwork = n } -const TicketRandomnessLookback = abi.ChainEpoch(1) +const TicketRandomnessLookback = abi.ChainEpoch(1) \ No newline at end of file diff --git a/cmd/curio/run.go b/cmd/curio/run.go index 9a359cddf..ef34b8ac3 100644 --- a/cmd/curio/run.go +++ b/cmd/curio/run.go @@ -135,7 +135,7 @@ var runCmd = &cli.Command{ return xerrors.Errorf("starting market RPCs: %w", err) } - err = rpc.ListenAndServe(ctx, dependencies, shutdownChan) // Monitor for shutdown. + err = rpc.ListenAndServe(ctx, dependencies, shutdownChan) if err != nil { return err } diff --git a/deps/apiinfo.go b/deps/apiinfo.go index e40b420f4..52affb261 100644 --- a/deps/apiinfo.go +++ b/deps/apiinfo.go @@ -22,6 +22,7 @@ import ( lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" cliutil "github.com/filecoin-project/lotus/cli/util" + "github.com/filecoin-project/lotus/build" ) var clog = logging.Logger("curio/chain") @@ -30,20 +31,20 @@ func GetFullNodeAPIV1Curio(ctx *cli.Context, ainfoCfg []string) (api.Chain, json if tn, ok := ctx.App.Metadata["testnode-full"]; ok { return tn.(api.Chain), func() {}, nil } + + if len(ainfoCfg) == 0 { + return nil, nil, xerrors.Errorf("could not get API info: none configured. \nConsider getting base.toml with './curio config get base >/tmp/base.toml' \nthen adding \n[APIs] \n ChainApiInfo = [\" result_from lotus auth api-info --perm=admin \"]\n and updating it with './curio config set /tmp/base.toml'") + } + var httpHeads []httpHead version := "v1" - { - if len(ainfoCfg) == 0 { - return nil, nil, xerrors.Errorf("could not get API info: none configured. \nConsider getting base.toml with './curio config get base >/tmp/base.toml' \nthen adding \n[APIs] \n ChainApiInfo = [\" result_from lotus auth api-info --perm=admin \"]\n and updating it with './curio config set /tmp/base.toml'") - } - for _, i := range ainfoCfg { - ainfo := cliutil.ParseApiInfo(i) - addr, err := ainfo.DialArgs(version) - if err != nil { - return nil, nil, xerrors.Errorf("could not get DialArgs: %w", err) - } - httpHeads = append(httpHeads, httpHead{addr: addr, header: ainfo.AuthHeader()}) + for _, i := range ainfoCfg { + ainfo := cliutil.ParseApiInfo(i) + addr, err := ainfo.DialArgs(version) + if err != nil { + return nil, nil, xerrors.Errorf("could not get DialArgs: %w", err) } + httpHeads = append(httpHeads, httpHead{addr: addr, header: ainfo.AuthHeader()}) } if cliutil.IsVeryVerbose { @@ -53,12 +54,30 @@ func GetFullNodeAPIV1Curio(ctx *cli.Context, ainfoCfg []string) (api.Chain, json var fullNodes []api.Chain var closers []jsonrpc.ClientCloser + // Check network compatibility for each node for _, head := range httpHeads { v1api, closer, err := newChainNodeRPCV1(ctx.Context, head.addr, head.header) if err != nil { clog.Warnf("Not able to establish connection to node with addr: %s, Reason: %s", head.addr, err.Error()) continue } + + // Validate network match + networkName, err := v1api.StateNetworkName(ctx.Context) + if err != nil { + clog.Warnf("Failed to get network name from node %s: %s", head.addr, err.Error()) + closer() + continue + } + + // Compare with binary's network using BuildTypeString() + if string(networkName) != build.BuildTypeString() { + clog.Warnf("Network mismatch for node %s: binary built for %s but node is on %s", + head.addr, build.BuildTypeString(), networkName) + closer() + continue + } + fullNodes = append(fullNodes, v1api) closers = append(closers, closer) }