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

Cycling too fast #35

Merged
merged 2 commits into from
Feb 12, 2025
Merged

Cycling too fast #35

merged 2 commits into from
Feb 12, 2025

Conversation

Dodecahedr0x
Copy link
Contributor

@Dodecahedr0x Dodecahedr0x commented Feb 12, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a plugin management system for enhanced transaction processing.
    • Added command-line support for specifying geyser plugins via --geyser-plugin-config option.
  • Bug Fixes
    • Improved handling of transaction confirmation statuses for more flexible processing.
  • Chores
    • Updated dependencies for improved functionality and compatibility.
    • Updated Rust toolchain version for better performance and features.

Copy link

coderabbitai bot commented Feb 12, 2025

Walkthrough

The changes enhance the plugin management and transaction processing in the simnet module by integrating a plugin system and modifying the function signatures for better configuration handling. The start function now accepts SurfpoolConfig directly, and a new field for plugin configuration has been added to the SurfpoolConfig struct. Additionally, the Rust toolchain version has been updated, and various dependencies have been modified in the Cargo.toml files across multiple crates.

Changes

File Change Summary
crates/core/src/simnet/mod.rs Updated start function signature to accept SurfpoolConfig directly; integrated plugin management for transactions.
.github/workflows/release.yaml Updated Rust toolchain version from 1.79 to 1.84.0.
crates/cli/Cargo.toml Updated versions of txtx-core from 0.2.1 to 0.2.2 and txtx-addon-network-svm from 0.1.2 to 0.1.3.
crates/cli/src/cli/mod.rs Added plugin_config_path field to StartSimnet struct for command-line plugin configuration.
crates/cli/src/cli/simnet/mod.rs Added plugin_config_path to SurfpoolConfig and modified the start_simnet call to pass the config directly.
crates/core/Cargo.toml Removed clap dependency; added multiple Solana-related dependencies and updated existing ones.
crates/core/src/lib.rs Updated start_simnet function signature to accept SurfpoolConfig directly.
crates/core/src/rpc/full.rs Modified transaction confirmation handling logic in the send_transaction method.
crates/core/src/types.rs Added plugin_config_path field to SurfpoolConfig and updated its trait derivation.
rust-toolchain Updated Rust toolchain version from 1.84.1 to 1.84.0.

Possibly related PRs

  • feat: deployments part ii #11: Changes to the start function's signature in crates/core/src/simnet/mod.rs are directly related to similar modifications in this PR.
  • simulateTransaction #19: Modifications in the SurfpoolConfig structure and transaction processing logic are related to adjustments made in this PR.
  • feat: implement tui #2: Direct connection in the handling of event processing within the start function and start_simnet function signatures.

Suggested reviewers

  • lgalabru

Poem

I’m a rabbit with a code-filled cheer,
Hopping through changes, loud and clear.
New plugins to load, oh what a delight,
Transactions now dance, in the moonlight.
With each hop, the simnet sings, a merry code parade, oh dear!
🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @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.

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: 2

🧹 Nitpick comments (4)
crates/cli/src/cli/simnet/mod.rs (1)

73-78: Add path validation and optimize path conversion.

Consider these improvements:

  1. Validate that plugin configuration paths exist before starting the simnet
  2. Use into_iter() instead of iter().map() for more efficient conversion
-        plugin_config_path: cmd
-            .plugin_config_path
-            .iter()
-            .map(|f| PathBuf::from(f))
-            .collect::<Vec<_>>(),
+        plugin_config_path: cmd
+            .plugin_config_path
+            .into_iter()
+            .map(|f| {
+                let path = PathBuf::from(f);
+                if !path.exists() {
+                    warn!(ctx.expect_logger(), "Plugin config path does not exist: {}", path.display());
+                }
+                path
+            })
+            .collect(),
crates/core/src/simnet/mod.rs (2)

291-315: Enhance error handling and logging for plugin configuration.

While error handling is present, consider these improvements:

  1. Add debug logging for troubleshooting
  2. Include suggestions for resolution in error messages
  3. Add validation for plugin configuration format
 let mut file = match File::open(geyser_plugin_config_file) {
     Ok(file) => file,
     Err(err) => {
+        log::debug!("Plugin config file error: {:?}", err);
         return Err(GeyserPluginManagerError::CannotOpenConfigFile(format!(
-            "Failed to open the plugin config file {geyser_plugin_config_file:?}, error: {err:?}"
+            "Failed to open the plugin config file {geyser_plugin_config_file:?}. Please verify the file exists and has correct permissions. Error: {err:?}"
         )));
     }
 };

