From a05ba8db387a6ab30e033b701cc740117fcc3814 Mon Sep 17 00:00:00 2001 From: Adam Spitz Date: Tue, 1 Sep 2026 09:57:08 -0400 Subject: [PATCH] Fix incremental deploy reusing one address for two contracts. After a local wipe, sequential CREATE still lands at the old Hardhat addresses. If localhost.env already mapped AlignmentAttestations to AccountAssertions, fingerprint reuse treated the latter as the former and attestAlignment reverted. Skip reuse when this run already claimed the address. --- hardhat/scripts/deploy-incremental.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hardhat/scripts/deploy-incremental.js b/hardhat/scripts/deploy-incremental.js index 18c267e7..993ef747 100644 --- a/hardhat/scripts/deploy-incremental.js +++ b/hardhat/scripts/deploy-incremental.js @@ -161,12 +161,18 @@ async function main() { // Reuse when the manifest fingerprint matches, or (adopt mode) whenever a live // on-chain address exists — pinning it at the current fingerprint so later runs // treat it as unchanged. - if (codePresent && (fingerprintMatch || adoptExisting)) { + const claimedBy = oldAddress && ethers.isAddress(oldAddress) + ? Object.entries(addresses).find(([, addr]) => ethers.getAddress(addr) === ethers.getAddress(oldAddress))?.[0] + : undefined; + if (codePresent && (fingerprintMatch || adoptExisting) && !claimedBy) { addresses[name] = ethers.getAddress(oldAddress); manifest.contracts[name] = { contractName, address: addresses[name], fingerprint: fp, reused: true, constructorArgs: args, ...(fingerprintMatch ? {} : { adopted: true }) }; console.log(`↻ ${name}: ${fingerprintMatch ? 'unchanged' : 'ADOPTED from env'}, reusing ${addresses[name]}`); return addresses[name]; } + if (claimedBy) { + console.log(`↻ ${name}: env ${keys[0]}=${oldAddress} is already ${claimedBy}; deploying a new ${contractName} instead`); + } if (planOnly) { // Genuinely new (no live address to adopt): record the intent, deploy nothing. wouldDeploy.push(name);