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

Support for deployments from anchor cli #39

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

Dodecahedr0x
Copy link
Collaborator

@Dodecahedr0x Dodecahedr0x commented Feb 13, 2025

This PR adds features and fixes to enable deploying and testing programs.

However, Anchor by default uses websockets and TPU client, which are not available in Surfpool yet. So deploying requires running solana program deploy -u localhost target/deploy/surfpool_test.so --use-rpc to do everything through the RPC, and testing programs works (transactions are correctely received and processed by Surfpool) but Anchor tries to stream program logs through websockets and so it currently gets no response.

Summary by CodeRabbit

  • New Features

    • Refined the command line interface by simplifying command aliases and updating the shortcut for network host configuration.
    • Now provides accurate block height reporting.
  • Bug Fixes

    • Streamlined account data retrieval for more consistent and efficient responses.
  • Chores

    • Removed redundant logging statements during request processing.

Copy link

coderabbitai bot commented Feb 13, 2025

Walkthrough

This pull request refines the command-line and RPC interfaces. In the CLI module, it removes the redundant alias "run" from the Simnet command and changes the short option for network_host in the StartSimnet struct. In the RPC modules, it updates method signatures and implementations: renaming parameters and streamlining asynchronous account fetching in accounts_data.rs, providing a concrete block height retrieval in minimal.rs, and updating logging in the middleware within mod.rs.

Changes

File(s) Change Summary
crates/cli/.../mod.rs Updated Command enum by removing "run" alias from the Simnet variant and changed the short option for network_host in StartSimnet from 'h' to 'o'.
crates/core/.../accounts_data.rs Removed join_all import; renamed parameter from pubkeys to pubkeys_str in get_multiple_accounts; streamlined error handling and account fetching logic.
crates/core/.../minimal.rs Modified the get_block_height method signature to accept meta (instead of _meta) and implemented block height retrieval via meta.get_state()?.
crates/core/.../mod.rs Altered the on_request method logging by removing commented-out statements; the core logic remains unchanged.

Possibly related PRs

  • feat: implement tui #2: The changes in the main PR, specifically to the Command enum and StartSimnet struct in crates/cli/src/cli/mod.rs, are related to the modifications in the handle_start_simnet_command function in the retrieved PR, which also involves the StartSimnet struct.
  • Fix blocking on async thread and add formatting in CI #1: The changes in the main PR, specifically to the StartSimnet struct in crates/cli/src/cli/mod.rs, are related to the modifications made to the start_simnet function in crates/core/src/lib.rs, as both involve adjustments to the command structure.
  • feat: improve start flow #29: The changes in the main PR, specifically the modifications to the StartSimnet struct and the Command enum in crates/cli/src/cli/mod.rs, are directly related to the updates made to the same StartSimnet struct in the retrieved PR.

Suggested reviewers

  • lgalabru

Poem

I’m a rabbit with a hop of cheer,
The “run” alias has scampered clear.
With 'o' shining for the host, so bright,
And RPC calls now taking flight.
Code refined makes my heart skip a beat—
Hop on, let’s celebrate this code treat! 🐇🎉


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.

.await;

// Save missing fetched accounts
let fetched_account =
Copy link
Member

Choose a reason for hiding this comment

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

Should we first load what we have locally, then fetch from the remote the ones we don't have, then merge?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It costs the same for most RPC providers but I fixed that nonetheless, it's more efficient

// println!("Processing took: {:?}", start.elapsed());
res
})))
println!("Processing request {:?}", request);
Copy link
Member

Choose a reason for hiding this comment

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

Debugging artifact

@lgalabru lgalabru changed the title Program deployment Support for deployments from anchor cli Feb 17, 2025
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 (1)
crates/core/src/rpc/accounts_data.rs (1)

150-157: Consider verifying pubkeys lazily.

While collecting all pubkey verification results before proceeding ensures early error detection, it may be inefficient for large input sets where only a few keys need remote fetching. Consider verifying keys lazily as needed.

-        let pubkeys = match pubkeys_str
-            .iter()
-            .map(|s| verify_pubkey(s))
-            .collect::<Result<Vec<_>>>()
-        {
-            Ok(p) => p,
-            Err(e) => return Box::pin(future::err(e.into())),
-        };
+        let mut pubkeys = Vec::with_capacity(pubkeys_str.len());
+        for s in pubkeys_str.iter() {
+            match verify_pubkey(s) {
+                Ok(pk) => pubkeys.push(pk),
+                Err(e) => return Box::pin(future::err(e.into())),
+            }
+        }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 70eab2f and d8681c5.

📒 Files selected for processing (2)
  • crates/core/src/rpc/accounts_data.rs (4 hunks)
  • crates/core/src/rpc/mod.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/core/src/rpc/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: run_cargo_checks
🔇 Additional comments (3)
crates/core/src/rpc/accounts_data.rs (3)

1-1: LGTM! Import changes align with the new implementation.

The removal of join_all and addition of Pubkey imports reflect the shift from parallel to batch account fetching.

Also applies to: 6-6, 10-10, 18-18


42-48: LGTM! Parameter rename improves clarity.

The rename from pubkey to pubkey_strs better indicates that the parameter is a collection of string-formatted public keys.


177-211: LGTM! Efficient implementation with proper caching.

The new implementation:

  1. Efficiently identifies missing accounts
  2. Uses batch fetching instead of parallel individual fetches
  3. Properly caches fetched accounts
  4. Handles errors robustly

@Dodecahedr0x
Copy link
Collaborator Author

Addressed feedbacks in the last commit @lgalabru

@MicaiahReid MicaiahReid requested a review from lgalabru February 27, 2025 03:23
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