Skip to content

Commit 63c7723

Browse files
authored
Merge pull request #7006 from NomicFoundation/ignition/bytecode-reconciliation
skip bytecode reconciliation for successfully deployed contract futures
2 parents 269b2f2 + dbd9368 commit 63c7723

File tree

6 files changed

+174
-4
lines changed

6 files changed

+174
-4
lines changed

.changeset/fluffy-kangaroos-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nomicfoundation/ignition-core": patch
3+
---
4+
5+
Allow Ignition reconciliation of changed bytecode when the contract has been successfully deployed ([#7006](https://github.com/NomicFoundation/hardhat/pull/7006))

v-next/hardhat-ignition-core/src/internal/reconciliation/helpers/reconcile-artifacts.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ import type {
66
NamedArtifactContractDeploymentFuture,
77
NamedArtifactLibraryDeploymentFuture,
88
} from "../../../types/module.js";
9-
import type {
10-
ContractAtExecutionState,
11-
DeploymentExecutionState,
12-
} from "../../execution/types/execution-state.js";
139
import type {
1410
ReconciliationContext,
1511
ReconciliationFutureResultFailure,
1612
} from "../types.js";
1713

14+
import {
15+
ExecutionStatus,
16+
type ContractAtExecutionState,
17+
type DeploymentExecutionState,
18+
} from "../../execution/types/execution-state.js";
1819
import { fail, getBytecodeWithoutMetadata } from "../utils.js";
1920

2021
export async function reconcileArtifacts(
@@ -28,6 +29,10 @@ export async function reconcileArtifacts(
2829
exState: DeploymentExecutionState | ContractAtExecutionState,
2930
context: ReconciliationContext,
3031
): Promise<ReconciliationFutureResultFailure | undefined> {
32+
if (exState.status === ExecutionStatus.SUCCESS) {
33+
return;
34+
}
35+
3136
const moduleArtifact =
3237
"artifact" in future
3338
? future.artifact

v-next/hardhat-ignition-core/test/reconciliation/futures/reconcileArtifactContractDeployment.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { FutureType } from "../../../src/types/module.js";
1111
import { exampleAccounts } from "../../helpers.js";
1212
import {
13+
ArtifactMapDeploymentLoader,
1314
assertSuccessReconciliation,
1415
createDeploymentState,
1516
mockArtifact,
@@ -360,4 +361,43 @@ describe("Reconciliation - artifact contract", () => {
360361
},
361362
]);
362363
});
364+
365+
it("should find changes to a future's artifact bytecode reconciliable if the contract was successfully deployed", async () => {
366+
const moduleDefinition = buildModule("Module", (m) => {
367+
const contract1 = m.contract("Contract1", mockArtifact, [], {
368+
id: "Example",
369+
});
370+
371+
return { contract1 };
372+
});
373+
374+
const reconiliationResult = await reconcile(
375+
moduleDefinition,
376+
createDeploymentState({
377+
...exampleDeploymentState,
378+
id: "Module#Example",
379+
status: ExecutionStatus.SUCCESS,
380+
contractName: "Contract1",
381+
futureType: FutureType.CONTRACT_DEPLOYMENT,
382+
result: {
383+
type: ExecutionResultType.SUCCESS,
384+
address: exampleAddress,
385+
},
386+
}),
387+
new ArtifactMapDeploymentLoader({
388+
"./artifact.json": {
389+
contractName: "Contract1",
390+
bytecode: "0x1234",
391+
abi: [],
392+
deployedBytecode: "0x5678",
393+
_format: "hh3-artifact-1",
394+
sourceName: "Contract1.sol",
395+
linkReferences: {},
396+
deployedLinkReferences: {},
397+
},
398+
}),
399+
);
400+
401+
assert.deepEqual(reconiliationResult.reconciliationFailures, []);
402+
});
363403
});

v-next/hardhat-ignition-core/test/reconciliation/futures/reconcileArtifactLibraryDeployment.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { FutureType } from "../../../src/types/module.js";
1111
import { exampleAccounts } from "../../helpers.js";
1212
import {
13+
ArtifactMapDeploymentLoader,
1314
assertSuccessReconciliation,
1415
createDeploymentState,
1516
mockArtifact,
@@ -247,4 +248,43 @@ describe("Reconciliation - artifact library", () => {
247248
},
248249
]);
249250
});
251+
252+
it("should find changes to a future's artifact bytecode reconciliable if the contract was successfully deployed", async () => {
253+
const moduleDefinition = buildModule("Module", (m) => {
254+
const contract1 = m.library("Contract1", mockArtifact, {
255+
id: "Example",
256+
});
257+
258+
return { contract1 };
259+
});
260+
261+
const reconiliationResult = await reconcile(
262+
moduleDefinition,
263+
createDeploymentState({
264+
...exampleDeploymentState,
265+
id: "Module#Example",
266+
status: ExecutionStatus.SUCCESS,
267+
contractName: "Contract1",
268+
futureType: FutureType.LIBRARY_DEPLOYMENT,
269+
result: {
270+
type: ExecutionResultType.SUCCESS,
271+
address: exampleAddress,
272+
},
273+
}),
274+
new ArtifactMapDeploymentLoader({
275+
"./artifact.json": {
276+
contractName: "Contract1",
277+
bytecode: "0x1234",
278+
abi: [],
279+
deployedBytecode: "0x5678",
280+
_format: "hh3-artifact-1",
281+
sourceName: "Contract1.sol",
282+
linkReferences: {},
283+
deployedLinkReferences: {},
284+
},
285+
}),
286+
);
287+
288+
assert.deepEqual(reconiliationResult.reconciliationFailures, []);
289+
});
250290
});

v-next/hardhat-ignition-core/test/reconciliation/futures/reconcileNamedContractDeployment.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { FutureType } from "../../../src/types/module.js";
1111
import { exampleAccounts } from "../../helpers.js";
1212
import {
13+
ArtifactMapDeploymentLoader,
1314
assertSuccessReconciliation,
1415
createDeploymentState,
1516
oneAddress,
@@ -393,4 +394,43 @@ describe("Reconciliation - named contract", () => {
393394
},
394395
]);
395396
});
397+
398+
it("should find changes to a future's artifact bytecode reconciliable if the contract was successfully deployed", async () => {
399+
const moduleDefinition = buildModule("Module", (m) => {
400+
const contract1 = m.contract("Contract1", [], {
401+
id: "Example",
402+
});
403+
404+
return { contract1 };
405+
});
406+
407+
const reconiliationResult = await reconcile(
408+
moduleDefinition,
409+
createDeploymentState({
410+
...exampleDeploymentState,
411+
id: "Module#Example",
412+
status: ExecutionStatus.SUCCESS,
413+
contractName: "Contract1",
414+
futureType: FutureType.NAMED_ARTIFACT_CONTRACT_DEPLOYMENT,
415+
result: {
416+
type: ExecutionResultType.SUCCESS,
417+
address: exampleAddress,
418+
},
419+
}),
420+
new ArtifactMapDeploymentLoader({
421+
"./artifact.json": {
422+
contractName: "Contract1",
423+
bytecode: "0x1234",
424+
abi: [],
425+
deployedBytecode: "0x5678",
426+
_format: "hh3-artifact-1",
427+
sourceName: "Contract1.sol",
428+
linkReferences: {},
429+
deployedLinkReferences: {},
430+
},
431+
}),
432+
);
433+
434+
assert.deepEqual(reconiliationResult.reconciliationFailures, []);
435+
});
396436
});

v-next/hardhat-ignition-core/test/reconciliation/futures/reconcileNamedLibraryDeployment.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { FutureType } from "../../../src/types/module.js";
1111
import { exampleAccounts } from "../../helpers.js";
1212
import {
13+
ArtifactMapDeploymentLoader,
1314
assertSuccessReconciliation,
1415
createDeploymentState,
1516
oneAddress,
@@ -235,4 +236,43 @@ describe("Reconciliation - named library", () => {
235236
},
236237
]);
237238
});
239+
240+
it("should find changes to a future's artifact bytecode reconciliable if the contract was successfully deployed", async () => {
241+
const moduleDefinition = buildModule("Module", (m) => {
242+
const contract1 = m.library("Contract1", {
243+
id: "Example",
244+
});
245+
246+
return { contract1 };
247+
});
248+
249+
const reconiliationResult = await reconcile(
250+
moduleDefinition,
251+
createDeploymentState({
252+
...exampleDeploymentState,
253+
id: "Module#Example",
254+
status: ExecutionStatus.SUCCESS,
255+
contractName: "Contract1",
256+
futureType: FutureType.NAMED_ARTIFACT_LIBRARY_DEPLOYMENT,
257+
result: {
258+
type: ExecutionResultType.SUCCESS,
259+
address: exampleAddress,
260+
},
261+
}),
262+
new ArtifactMapDeploymentLoader({
263+
"./artifact.json": {
264+
contractName: "Contract1",
265+
bytecode: "0x1234",
266+
abi: [],
267+
deployedBytecode: "0x5678",
268+
_format: "hh3-artifact-1",
269+
sourceName: "Contract1.sol",
270+
linkReferences: {},
271+
deployedLinkReferences: {},
272+
},
273+
}),
274+
);
275+
276+
assert.deepEqual(reconiliationResult.reconciliationFailures, []);
277+
});
238278
});

0 commit comments

Comments
 (0)