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

Show missing futures warnings in execution UI #474

Merged
merged 3 commits into from
Sep 19, 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
15 changes: 14 additions & 1 deletion packages/core/src/internal/deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ export class Deployer {
}

if (reconciliationResult.missingExecutedFutures.length > 0) {
// TODO: indicate to UI that warnings should be shown
this._emitReconciliationWarningsEvent(
reconciliationResult.missingExecutedFutures
);
}

const batches = Batcher.batch(ignitionModule, deploymentState);
Expand Down Expand Up @@ -275,6 +277,17 @@ export class Deployer {
});
}

private _emitReconciliationWarningsEvent(warnings: string[]): void {
if (this._executionEventListener === undefined) {
return;
}

this._executionEventListener.reconciliationWarnings({
type: ExecutionEventType.RECONCILIATION_WARNINGS,
warnings,
});
}

private _emitDeploymentBatchEvent(batches: string[][]): void {
if (this._executionEventListener === undefined) {
return;
Expand Down
13 changes: 13 additions & 0 deletions packages/core/src/types/execution-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type ExecutionEvent =
| OnchainInteractionTimeoutEvent
| BatchInitializeEvent
| DeploymentStartEvent
| ReconciliationWarningsEvent
| BeginNextBatchEvent
| SetModuleIdEvent;

Expand Down Expand Up @@ -61,6 +62,7 @@ export enum ExecutionEventType {
ONCHAIN_INTERACTION_TIMEOUT = "ONCHAIN_INTERACTION_TIMEOUT",
BATCH_INITIALIZE = "BATCH_INITIALIZE",
DEPLOYMENT_START = "DEPLOYMENT_START",
RECONCILIATION_WARNINGS = "RECONCILIATION_WARNINGS",
BEGIN_NEXT_BATCH = "BEGIN_NEXT_BATCH",
DEPLOYMENT_COMPLETE = "DEPLOYMENT_COMPLETE",
SET_MODULE_ID = "SET_MODULE_ID",
Expand Down Expand Up @@ -116,6 +118,16 @@ export interface DeploymentCompleteEvent {
result: DeploymentResult<string, IgnitionModuleResult<string>>;
}

/**
* An event indicating that a deployment has reconciliation warnings.
*
* @beta
*/
export interface ReconciliationWarningsEvent {
type: ExecutionEventType.RECONCILIATION_WARNINGS;
warnings: string[];
}

/**
* An event indicating a future that deploys a contract
* or library has started execution.
Expand Down Expand Up @@ -434,6 +446,7 @@ export interface ExecutionEventTypeMap {
[ExecutionEventType.DEPLOYMENT_START]: DeploymentStartEvent;
[ExecutionEventType.BEGIN_NEXT_BATCH]: BeginNextBatchEvent;
[ExecutionEventType.DEPLOYMENT_COMPLETE]: DeploymentCompleteEvent;
[ExecutionEventType.RECONCILIATION_WARNINGS]: ReconciliationWarningsEvent;
[ExecutionEventType.SET_MODULE_ID]: SetModuleIdEvent;
}

Expand Down
9 changes: 9 additions & 0 deletions packages/hardhat-plugin/src/ui/UiEventHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
OnchainInteractionReplacedByUserEvent,
OnchainInteractionTimeoutEvent,
ReadEventArgExecutionStateInitializeEvent,
ReconciliationWarningsEvent,
RunStartEvent,
SendDataExecutionStateCompleteEvent,
SendDataExecutionStateInitializeEvent,
Expand Down Expand Up @@ -68,6 +69,7 @@ export class UiEventHandler implements ExecutionEventListener {
moduleName: null,
batches: [],
result: null,
warnings: [],
};

constructor(private _deploymentParams: DeploymentParameters = {}) {}
Expand Down Expand Up @@ -333,6 +335,13 @@ export class UiEventHandler implements ExecutionEventListener {
};
}

public reconciliationWarnings(event: ReconciliationWarningsEvent): void {
this.state = {
...this.state,
warnings: [...this.state.warnings, ...event.warnings],
};
}

public setModuleId(event: SetModuleIdEvent): void {
this.state = {
...this.state,
Expand Down
9 changes: 9 additions & 0 deletions packages/hardhat-plugin/src/ui/VerboseEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
OnchainInteractionReplacedByUserEvent,
OnchainInteractionTimeoutEvent,
ReadEventArgExecutionStateInitializeEvent,
ReconciliationWarningsEvent,
RunStartEvent,
SendDataExecutionStateCompleteEvent,
SendDataExecutionStateInitializeEvent,
Expand Down Expand Up @@ -251,6 +252,14 @@ export class VerboseEventHandler implements ExecutionEventListener {
console.log(`Deployment complete`);
}

public reconciliationWarnings(event: ReconciliationWarningsEvent): void {
console.log(
`Deployment produced reconciliation warnings:\n${event.warnings.join(
" -"
)}`
);
}

public setModuleId(event: SetModuleIdEvent): void {
console.log(`Starting validation for module: ${event.moduleName}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { UiState } from "../../types";
import { BatchExecution } from "./BatchExecution";
import { FinalStatus } from "./FinalStatus";
import { SummarySection } from "./SummarySection";
import { Warnings } from "./Warnings";
import { viewEverythingExecutedAlready } from "./views";

export const ExecutionPanel = ({
Expand All @@ -19,6 +20,7 @@ export const ExecutionPanel = ({
if (viewEverythingExecutedAlready(state)) {
return (
<Box flexDirection="column">
{state.warnings.length > 0 && <Warnings state={state} />}
<FinalStatus state={state} />
</Box>
);
Expand All @@ -27,6 +29,7 @@ export const ExecutionPanel = ({
return (
<Box flexDirection="column">
<SummarySection state={state} deployParams={deployParams} />
{state.warnings.length > 0 && <Warnings state={state} />}
<BatchExecution state={state} />
<FinalStatus state={state} />
</Box>
Expand Down
23 changes: 23 additions & 0 deletions packages/hardhat-plugin/src/ui/components/execution/Warnings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Box, Newline, Text } from "ink";

import { UiState } from "../../types";

export const Warnings = ({ state: { warnings } }: { state: UiState }) => {
return (
<>
<Box
paddingBottom={1}
borderStyle="single"
flexDirection="column"
borderColor="yellowBright"
>
<Text bold>
Warning, deployment missing previously executed futures:
</Text>
<Newline />

{...warnings.map((warning) => <Text> - {warning}</Text>)}
</Box>
</>
);
};
1 change: 1 addition & 0 deletions packages/hardhat-plugin/src/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface UiState {
moduleName: string | null;
batches: UiBatches;
result: DeploymentResult<string, IgnitionModuleResult<string>> | null;
warnings: string[];
}

export interface AddressMap {
Expand Down
Loading