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(contracts): numerous improvements to deploy scripts (+). #1108

Merged
merged 9 commits into from
Aug 15, 2024

Conversation

raulk
Copy link
Contributor

@raulk raulk commented Aug 15, 2024

Tolerating null rounds

Filecoin chains will occasionally produce null rounds. Ethers' transaction monitoring cannot handle skipped block heights. It will try to request intermediate blocks that don't exist. Lotus returns a JSON-RPC error when calling eth_getBlock* with a height corresponding to a null round. Ethers reacts with an exception, and this aborts the deployment process.

To overcome this situation, we inject a custom provider that catches this specific error, and returns an artificial empty block instead of an error. With this, hardhat-ethers can now cope with null rounds.

Major refactors and cleanups for easier maintenance

  • Adopted the hardhat-deploy plugin, which keeps track of deployments for us.
  • Removed hand-rolled deployment tracking and codegen. We no longer codegen scripts; any script can resolve any contract now.
  • All the mess under ops/deploy*.sh is now gone.
  • Refactored all Hardhat tasks, simplified aggressively, deduplicated code, deleted dead code, and removed tons of cruft.
  • Adopted Typescript typing.
  • Upgrade scripts are also massively overhauled for simplicity.
  • LoC delta: around -1000.

TODO

  • Update docs.

Next steps

  • Move to Hardhat Ignition. We should be able to get transaction deployment parallelism, but it requires bumping Hardhat and Ethers versions, which should be much simpler to do now than it was before.

Tolerating null rounds.

Filecoin chains will occasionally produce null rounds. Ethers'
transaction monitoring cannot handle skipped block heights. It
will try to request intermediate blocks that don't exist. Lotus
returns a JSON-RPC error when calling eth_getBlock* with a height
corresponding to a null round. Ethers reacts with an exception,
and this aborts the deployment process.

To overcome this situation, we inject a custom provider that
catches this specific error, and returns an artificial empty block
instead of an error. With this, hardhat-ethers can now cope with
null rounds.

Major refactors and cleanups.

- Adopted the hardhat-deploy plugin, which keeps track of deployments
  for us.
- Removed hand-rolled deployment tracking and codegen. We no longer
  codegen scripts; any script can resolve any contract now.
- All the mess under ops/deploy*.sh is now gone.
- Refactored all Hardhat tasks, simplified aggressively, deduplicated
  code, deleted dead code, and removed tons of cruft.
- Adopted Typescript typing.
- Upgrade scripts are also massively overhauled for simplicity.
@raulk raulk requested a review from a team as a code owner August 15, 2024 08:57
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cryptoAtwill @gvelez17 @avichalp here's the extension that injects a custom provider to deal with null rounds through the RPC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xBalbinus @rk-rishikesh I'll submit this to the Hardhat FEVM kit so Filecoin devs can also benefit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The diamond stuff is so simple... it's insane how overcomplicated and dirty it was before.

activeValidatorsLimit: 100,
majorityPercentage: 66,
networkName: {
root: undefined, // Will be set later.
Copy link
Contributor

Choose a reason for hiding this comment

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

As in the program will auto set it for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's done below.

(selector) => !current[selector],
)

const addressToSelectors = _.groupBy(selectorsToAdd, (selector) => needed[selector])
Copy link
Contributor

Choose a reason for hiding this comment

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

curious, why not use import {groupBy} from "lodash" (or is it supported) but use _?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just a preference. I tend to dislike importing external functions in ways that lose the namespace at the usage sites.

@raulk raulk force-pushed the raulk/simplify-deploy branch from 56401a5 to 4a58a4d Compare August 15, 2024 14:43
@raulk raulk merged commit 4777940 into main Aug 15, 2024
23 checks passed
@raulk raulk deleted the raulk/simplify-deploy branch August 15, 2024 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants