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

Bring back UI for execution #401

Merged
merged 29 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4321b68
restore old ui files
zoeyTM Aug 23, 2023
6863f45
add new types for execution UI
zoeyTM Aug 24, 2023
48a2637
add basic wiring up of UiEventEmitter
zoeyTM Aug 24, 2023
275db43
refactor UiEventListener
zoeyTM Aug 24, 2023
7343c32
rename UiEvent and derivatives to ExecutionEvent
zoeyTM Aug 24, 2023
b422de6
implement execution event result helpers and evm error helper
zoeyTM Aug 24, 2023
089b8fd
implement initial UiEventHandler for hardhat-plugin
zoeyTM Aug 24, 2023
f06f77b
updated some event types and implemented ui render logic
zoeyTM Aug 25, 2023
5ca1fa8
some initial react changes
zoeyTM Aug 25, 2023
3a587f9
add event and emitter to send batch info to the UI
zoeyTM Aug 25, 2023
fbe5f0c
update UiEventHandler with batch logic
zoeyTM Aug 25, 2023
ec18206
update react views for new API
zoeyTM Aug 26, 2023
cfc9989
fixed all build errors
zoeyTM Aug 26, 2023
5548119
implement remaining journal messages as events
zoeyTM Aug 28, 2023
af7b059
implement VerboseEventHelper to encompass previous "verbose mode" via…
zoeyTM Aug 28, 2023
4bd0e68
added events for beginning new deployments and beginning each new batch
zoeyTM Aug 29, 2023
a264ed1
Remove double .ts extension in a file
alcuadrado Aug 29, 2023
3f0e8f9
Remove ".js" extension from some imports
alcuadrado Aug 29, 2023
0e561b7
emit moduleName for UI
zoeyTM Aug 31, 2023
3ff57a6
fix: apply `.flat` rather than lodash flat
kanej Aug 31, 2023
a5bc920
Merge branch 'development' into feat/execution-ui
kanej Aug 31, 2023
e018f52
feat: show deployed addresses on rerun
kanej Aug 31, 2023
0c0ab65
chore: sketch out display of error results
kanej Aug 31, 2023
680ef1b
added display of validation errors
zoeyTM Sep 1, 2023
4c9ebc7
add display for reconciliation errors
zoeyTM Sep 1, 2023
7aefcd5
fix: moduleName in UI not displaying during early phase errors
zoeyTM Sep 1, 2023
0a3e89a
feat: cleanup execution spinner
kanej Sep 1, 2023
a20a35a
feat: support execution error result in ui
kanej Sep 1, 2023
9e067ba
feat: only display a batch if a future has started
kanej Sep 1, 2023
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
30 changes: 20 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@types/fs-extra": "^9.0.13",
"@types/mocha": "9.1.1",
"@types/ndjson": "2.0.1",
"@types/node": "12.20.25",
"@types/node": "^16.0.0",
"@typescript-eslint/eslint-plugin": "4.31.2",
"@typescript-eslint/parser": "4.31.2",
"chai": "^4.3.4",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from "./new-api/types/module";
export * from "./new-api/types/module-builder";
export * from "./new-api/types/provider";
export * from "./new-api/types/serialized-deployment";
export * from "./new-api/types/execution-events";
12 changes: 7 additions & 5 deletions packages/core/src/new-api/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
DeploymentParameters,
DeploymentResult,
} from "./types/deployer";
import { ExecutionEventListener } from "./types/execution-events";
import { IgnitionModule } from "./types/module";
import { EIP1193Provider } from "./types/provider";

