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

Fix config add-dir regression #406

Merged
merged 6 commits into from
Feb 4, 2021
Merged

Conversation

akhilkumarpilli
Copy link
Contributor

@akhilkumarpilli akhilkumarpilli commented Feb 4, 2021

Fixes: #401

Splits the add-dir comman into add-chains and add-paths. Adding chain configuration files and adding a key is required before running add-paths since add-paths will query the chains to ensure the path is valid

@akhilkumarpilli
Copy link
Contributor Author

@colin-axner , we are actually getting nil pointer dereference issue from here. Since key is not added for chain, we are unable to get address of it and that's the reason, we are getting error. But we need chain to validate provided identifiers. Can you suggest any solution for this?

@colin-axner
Copy link
Contributor

colin-axner commented Feb 4, 2021

@akhilkumarpilli interesting. I would have thought the key is being set when the chain is being set (which I assumed occurs in the for loop over files). I will take a closer look in a second.

Ideally we set the chains first then the paths. In this fix though I was hoping to set both the chains and the paths and then do validation.

@colin-axner
Copy link
Contributor

@akhilkumarpilli are you still getting the error? I tried reproducing @michaelfig's error (thanks for the how-to-reproduce steps) and everything works for me

cmd/config.go Outdated
@@ -263,6 +259,12 @@ func cfgFilesAdd(dir string) (cfg *Config, err error) {
}
fmt.Printf("added chain %s...\n", c.ChainID)
}
for _, p := range cfg.Paths {
if err = config.ValidatePath(p); err != nil {
fmt.Println("Error occured...Config is not updated")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fmt.Println("Error occured...Config is not updated")

maybe we could wrap the error and say the path validation failed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah Sure, but we are displaying added chain logs before. That's the reason, I wrote Config is not updated

@akhilkumarpilli
Copy link
Contributor Author

@akhilkumarpilli are you still getting the error? I tried reproducing @michaelfig's error (thanks for the how-to-reproduce steps) and everything works for me

I am still getting issue. Can you try once by clearing config?

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

can you update, Skipping non chain file... to say added path: %s\n", pathName

@colin-axner
Copy link
Contributor

are you getting this?

panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/cosmos/relayer/relayer.Paths.Add(...)
	/home/bartleby/work/go/src/github.com/cosmos/relayer/relayer/path.go:56
github.com/cosmos/relayer/cmd.(*Config).AddPath(0xc000f96480, 0xc000f7f628, 0x6, 0xc000f87820, 0x0, 0x1)
	/home/bartleby/work/go/src/github.com/cosmos/relayer/cmd/config.go:318 +0x125
github.com/cosmos/relayer/cmd.cfgFilesAdd(0x7ffcf6582a54, 0x7, 0xc000f5fd48, 0x0, 0x0)
	/home/bartleby/work/go/src/github.com/cosmos/relayer/cmd/config.go:221 +0x7d6
github.com/cosmos/relayer/cmd.configAddDirCmd.func1(0xc000dd3600, 0xc000fa4c90, 0x1, 0x1, 0x0, 0x0)
	/home/bartleby/work/go/src/github.com/cosmos/relayer/cmd/config.go:163 +0x45
github.com/spf13/cobra.(*Command).execute(0xc000dd3600, 0xc000fa4c70, 0x1, 0x1, 0xc000dd3600, 0xc000fa4c70)
	/home/bartleby/work/go/pkg/mod/github.com/spf13/[email protected]/command.go:850 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0x2276b20, 0x0, 0x0, 0x0)
	/home/bartleby/work/go/pkg/mod/github.com/spf13/[email protected]/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/bartleby/work/go/pkg/mod/github.com/spf13/[email protected]/command.go:895
github.com/cosmos/relayer/cmd.Execute()
	/home/bartleby/work/go/src/github.com/cosmos/relayer/cmd/root.go:107 +0x4d
main.main()
	/home/bartleby/work/go/src/github.com/cosmos/relayer/main.go:21 +0x25

@colin-axner colin-axner changed the title WIP: Fix config add-dir regression Fix config add-dir regression Feb 4, 2021
@akhilkumarpilli
Copy link
Contributor Author

I am getting this:

$ rly config add-dir configs/gaia
Skipping non chain file: demo.json
added chain ibc-0...
added chain ibc-1...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x12ebcf7]

