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

✨ Feat: Add events to tevm #1154

Merged
merged 11 commits into from
Jun 3, 2024
Merged

✨ Feat: Add events to tevm #1154

merged 11 commits into from
Jun 3, 2024

Conversation

roninjin10
Copy link
Collaborator

@roninjin10 roninjin10 commented Jun 2, 2024

Description

Add event json rpc support and viem tests

Testing

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

Additional Information

Your ENS/address:

Summary by CodeRabbit

  • New Features

    • Enhanced @tevm/actions module to handle events for newBlock, newReceipt, and newLog.
    • Added new JSON-RPC support for eth_getFilterLogs and eth_getFilterChanges in @tevm/procedures.
    • BaseClient in @tevm/base-client now emits a 'connect' event after becoming ready.
  • Bug Fixes

    • Fixed a race condition in @tevm/actions where a transaction could fail validation but still be added to the transaction pool.
    • Resolved a bug in @tevm/actions where eth_getLogs did not handle optional properties correctly.
  • Documentation

    • Updated various documentation files to correct source references and improve clarity.

Copy link

vercel bot commented Jun 2, 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 Jun 3, 2024 3:14am

Copy link

changeset-bot bot commented Jun 2, 2024

🦋 Changeset detected

Latest commit: da87a05

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@tevm/actions Minor
@tevm/procedures Minor
@tevm/actions-types Minor
@tevm/base-client Minor
@tevm/decorators Minor
@tevm/server Minor
tevm Minor
@tevm/ethers Minor
@tevm/memory-client Minor
@tevm/http-client Minor
@tevm/opstack Minor

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

coderabbitai bot commented Jun 2, 2024

Walkthrough

The changes involve updates across various packages, focusing on restructuring configuration settings, enhancing functionality, improving error handling, and updating documentation. Key updates include refining task dependencies in nx.json, improving promise handling in createTransaction.js, adding new event handling in mineHandler.js, and enhancing log filters and event emitters in the base-client package.

Changes

Files/Paths Change Summary
nx.json Restructured configuration settings for tasks, simplifying dependencies and inputs.
packages/actions/src/tevm/createTransaction.js Updated JSDoc comments and improved promise handling.
packages/actions/src/tevm/mineHandler.js Added new blocks and receipts handling with event emissions.
packages/base-client/docs/... Updated line numbers and source references in multiple documentation files.
packages/base-client/src/EIP1193EventEmitterTypes.ts Added newReceipt and newLog functions to EIP1193EventMap.
packages/base-client/src/Filter.ts Added registeredListeners field to the Filter type.
.changeset/curly-hats-tickle.md Introduced a patch to address a race condition in transaction validation.
.changeset/fair-badgers-arrive.md Added JSON-RPC support for eth_getFilterLogs and eth_getFilterChanges.
.changeset/forty-trees-refuse.md Updated BaseClient to emit a 'connect' event after becoming ready.
.changeset/funny-drinks-brush.md Enhanced log filters type to include transaction and block hashes.
.changeset/lazy-pumas-grab.md Fixed a bug related to eth_getLogs handling optional properties.
.changeset/lemon-camels-decide.md Enhanced tevmMine to handle events for newBlock, newReceipt, and newLog.

Poem

In code's deep forest, changes grow,
Tasks refined, dependencies flow.
Promises kept, errors tamed,
Logs and blocks now better named.
Events arise, connections bloom,
In the heart of data's room.
Celebrate, for code's delight,
A rabbit's joy in every byte! 🐰✨


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.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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
Collaborator Author

roninjin10 commented Jun 2, 2024

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 June 2, 2024 22:58
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

Outside diff range and nitpick comments (2)
tevm/docs/index/type-aliases/Filter.md (1)

Line range hint 29-29: Convert the bare URL to a markdown link to improve readability and comply with markdown best practices.

[go-ethereum filter system](https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329)
packages/base-client/src/createBaseClient.js (1)

286-292: The new readyPromise block is a good addition for ensuring that all components are initialized before the client becomes active.

Consider adding more detailed logging within the readyPromise block to trace the initialization steps more clearly. This could help in debugging and maintaining the system.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 94610ac and afe5483.

Files selected for processing (30)
  • nx.json (4 hunks)
  • packages/actions/src/tevm/createTransaction.js (5 hunks)
  • packages/actions/src/tevm/mineHandler.js (3 hunks)
  • packages/base-client/docs/classes/ProviderRpcError.md (3 hunks)
  • packages/base-client/docs/type-aliases/EIP1193EventEmitter.md (1 hunks)
  • packages/base-client/docs/type-aliases/EIP1193EventMap.md (1 hunks)
  • packages/base-client/docs/type-aliases/EIP1193Events.md (1 hunks)
  • packages/base-client/docs/type-aliases/ProviderConnectInfo.md (1 hunks)
  • packages/base-client/docs/type-aliases/ProviderMessage.md (1 hunks)
  • packages/base-client/src/EIP1193EventEmitterTypes.ts (2 hunks)
  • packages/base-client/src/Filter.ts (1 hunks)
  • packages/base-client/src/createBaseClient.js (2 hunks)
  • packages/procedures/src/requestProcedure.js (8 hunks)
  • tevm/docs/index/functions/createBaseClient.md (1 hunks)
  • tevm/docs/index/type-aliases/AutoMining.md (1 hunks)
  • tevm/docs/index/type-aliases/BaseClient.md (1 hunks)
  • tevm/docs/index/type-aliases/BaseClientOptions.md (1 hunks)
  • tevm/docs/index/type-aliases/CustomPrecompile.md (1 hunks)
  • tevm/docs/index/type-aliases/EIP1193EventEmitter.md (1 hunks)
  • tevm/docs/index/type-aliases/EIP1193EventMap.md (1 hunks)
  • tevm/docs/index/type-aliases/EIP1193Events.md (1 hunks)
  • tevm/docs/index/type-aliases/Extension.md (1 hunks)
  • tevm/docs/index/type-aliases/Filter.md (1 hunks)
  • tevm/docs/index/type-aliases/FilterType.md (1 hunks)
  • tevm/docs/index/type-aliases/Hardfork.md (1 hunks)
  • tevm/docs/index/type-aliases/IntervalMining.md (1 hunks)
  • tevm/docs/index/type-aliases/ManualMining.md (1 hunks)
  • tevm/docs/index/type-aliases/MiningConfig.md (1 hunks)
  • tevm/docs/index/variables/GENESIS_STATE.md (1 hunks)
  • tevm/docs/index/variables/prefundedAccounts.md (1 hunks)
Files skipped from review due to trivial changes (16)
  • packages/base-client/docs/type-aliases/EIP1193EventEmitter.md
  • packages/base-client/docs/type-aliases/EIP1193Events.md
  • packages/base-client/docs/type-aliases/ProviderConnectInfo.md
  • packages/base-client/docs/type-aliases/ProviderMessage.md
  • tevm/docs/index/functions/createBaseClient.md
  • tevm/docs/index/type-aliases/AutoMining.md
  • tevm/docs/index/type-aliases/CustomPrecompile.md
  • tevm/docs/index/type-aliases/EIP1193EventEmitter.md
  • tevm/docs/index/type-aliases/EIP1193Events.md
  • tevm/docs/index/type-aliases/Extension.md
  • tevm/docs/index/type-aliases/FilterType.md
  • tevm/docs/index/type-aliases/Hardfork.md
  • tevm/docs/index/type-aliases/IntervalMining.md
  • tevm/docs/index/type-aliases/MiningConfig.md
  • tevm/docs/index/variables/GENESIS_STATE.md
  • tevm/docs/index/variables/prefundedAccounts.md
Additional context used
Markdownlint
tevm/docs/index/type-aliases/Filter.md

56-56: null
Bare URL used

packages/base-client/docs/classes/ProviderRpcError.md

123-123: null
Bare URL used

tevm/docs/index/type-aliases/BaseClient.md

109-109: null
Lists should be surrounded by blank lines

tevm/docs/index/type-aliases/BaseClientOptions.md

72-72: Column: 1
Hard tabs


73-73: Column: 1
Hard tabs


74-74: Column: 1
Hard tabs


75-75: Column: 1
Hard tabs


76-76: Column: 1
Hard tabs


77-77: Column: 1
Hard tabs


78-78: Column: 1
Hard tabs


79-79: Column: 1
Hard tabs


80-80: Column: 1
Hard tabs


81-81: Column: 1
Hard tabs


82-82: Column: 1
Hard tabs


83-83: Column: 1
Hard tabs


84-84: Column: 1
Hard tabs


85-85: Column: 1
Hard tabs


36-36: null
Fenced code blocks should be surrounded by blank lines


137-137: null
Lists should be surrounded by blank lines


31-31: null
Fenced code blocks should have a language specified

Additional comments not posted (33)
tevm/docs/index/type-aliases/ManualMining.md (1)

19-19: The update of the source line number correctly reflects changes in the source file.

tevm/docs/index/type-aliases/Filter.md (1)

72-72: The update of the source line number correctly reflects changes in the source file.