337-345: Review dynamic library loading security implications.

The dynamic loading of plugin libraries could pose security risks if not properly validated. Consider implementing additional security measures:

  1. Verify library signatures before loading
  2. Implement a plugin allowlist
  3. Add sandbox restrictions for loaded plugins
❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Check if any of the plugin libraries have unsafe permissions
fd -t f -e so -e dylib . | xargs ls -l | awk '$1 ~ /^.....w.w./' || echo "No libraries with unsafe permissions found"

Length of output: 66


Dynamic Library Loading Security - Further Verification Required

The reviewed code in crates/core/src/simnet/mod.rs (lines 337-345) uses an unsafe block for dynamic library loading, which inherently carries security risks. While our shell script scan did not flag any libraries with unsafe file permissions, file permission checks alone do not address all aspects of dynamic load security. As noted in the review comment, consider additional security measures such as:

  • Verifying library signatures before loading to ensure authenticity.
  • Implementing a plugin allowlist to restrict which libraries may be loaded.
  • Adding sandbox restrictions to limit the impact if a plugin behaves maliciously.

Given that the shell script output did not provide conclusive evidence regarding overall security and only covered unsafe permissions, please manually verify and assess the plugin library validation and sandboxing measures in your environment.

crates/core/Cargo.toml (1)

41-75: Consider dependency management strategy.

While pinning Solana dependencies to a specific version ensures stability, consider:

  1. Documenting the version update process
  2. Setting up dependency update automation
  3. Evaluating if all Solana dependencies are necessary
❌ Verification inconclusive

🌐 Web query:

What is the latest stable version of Solana?

💡 Result:

The latest stable version of Solana as of February 2025 is v2.1.5 under the Agave validator client maintained by Anza (formerly Solana Labs). This follows the transition from earlier v1.x releases in the original solana-labs repository to newer versions under Agave[4].

Key details:

  • Agave v2.x has become the maintained fork since late 2024
  • Installation command:
    sh -c "$(curl -sSfL https://release.anza.xyz/v2.1.5/install)"
  • Previous solana-labs releases like v1.18.26 (Dec 2024) remain available but are being phased out[2][3]
  • New features and updates now appear in Agave releases rather than legacy solana-labs packages[4]

Developers should migrate to Agave using symbolic channel names (stable, beta, edge) or explicit version tags like v2.1.x for production deployments[4][5]. The transition was announced in late 2024 with full archival planned after v1.18[2].

Citations:


Action: Revisit and Document the Dependency Update Strategy

The code pins a suite of Solana dependencies at version 2.1.10, while the current stable release (per external info) is v2.1.5. This discrepancy suggests that either a newer (or custom) version is intentionally used or the update process needs clarification. Consider the following:

  • Document the Rationale: Clarify in the project documentation why 2.1.10 is used over the stable 2.1.5 release.
  • Automate Dependency Updates: Look into setting up automated tools (e.g., Dependabot or similar) to manage future updates seamlessly.
  • Review Necessity: Evaluate if all the listed Solana dependencies are required, or if they can be consolidated or removed for simpler maintenance.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ba08667 and 54e0de0.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .github/workflows/release.yaml (1 hunks)
  • crates/cli/Cargo.toml (1 hunks)
  • crates/cli/src/cli/mod.rs (1 hunks)
  • crates/cli/src/cli/simnet/mod.rs (2 hunks)
  • crates/core/Cargo.toml (2 hunks)
  • crates/core/src/lib.rs (1 hunks)
  • crates/core/src/rpc/full.rs (1 hunks)
  • crates/core/src/simnet/mod.rs (5 hunks)
  • crates/core/src/types.rs (2 hunks)
  • rust-toolchain (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • rust-toolchain
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: run_cargo_checks
🔇 Additional comments (8)
.github/workflows/release.yaml (1)

88-88: Verify Rust toolchain version compatibility and security.

The Rust toolchain version has been updated to 1.84.0. Let's verify the version's compatibility and security status.

Also, run this script to check version consistency across the codebase:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check for Rust version references across the codebase

# Check rust-toolchain file
echo "Checking rust-toolchain file:"
fd -t f "rust-toolchain" -x cat {}

# Check for other version references
echo -e "\nChecking for other version references:"
rg -i "1\.84\.0|1\.79" --type yaml

Length of output: 455


🌐 Web query:

What is the latest stable version of Rust? Are there any known security advisories for Rust 1.84.0?

💡 Result:

The latest stable version of Rust is 1.84.1, released on January 30, 2025[4][5]. This point release addresses regressions introduced in Rust 1.84.0[5], including:

  • Internal Compiler Error (ICE) fixes for diagnostics and incremental rebuilds[5]
  • Performance improvements for compilation times affected by the next-generation trait solver[5]
  • Debuginfo fixes related to LLVM's location discriminator limits[5]

There are no known security advisories specifically for Rust 1.84.x versions according to the provided search results[2][5][8]. However, developers should be aware of these notable considerations when using Rust 1.84.x:

Consideration Details
WASI Target Rename The wasm32-wasi target was removed in favor of wasm32-wasip1, requiring manual cleanup of old targets before upgrading[2][6][8]
MSRV-Aware Resolver New dependency version selection that respects rust-version in Cargo.toml (requires explicit opt-in)[1][2]
Trait Solver Changes Next-generation trait solver now handles coherence checks, potentially revealing hidden implementation conflicts[1][6]

For production systems, upgrading to 1.84.1 is recommended over using 1.84.0 due to its stability improvements[5]. Security-conscious users should monitor the official Rust Security Advisory Database for updates, though no current vulnerabilities are reported in these releases[10].

Citations:


Rust toolchain update is consistent but consider a potential upgrade.

  • The update to 1.84.0 is consistently reflected in both the workflow (release.yaml) and the rust-toolchain file.
  • There aren’t any known security advisories for Rust 1.84.0.
  • However, web results indicate that the latest stable Rust release is now 1.84.1—which includes fixes for regressions observed in 1.84.0. Please verify that all dependencies remain compatible, and consider upgrading to 1.84.1 for improved stability if it’s feasible.
crates/core/src/lib.rs (1)

26-28: Verify the ownership change impact.

The function signature change from &SurfpoolConfig to SurfpoolConfig is a breaking change. Ensure all callers are updated to handle the new ownership semantics.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for all calls to start_simnet to verify they've been updated
rg -A 2 "start_simnet\(" 

Length of output: 512


Ownership Change Impact Verified

  • The search confirms that all call sites—including the one in crates/cli/src/cli/simnet/mod.rs—pass the config by ownership (i.e., as config rather than as &config), aligning with the new function signature.
  • No callers were found still using borrowed values, so the breaking change has been properly addressed.
crates/core/src/types.rs (2)

15-15: LGTM! Good choice of type for plugin paths.

Using Vec<PathBuf> is appropriate for storing multiple plugin configuration paths, providing type safety and platform-independent path handling.


11-11: Consider implications of removing Clone trait.

The removal of #[derive(Clone)] from SurfpoolConfig is a breaking change. This change aligns with the new ownership model but may impact existing code that needs to clone configurations.

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Search for potential clone() calls on SurfpoolConfig
rg "config\.clone\(\)" 

Length of output: 24


Clone Trait Removal — Manual Verification Recommended

Based on our search for explicit clone() invocations (e.g. via config.clone()) on SurfpoolConfig, no direct calls were found in the repository. However, because the removal of the Clone trait can be a breaking change if any dependent code expects to clone a SurfpoolConfig, please manually verify that no indirect clone usage (or reliance on automatic cloning via macros and such) exists.

  • No explicit .clone() calls on SurfpoolConfig were detected.
  • Ensure that other parts of the codebase or client code do not depend on cloning SurfpoolConfig.
crates/cli/src/cli/mod.rs (1)

109-111: LGTM! Well-documented CLI argument.

The new CLI argument for geyser plugin configuration is well-implemented with:

  • Clear documentation
  • Intuitive short (-g) and long options
  • Support for multiple plugin configurations
crates/cli/src/cli/simnet/mod.rs (1)

88-88: LGTM! Ownership change properly implemented.

The direct passing of config aligns with the new ownership model in start_simnet.

crates/core/src/rpc/full.rs (1)

351-354: LGTM! Improved transaction confirmation handling.

The changes to allow None or Some(CommitmentLevel::Confirmed) for transaction confirmation provide more flexibility while maintaining correctness.

crates/cli/Cargo.toml (1)

21-22: LGTM! Dependency versions updated appropriately.

The version updates for txtx-core and txtx-addon-network-svm align with the plugin system integration.

Copy link
Member

@lgalabru lgalabru left a comment

Choose a reason for hiding this comment

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

Works like a charm, thanks @Dodecahedr0x!

@lgalabru lgalabru merged commit 531510b into main Feb 12, 2025
3 checks passed
Dodecahedr0x added a commit that referenced this pull request Feb 12, 2025
@lgalabru lgalabru deleted the fix/cpu-consumption branch February 19, 2025 17:12
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