goroutine 1 [running]:
github.com/cosmos/relayer/relayer.(*Chain).GetAddress(0xc000d9be60, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vitwit/go/src/github.com/cosmos/relayer/relayer/chain.go:422 +0x97
github.com/cosmos/relayer/relayer.Chains.Get(0xc000db3020, 0x2, 0x2, 0xc000d8dde0, 0x5, 0xc00016c000, 0x0, 0xc000c5fac8)
        /home/vitwit/go/src/github.com/cosmos/relayer/relayer/chain.go:559 +0xad
github.com/cosmos/relayer/cmd.(*Config).ValidatePathEnd(0xc000d710c0, 0xc000da4e70, 0x152b320, 0xc000db9ba8)
        /home/vitwit/go/src/github.com/cosmos/relayer/cmd/config.go:478 +0x85
github.com/cosmos/relayer/cmd.(*Config).ValidatePath(0xc000d710c0, 0xc000d9ee60, 0xc000c5fcf8, 0x12)
        /home/vitwit/go/src/github.com/cosmos/relayer/cmd/config.go:456 +0x47
github.com/cosmos/relayer/cmd.cfgFilesAdd(0x7ffc166859e6, 0xc, 0xc000c5fd50, 0x0, 0x0)
        /home/vitwit/go/src/github.com/cosmos/relayer/cmd/config.go:267 +0x377
github.com/cosmos/relayer/cmd.configAddDirCmd.func1(0xc0001c9600, 0xc000db2bc0, 0x1, 0x1, 0x0, 0x0)
        /home/vitwit/go/src/github.com/cosmos/relayer/cmd/config.go:185 +0x45
github.com/spf13/cobra.(*Command).execute(0xc0001c9600, 0xc000db2ba0, 0x1, 0x1, 0xc0001c9600, 0xc000db2ba0)
        /home/vitwit/go/pkg/mod/github.com/spf13/[email protected]/command.go:850 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0x22c9c80, 0x0, 0x0, 0x0)
        /home/vitwit/go/pkg/mod/github.com/spf13/[email protected]/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/vitwit/go/pkg/mod/github.com/spf13/[email protected]/command.go:895
github.com/cosmos/relayer/cmd.Execute()
        /home/vitwit/go/src/github.com/cosmos/relayer/cmd/root.go:109 +0x4d
main.main()
        /home/vitwit/go/src/github.com/cosmos/relayer/main.go:21 +0x25

@colin-axner colin-axner marked this pull request as ready for review February 4, 2021 10:58
@colin-axner colin-axner self-assigned this Feb 4, 2021
@colin-axner colin-axner marked this pull request as draft February 4, 2021 11:18
@colin-axner colin-axner marked this pull request as ready for review February 4, 2021 12:44
Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

tested

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. I'd suggest to return the errors when encountered

cmd/config.go Outdated
Comment on lines 242 to 243
fmt.Printf("%s: %s\n", pth, err.Error())
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should return the error

Copy link
Contributor

Choose a reason for hiding this comment

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

will update

cmd/config.go Outdated
Comment on lines 266 to 267
fmt.Printf("failed to read file %s, skipping...\n", pth)
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

cmd/config.go Outdated
Comment on lines 272 to 273
fmt.Printf("failed to unmarshal file %s, skipping...\n", pth)
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

cmd/config.go Outdated
Comment on lines 292 to 293
fmt.Printf("%s: failed to validate path: %s\n", pth, err.Error())
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

cmd/config.go Outdated
Comment on lines 297 to 298
fmt.Printf("%s: %s\n", pth, err.Error())
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

@colin-axner colin-axner merged commit d213300 into master Feb 4, 2021
@colin-axner colin-axner deleted the akhil/401-config-regression branch February 4, 2021 13:15
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.

config add-dir regression (segmentation violation)
3 participants