packages/base-client/src/Filter.ts (1)

54-54: The addition of registeredListeners enhances the functionality of filters by allowing event listeners to be registered, aligning with the updated documentation.

tevm/docs/index/type-aliases/EIP1193EventMap.md (1)

93-101: The addition of the newReceipt method enhances the functionality of the EIP1193EventMap by handling receipt events, aligning with the source code updates.

packages/base-client/docs/type-aliases/EIP1193EventMap.md (2)

93-101: The addition of the newReceipt method enhances the functionality of the EIP1193EventMap by handling receipt events, aligning with the source code updates.


105-105: The update to the source link correctly reflects the updated location in the source file.

packages/base-client/src/EIP1193EventEmitterTypes.ts (1)

40-40: The addition of the newReceipt method enhances the functionality of the EIP1193EventMap by handling receipt events, aligning with the documentation updates.

nx.json (12)

6-6: LGTM! Caching and specifying inputs for lint:check enhances performance.


10-11: Well-configured dependencies for lint:package ensure that linting occurs post-build, enhancing reliability.


15-15: Caching for lint:deps is a good practice for improving task execution speed.


19-19: Standardizing inputs and enabling caching for format:check is beneficial for consistent formatting checks.


23-24: Logical update to test configuration to ensure tests run post-build, capturing the latest changes effectively.


27-28: Ensuring test:run depends on the build process is a good practice for accurate and up-to-date testing.


32-33: Configuring test:watch to depend on builds enhances developer experience by ensuring immediate feedback on changes.


36-38: Enhanced test:coverage configuration with clear outputs and dependencies ensures accurate and efficient coverage reporting.


42-43: Streamlining typecheck with specific inputs and dependencies optimizes performance and reliability.


47-48: Comprehensive configuration for build:types ensures robust and reliable type generation.


58-60: Configuring build:app to depend on up-to-date distributions and types ensures consistency and reliability in the build process.


70-72: Optimized configuration for generate:docs ensures efficient and reliable documentation generation.

packages/base-client/docs/classes/ProviderRpcError.md (3)

35-35: Updated source link for the constructor ensures accurate reference to the source code.


59-59: Updated source link for the code property maintains coherence and accuracy in documentation.


69-69: Updated source link for the details property ensures accurate documentation.

tevm/docs/index/type-aliases/BaseClient.md (1)

200-200: Updated source link for BaseClient ensures accurate reference to the source code.

tevm/docs/index/type-aliases/BaseClientOptions.md (1)

171-171: Updated source link for BaseClientOptions ensures accurate reference to the source code.

packages/actions/src/tevm/mineHandler.js (2)

24-30: Addition of newBlocks and newReceipts enhances the mining handler's functionality by enabling tracking of mined blocks and associated receipts.


116-129: Emitting events for new blocks and receipts enhances the system's interactivity and ensures real-time updates are propagated.

packages/actions/src/tevm/createTransaction.js (1)

Line range hint 101-128: Addition of poolPromise enhances the transaction handler's functionality by managing asynchronous operations effectively.

packages/procedures/src/requestProcedure.js (6)

3-3: Added import for ethGetLogsHandler.

This import is necessary for handling the eth_getLogs JSON-RPC method, which is part of the new functionality introduced in this PR.


12-21: Added multiple utility imports from @tevm/utils.

These utilities are likely used in the new functionalities added to handle various data transformations and manipulations required by the JSON-RPC methods.


1038-1089: Handling of eth_getFilterLogs method.

The implementation correctly retrieves the filter by ID and handles the case where the filter is not found. The error handling and the transformation of logs into the expected JSON-RPC format are well implemented.


Line range hint 1097-1116: Added a new case for eth_newBlockFilter.

This addition supports the creation of new block filters, which is a necessary feature for clients that need to track blocks. The implementation correctly manages the lifecycle of the filter and its associated listener.


1130-1147: Enhanced the eth_uninstallFilter method to handle different types of filters.

The update improves the robustness of filter removal by ensuring that listeners associated with the filter are correctly removed based on the filter type.


Line range hint 1172-1192: Added handling for eth_newPendingTransactionFilter.

This addition allows clients to track new pending transactions, which is useful for applications that need to react to unconfirmed transactions. The implementation is consistent with other filter types.

Comment on lines 991 to 1028

/**
* @param {import('@tevm/utils').EthjsLog} log
*/
const listener = (log) => {
const filter = client.getFilters().get(id)
if (!filter) {
return
}
filter.logs.push(log)
}
client.on('newLog', listener)
// populate with past blocks
const receiptsManager = await client.getReceiptsManager()
const pastLogs = (
await receiptsManager.getLogs(
_fromBlock,
_toBlock,
[EthjsAddress.fromString(address).bytes],
topics.map((topic) => hexToBytes(topic)),
)
).map((res) => res.log)
client.setFilter({
id,
type: 'Log',
created: Date.now(),
logs: [],
logs: pastLogs,
tx: [],
blocks: [],
logsCriteria: {
topics,
address,
toBlock: _toBlock,
fromBlock: _fromBlock,
toBlock: toBlock,
fromBlock: fromBlock,
},
installed: {},
err: undefined,
registeredListeners: [listener],
Copy link
Contributor

Choose a reason for hiding this comment

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

Added a new case for eth_newFilter in the JSON-RPC request handler.

- client.on('newLog', listener)
+ client.on('log', listener)

The event name should be corrected to match the expected event that triggers the listener. Ensure that the event 'newLog' is defined or change it to the correct event name.

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
/**
* @param {import('@tevm/utils').EthjsLog} log
*/
const listener = (log) => {
const filter = client.getFilters().get(id)
if (!filter) {
return
}
filter.logs.push(log)
}
client.on('newLog', listener)
// populate with past blocks
const receiptsManager = await client.getReceiptsManager()
const pastLogs = (
await receiptsManager.getLogs(
_fromBlock,
_toBlock,
[EthjsAddress.fromString(address).bytes],
topics.map((topic) => hexToBytes(topic)),
)
).map((res) => res.log)
client.setFilter({
id,
type: 'Log',
created: Date.now(),
logs: [],
logs: pastLogs,
tx: [],
blocks: [],
logsCriteria: {
topics,
address,
toBlock: _toBlock,
fromBlock: _fromBlock,
toBlock: toBlock,
fromBlock: fromBlock,
},
installed: {},
err: undefined,
registeredListeners: [listener],
/**
* @param {import('@tevm/utils').EthjsLog} log
*/
const listener = (log) => {
const filter = client.getFilters().get(id)
if (!filter) {
return
}
filter.logs.push(log)
}
client.on('log', listener)
// populate with past blocks
const receiptsManager = await client.getReceiptsManager()
const pastLogs = (
await receiptsManager.getLogs(
_fromBlock,
_toBlock,
[EthjsAddress.fromString(address).bytes],
topics.map((topic) => hexToBytes(topic)),
)
).map((res) => res.log)
client.setFilter({
id,
type: 'Log',
created: Date.now(),
logs: pastLogs,
tx: [],
blocks: [],
logsCriteria: {
topics,
address,
toBlock: toBlock,
fromBlock: fromBlock,
},
installed: {},
err: undefined,
registeredListeners: [listener],

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 afe5483 and 91103de.

Files selected for processing (3)
  • packages/base-client/src/EIP1193EventEmitterTypes.ts (1 hunks)
  • packages/base-client/src/Filter.ts (1 hunks)
  • packages/procedures/src/requestProcedure.js (8 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/base-client/src/Filter.ts
  • packages/procedures/src/requestProcedure.js
Additional comments not posted (5)
packages/base-client/src/EIP1193EventEmitterTypes.ts (5)

13-13: LGTM! The ProviderConnectInfo type is well-defined.


17-18: LGTM! The ProviderMessage type is correctly structured.


33-43: LGTM! The additions to EIP1193EventMap align with the PR's objectives to enhance event handling.


47-48: LGTM! The EIP1193Events type provides clear methods for event management.


51-60: LGTM! The EIP1193EventEmitter interface is minimal and well-documented.

Comment on lines 22 to 29
code: number
details: string

constructor(code: number, message: string) {
super(message)
this.code = code
this.details = message
}
constructor(code: number, message: string) {
super(message)
this.code = code
this.details = message
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider differentiating between code and details in ProviderRpcError.

- this.details = message
+ this.details = "Additional details: " + message
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
code: number
details: string
constructor(code: number, message: string) {
super(message)
this.code = code
this.details = message
}
constructor(code: number, message: string) {
super(message)
this.code = code
this.details = message
}
code: number
details: string
constructor(code: number, message: string) {
super(message)
this.code = code
this.details = "Additional details: " + message
}

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

Outside diff range and nitpick comments (6)
tevm/docs/index/type-aliases/Filter.md (1)

Line range hint 47-63: The documentation updates accurately reflect the changes to the Filter type.

Replace the bare URL with a markdown link for better readability.

- https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329
+ [Ethereum Go Filter System](https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329)
Tools
Markdownlint

56-56: null
Bare URL used

packages/base-client/docs/classes/ProviderRpcError.md (1)

Line range hint 123-123: Consider using a Markdown link with descriptive text instead of a bare URL for better readability.

- https://v8.dev/docs/stack-trace-api#customizing-stack-traces
+ [Customizing Stack Traces](https://v8.dev/docs/stack-trace-api#customizing-stack-traces)
docs/src/content/docs/reference/@tevm/base-client/classes/ProviderRpcError.md (1)

Line range hint 122-122: Consider using a Markdown link with descriptive text instead of a bare URL for better readability.

- https://v8.dev/docs/stack-trace-api#customizing-stack-traces
+ [Customizing Stack Traces](https://v8.dev/docs/stack-trace-api#customizing-stack-traces)
tevm/docs/index/type-aliases/BaseClient.md (1)

Line range hint 109-109: Consider adding blank lines around lists for better Markdown formatting.

- let client = createMemoryClient()
- console.log(client.mode) // 'normal'
- client = createMemoryClient({ forkUrl: 'https://mainnet.infura.io/v3/your-api-key' })
- console.log(client.mode) // 'fork'
+ let client = createMemoryClient()
+
+ console.log(client.mode) // 'normal'
+
+ client = createMemoryClient({ forkUrl: 'https://mainnet.infura.io/v3/your-api-key' })
+
+ console.log(client.mode) // 'fork'
tevm/docs/index/type-aliases/BaseClientOptions.md (2)

Line range hint 72-85: Replace hard tabs with spaces to maintain consistency in Markdown files.


Line range hint 36-36: Ensure fenced code blocks are surrounded by blank lines and specify a language for syntax highlighting.

Also applies to: 137-137, 31-31

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 91103de and da3344b.

Files selected for processing (41)
  • .changeset/famous-planets-pretend.md (1 hunks)
  • docs/src/content/docs/reference/@tevm/base-client/classes/ProviderRpcError.md (3 hunks)
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/EIP1193EventEmitter.md (1 hunks)
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/EIP1193EventMap.md (2 hunks)
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/EIP1193Events.md (1 hunks)
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/Filter.md (3 hunks)
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/FilterType.md (1 hunks)
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/ProviderConnectInfo.md (1 hunks)
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/ProviderMessage.md (1 hunks)
  • docs/src/content/docs/reference/@tevm/procedures/functions/requestProcedure.md (1 hunks)
  • packages/actions-types/docs/type-aliases/FilterParams.md (1 hunks)
  • packages/actions-types/src/common/FilterParams.ts (1 hunks)
  • packages/actions/src/eth/ethGetLogsHandler.js (2 hunks)
  • packages/base-client/docs/classes/ProviderRpcError.md (3 hunks)
  • packages/base-client/docs/type-aliases/EIP1193EventEmitter.md (1 hunks)
  • packages/base-client/docs/type-aliases/EIP1193EventMap.md (2 hunks)
  • packages/base-client/docs/type-aliases/EIP1193Events.md (1 hunks)
  • packages/base-client/docs/type-aliases/Filter.md (3 hunks)
  • packages/base-client/docs/type-aliases/FilterType.md (1 hunks)
  • packages/base-client/docs/type-aliases/ProviderConnectInfo.md (1 hunks)
  • packages/base-client/docs/type-aliases/ProviderMessage.md (1 hunks)
  • packages/base-client/src/EIP1193EventEmitterTypes.ts (2 hunks)
  • packages/base-client/src/Filter.ts (3 hunks)
  • packages/memory-client/src/test/viem/uninstallFilter.spec.ts (1 hunks)
  • packages/procedures/docs/functions/requestProcedure.md (1 hunks)
  • packages/procedures/src/requestProcedure.js (9 hunks)
  • tevm/docs/actions-types/type-aliases/FilterParams.md (1 hunks)
  • tevm/docs/index/functions/createBaseClient.md (1 hunks)
  • tevm/docs/index/type-aliases/AutoMining.md (1 hunks)
  • tevm/docs/index/type-aliases/BaseClient.md (1 hunks)
  • tevm/docs/index/type-aliases/BaseClientOptions.md (1 hunks)
  • tevm/docs/index/type-aliases/CustomPrecompile.md (1 hunks)
  • tevm/docs/index/type-aliases/EIP1193EventMap.md (2 hunks)
  • tevm/docs/index/type-aliases/Extension.md (1 hunks)
  • tevm/docs/index/type-aliases/Filter.md (3 hunks)
  • tevm/docs/index/type-aliases/Hardfork.md (1 hunks)
  • tevm/docs/index/type-aliases/IntervalMining.md (1 hunks)
  • tevm/docs/index/type-aliases/ManualMining.md (1 hunks)
  • tevm/docs/index/type-aliases/MiningConfig.md (1 hunks)
  • tevm/docs/index/variables/GENESIS_STATE.md (1 hunks)
  • tevm/docs/index/variables/prefundedAccounts.md (1 hunks)
Files skipped from review due to trivial changes (8)
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/EIP1193EventEmitter.md
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/EIP1193Events.md
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/FilterType.md
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/ProviderConnectInfo.md
  • docs/src/content/docs/reference/@tevm/base-client/type-aliases/ProviderMessage.md
  • packages/base-client/docs/type-aliases/FilterType.md
  • packages/memory-client/src/test/viem/uninstallFilter.spec.ts
  • packages/procedures/docs/functions/requestProcedure.md
Files skipped from review as they are similar to previous changes (19)
  • packages/base-client/docs/type-aliases/EIP1193EventEmitter.md
  • packages/base-client/docs/type-aliases/EIP1193EventMap.md
  • packages/base-client/docs/type-aliases/EIP1193Events.md
  • packages/base-client/docs/type-aliases/ProviderConnectInfo.md
  • packages/base-client/docs/type-aliases/ProviderMessage.md
  • packages/base-client/src/EIP1193EventEmitterTypes.ts
  • packages/base-client/src/Filter.ts
  • packages/procedures/src/requestProcedure.js
  • tevm/docs/index/functions/createBaseClient.md
  • tevm/docs/index/type-aliases/AutoMining.md
  • tevm/docs/index/type-aliases/CustomPrecompile.md
  • tevm/docs/index/type-aliases/EIP1193EventMap.md
  • tevm/docs/index/type-aliases/Extension.md
  • tevm/docs/index/type-aliases/Hardfork.md
  • tevm/docs/index/type-aliases/IntervalMining.md
  • tevm/docs/index/type-aliases/ManualMining.md
  • tevm/docs/index/type-aliases/MiningConfig.md
  • tevm/docs/index/variables/GENESIS_STATE.md
  • tevm/docs/index/variables/prefundedAccounts.md
Additional context used
Markdownlint
tevm/docs/index/type-aliases/Filter.md

56-56: null
Bare URL used

packages/base-client/docs/type-aliases/Filter.md

56-56: null
Bare URL used

docs/src/content/docs/reference/@tevm/base-client/type-aliases/Filter.md

55-55: null
Bare URL used

packages/base-client/docs/classes/ProviderRpcError.md

123-123: null
Bare URL used

docs/src/content/docs/reference/@tevm/base-client/classes/ProviderRpcError.md

122-122: null
Bare URL used

tevm/docs/index/type-aliases/BaseClient.md

109-109: null
Lists should be surrounded by blank lines

tevm/docs/index/type-aliases/BaseClientOptions.md

72-72: Column: 1
Hard tabs


73-73: Column: 1
Hard tabs


74-74: Column: 1
Hard tabs


75-75: Column: 1
Hard tabs


76-76: Column: 1
Hard tabs


77-77: Column: 1
Hard tabs


78-78: Column: 1
Hard tabs


79-79: Column: 1
Hard tabs


80-80: Column: 1
Hard tabs


81-81: Column: 1
Hard tabs


82-82: Column: 1
Hard tabs


83-83: Column: 1
Hard tabs


84-84: Column: 1
Hard tabs


85-85: Column: 1
Hard tabs


36-36: null
Fenced code blocks should be surrounded by blank lines


137-137: null
Lists should be surrounded by blank lines


31-31: null
Fenced code blocks should have a language specified

Additional comments not posted (19)
.changeset/famous-planets-pretend.md (1)

1-5: The changeset description accurately reflects the modifications made to the FilterParams type.

tevm/docs/actions-types/type-aliases/FilterParams.md (1)

15-29: The documentation updates accurately reflect the changes to the FilterParams type.

packages/actions-types/docs/type-aliases/FilterParams.md (1)

15-29: The documentation updates accurately reflect the changes to the FilterParams type.

docs/src/content/docs/reference/@tevm/procedures/functions/requestProcedure.md (1)

46-46: The source link is correctly updated to reflect the new line number in the source code.

packages/base-client/docs/type-aliases/Filter.md (2)

47-47: Updated logs type to GetFilterLogsReturnType[number][] enhances type specificity and safety.


58-63: Added registeredListeners field to track event listeners, enhancing event management capabilities.

docs/src/content/docs/reference/@tevm/base-client/type-aliases/Filter.md (2)

46-46: Updated logs type to GetFilterLogsReturnType[number][] enhances type specificity and safety.


57-62: Added registeredListeners field to track event listeners, enhancing event management capabilities.

docs/src/content/docs/reference/@tevm/base-client/type-aliases/EIP1193EventMap.md (2)

76-76: Added newLog function to handle new log events, enhancing the event handling capabilities.


92-101: Added newReceipt function to handle new receipt events, enhancing transaction management capabilities.

packages/base-client/docs/classes/ProviderRpcError.md (3)

35-35: Updated source reference for the constructor points to the correct location in the source code.


59-59: Updated source reference for the code property points to the correct location in the source code.


69-69: Updated source reference for the details property points to the correct location in the source code.

docs/src/content/docs/reference/@tevm/base-client/classes/ProviderRpcError.md (3)

34-34: Updated source reference for the constructor points to the correct location in the source code.


58-58: Updated source reference for the code property points to the correct location in the source code.


68-68: Updated source reference for the details property points to the correct location in the source code.

tevm/docs/index/type-aliases/BaseClient.md (1)

200-200: Updated source reference for BaseClient points to the correct location in the source code.

packages/actions/src/eth/ethGetLogsHandler.js (2)

67-72: Ensure proper handling of default values for fromBlock and toBlock parameters.


140-141: Verify the handling of optional address and topics parameters to prevent errors when they are undefined.

Verification successful

The ethGetLogsHandler function is defined in packages/actions/src/eth/ethGetLogsHandler.js and is used in packages/procedures/src/requestProcedure.js and packages/procedures/src/eth/ethGetLogsProcedure.js. The function definition and its usage indicate that the address and topics parameters are accessed directly from params.filterParams.

Observations:

  • The function definition in ethGetLogsHandler.js accesses params.filterParams.address and params.filterParams.topics directly.
  • The usage in requestProcedure.js and ethGetLogsProcedure.js passes filterParams with address and topics to the handler.

Verification:

  • The code snippet in ethGetLogsHandler.js handles address and topics parameters with optional chaining (?.) and default values (??), which should prevent errors when these parameters are undefined.

Conclusion:

The handling of optional address and topics parameters in ethGetLogsHandler appears to be correct, as the code uses optional chaining and default values to prevent errors when these parameters are undefined.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the handling of optional parameters in `ethGetLogsHandler`.

# Test: Search for the function usage. Expect: Proper checks for undefined values.
rg --type javascript $'ethGetLogsHandler'

Length of output: 75



Script:

#!/bin/bash
# Description: Verify the handling of optional parameters in `ethGetLogsHandler`.

# Correct file type for JavaScript
rg --type js 'ethGetLogsHandler'

Length of output: 713



Script:

#!/bin/bash
# Description: Extract the function definition and its usage for `ethGetLogsHandler`.

# Extract the function definition
rg --type js --context 10 'export const ethGetLogsHandler' packages/actions/src/eth/ethGetLogsHandler.js

# Extract the function usage in requestProcedure.js
rg --type js --context 10 'ethGetLogsHandler' packages/procedures/src/requestProcedure.js

# Extract the function usage in ethGetLogsProcedure.js
rg --type js --context 10 'ethGetLogsHandler' packages/procedures/src/eth/ethGetLogsProcedure.js

Length of output: 2875

Comment on lines +9 to +12
readonly fromBlock?: BlockParam
readonly toBlock?: BlockParam
readonly address?: Address
readonly topics?: ReadonlyArray<Hex>
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The documentation for FilterParams has been updated to reflect the changes. However, the search for test cases did not yield any specific test cases directly covering the optional properties of FilterParams.

To ensure comprehensive testing, it is crucial to have test cases that specifically verify the behavior of FilterParams with its optional properties. This includes scenarios where some or all properties are omitted.

Please verify and add test cases for FilterParams to ensure that the optional properties are adequately tested.

  • Ensure that test cases cover scenarios where FilterParams is used with some or all properties omitted.
  • Verify that the behavior of FilterParams is as expected when properties are optional.
Analysis chain

The modifications to make FilterParams properties optional are correctly implemented.

Ensure that the documentation and tests are updated to reflect these changes.


The documentation for FilterParams has been updated to reflect the changes. However, the search for test cases failed due to an unrecognized file type. Let's correct the file type and re-run the script to verify the presence of test cases for FilterParams.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if the documentation and tests for `FilterParams` have been updated.

# Test: Search for documentation updates.
rg --type markdown 'FilterParams' --files-with-matches | xargs cat

# Test: Search for test cases covering the optional properties.
rg --type typescript 'FilterParams' --files-with-matches | xargs cat

Length of output: 76758



Script:

#!/bin/bash
# Description: Verify if the test cases for `FilterParams` have been updated.

# Test: Search for test cases covering the optional properties.
rg --type ts 'FilterParams' --files-with-matches | xargs cat

Length of output: 46395

@@ -55,6 +55,12 @@ Stores logs
Criteria of the logs
https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a Markdown link with descriptive text instead of a bare URL for better readability.

- https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329
+ [Ethereum Go Filter System](https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329)
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
https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329
[Ethereum Go Filter System](https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329)
Tools
Markdownlint

56-56: null
Bare URL used

@@ -54,6 +54,12 @@ Stores logs
Criteria of the logs
https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a Markdown link with descriptive text instead of a bare URL for better readability.

- https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329
+ [Ethereum Go Filter System](https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329)
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
https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329
[Ethereum Go Filter System](https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L329)
Tools
Markdownlint

55-55: null
Bare URL used

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between da3344b and da87a05.

Files selected for processing (6)
  • .changeset/curly-hats-tickle.md (1 hunks)
  • .changeset/fair-badgers-arrive.md (1 hunks)
  • .changeset/forty-trees-refuse.md (1 hunks)
  • .changeset/funny-drinks-brush.md (1 hunks)
  • .changeset/lazy-pumas-grab.md (1 hunks)
  • .changeset/lemon-camels-decide.md (1 hunks)
Files skipped from review due to trivial changes (4)
  • .changeset/fair-badgers-arrive.md
  • .changeset/forty-trees-refuse.md
  • .changeset/funny-drinks-brush.md
  • .changeset/lemon-camels-decide.md
Additional comments not posted (2)
.changeset/curly-hats-tickle.md (1)

5-5: Clear and concise description of the patch addressing the race condition in transaction validation.

.changeset/lazy-pumas-grab.md (1)

5-5: Well-documented fix for handling optional properties in eth_getLogs.

@roninjin10 roninjin10 merged commit 693653e into main Jun 3, 2024
16 checks passed
@roninjin10 roninjin10 deleted the logslogslogs branch June 3, 2024 04:24
@github-actions github-actions bot mentioned this pull request Jun 3, 2024
roninjin10 pushed a commit that referenced this pull request Jun 3, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @tevm/[email protected]

### Minor Changes

- [#1154](#1154)
[`693653e`](693653e)
Thanks [@roninjin10](https://github.com/roninjin10)! - Updated tevmMine
to events for newBlock, newReceipt, and newLog

### Patch Changes

- [#1154](#1154)
[`693653e`](693653e)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed race
condition where a tx can fail validation but still be added to tx pool

- [#1154](#1154)
[`693653e`](693653e)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed bug with
eth_getLogs not properly handling optional properties when undefined

-   Updated dependencies \[]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]

## @tevm/[email protected]

### Minor Changes

- [#1154](#1154)
[`693653e`](693653e)
Thanks [@roninjin10](https://github.com/roninjin10)! - Updated
BaseClient to emit a 'connect' event after it is ready

- [#1154](#1154)
[`693653e`](693653e)
Thanks [@roninjin10](https://github.com/roninjin10)! - Updated
base-client log filters type to include more information such as the tx
hash and block hash

## @tevm/[email protected]

### Minor Changes

- [#1158](#1158)
[`7b4b13e`](7b4b13e)
Thanks [@roninjin10](https://github.com/roninjin10)! - Removed all test
actions from MemoryClient

### Patch Changes

- Updated dependencies
\[[`693653e`](693653e),
[`693653e`](693653e)]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]

## @tevm/[email protected]

### Minor Changes

- [#1154](#1154)
[`693653e`](693653e)
Thanks [@roninjin10](https://github.com/roninjin10)! - Added new
JSON-RPC support eth_getFilterLogs and eth_getFilterChanges

### Patch Changes

- Updated dependencies
\[[`693653e`](693653e),
[`693653e`](693653e),
[`693653e`](693653e)]:
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

-   Updated dependencies \[]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

- Updated dependencies
\[[`7b4b13e`](7b4b13e)]:
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

- [#1154](#1154)
[`693653e`](693653e)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed bug with
filter params being required rather than optional

## @tevm/[email protected]

### Patch Changes

- Updated dependencies
\[[`693653e`](693653e),
[`693653e`](693653e),
[`693653e`](693653e),
[`693653e`](693653e),
[`693653e`](693653e)]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]

## [email protected]

### Patch Changes

- Updated dependencies
\[[`7b4b13e`](7b4b13e),
[`693653e`](693653e),
[`693653e`](693653e),
[`693653e`](693653e)]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

1 participant