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

Conversation

hard-nett
Copy link
Collaborator

@hard-nett hard-nett commented Feb 27, 2025

resolves issue nodes experience causing recursive tempdir creation , as well as patch for ASA-2025-004

Summary by CodeRabbit

  • Refactor
    • Streamlined the application’s initialization and cleanup processes for more reliable temporary resource management.
  • Chores
    • Updated external dependencies to enhance overall stability and compatibility.
    • Added a new indirect dependency for improved functionality.
    • Upgraded versions of key dependencies, including cosmossdk.io/math and github.com/cosmos/ibc-go/v8.

Copy link

coderabbitai bot commented Feb 27, 2025

📝 Walkthrough

Walkthrough

This pull request removes the dataDir variable from the NewBitsongApp function and the corresponding parameter from the NewAppKeepers function, simplifying their interfaces. It also updates the cleanup logic in the NewRootCmd function to include error checking when closing temporary resources and conditional removal of directories. Additionally, dependency versions in the go.mod file have been updated to newer releases.

Changes

File(s) Change Summary
app/app.go, app/keepers/keepers.go Removed the dataDir variable and parameter from the NewBitsongApp and NewAppKeepers functions, respectively, simplifying the function interfaces.
cmd/bitsongd/cmd/root.go Enhanced cleanup logic for temporary directories: added deferred error handling for closing tempApp, conditional removal of tempDir if not equal to the default home, and checks to remove an empty "data" directory.
go.mod Updated dependency versions for cosmossdk.io/math, github.com/cosmos/ibc-apps/modules/ibc-hooks/v8, and github.com/cosmos/ibc-go/v8 to newer versions, and added a new indirect dependency github.com/cockroachdb/apd/v3.
tests/ict/go.mod Updated the version of github.com/cosmos/ibc-go/v8 from v8.5.3 to v8.6.1.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant RootCmd as NewRootCmd
    participant TempApp as tempApp
    participant TempDir as TemporaryDirectory
    participant DataDir as "Data Directory"

    App->>RootCmd: Start
    RootCmd->>TempApp: Defer closure
    TempApp-->>RootCmd: Return (ok/error)
    RootCmd->>TempDir: Check if not default
    RootCmd->>TempDir: Remove directory if condition met
    RootCmd->>DataDir: Check existence and emptiness
    DataDir-->>RootCmd: Return status
    RootCmd->>DataDir: Remove if empty
Loading

Possibly related PRs

  • register wasmkeeper first before wasm.NewIBCHandler #257: The changes in the main PR, which involve the removal of the dataDir variable from the NewBitsongApp function and its corresponding removal from the NewAppKeepers function signature, are directly related to the modifications in the retrieved PR that also involve changes to the NewAppKeepers function, specifically its parameters and internal logic.
  • V0.19.0 patch #244: The changes in the main PR, specifically the removal of the dataDir variable from the NewBitsongApp function and its corresponding removal from the NewAppKeepers function, are directly related to the modifications in the retrieved PR, which also involves updates to the keepers module and the management of application parameters.

Poem

I'm a rabbit with nimble paws,
Hopping through code and debugging flaws,
I prance past data that's no longer there,
Cleaning up directories with care,
With updated hooks and paths so neat,
My code garden is a joyful treat!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd818c9 and fdd472c.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • tests/ict/go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod (3 hunks)
  • tests/ict/go.mod (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/ict/go.mod
  • go.mod

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hard-nett hard-nett marked this pull request as ready for review February 27, 2025 17:16
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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
cmd/bitsongd/cmd/root.go (3)

80-83: Avoid panicking when closing the application.
Panic might be too disruptive for a CLI application. Consider handling the error more gracefully, for instance by logging a warning or returning an error instead.

Example adjustment:

   defer func() {
-    if err := tempApp.Close(); err != nil {
-      panic(err)
-    }
+    if closeErr := tempApp.Close(); closeErr != nil {
+      fmt.Fprintf(os.Stderr, "Warning: error closing tempApp: %v\n", closeErr)
+    }

84-86: Handle the os.RemoveAll error.
Currently, the removal error is silently ignored. If removal fails unexpectedly, logging or returning an error could facilitate debugging.

Example improvement:

   if tempDir != bitsong.DefaultNodeHome {
-    os.RemoveAll(tempDir)
+    if err := os.RemoveAll(tempDir); err != nil {
+      fmt.Fprintf(os.Stderr, "Warning: failed to remove tempDir: %v\n", err)
+    }
   }

95-107: Guard against panics during directory cleanup.
Panic is called on any error, which might hamper UX. Logging or error propagation would allow CLI commands to fail gracefully.

Example adjustment:

     dirEntries, err := os.ReadDir(dataDir)
     if err != nil {
-        panic(err)
+        fmt.Fprintf(os.Stderr, "Warning: could not read directory %s: %v\n", dataDir, err)
+        return
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86207b7 and 0e34502.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • app/app.go (0 hunks)
  • app/keepers/keepers.go (0 hunks)
  • cmd/bitsongd/cmd/root.go (1 hunks)
  • go.mod (1 hunks)
💤 Files with no reviewable changes (2)
  • app/app.go
  • app/keepers/keepers.go
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: e2e-tests (e2e-pfm)
  • GitHub Check: e2e-tests (e2e-basic)
🔇 Additional comments (4)
go.mod (2)

27-27: Dependency Version Update for IBC Hooks Module

The version for github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 has been updated to a newer pre-release (v8.0.0-20250226172931-56b9c5e4400a). Verify that this upgrade introduces no breaking changes and that all dependent functionalities (especially those related to inter-blockchain communication) remain compatible.


30-30: Dependency Version Update for IBC-Go

The dependency github.com/cosmos/ibc-go/v8 was updated from version v8.5.3 to v8.6.0, reflecting an upgrade to a stable release. Please confirm that this update has been tested against the application's IBC-related workflows and that no API changes adversely affect your code.

cmd/bitsongd/cmd/root.go (2)

78-79: No concerns here.
These lines only introduce comments explaining the cleanup logic, and they are clear and informative.


88-94: Verify assumptions when building the data directory path.
Relying on os.Getwd() at runtime for cleanup can introduce edge cases if the working directory changes. Consider storing the initial working directory or allowing a configurable path for more robust handling.

@angelorc angelorc merged commit d2bff90 into main Feb 28, 2025
4 checks passed
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.

2 participants