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

V0.21.5.rc - temp dir cache bug resolution, ASA-2025-004 patch #273

Merged
merged 5 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ func NewBitsongApp(
}

app.homePath = homePath
dataDir := filepath.Join(homePath, "data")
wasmDir := filepath.Join(homePath, "wasm")
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
Expand All @@ -272,7 +271,6 @@ func NewBitsongApp(
keepers.GetMaccPerms(),
appOpts,
wasmOpts,
dataDir,
wasmDir,
wasmConfig,
ibcWasmConfig,
Expand Down
1 change: 0 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ func NewAppKeepers(
maccPerms map[string][]string,
appOpts servertypes.AppOptions,
wasmOpts []wasmkeeper.Option,
dataDir string,
wasmDir string,
wasmConfig wasmtypes.WasmConfig,
ibcWasmConfig ibcwasmtypes.WasmConfig,
Expand Down
35 changes: 31 additions & 4 deletions cmd/bitsongd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
appOptions := make(simtestutil.AppOptionsMap, 0)

tempDir := tempDir()
// cleanup temp dir after we are done with the tempApp, so we don't leave behind a
// new temporary directory for every invocation. See /~https://github.com/CosmWasm/wasmd/issues/2017
defer os.RemoveAll(tempDir)

tempApp := bitsong.NewBitsongApp(
log.NewNopLogger(),
cosmosdb.NewMemDB(),
Expand All @@ -79,6 +75,37 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
appOptions,
[]wasmkeeper.Option{},
)
// cleanup temp dir & remove empty data dir after we are done with the tempApp, so we don't leave behind a
// new temporary directory for every invocation. See /~https://github.com/CosmWasm/wasmd/issues/2017
defer func() {
if err := tempApp.Close(); err != nil {
panic(err)
}
if tempDir != bitsong.DefaultNodeHome {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that the user must manually delete the /tmp folder

Copy link
Collaborator Author

@hard-nett hard-nett Feb 27, 2025

Choose a reason for hiding this comment

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

a temp file is created during each invocation of the cli root process.

os.RemoveAll(tempDir)
}

// Get current working directory
currentDir, err := os.Getwd()
if err != nil {
panic(err)
}
dataDir := filepath.Join(currentDir, "data")

// Check if data directory exists
if _, err := os.Stat(dataDir); err == nil {
// Directory exists, check if it's empty
dirEntries, err := os.ReadDir(dataDir)
if err != nil {
panic(err)
} else if len(dirEntries) == 0 {
// Directory is empty, remove it
if err := os.RemoveAll(dataDir); err != nil {
panic(err)
}
}
}
}()

initClientCtx := client.Context{}.
WithCodec(encodingConfig.Marshaler).
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ require (
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.1.1
github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0
github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20250211213414-515bdcaf73ac
github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20250226172931-56b9c5e4400a
github.com/cosmos/ibc-go/modules/capability v1.0.1
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.4.2-0.20240730185033-ccd4dc278e72
github.com/cosmos/ibc-go/v8 v8.5.3
github.com/cosmos/ibc-go/v8 v8.6.0
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.4
github.com/gorilla/mux v1.8.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -828,16 +828,16 @@ github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.1.1 h1:+EG
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.1.1/go.mod h1:8sbOclBgOCgBPesufd3ZlLRHvJ3dOeN9+dXhn3KbKOc=
github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0 h1:nKP2+Rzlz2iyvTosY5mvP+aEBPe06oaDl3G7xLGBpNI=
github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0/go.mod h1:D3Q380FpWRFtmUQWLosPxachi6w24Og2t5u/Tww5wtY=
github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20250211213414-515bdcaf73ac h1:iudNpWmHGPglQ5vbeLzStgGdjgHDoKqiaqhJ9k4RDkg=
github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20250211213414-515bdcaf73ac/go.mod h1:9+Z14xz3Y+5uEn5i1CvLcDN1aTthEhYUdI7pphySkY8=
github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20250226172931-56b9c5e4400a h1:1r7I7ZaLhmDxpl9qSaiOi2DzCV4qiEpmAoxPZbGbs94=
github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20250226172931-56b9c5e4400a/go.mod h1:9+Z14xz3Y+5uEn5i1CvLcDN1aTthEhYUdI7pphySkY8=
github.com/cosmos/ibc-go/modules/apps/callbacks v0.2.1-0.20231113120333-342c00b0f8bd h1:Lx+/5dZ/nN6qPXP2Ofog6u1fmlkCFA1ElcOconnofEM=
github.com/cosmos/ibc-go/modules/apps/callbacks v0.2.1-0.20231113120333-342c00b0f8bd/go.mod h1:JWfpWVKJKiKtd53/KbRoKfxWl8FsT2GPcNezTOk0o5Q=
github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI=
github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E=
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.4.2-0.20240730185033-ccd4dc278e72 h1:QjCi4bJoy9AXLL1e4jqi+4rHYN0gGZAQxf937cdWhw4=
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.4.2-0.20240730185033-ccd4dc278e72/go.mod h1:yiulzyQAZ+Ci802z/kVQqTA3lGiSJOmDpTq7kZxOUNE=
github.com/cosmos/ibc-go/v8 v8.5.3 h1:VF1Vq3/zZB40eeFvx4wI4WmlJGGF74o+/MxcPxQ2mWY=
github.com/cosmos/ibc-go/v8 v8.5.3/go.mod h1:P5hkAvq0Qbg0h18uLxDVA9q1kOJ0l36htMsskiNwXbo=
github.com/cosmos/ibc-go/v8 v8.6.0 h1:mU0cztvIraZ2OWZMNKDrOos63D5OHTIYlTGlEwugqPw=
github.com/cosmos/ibc-go/v8 v8.6.0/go.mod h1:6fe2axQco2tSBvBIi7ExRQJ2BVrWL3QAxQDguLcmw1g=
github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU=
github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0=
github.com/cosmos/ledger-cosmos-go v0.14.0 h1:WfCHricT3rPbkPSVKRH+L4fQGKYHuGOK9Edpel8TYpE=
Expand Down
Loading