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 support for incrementing nonces #1074

Merged
merged 4 commits into from
May 15, 2024

Conversation

roninjin10
Copy link
Collaborator

@roninjin10 roninjin10 commented May 14, 2024

Description

Fixes a bug where nonces would not increment if more than 0 tx from the same address are in the tx pool

Testing

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

Additional Information

Your ENS/address:

Summary by CodeRabbit

  • New Features

    • Added the ability to retrieve all mempool transactions from a specific sender address.
  • Bug Fixes

    • Improved error handling in transaction processing and contract interactions.
  • Tests

    • Introduced new test cases for multiple transactions and mining scenarios.
  • Documentation

    • Updated method locations and descriptions in TxPool documentation.
  • Refactor

    • Enhanced error decoding logic in contract handling.
    • Adjusted nonce and gas limit calculations for transactions.
  • Chores

    • Updated dependencies and expanded exported entities across various modules.

Copy link

vercel bot commented May 14, 2024

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

Name Status Preview Comments Updated (UTC)
tevm-monorepo-tevm ❌ Failed (Inspect) May 15, 2024 2:16am

Copy link

changeset-bot bot commented May 14, 2024

🦋 Changeset detected

Latest commit: 220efe9

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

This PR includes changesets to release 11 packages
Name Type
@tevm/txpool Minor
tevm Minor
@tevm/base-client Minor
@tevm/ethers Minor
@tevm/actions Minor
@tevm/decorators Minor
@tevm/memory-client Minor
@tevm/procedures Minor
@tevm/server Minor
@tevm/opstack Minor
@tevm/http-client 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 May 14, 2024

Walkthrough

The updates introduce significant enhancements to the tevm module, including new functionalities for transaction pools, error handling improvements, and extended support for deployment and mining operations. Key additions include the bySenderAddress method for retrieving transactions, refined error handling in various handlers, and expanded test cases. The changes also involve updates to documentation and the expansion of exported entities across multiple modules.

Changes

File/Path Change Summary
.changeset/young-actors-battle.md Introduced bySenderAddress method for transaction pools in the tevm module.
packages/actions/src/tevm/callHandler.js Enhanced block forking, transaction processing, and error handling in forkAndCacheBlock and callHandler.
packages/actions/src/tevm/callHandler.spec.ts Added parseEther, type Address imports, and new test case for multiple transactions.
packages/actions/src/tevm/contractHandler.js Modified error decoding logic with try-catch block and updated error message construction.
packages/actions/src/tevm/createTransaction.js Added fetching txPool and retrieving transactions by sender address; modified nonce and gas limit calculation.
packages/memory-client/src/test/viemPublicActions.spec.ts Added test cases for public actions covering contract calls, gas estimation, and event handling.
packages/txpool/docs/classes/TxPool.md Updated method locations and added getBySenderAddress method.
packages/txpool/src/TxPool.ts Added EthjsAddress import and getBySenderAddress method to TxPool class.
tevm/actions-types/index.d.cts Added new entities for deployment and mining operations.
tevm/actions-types/index.d.ts Added new entities for deployment and mining operations.
tevm/base-client/index.d.cts Added GENESIS_STATE and prefundedAccounts to exports.
tevm/errors/index.d.cts Removed MineError and added InvalidCreateParams to exports.
tevm/errors/index.d.ts Removed MineError and added InvalidCreateParams to exports.
tevm/memory-client/index.d.cts Added TevmActions to exports.
tevm/memory-client/index.d.ts Added TevmActions to exports.
tevm/package.json Updated dependency version for @tevm/viem.
tevm/procedures-types/index.d.cts Added MineJsonRpcProcedure, MineJsonRpcRequest, and MineJsonRpcResponse to exports.
tevm/procedures-types/index.d.ts Added MineJsonRpcProcedure, MineJsonRpcRequest, and MineJsonRpcResponse to exports.
tevm/server/index.d.cts Removed CreateHttpHandlerParameters from exports.
tevm/server/index.d.ts Removed CreateHttpHandlerParameters from exports.
tevm/utils/index.d.cts Expanded exported entities with new types and utilities.
tevm/utils/index.d.ts Expanded exported entities with new types and utilities.

🐰✨ In the realm of code so bright,
New features come to light.
Transactions by address, oh so neat,
Error handling now complete.
With tests and docs all in place,
The tevm module finds its grace.
Let's celebrate this coding feat! 🚀


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
Collaborator Author

roninjin10 commented May 14, 2024

@roninjin10 roninjin10 marked this pull request as ready for review May 14, 2024 20:51
@roninjin10 roninjin10 force-pushed the 05-14-_loud_sound_fix_add_try_catch_to_rever_data_decoding branch from 61a38f7 to 732b4ae Compare May 14, 2024 20:59
@roninjin10 roninjin10 force-pushed the 05-14-_bug_fix_add_support_for_incrementing_nonces branch from 8a5427c to ac9a0e0 Compare May 14, 2024 20:59
@roninjin10 roninjin10 force-pushed the 05-14-_loud_sound_fix_add_try_catch_to_rever_data_decoding branch from 732b4ae to 0e739c0 Compare May 14, 2024 21:08
@roninjin10 roninjin10 force-pushed the 05-14-_bug_fix_add_support_for_incrementing_nonces branch from ac9a0e0 to 7ffcbf0 Compare May 14, 2024 21:08
Base automatically changed from 05-14-_loud_sound_fix_add_try_catch_to_rever_data_decoding to main May 14, 2024 21:29
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

Out of diff range and nitpick comments (1)
.changeset/young-actors-battle.md (1)

6-6: Clarify the description of the bySenderAddress method.

Consider providing a more detailed description of the bySenderAddress method, including its purpose and usage.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 77dc398 and 220efe9.
Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml
Files selected for processing (23)
  • .changeset/young-actors-battle.md (1 hunks)
  • packages/actions/src/tevm/callHandler.js (3 hunks)
  • packages/actions/src/tevm/callHandler.spec.ts (2 hunks)
  • packages/actions/src/tevm/contractHandler.js (1 hunks)
  • packages/actions/src/tevm/createTransaction.js (4 hunks)
  • packages/memory-client/src/test/viemPublicActions.spec.ts (1 hunks)
  • packages/txpool/docs/classes/TxPool.md (5 hunks)
  • packages/txpool/src/TxPool.ts (2 hunks)
  • tevm/actions-types/index.d.cts (1 hunks)
  • tevm/actions-types/index.d.ts (1 hunks)
  • tevm/base-client/index.d.cts (1 hunks)
  • tevm/base-client/index.d.ts (1 hunks)
  • tevm/errors/index.d.cts (1 hunks)
  • tevm/errors/index.d.ts (1 hunks)
  • tevm/memory-client/index.d.cts (1 hunks)
  • tevm/memory-client/index.d.ts (1 hunks)
  • tevm/package.json (1 hunks)
  • tevm/procedures-types/index.d.cts (1 hunks)
  • tevm/procedures-types/index.d.ts (1 hunks)
  • tevm/server/index.d.cts (1 hunks)
  • tevm/server/index.d.ts (1 hunks)
  • tevm/utils/index.d.cts (1 hunks)
  • tevm/utils/index.d.ts (1 hunks)
Files skipped from review due to trivial changes (6)
  • packages/actions/src/tevm/callHandler.spec.ts
  • tevm/base-client/index.d.cts
  • tevm/base-client/index.d.ts
  • tevm/package.json
  • tevm/server/index.d.cts
  • tevm/server/index.d.ts
Additional comments not posted (19)
tevm/memory-client/index.d.cts (1)

1-1: Ensure that TevmActions is correctly defined and exported in @tevm/memory-client.

Please verify that TevmActions is correctly defined and exported in the @tevm/memory-client module.

tevm/memory-client/index.d.ts (1)

1-1: Ensure that TevmActions is correctly defined and exported in @tevm/memory-client.

Please verify that TevmActions is correctly defined and exported in the @tevm/memory-client module.

.changeset/young-actors-battle.md (1)

2-4: Ensure that the version updates are correctly reflected in the package files.

Please verify that the minor version updates for @tevm/txpool and tevm are correctly reflected in the respective package files.

tevm/errors/index.d.cts (1)

1-1: Ensure that InvalidCreateParams is correctly defined and exported in @tevm/errors.

Please verify that InvalidCreateParams is correctly defined and exported in the @tevm/errors module.

tevm/errors/index.d.ts (1)

1-1: Ensure that InvalidCreateParams is correctly defined and exported in @tevm/errors.

Please verify that InvalidCreateParams is correctly defined and exported in the @tevm/errors module.

tevm/utils/index.d.cts (1)

1-1: The added entities in the export statement are correctly named and relevant to the module. The changes look good.

tevm/utils/index.d.ts (1)

1-1: The added entities in the export statement are correctly named and relevant to the module. The changes look good.

packages/memory-client/src/test/viemPublicActions.spec.ts (1)

