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: port the Http Provider to v3 #5580

Merged
merged 17 commits into from
Aug 14, 2024
Merged

feat: port the Http Provider to v3 #5580

merged 17 commits into from
Aug 14, 2024

Conversation

schaable
Copy link
Member

@schaable schaable commented Aug 6, 2024

Part of #5549

The PR includes all the changes required for porting the HttpProvider and tests for the request and sendBatch methods. The PR is quite large, but it can be reviewed commit by commit. Each commit includes a description of the changes made.

@schaable schaable added the v-next A Hardhat v3 development task label Aug 6, 2024
@schaable schaable requested a review from alcuadrado August 6, 2024 15:40
@schaable schaable self-assigned this Aug 6, 2024
Copy link

vercel bot commented Aug 6, 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 Aug 14, 2024 3:47pm

Copy link

changeset-bot bot commented Aug 6, 2024

⚠️ No Changeset found

Latest commit: 7229bd0

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
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.

Testing the merge queue, please ignore this review

@alcuadrado alcuadrado self-requested a review August 13, 2024 17:59
- Created a Dispatcher type alias for UndiciT.Dispatcher.
- This change ensures that Undici types are not directly exposed in getDispatcher.
- In the future, we may narrow down the Dispatcher type to include only the required properties.
- Copied the getHardhatVersion helper from the hardhat package to the core package.
- Added a caching mechanism to store the hardhat version once obtained, improving performance.
- The future structure of the packages is still uncertain: we might have two different packages each with its own version, different packages with mirrored versions, or a single combined package for core and hardhat.
- Currently, the helper is duplicated, which may be sufficient for now but might need to be revisited in the future.
- Added ConnectionRefusedError handling for ECONNREFUSED errors.
- Added RequestTimeoutError handling for UND_ERR_CONNECT_TIMEOUT, UND_ERR_HEADERS_TIMEOUT, and UND_ERR_BODY_TIMEOUT errors.
…tDispatcher

- Added getTestDispatcher function to obtain a MockAgent from undici.
- Refactored test code to use a new helper function initializeTestDispatcher, which sets up the test dispatcher and returns an interceptor.
- Renamed mockPool to interceptor in the test file for clarity.
- Introduced a new error type ResponseStatusCodeError to handle 4xx and 5xx HTTP response status codes. This is needed because we set throwOnError to true in all requests.
- ResponseStatusCodeError includes `statusCode`, `headers`, and `body` properties.
- Ported existing HTTP provider functionality to v-next.
- Updated code to support ESM, follow modern TypeScript practices, and use hardhat-utils.
- Added tests for request and sendBatch.
… tests

- Moved error handling logic to a handleError function to avoid code duplication.
- Updated the error handling to correctly check for e.cause.code or e.code existence.
- Fixed tests that were not previously updated to expect ResponseStatusCodeError.
- Added send and sendAsync from the backwards compatibility provider
as we're no longer going to use wrappers.
- Added jsdoc for the public methods.
- Changed the HttpProvider.create signature to receive a config
object. timeout is no longer optional in this object.
- Default the params to an empty array if not provided.
- Renamed delay to sleep.
- Do not set error.data on failed retry.
@schaable schaable added this pull request to the merge queue Aug 14, 2024
Merged via the queue into v-next with commit 36cf2b2 Aug 14, 2024
58 checks passed
@schaable schaable deleted the http-provider branch August 14, 2024 21:05
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:ready This issue is ready to be worked on v-next A Hardhat v3 development task
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants