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: rename plan to visualize #471

Merged
merged 5 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ See our [Getting started guide](./docs/getting-started-guide.md) for a worked ex
- [Switching based on the _Network Chain ID_](./docs/creating-modules-for-deployment.md#switching-based-on-the-network-chain-id)
- [Using Ignition in _Hardhat_ tests](./docs/using-ignition-in-hardhat-tests.md)
- [Running a deployment](./docs/running-a-deployment.md)
- [Visualizing your deployment with the `plan` task](./docs/running-a-deployment.md#visualizing-your-deployment-with-the-plan-task)
- [Visualizing your deployment with the `visualize` task](./docs/running-a-deployment.md#visualizing-your-deployment-with-the-visualize-task)
- [Executing the deployment](./docs/running-a-deployment.md#executing-the-deployment)

### Examples
Expand Down
File renamed without changes
File renamed without changes
18 changes: 9 additions & 9 deletions docs/running-a-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@

### Table of Contents

- [Visualizing your deployment with the `plan` task](./running-a-deployment.md#visualizing-your-deployment-with-the-plan-task)
- [Visualizing your deployment with the `visualize` task](./running-a-deployment.md#visualizing-your-deployment-with-the-visualize-task)
- [Executing the deployment](./running-a-deployment.md#executing-the-deployment)
- [Configuration options](./running-a-deployment.md#configuration-options)
<!-- - [Resuming a failed or onhold deployment](./running-a-deployment.md#visualizing-your-deployment-with-the-plan-task) -->
<!-- - [Resuming a failed or onhold deployment](./running-a-deployment.md#visualizing-your-deployment-with-the-visualize-task) -->

---

Once you have built and tested your deployment module, it is time to deploy it! Start by making sure you understand exactly what will be executed on chain.

## Visualizing your deployment with the `plan` task
## Visualizing your deployment with the `visualize` task

**Ignition** adds a `plan` task to the cli, that will generate a HTML report showing a _dry run_ of the deployment - the contract deploys and contract calls.
**Ignition** adds a `visualize` task to the cli, that will generate a HTML report showing a _dry run_ of the deployment - the contract deploys and contract calls.

The `plan` task takes one argument, the module to visualize. For example, using the `ENS.js` module from our [ENS example project](../examples/ens/README.md):
The `visualize` task takes one argument, the module to visualize. For example, using the `ENS.js` module from our [ENS example project](../examples/ens/README.md):

```bash
npx hardhat plan ENS
npx hardhat visualize ENS
```

Running `plan` will generate the report based on the given module (in this case `ENS.js`), it will then open the report in your system's default browser:
Running `visualize` will generate the report based on the given module (in this case `ENS.js`), it will then open the report in your system's default browser:

![Main plan output](images/plan-1.png)
![Main visualize output](images/visualize-1.png)

The report summarises the contract that will be deployed and the contract calls that will be made.

It shows the dependency graph as it will be executed by Ignition (where a dependency will not be run until all its dependents have successfully completed).

If something in your deployment isn't behaving the way you expected, the `plan` task can be an extremely helpful tool for debugging and verifying that your and **Ignition**'s understanding of the deployment are the same.
If something in your deployment isn't behaving the way you expected, the `visualize` task can be an extremely helpful tool for debugging and verifying that your and **Ignition**'s understanding of the deployment are the same.

## Executing the deployment

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ import {
SerializedArtifactLibraryDeploymentFuture,
SerializedBigInt,
SerializedFuture,
SerializedIgnitionModule,
SerializedLibraries,
SerializedModuleDescription,
SerializedModuleParameterRuntimeValue,
SerializedNamedContractAtFuture,
SerializedNamedContractCallFuture,
Expand All @@ -60,24 +62,21 @@ import {
SerializedNamedStaticCallFuture,
SerializedReadEventArgumentFuture,
SerializedSendDataFuture,
SerializedStoredDeployment,
SerializedStoredModule,
StoredDeployment,
} from "./types/serialized-deployment";
} from "./types/serialization";

interface SerializeContext {
argReplacer: (arg: ArgumentType) => SerializedArgumentType;
}

/**
* Serialize a deployment.
* Serialize an Ignition module.
*
* @beta
*/
export class StoredDeploymentSerializer {
export class IgnitionModuleSerializer {
public static serialize(
deployment: StoredDeployment
): SerializedStoredDeployment {
ignitionModule: IgnitionModule<string, string, IgnitionModuleResult<string>>
): SerializedIgnitionModule {
const argReplacer = (arg: ArgumentType) =>
replaceWithinArg<SerializedArgumentType>(arg, {
accountRuntimeValue: this._serializeAccountRuntimeValue,
Expand All @@ -87,13 +86,10 @@ export class StoredDeploymentSerializer {
future: this._convertFutureToFutureToken,
});

const allModules = this._getModulesAndSubmoduleFor(deployment.module);
const allModules = this._getModulesAndSubmoduleFor(ignitionModule);

return {
details: {
...deployment.details,
},
startModule: deployment.module.id,
startModule: ignitionModule.id,
modules: Object.fromEntries(
allModules.map((m) => [m.id, this._serializeModule(m, { argReplacer })])
),
Expand All @@ -103,7 +99,7 @@ export class StoredDeploymentSerializer {
private static _serializeModule(
userModule: IgnitionModule<string, string, IgnitionModuleResult<string>>,
context: SerializeContext
): SerializedStoredModule {
): SerializedModuleDescription {
return {
id: userModule.id,
futures: Array.from(userModule.futures).map((future) =>
Expand Down Expand Up @@ -399,16 +395,18 @@ export class StoredDeploymentSerializer {
}

/**
* Deserialize a deployment that was previously serialized using StoredDeploymentSerialized.
* Deserialize an `IgnitionModule` that was previously serialized using
* IgnitionModuleSerializer.
*
* @beta
*/
export class StoredDeploymentDeserializer {
export class IgnitionModuleDeserializer {
public static deserialize(
serializedDeployment: SerializedStoredDeployment
): StoredDeployment {
const sortedModules =
this._getSerializedModulesInReverseTopologicalOrder(serializedDeployment);
serializedIgnitionModule: SerializedIgnitionModule
): IgnitionModule<string, string, IgnitionModuleResult<string>> {
const sortedModules = this._getSerializedModulesInReverseTopologicalOrder(
serializedIgnitionModule
);

const modulesLookup: Map<string, IgnitionModuleImplementation> = new Map();
for (const serializedModule of sortedModules) {
Expand All @@ -421,8 +419,9 @@ export class StoredDeploymentDeserializer {
}
}

const sortedFutures =
this._getSerializedFuturesInReverseTopologicalOrder(serializedDeployment);
const sortedFutures = this._getSerializedFuturesInReverseTopologicalOrder(
serializedIgnitionModule
);

const futuresLookup: Map<string, Future> = new Map();
const contractFuturesLookup: Map<
Expand Down Expand Up @@ -458,7 +457,7 @@ export class StoredDeploymentDeserializer {
}

for (const serializedModule of Object.values(
serializedDeployment.modules
serializedIgnitionModule.modules
)) {
const mod = this._lookup(modulesLookup, serializedModule.id);

Expand All @@ -477,26 +476,21 @@ export class StoredDeploymentDeserializer {
}
}

return {
details: {
...serializedDeployment.details,
},
module: this._lookup(modulesLookup, serializedDeployment.startModule),
};
return this._lookup(modulesLookup, serializedIgnitionModule.startModule);
}

private static _getSerializedModulesInReverseTopologicalOrder(
serializedDeployment: SerializedStoredDeployment
): SerializedStoredModule[] {
const graph: Graph<SerializedStoredModule> = new Map();
serializedIgnitionModule: SerializedIgnitionModule
): SerializedModuleDescription[] {
const graph: Graph<SerializedModuleDescription> = new Map();

for (const mod of Object.values(serializedDeployment.modules)) {
for (const mod of Object.values(serializedIgnitionModule.modules)) {
graph.set(mod, new Set());
}

for (const mod of Object.values(serializedDeployment.modules)) {
for (const mod of Object.values(serializedIgnitionModule.modules)) {
for (const submodToken of mod.submodules) {
const submod = serializedDeployment.modules[submodToken.moduleId];
const submod = serializedIgnitionModule.modules[submodToken.moduleId];
graph.get(submod)!.add(mod);
}
}
Expand All @@ -505,9 +499,9 @@ export class StoredDeploymentDeserializer {
}

private static _getSerializedFuturesInReverseTopologicalOrder(
serializedDeployment: SerializedStoredDeployment
serializedIgnitionModule: SerializedIgnitionModule
): SerializedFuture[] {
const serializedFutures = this._getAllFuturesFor(serializedDeployment);
const serializedFutures = this._getAllFuturesFor(serializedIgnitionModule);
const serializedFuturesMap = Object.fromEntries(
serializedFutures.map((f) => [f.id, f])
);
Expand Down Expand Up @@ -612,7 +606,7 @@ export class StoredDeploymentDeserializer {
}

private static _getAllFuturesFor(
deployment: SerializedStoredDeployment
deployment: SerializedIgnitionModule
): SerializedFuture[] {
return Object.values(deployment.modules).flatMap((m) =>
Object.values(m.futures)
Expand Down
7 changes: 3 additions & 4 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
export * from "./errors";
export { buildModule } from "./build-module";
export { deploy } from "./deploy";
export * from "./errors";
export { IgnitionModuleSerializer } from "./ignition-module-serializer";
export { formatSolidityParameter } from "./internal/formatters";
export { plan } from "./plan";
export { StoredDeploymentSerializer } from "./stored-deployment-serializer";
export * from "./type-guards";
export * from "./types/artifact";
export * from "./types/deploy";
export * from "./types/execution-events";
export * from "./types/module";
export * from "./types/module-builder";
export * from "./types/provider";
export * from "./types/serialized-deployment";
export * from "./types/serialization";
export { wipe } from "./wipe";
24 changes: 0 additions & 24 deletions packages/core/src/plan.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Artifact } from "./artifact";
import { FutureType, IgnitionModule, IgnitionModuleResult } from "./module";
import { FutureType } from "./module";

/**
* A serialized bigint.
Expand Down Expand Up @@ -238,71 +238,33 @@ export interface SerializedModuleParameterRuntimeValue {
defaultValue: string | undefined;
}

/**
* The details of a deployment that will be used in the UI.
*
* @beta
*/
export interface StoredDeployment {
details: {
networkName: string;
chainId: number;
};
module: IgnitionModule<string, string, IgnitionModuleResult<string>>;
}

// Serialized Deployments

/**
* The serialized version of a complete deployment, combining the
* chain details with the module to be deployed.
* The serialized version of an Ignition module and its submodules.
*
* @beta
*/
export interface SerializedStoredDeployment {
details: {
networkName: string;
chainId: number;
};
export interface SerializedIgnitionModule {
startModule: string;
modules: {
[key: string]: SerializedStoredModule;
[key: string]: SerializedModuleDescription;
};
}

/**
* The serialized version of an Ignition module.
* A subpart of the `SerializedIgnitionModule` that describes one
* module/submodule and its relations to futures and other submodule.
*
* @beta
*/
export interface SerializedStoredModule {
export interface SerializedModuleDescription {
id: string;
submodules: ModuleToken[];
futures: SerializedStoredFutures;
results: SerializedStoredResults;
futures: SerializedFuture[];
results: Array<[name: string, token: FutureToken]>;
}

/**
* Serialized versions of a modules used submodules.
*
* @beta
*/
export type SerializedStoredSubmodules = SerializedStoredModule[];

/**
* The serialized futures that are executed in deploying a module.
*
* @beta
*/
export type SerializedStoredFutures = SerializedFuture[];

/**
* The serialized results of a module.
*
* @beta
*/
export type SerializedStoredResults = Array<[name: string, token: FutureToken]>;

/**
* The serialized libraries, where each library
* has been replaced by a token.
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/ui-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export {
StoredDeploymentDeserializer,
StoredDeploymentSerializer,
} from "./stored-deployment-serializer";
IgnitionModuleDeserializer,
IgnitionModuleSerializer,
} from "./ignition-module-serializer";
export { formatSolidityParameter } from "./internal/formatters";
export * from "./type-guards";
export * from "./types/module";
export * from "./types/serialized-deployment";
export { formatSolidityParameter } from "./internal/formatters";
export * from "./types/serialization";
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { assert } from "chai";

import { useHardhatProject } from "../../../helpers/hardhat-projects";

describe("chainId reconciliation", () => {
describe("chainId reconciliation", function () {
this.timeout(60000);

useHardhatProject("default-with-new-chain-id");

it("should halt when running a deployment on a different chain", async function () {
Expand Down
Loading
Loading