Hardhat Ignition is a declarative deployment system that enables you to deploy your smart contracts without navigating the mechanics of the deployment process.
This happens when I try to test my contracts (which makes use of the hardhat network configuration): modules are not preserved in the hardhat network. Edit: no, I'm not talking about preserving in-disk, but about in-memory preserving while running a single test file in the hardhat network -- this is still not happening.
If, by chance, I have several modules depending on the same module and I need to use all of them, that other module would be loaded multiple times. Edit: or, as in this case, I need to get a module and also the module it depends on.
While I understand that keeping artifacts for hardhat network led to inconsistencies (e.g. manually needing later to delete de deployments/chain-31337 directory or stuff like that), it seems that the in-memory keeping of those artifacts is not being done or has some kind of error..
Minimal reproduction steps
Consider the following layout:
Two contracts Foo and Bar, where Bar depends on Foo:
This is OK, since deploying a multiple time the same module should be idempotent and return the same direction. In this case, 0x8af21B3aB487f6ea74CD7EC35cc7F09Ce97Da5f6 appears standalone (product of logging .fooContract() call as well) and also as the target of the first contract. THIS IS OK.
However, running deployment on the hardhat network seems to not preserve artifacts on any deployment module. So far, to make a recap, let's consider what my fixture does:
Loads the Foo module.
Loads the Bar module, which includes first also depending on the Foo module.
In localhost network nothing is wrong here, but since the ignition artifacts are not preserved... the Foo module is invoked twice. So what I see when running tests in the hardhat network I see this:
The problems this brings is that many tests will fail because there are many contracts wrongfully created and interacted with instead of a single contract (of the same type) when such condition is needed... and this happens even inside a single test file, even inside a single before() hook invocation, and even inside a single fixture invocation.
Just in case: I cannot get the contract at bar.fooContract() address in the regular way (i.e. a .getContractAt call) SINCE THE ARTIFACT WAS NOT BUILT. Hacky ways are supported, yes, but not the typical / regular ones when you just do a .contractAt on ignition or ethers (i.e. I need to manually build and retrieve an artifact in a non-quick way).
What happened?
This happens when I try to test my contracts (which makes use of the
hardhat
network configuration): modules are not preserved in the hardhat network. Edit: no, I'm not talking about preserving in-disk, but about in-memory preserving while running a single test file in the hardhat network -- this is still not happening.If, by chance, I have several modules depending on the same module and I need to use all of them, that other module would be loaded multiple times. Edit: or, as in this case, I need to get a module and also the module it depends on.
This involves versions in my project are:
While the locked / effective ones are:
├── @nomicfoundation/hardhat-toolbox@5.0.0 ├── chai@4.5.0 └── hardhat@2.22.10
While I understand that keeping artifacts for hardhat network led to inconsistencies (e.g. manually needing later to delete de deployments/chain-31337 directory or stuff like that), it seems that the in-memory keeping of those artifacts is not being done or has some kind of error..
Minimal reproduction steps
Consider the following layout:
Then everything goes fine. For example the 3 console.log commands show this:
This is OK, since deploying a multiple time the same module should be idempotent and return the same direction. In this case, 0x8af21B3aB487f6ea74CD7EC35cc7F09Ce97Da5f6 appears standalone (product of logging
.fooContract()
call as well) and also as thetarget
of the first contract. THIS IS OK.However, running deployment on the
hardhat
network seems to not preserve artifacts on any deployment module. So far, to make a recap, let's consider what my fixture does:In
localhost
network nothing is wrong here, but since the ignition artifacts are not preserved... the Foo module is invoked twice. So what I see when running tests in the hardhat network I see this:The problems this brings is that many tests will fail because there are many contracts wrongfully created and interacted with instead of a single contract (of the same type) when such condition is needed... and this happens even inside a single test file, even inside a single before() hook invocation, and even inside a single fixture invocation.
bar.fooContract()
address in the regular way (i.e. a.getContractAt
call) SINCE THE ARTIFACT WAS NOT BUILT. Hacky ways are supported, yes, but not the typical / regular ones when you just do a .contractAt on ignition or ethers (i.e. I need to manually build and retrieve an artifact in a non-quick way).Search terms
No response