1-105: The added and updated test cases for public actions in the viem module are correctly implemented and cover the intended functionality. The changes look good.

tevm/actions-types/index.d.cts (1)

1-1: The added entities in the export statement are correctly named and relevant to the module. The changes look good.

tevm/actions-types/index.d.ts (1)

1-1: The added entities in the export statement are correctly named and relevant to the module. The changes look good.

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

119-133: Good use of a try-catch block to handle potential errors during the decoding process. This ensures that the contractHandler function can handle unexpected issues gracefully.

tevm/procedures-types/index.d.cts (1)

1-1: The addition of MineJsonRpcProcedure, MineJsonRpcRequest, and MineJsonRpcResponse to the export list is appropriate. Ensure these entities are correctly defined and used in the codebase.

tevm/procedures-types/index.d.ts (1)

1-1: The addition of MineJsonRpcProcedure, MineJsonRpcRequest, and MineJsonRpcResponse to the export list is appropriate. Ensure these entities are correctly defined and used in the codebase.

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

61-63: Fetching transactions by sender address is a necessary step for correctly calculating the nonce. Ensure that the getBySenderAddress method is correctly implemented and used.


74-75: The nonce calculation logic ensures that the nonce is correctly incremented when there are multiple transactions from the same address. This is a necessary fix for the bug mentioned in the PR summary.

packages/txpool/docs/classes/TxPool.md (1)

268-279: The documentation for the getBySenderAddress method is clear and provides necessary information about its parameters and source location. Ensure that the method is correctly documented and the source location is accurate.

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

152-154: Improve error handling by checking for the presence of a message in the error object.


220-222: Improve error handling by checking for the presence of a message in the error object.

packages/txpool/src/TxPool.ts (1)

435-437: Add method to retrieve transactions by sender address.

@roninjin10 roninjin10 merged commit 2ba2c27 into main May 15, 2024
15 of 16 checks passed
@roninjin10 roninjin10 deleted the 05-14-_bug_fix_add_support_for_incrementing_nonces branch May 15, 2024 02:20
roninjin10 pushed a commit that referenced this pull request May 15, 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

- [#1069](#1069)
[`a6655fc`](a6655fc)
Thanks [@roninjin10](https://github.com/roninjin10)! - Exported
`prefundedAccount` as an array of contract addresses that are prefunded.
These map to the the same accounts prefunded by anvil and hardhat.

### Patch Changes

- Updated dependencies
\[[`40547fe`](40547fe),
[`40547fe`](40547fe),
[`2ba2c27`](2ba2c27)]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]

## @tevm/[email protected]

### Minor Changes

- [#1074](#1074)
[`2ba2c27`](2ba2c27)
Thanks [@roninjin10](https://github.com/roninjin10)! - Added
bySenderAddress method to return all mempool tx from a single sender
address

### Patch Changes

- [#1076](#1076)
[`40547fe`](40547fe)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed bug with
txPool not removing processed tx after block is mined

## @tevm/[email protected]

### Minor Changes

- [#1071](#1071)
[`3546dc4`](3546dc4)
Thanks [@roninjin10](https://github.com/roninjin10)! - Added
simpleContract to testutils

## [email protected]

### Minor Changes

- [#1074](#1074)
[`2ba2c27`](2ba2c27)
Thanks [@roninjin10](https://github.com/roninjin10)! - Added
bySenderAddress method to return all mempool tx from a single sender
address

### Patch Changes

- [#1076](#1076)
[`40547fe`](40547fe)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed bug with
not updating nonce when more than one tx is in the tx pool

- Updated dependencies
\[[`a6655fc`](a6655fc),
[`40547fe`](40547fe)]:
    -   @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]
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

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

## @tevm/[email protected]

### Patch Changes

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

## @tevm/[email protected]

### Patch Changes

- [#1076](#1076)
[`40547fe`](40547fe)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed bug with
not updating nonce when more than one tx is in the tx pool

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

## @tevm/[email protected]

### Patch Changes

- Updated dependencies
\[[`40547fe`](40547fe)]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

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

## @tevm/[email protected]

### Patch Changes

- Updated dependencies
\[[`40547fe`](40547fe)]:
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

- [#1076](#1076)
[`40547fe`](40547fe)
Thanks [@roninjin10](https://github.com/roninjin10)! - Cleaned up how
deep copying works. Change should help with performance a bit.

- Updated dependencies
\[[`3546dc4`](3546dc4)]:
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

- Updated dependencies
\[[`40547fe`](40547fe)]:
    -   @tevm/[email protected]

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Oct 1, 2024
1 task
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