Hardhat+UUPS: Deployment at address 0x... is not registered

That's right, it checks against the layout stored in the network file. The on-chain bytecode doesn't have explicit nor precise information about storage layout.

1 Like

I see, so that makes manual changes to the network file even riskier. With the new forceImport and the git history we wrote a script to safely re-create the network file from past deployments. This feature really helped a lot.

What would even be better though, is if the upgrades plugin would do a bytecode comparison during network file re-creation via eth_getCode. Secondly, which might be redundant then, it could attempt to read the verified source code on a block explorer and use that for the creation of the storage layout inside the network file.

@Marcel_Jackisch Glad to hear that forceImport is working well for you.

We had previously considered doing bytecode comparison while importing, but found that it was unreliable. Immutable variables can cause the bytecode to be different, which is the case for UUPS implementations that use UUPSUpgradeable. Also, if previously deployed contracts were compiled with different compiler settings, then bytecode comparison would fail as well.

Reading verified source is an interesting idea but would create an additional dependency on block explorers which may differ for different networks.

1 Like