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

refactor: update ethers to v6.1 from v5.7 #670

Merged
merged 1 commit into from
Mar 19, 2023
Merged

Conversation

varunsrin
Copy link
Member

@varunsrin varunsrin commented Mar 18, 2023

Motivation

  • Ethers v6 uses noble crypto instead of elliptic, which avoids issues like this one (cc @CassOnMars)
  • Ethers v6 will introduce breaking changes to our library so best to get it out before launch vs after.

The downside is that we may be introducing some last minute bugs here which can go undetected, so I'd like to get some second opinions from folks working in the codebase.

Change Summary

The most significant changes being made are:

JS BigInt instead of Ethers.BigNum
BigInt seems like a drop in replacement except for the fact that serialization returns odd-length hex values like 0x3e8 instead of 0x03e8. In some cases this needs to be sanitized because parts of our codebase expect even length values.

Providers are very different under the hood
The internals of Providers have been refactored significantly. Providers now inherit from an AbstractProvider class and polling logic is handled explicitly by a Subscription. Since we used to reach into providers and modify polling behavior manually, this needs to be refactored carefully.

TypedDataSigner and verifyTypedData no longer exist
TypedDataSigner is superseded by the new Signer class and verifyTypedData no longer seems to exist for EIP712 verifications, which means we must perform signature recovery using more manual steps.

There are also some minor changes:

  • Utilities and most exports now happen at the top level
  • Types returned by Contracts and their listeners have changed slightly
  • Using Wallet.createRandom() instead of new Wallet(utils.randomBytes(32)) which has existed since v5, not sure if there's a reason we were doing this or just an omission.

Merge Checklist

  • PR title adheres to the conventional commits standard
  • PR has a changeset
  • PR has been tagged with a change label(s) (i.e. documentation, feature, bugfix, or chore)
  • PR does not require changes to the protocol

@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2023

🦋 Changeset detected

Latest commit: 313391d

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

This PR includes changesets to release 3 packages
Name Type
@farcaster/hub-nodejs Minor
@farcaster/utils Minor
@farcaster/hubble Patch

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

@varunsrin varunsrin added the t-chore Miscellaneous improvements label Mar 18, 2023
@varunsrin varunsrin added this to the v2.0.0 p2 milestone Mar 18, 2023
// Remove right padding
let hex = value.toHexString();
let hex = value.toString(16);
Copy link
Member Author

Choose a reason for hiding this comment

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

With BigInt, its possible that this value is an odd-length hex value. Is that going to create a problem here? Are there any additional test cases we should be adding?

cc @pfletcherhill and @deodad

apps/hubble/src/eth/ethEventsProvider.ts Show resolved Hide resolved
apps/hubble/src/eth/ethEventsProvider.test.ts Show resolved Hide resolved
@varunsrin varunsrin force-pushed the varunsrin/ethers-6.1 branch 2 times, most recently from be945a3 to 5c18455 Compare March 18, 2023 18:33
@varunsrin varunsrin merged commit 59920f9 into main Mar 19, 2023
@varunsrin varunsrin deleted the varunsrin/ethers-6.1 branch March 19, 2023 00:38
vinliao pushed a commit to vinliao/hubble that referenced this pull request Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-chore Miscellaneous improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants