hirosystems / clarinet

Write, test and deploy high-quality smart contracts to the Stacks blockchain and Bitcoin.
https://hiro.so/clarinet
GNU General Public License v3.0
301 stars 134 forks source link

Migrations on Devnet #1576

Open cipherzzz opened 2 weeks ago

cipherzzz commented 2 weeks ago

Summary

I'd like to be able to have granular migrations similar to most tooling so that I can test out my migrations and have a well known migration path.

Setup


# create new project
clarinet new devnet-feature && cd devnet-feature && npm i

# create contracts
clarinet contract new contract-v1
clarinet contract new contract-v2

# generate deployments
clarinet deployment generate --devnet
 mv deployments/default.devnet-plan.yaml  ./deployments/initial.deploy.
yaml
# remove `contract-v2`  from the deployment file above

clarinet deployment generate --devnet
 mv deployments/default.devnet-plan.yaml  ./deployments/upgrade.deploy.
yaml
# remove `contract-v1`  from the deployment file above

# Run initial deployment
clarinet integrate --deployment-plan-path=./deployments/initial.deploy.yaml

Fails with

cipherz@cipherz-razer:~/projects/mechanism/devnet-feature$ clarinet integrate --deployment-plan-path=./deployments/initial.deploy.yaml
warn: This command is deprecated. Use 'clarinet devnet start' instead
Computing deployment plan
unexpected error: receiving on a closed channel
terminating devnet network: logs and chainstate available at location /home/cipherz/projects/mechanism/devnet-feature/./.cache/stacks-devnet-1728066203
error: unable to start bitcoind container: network devnet-feature.devnet is ambiguous (2 matches found on name)

I tried

docker network prune

It fails with the same error What I'd like to be able to do is start the devnet with the specified file and then run

clarinet deployment apply --deployment-plan-path=./deployments/upgrade.deploy.yaml

hugocaillard commented 2 days ago

Hey @cipherzzz Looks like deployment plans are not the issue here, it fails right from the beginning.

I'm able to make it work following your steps to reproduce (thanks for this beautifully written issue btw 🙏 ). Including:

clarinet deployment apply --deployment-plan-path ./deployments/upgrade.deploy.yaml

error: unable to start bitcoind container: network devnet-feature.devnet is ambiguous (2 matches found on name)

That's the real issue. You could have an container or a volume that still use an volume. Or it could be something else. If you don't want to spend too much time finding what's wrong docker system prune --all will prune all your docker and leave it ready to be used (but that's only if you're ok to loose all of your images, volumes, etc)

cipherzzz commented 1 day ago

Hey @cipherzzz Looks like deployment plans are not the issue here, it fails right from the beginning.

I'm able to make it work following your steps to reproduce (thanks for this beautifully written issue btw 🙏 ). Including:

clarinet deployment apply --deployment-plan-path ./deployments/upgrade.deploy.yaml

error: unable to start bitcoind container: network devnet-feature.devnet is ambiguous (2 matches found on name)

That's the real issue. You could have an container or a volume that still use an volume. Or it could be something else. If you don't want to spend too much time finding what's wrong docker system prune --all will prune all your docker and leave it ready to be used (but that's only if you're ok to loose all of your images, volumes, etc)

Hey man! Yeah, I can do a docker network prune for that. The reason it's throwing that is that there is already an instance of clarinet running and the apply attempts to start another instance. It only starts an instance for devnet, whereas it simply applies to testnet and mainnet. I guess what I'd like is a way to apply changes to an already running devnet.

hugocaillard commented 1 day ago

I guess what I'd like is a way to apply changes to an already running devnet.

It is already the case. The workflow your a describing works and i was able to try and confirm it works

cipherzzz commented 1 day ago

Oh! Ok, awesome I’ll try it again -thanks!

On Sat, Oct 19, 2024 at 11:02 AM Hugo C @.***> wrote:

I guess what I'd like is a way to apply changes to an already running devnet.

It is already the case. The workflow your a describing works and i was able to try and confirm it works

— Reply to this email directly, view it on GitHub https://github.com/hirosystems/clarinet/issues/1576#issuecomment-2423937777, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH57I2Q3QOCSQLVZ536AZLDZ4JX7JAVCNFSM6AAAAABPMMQUO6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRTHEZTONZXG4 . You are receiving this because you were mentioned.Message ID: @.***>