diff --git a/protocol/cmd/dydxprotocold/cmd/root.go b/protocol/cmd/dydxprotocold/cmd/root.go index 53eea3c6a5..368ac90b9b 100644 --- a/protocol/cmd/dydxprotocold/cmd/root.go +++ b/protocol/cmd/dydxprotocold/cmd/root.go @@ -165,6 +165,10 @@ func NewRootCmdWithInterceptors( if err != nil { panic(err) } + // [ Home Dir Temp Fix ] (also see protocol/cmd/dydxprotocold/main.go) + // Unset the temp home dir. This must be done after `ReadFromClientConfig`, otherwise it will + // create a temp dir in cwd. + initClientCtx.HomeDir = "" if err := autoCliOpts(tempApp, initClientCtx).EnhanceRootCommand(rootCmd); err != nil { panic(err) } diff --git a/protocol/cmd/dydxprotocold/main.go b/protocol/cmd/dydxprotocold/main.go index a17b70d60d..2ccb4cd382 100644 --- a/protocol/cmd/dydxprotocold/main.go +++ b/protocol/cmd/dydxprotocold/main.go @@ -14,7 +14,12 @@ func main() { config.SetupConfig() option := cmd.GetOptionWithCustomStartCmd() - rootCmd := cmd.NewRootCmd(option, app.DefaultNodeHome) + // [ Home Dir Temp Fix ] (also see protocol/cmd/dydxprotocold/cmd/root.go) + // We pass in a tempdir as a temporary hack until fixed in cosmos. + // If not, and we pass in a custom home dir, it will try read or create the default home dir + // before using the custom home dir. + // See https://github.com/cosmos/cosmos-sdk/issues/18868. + rootCmd := cmd.NewRootCmd(option, tempDir()) cmd.AddTendermintSubcommands(rootCmd) cmd.AddInitCmdPostRunE(rootCmd) @@ -23,3 +28,13 @@ func main() { os.Exit(1) } } + +var tempDir = func() string { + dir, err := os.MkdirTemp("", "dydxprotocol") + if err != nil { + dir = app.DefaultNodeHome + } + defer os.RemoveAll(dir) + + return dir +} diff --git a/protocol/testing/containertest/node.go b/protocol/testing/containertest/node.go index 7c5a07aecb..cf901e07a9 100644 --- a/protocol/testing/containertest/node.go +++ b/protocol/testing/containertest/node.go @@ -3,9 +3,10 @@ package containertest import ( "context" "fmt" - "github.com/dydxprotocol/v4-chain/protocol/app" "time" + "github.com/dydxprotocol/v4-chain/protocol/app" + comethttp "github.com/cometbft/cometbft/rpc/client/http" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config"