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

⚡ Fix: Add slow call to benchmark tests #1110

Merged
merged 1 commit into from
May 21, 2024

Conversation

roninjin10
Copy link
Collaborator

@roninjin10 roninjin10 commented May 21, 2024

Description

Concise description of proposed changes

Testing

Explain the quality checks that have been done on the code changes

Additional Information

Your ENS/address:

Summary by CodeRabbit

  • New Features
    • Introduced benchmarking for initializing a TEVM client and executing storage-intensive calls, simulating serverless function usage.

Copy link

vercel bot commented May 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tevm-monorepo-tevm ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2024 8:46am

Copy link

changeset-bot bot commented May 21, 2024

⚠️ No Changeset found

Latest commit: b15d76d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @roninjin10 and the rest of your teammates on Graphite Graphite

@roninjin10 roninjin10 marked this pull request as ready for review May 21, 2024 08:19
Copy link
Contributor

coderabbitai bot commented May 21, 2024

Warning

Rate Limit Exceeded

@roninjin10 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 53 minutes and 51 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between d4a0bb1 and b15d76d.

Walkthrough

The recent updates introduce a benchmark test and a new function aimed at simulating serverless function usage with significant storage requirements. The benchmark test (slowCallRepo.bench.ts) evaluates the performance of initializing a TEVM client and executing a memory-intensive call. Meanwhile, the function slowCallRepo in slowCallRepo.ts performs a slow call to a specified RPC URL using a memory client, enhancing the testing and simulation capabilities of the repository.

Changes

File Path Change Summary
test/bench/src/slowCallRepo/slowCallRepo.bench.ts Introduced a benchmark test for initializing a TEVM client and executing a call with significant storage requirements.
test/bench/src/slowCallRepo/slowCallRepo.ts Added a function slowCallRepo to make a slow call to a specified RPC URL using a memory client.

🐇
In the code, where bytes do flow,
A rabbit's touch makes benchmarks glow.
Slow calls to RPC, they test,
Ensuring our functions are at their best.
With memory clients, swift and keen,
Performance shines in every scene.
🌟


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
Contributor

@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: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3c02464 and d4a0bb1.
Files selected for processing (2)
  • test/bench/src/slowCallRepo/slowCallRepo.bench.ts (1 hunks)
  • test/bench/src/slowCallRepo/slowCallRepo.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • test/bench/src/slowCallRepo/slowCallRepo.bench.ts
Additional comments not posted (3)
test/bench/src/slowCallRepo/slowCallRepo.ts (3)

1-2: Ensure that the imported modules are used appropriately.


6-19: Review the asynchronous function slowCallRepo for best practices in error handling and performance.


4-4: Validate the usage of the rpcUrl constant to ensure it aligns with the intended environments.

Verification successful

The search results indicate that the rpcUrl constant and the getAlchemyUrl function are used consistently across various files and environments. The rpcUrl is primarily used to set up clients and forks, and the getAlchemyUrl function is imported from @tevm/test-utils and used to generate URLs for different environments.

The usage of rpcUrl in the file test/bench/src/slowCallRepo/slowCallRepo.ts aligns with the intended environments, as it follows the same pattern observed in other files.

  • test/bench/src/slowCallRepo/slowCallRepo.ts: const rpcUrl = getAlchemyUrl('optimism-sepolia')

This confirms that the rpcUrl is being set correctly for the optimism-sepolia environment.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `rpcUrl` across different environments.

# Test: Search for the usage of `rpcUrl` in different environments. Expect: Consistent usage across environments.
rg --type typescript $'getAlchemyUrl'

Length of output: 71



Script:

#!/bin/bash
# Description: Verify the usage of `rpcUrl` across different environments.

# Test: Search for the usage of `rpcUrl` in different environments. Expect: Consistent usage across environments.
rg --type ts 'rpcUrl'

# Test: Search for the usage of `getAlchemyUrl` in different environments. Expect: Consistent usage across environments.
rg --type ts 'getAlchemyUrl'

Length of output: 33097

Comment on lines 8 to 18
const forkClient = createMemoryClient({
fork: { url: rpcUrl },
})

await forkClient.tevmReady()

const result = await forkClient.tevmCall({
from: '0xef987cde72bc6a9e351d2460214d75f095b1b862',
data: '0x608060405234801561001057600080fd5b5060405161012938038061012983398101604081905261002f91610037565b600055610050565b60006020828403121561004957600080fd5b5051919050565b60cb8061005e6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806301339c211460375780638c59507c14603f575b600080fd5b603d6059565b005b604760005481565b60405190815260200160405180910390f35b7f7c84ba1c5769a0155145414f13e03f1d0d6a3a7e5d4f6d45262df4d9d48c32cd600054604051608b91815260200190565b60405180910390a156fea26469706673582212201509e5f7aed59985fb32c8f48b792565644fc6decb12b235b12226ae2855c4f464736f6c634300080d0033000000000000000000000000000000000000000000000000000000000000000a',
skipBalance: true,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding error handling for the asynchronous operations within slowCallRepo.

-	const forkClient = createMemoryClient({
-		fork: { url: rpcUrl },
-	})
-	await forkClient.tevmReady()
-	const result = await forkClient.tevmCall({
-		from: '0xef987cde72bc6a9e351d2460214d75f095b1b862',
-		data: '0x608060405234801561001057600080fd5b5060405161012938038061012983398101604081905261002f91610037565b600055610050565b60006020828403121561004957600080fd5b5051919050565b60cb8061005e6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806301339c211460375780638c59507c14603f575b600080fd5b603d6059565b005b604760005481565b60405190815260200160405180910390f35b7f7c84ba1c5769a0155145414f13e03f1d0d6a3a7e5d4f6d45262df4d9d48c32cd600054604051608b91815260200190565b60405180910390a156fea26469706673582212201509e5f7aed59985fb32c8f48b792565644fc6decb12b235b12226ae2855c4f464736f6c634300080d0033000000000000000000000000000000000000000000000000000000000000000a',
-		skipBalance: true,
-	})
+	try {
+		const forkClient = createMemoryClient({
+			fork: { url: rpcUrl },
+		})
+		await forkClient.tevmReady()
+		const result = await forkClient.tevmCall({
+			from: '0xef987cde72bc6a9e351d2460214d75f095b1b862',
+			data: '0x608060405234801561001057600080fd5b5060405161012938038061012983398101604081905261002f91610037565b600055610050565b60006020828403121561004957600080fd5b5051919050565b60cb8061005e6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806301339c211460375780638c59507c14603f575b600080fd5b603d6059565b005b604760005481565b60405190815260200160405180910390f35b7f7c84ba1c5769a0155145414f13e03f1d0d6a3a7e5d4f6d45262df4d9d48c32cd600054604051608b91815260200190565b60405180910390a156fea26469706673582212201509e5f7aed59985fb32c8f48b792565644fc6decb12b235b12226ae2855c4f464736f6c634300080d0033000000000000000000000000000000000000000000000000000000000000000a',
+			skipBalance: true,
+		})
+	} catch (error) {
+		console.error('Error during TEVM call:', error)
+	}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const forkClient = createMemoryClient({
fork: { url: rpcUrl },
})
await forkClient.tevmReady()
const result = await forkClient.tevmCall({
from: '0xef987cde72bc6a9e351d2460214d75f095b1b862',
data: '0x608060405234801561001057600080fd5b5060405161012938038061012983398101604081905261002f91610037565b600055610050565b60006020828403121561004957600080fd5b5051919050565b60cb8061005e6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806301339c211460375780638c59507c14603f575b600080fd5b603d6059565b005b604760005481565b60405190815260200160405180910390f35b7f7c84ba1c5769a0155145414f13e03f1d0d6a3a7e5d4f6d45262df4d9d48c32cd600054604051608b91815260200190565b60405180910390a156fea26469706673582212201509e5f7aed59985fb32c8f48b792565644fc6decb12b235b12226ae2855c4f464736f6c634300080d0033000000000000000000000000000000000000000000000000000000000000000a',
skipBalance: true,
})
const forkClient = createMemoryClient({
fork: { url: rpcUrl },
})
try {
await forkClient.tevmReady()
const result = await forkClient.tevmCall({
from: '0xef987cde72bc6a9e351d2460214d75f095b1b862',
data: '0x608060405234801561001057600080fd5b5060405161012938038061012983398101604081905261002f91610037565b600055610050565b60006020828403121561004957600080fd5b5051919050565b60cb8061005e6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806301339c211460375780638c59507c14603f575b600080fd5b603d6059565b005b604760005481565b60405190815260200160405180910390f35b7f7c84ba1c5769a0155145414f13e03f1d0d6a3a7e5d4f6d45262df4d9d48c32cd600054604051608b91815260200190565b60405180910390a156fea26469706673582212201509e5f7aed59985fb32c8f48b792565644fc6decb12b235b12226ae2855c4f464736f6c634300080d0033000000000000000000000000000000000000000000000000000000000000000a',
skipBalance: true,
})
} catch (error) {
console.error('Error during TEVM call:', error)
}

@roninjin10 roninjin10 force-pushed the 05-21-_zap_fix_add_slow_call_to_benchmark_tests branch from d4a0bb1 to b15d76d Compare May 21, 2024 08:25
@roninjin10 roninjin10 merged commit 4d3d1c0 into main May 21, 2024
15 of 16 checks passed
@roninjin10 roninjin10 deleted the 05-21-_zap_fix_add_slow_call_to_benchmark_tests branch May 21, 2024 08:32
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.

None yet

1 participant