Expand All @@ -30,21 +31,21 @@ export async function deploy({
config = {},
artifactResolver,
provider,
executionEventListener,
deploymentDir,
ignitionModule,
deploymentParameters,
accounts,
verbose,
defaultSender,
}: {
config?: Partial<DeployConfig>;
artifactResolver: ArtifactResolver;
provider: EIP1193Provider;
executionEventListener?: ExecutionEventListener;
deploymentDir?: string;
ignitionModule: IgnitionModule;
deploymentParameters: DeploymentParameters;
accounts: string[];
verbose: boolean;
defaultSender?: string;
}): Promise<DeploymentResult> {
await validateStageOne(ignitionModule, artifactResolver);
Expand All @@ -61,8 +62,8 @@ export async function deploy({

const deploymentLoader =
deploymentDir === undefined
? new EphemeralDeploymentLoader(artifactResolver, verbose)
: new FileDeploymentLoader(deploymentDir, verbose);
? new EphemeralDeploymentLoader(artifactResolver, executionEventListener)
: new FileDeploymentLoader(deploymentDir, executionEventListener);

const executionStrategy = new BasicExecutionStrategy((artifactId) =>
deploymentLoader.loadArtifact(artifactId)
Expand All @@ -85,7 +86,8 @@ export async function deploy({
executionStrategy,
jsonRpcClient,
artifactResolver,
deploymentLoader
deploymentLoader,
executionEventListener
);

return deployer.deploy(
Expand Down
29 changes: 28 additions & 1 deletion packages/core/src/new-api/internal/deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {
DeploymentResult,
DeploymentResultContracts,
} from "../types/deployer";
import {
ExecutionEventListener,
ExecutionEventType,
} from "../types/execution-events";

import { Batcher } from "./batcher";
import { DeploymentLoader } from "./deployment-loader/types";
Expand Down Expand Up @@ -44,7 +48,8 @@ export class Deployer {
private readonly _executionStrategy: ExecutionStrategy,
private readonly _jsonRpcClient: JsonRpcClient,
private readonly _artifactResolver: ArtifactResolver,
private readonly _deploymentLoader: DeploymentLoader
private readonly _deploymentLoader: DeploymentLoader,
private readonly _executionEventListener?: ExecutionEventListener
) {
assertIgnitionInvariant(
this._config.requiredConfirmations >= 1,
Expand Down Expand Up @@ -111,11 +116,14 @@ export class Deployer {

const batches = Batcher.batch(ignitionModule, deploymentState);

this._emitDeploymentBatchEvent(batches);

const executionEngine = new ExecutionEngine(
this._deploymentLoader,
this._artifactResolver,
this._executionStrategy,
this._jsonRpcClient,
this._executionEventListener,
this._config.requiredConfirmations,
this._config.timeBeforeBumpingFees,
this._config.maxFeeBumps,
Expand Down Expand Up @@ -180,6 +188,8 @@ export class Deployer {
const deploymentState = await loadDeploymentState(this._deploymentLoader);

if (deploymentState === undefined) {
this._emitDeploymentStartEvent();

return initializeDeploymentState(chainId, this._deploymentLoader);
}

Expand All @@ -190,4 +200,21 @@ export class Deployer {

return deploymentState;
}

private _emitDeploymentBatchEvent(batches: string[][]): void {
if (this._executionEventListener !== undefined) {
this._executionEventListener.BATCH_INITIALIZE({
type: ExecutionEventType.BATCH_INITIALIZE,
batches,
});
}
}

private _emitDeploymentStartEvent(): void {
if (this._executionEventListener !== undefined) {
this._executionEventListener.DEPLOYMENT_START({
type: ExecutionEventType.DEPLOYMENT_START,
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Artifact, ArtifactResolver, BuildInfo } from "../../types/artifact";
import { ExecutionEventListener } from "../../types/execution-events";
import { MemoryJournal } from "../journal/memory-journal";
import { Journal } from "../journal/types";
import { JournalMessage } from "../new-execution/types/messages";
Expand All @@ -23,9 +24,9 @@ export class EphemeralDeploymentLoader implements DeploymentLoader {

constructor(
private _artifactResolver: ArtifactResolver,
private _verbose: boolean
private _executionEventListener?: ExecutionEventListener
) {
this._journal = new MemoryJournal(this._verbose);
this._journal = new MemoryJournal(this._executionEventListener);
this._deployedAddresses = {};
this._savedArtifacts = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ensureDir, pathExists, readFile, writeFile } from "fs-extra";
import path from "path";

import { Artifact, BuildInfo } from "../../types/artifact";
import { ExecutionEventListener } from "../../types/execution-events";
import { FileJournal } from "../journal/file-journal";
import { Journal } from "../journal/types";
import { JournalMessage } from "../new-execution/types/messages";
Expand All @@ -22,7 +23,7 @@ export class FileDeploymentLoader implements DeploymentLoader {

constructor(
private readonly _deploymentDirPath: string,
private readonly _verbose: boolean
private readonly _executionEventListener?: ExecutionEventListener
) {
const artifactsDir = path.join(this._deploymentDirPath, "artifacts");
const buildInfoDir = path.join(this._deploymentDirPath, "build-info");
Expand All @@ -32,7 +33,7 @@ export class FileDeploymentLoader implements DeploymentLoader {
"deployed_addresses.json"
);

this._journal = new FileJournal(journalPath, this._verbose);
this._journal = new FileJournal(journalPath, this._executionEventListener);

this._paths = {
deploymentDir: this._deploymentDirPath,
Expand Down
12 changes: 8 additions & 4 deletions packages/core/src/new-api/internal/journal/file-journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import fs, { closeSync, constants, openSync, writeFileSync } from "fs";
import { parse } from "ndjson";

import { ExecutionEventListener } from "../../types/execution-events";
import { JournalMessage } from "../new-execution/types/messages";

import { Journal } from "./types";
import { deserializeReplacer } from "./utils/deserialize-replacer";
import { logJournalableMessage } from "./utils/log";
import { emitExecutionEvent } from "./utils/emitExecutionEvent";
import { serializeReplacer } from "./utils/serialize-replacer";

/**
Expand All @@ -15,7 +16,10 @@ import { serializeReplacer } from "./utils/serialize-replacer";
* @beta
*/
export class FileJournal implements Journal {
constructor(private _filePath: string, private _verbose: boolean = false) {}
constructor(
private _filePath: string,
private _executionEventListener?: ExecutionEventListener
) {}

public record(message: JournalMessage): void {
this._log(message);
Expand Down Expand Up @@ -60,8 +64,8 @@ export class FileJournal implements Journal {
}

private _log(message: JournalMessage): void {
if (this._verbose) {
return logJournalableMessage(message);
if (this._executionEventListener !== undefined) {
emitExecutionEvent(message, this._executionEventListener);
}
}
}
9 changes: 5 additions & 4 deletions packages/core/src/new-api/internal/journal/memory-journal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ExecutionEventListener } from "../../types/execution-events";
import { JournalMessage } from "../new-execution/types/messages";

import { Journal } from "./types";
import { logJournalableMessage } from "./utils/log";
import { emitExecutionEvent } from "./utils/emitExecutionEvent";

/**
* An in-memory journal.
Expand All @@ -11,7 +12,7 @@ import { logJournalableMessage } from "./utils/log";
export class MemoryJournal implements Journal {
private messages: JournalMessage[] = [];

constructor(private _verbose: boolean = false) {}
constructor(private _executionEventListener?: ExecutionEventListener) {}

public record(message: JournalMessage): void {
this._log(message);
Expand All @@ -26,8 +27,8 @@ export class MemoryJournal implements Journal {
}

private _log(message: JournalMessage): void {
if (this._verbose) {
return logJournalableMessage(message);
if (this._executionEventListener !== undefined) {
emitExecutionEvent(message, this._executionEventListener);
}
}
}
Loading
Loading