Having a custom node location (using the --home flag) is causing many issues at node instantiation.
We have been using many hacks to avoid using the default one:
Default one set here:
|
userHomeDir, err := os.UserHomeDir() |
|
if err != nil { |
|
panic(err) |
|
} |
|
|
|
DefaultNodeHome = filepath.Join(userHomeDir, ".simapp") |
Hack 1:
|
simtestutil.NewAppOptionsWithFlagHome(tempDir()), |
|
tempApp := simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(tempDir())) |
Hack 2:
|
initClientCtx, err = config.ReadDefaultValuesFromDefaultClientConfig(initClientCtx, customClientTemplate, customClientConfig) |
|
if err != nil { |
|
panic(err) |
|
} |
The issue is the --home flag is parsed too late (at cobra run (RunE and & co), while most of the instantiation is done before the commands and the flag parsing.
We need to parse the --home flag earlier or rely solely on environment variable. Best would be at init() or somewhere in main() before any other logic, and pass it down.
Having a custom node location (using the
--homeflag) is causing many issues at node instantiation.We have been using many hacks to avoid using the default one:
Default one set here:
cosmos-sdk/simapp/app.go
Lines 186 to 191 in 340f85f
Hack 1:
cosmos-sdk/simapp/simd/cmd/root_di.go
Line 43 in 340f85f
cosmos-sdk/simapp/simd/cmd/root.go
Line 33 in 340f85f
Hack 2:
cosmos-sdk/simapp/simd/cmd/root.go
Lines 117 to 120 in 340f85f
The issue is the
--homeflag is parsed too late (at cobra run (RunE and & co), while most of the instantiation is done before the commands and the flag parsing.We need to parse the
--homeflag earlier or rely solely on environment variable. Best would be atinit()or somewhere inmain()before any other logic, and pass it down.