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

New deployment result types #423

Merged
merged 12 commits into from
Aug 29, 2023
Merged

New deployment result types #423

merged 12 commits into from
Aug 29, 2023

Conversation

alcuadrado
Copy link
Member

No description provided.

deploymentParameters: DeploymentParameters,
accounts: string[],
defaultSender: string
): Promise<DeploymentResult> {
): Promise<DeploymentResult<ContractNameT, IgnitionModuleResultsT>> {
await validateStageTwo(
Copy link
Member Author

Choose a reason for hiding this comment

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

This is something you can take over if you want @kanej.

Here the validate functions are throwing an error that doesn't give you access to the futureId that caused the error.

Ideally, the validation function would return all the errors. A quick fix is changing the error they throw so that they include the futureId. We can do the proper fix later.

Copy link
Member

Choose a reason for hiding this comment

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

I am tackling this now.

I am going to alter the validate stage two to return [futureId, validationErrorMessage] pairs (or some such) that can then be returned as a result if there are any validation failures.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, I backed out of the larger change and did as you suggested.

Stage two now returns either a ValidationErrorDeploymentResult or null, and deploy returns the error result if detected.

Copy link
Member

Choose a reason for hiding this comment

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

I have added an issue to expand out the number of validation messages returned: #424

if (result.type === DeploymentResultType.EXECUTION_ERROR) {
console.log(result);
throw new IgnitionError(
`The deployment wan't succesful: TODO: create a good error message`
Copy link
Member Author

Choose a reason for hiding this comment

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

This is also something else that you can make progress on, @kanej

Copy link
Member

Choose a reason for hiding this comment

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

What do you think of only showing the failed and timed out within the Ignition Error:

The deployment wan't succesful, there were timeouts and errors:

Timed out
  * SomeContract

Errors
  * MyContract: reverted with reason z
  * AnotherContract: reverted with reason y

verbose: logs,
});

// TODO: print a better result
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this just to make it compile. We should reintroduce better messages.

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 there is a rugged simplicity to stringified result.

Copy link
Member

Choose a reason for hiding this comment

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

I have added a basic console.log print out of results leveraging the same helper message as is used in the ignition helper exception code.

@@ -14,6 +10,15 @@ import { IgnitionHelper } from "../src/ignition-helper";
import { clearPendingTransactionsFromMemoryPool } from "./execution/helpers";
import { waitForPendingTxs } from "./helpers";

declare module "mocha" {
Copy link
Member Author

Choose a reason for hiding this comment

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

@kanej I tried to type these helpers to be able to debug some things, but I don't think the other deploy helper can be typed.

To be honest, I find creating this kind of helpers really hard to reason, especially since they have type any unless you type them.

Copy link
Member

Choose a reason for hiding this comment

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

I have no problem pulling them out as just standard helper functions. Is that your preference?

Copy link
Member

Choose a reason for hiding this comment

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

I have pushed a temporary typing. I split out the two deploys (file based and ephemeral), one is now runControlledDeploy and is mainly used in the execution that is currently skipped.

I have no problem pulling these helpers out/replacing the tests with a different structure. We talked about moving the execution tests currently skipped into core, which may simplify the integration tests enough this issue goes away.

@alcuadrado
Copy link
Member Author

I accidentally broke a plugin test. That's confusing me a ton. I'll debug it early tomorrow.

@alcuadrado
Copy link
Member Author

alcuadrado commented Aug 29, 2023

Also, I think this works nicely with TypeChain, but I still need to test it.

kanej added 2 commits August 29, 2023 11:20
The stage two validation now returns either a validation error result or
null.

Internally the validtion continues to throw validation errors, so only
one error will be reported at a time. However the types now match the
return result so we can improve this in the future.
// however, by taking only the top level submodules of the current depth and recursively
// validating each of those, we achieve the same effect.
const submodules = module.submodules;
for (const submodule of submodules) {
Copy link
Member

Choose a reason for hiding this comment

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

Get futures from module, gets the futures of all submodules as well recursively. Have I missed a case that submodule recursion gets us here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds right! We should have a small test for this though

Copy link
Member

Choose a reason for hiding this comment

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

Whoever does the validation multi-result work can add tests around this as well.

Submodule: {
depositValue: BigInt(this.hre.ethers.parseEther("1")),
parameters: {
Submodule: {
Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

kanej and others added 5 commits August 29, 2023 14:26
Adds a basic exception message from the Ignition helper for error
deployment results.

Adds a few basic tests to let us iterate on the messages.
Leverage the result to error message function and a new display success
message function to show the deployment result at the command line.
@alcuadrado alcuadrado changed the title [WIP] New deployment result types New deployment result types Aug 29, 2023
@alcuadrado alcuadrado merged commit 08a20ff into development Aug 29, 2023
6 checks passed
@alcuadrado alcuadrado deleted the return-types branch August 29, 2023 21:52
@kanej kanej linked an issue Aug 30, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Ensure deployParameters are typed cleanly in hardhat-ignition
2 participants