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

Move V2 wrapped providers to v3 #5810

Merged
merged 27 commits into from
Oct 17, 2024
Merged

Conversation

ChristopherDedominici
Copy link
Contributor

@ChristopherDedominici ChristopherDedominici commented Oct 9, 2024

Related Issues

See the NOTE section in this issue

Changes

The current PR implements:

  • porting of the V2 gas providers
  • porting of the chain validation V2 provider
  • port of the V2 unit tests for gas and validation providers
  • addition of e2e tests for gas and validation

All the code has been ported while maintaining most of the original structure in both the source code and the tests; therefore, there are no significant changes in the logic.

Additional work

While porting the accounts provider I discovered that there are quite a few missing functionalities that are not currently implemented in V3. For example:

  • there are a lot of functions that in V2 are imported from @nomicfoundation/ethereumjs-util, @nomicfoundation/ethereumjs-tx, etc. Example: FeeMarketEIP1559Transaction.
    See here, search for @nomicfoundation/ to see all the imports
  • there are quite a lot of RPC types leveraging t defined types that need to be defined because currently they are not available in V3, for example in this file (not all of them are needed).
  • adding the account property in the network configuration is a straightforward task, but there are a lot of tests to port, like in this file

I think this should be split into multiple PRs since these side tasks, while related to moving the providers, are dependencies rather than the main focus.

How could the work be re-organized:

  • split the accounts work from the current branch, then work it up to a PR with providers that don’t depend on accounts : both logic + tests (done in this PR)
  • follow up PR with accounts property port + tests, and the simple FixedSenderProvider and AutomaticSenderProvider providers
  • final follow up PR with missing types and util functions for accounts + LocalAccountsProvider and HDWalletProvider ported with logic + tests

Notes on the implementation

  • A similar class structure from V2 will be retained in V3. While some previous functionalities could be converted into simple functions in V3, the majority need to remain as classes. To maintain code consistency, even those that could be converted to functions will be kept as classes. This approach ensures cleaner and more efficient access to values using this in various parts of the code, rather than passing the same variables multiple times.
  • There are a few TODOs from the V2 code, I kept them as TODOs. I marked them as TODO: from V2 -

Copy link

vercel bot commented Oct 9, 2024

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

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 17, 2024 0:57am

Copy link

changeset-bot bot commented Oct 9, 2024

⚠️ No Changeset found

Latest commit: 6472432

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

// the AutomaticGasPrice for it unless there are provider extenders.
// The reason for this is that some extenders (like hardhat-ledger's) might
// do the signing themselves, and that needs the gas price to be set.
if (isResolvedHttpNetworkConfig(this.#networkConfig)) {
Copy link
Contributor Author

@ChristopherDedominici ChristopherDedominici Oct 9, 2024

Choose a reason for hiding this comment

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

I need a double-check on this because, based on the V2 comment description above, I'm not entirely sure whether this "if condition" is correct. I'll update the V2 description as soon as I confirm the correct code.

Original implementation at this link

Copy link
Member

Choose a reason for hiding this comment

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

I think it's correct, but we can ask Pato or John if you want to be absolutely sure before merging.

Co-authored-by: Patricio Palladino <[email protected]>
Copy link
Member

@schaable schaable left a comment

Choose a reason for hiding this comment

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

Nice work! I left some comments, but I think most of them can be addressed later (we just need to create issues to track them). Also, I find using assertHardhatInvariant after each request a bit annoying. We could simplify things by adding type guards for the RPC methods and exposing them as utilities.

@ChristopherDedominici ChristopherDedominici added this pull request to the merge queue Oct 17, 2024
Merged via the queue into v-next with commit 1ed9f9e Oct 17, 2024
69 checks passed
@ChristopherDedominici ChristopherDedominici deleted the move-providers-to-v3 branch October 17, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changeset needed This PR doesn't require a changeset
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add the replacement of provider wrappers using hooks (M2)
4 participants