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

Rework providers #5994

Merged
merged 19 commits into from
Dec 9, 2024
Merged

Rework providers #5994

merged 19 commits into from
Dec 9, 2024

Conversation

ChristopherDedominici
Copy link
Contributor

@ChristopherDedominici ChristopherDedominici commented Nov 27, 2024

DESCRIPTION
This PR reworks the logic for the providers.

Main Points:

  • the providers are now stored in an array, making it easier to track which provider is being executed by stepping through a simple for loop. This replaces the previous solution, which relied on recursive behavior and was harder to follow.
  • e2e tests have been simplified. The old tests have been replaced with a single e2e file, which is easier to maintain.
  • minor renaming adjustments have been made for improved clarity.

QUESTIONS

  • the v2 code was using this function to convert from number to rpc quantity. The v3 code is following this logic. I think the logic is the same, but I'd like to have a double check on this.

Copy link

vercel bot commented Nov 27, 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 Dec 6, 2024 11:31am

Copy link

changeset-bot bot commented Nov 27, 2024

⚠️ No Changeset found

Latest commit: 64ed264

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

public async handle(
jsonRpcRequest: JsonRpcRequest,
): Promise<JsonRpcRequest | JsonRpcResponse> {
const response = await this.#resolveRequest(jsonRpcRequest);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This handler can modify a JSON-RPC request and return a JSON-RPC response. In the v2 implementation, the execution order first handled the response logic and then processed the request modification. I have retained the same approach here. See the v2 code here

@@ -0,0 +1,271 @@
import type { HttpNetworkHDAccountsConfig } from "../../../../../src/types/config.js";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are these e2e tests comprehensive enough, or is there an additional scenario you believe would be worth including?

//
// EDR Network handles this in a more performant way, so we don't use
// the AutomaticGasPrice for it.
if (networkConfig.type === "http") {
Copy link
Contributor Author

@ChristopherDedominici ChristopherDedominici Nov 28, 2024

Choose a reason for hiding this comment

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

Is this the if condition that can be removed because also supported in EDR networks?
See related issues here:

Copy link
Member

Choose a reason for hiding this comment

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

Let's remove this one, but not the one in line 92. Let's let EDR handle the signing of transactions from its own accounts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done here

params: [
{
to: "0x0000000000000000000000000000000000000012",
maxFeePerGas: "0x99",
Copy link
Member

Choose a reason for hiding this comment

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

this value here confuses me a bit. Why is it necessary?

Copy link
Contributor Author

@ChristopherDedominici ChristopherDedominici Dec 6, 2024

Choose a reason for hiding this comment

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

It's not strictly necessary. It's more of an additional check to be sure that there is no conflict with the logic if maxFeePerGas is present. But it can be removed, I did it here

Copy link
Member

@alcuadrado alcuadrado left a comment

Choose a reason for hiding this comment

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

I left a few comments, but this looks good. It's now definitely simpler to reason about it.

@ChristopherDedominici ChristopherDedominici added this pull request to the merge queue Dec 9, 2024
Merged via the queue into v-next with commit 7273a6a Dec 9, 2024
45 checks passed
@ChristopherDedominici ChristopherDedominici deleted the rework-providers branch December 9, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

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