Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add warning about using mud dev-contracts on non-local chains #3567

Open
yonadaa opened this issue Feb 4, 2025 · 6 comments
Open

add warning about using mud dev-contracts on non-local chains #3567

yonadaa opened this issue Feb 4, 2025 · 6 comments
Labels
good first issue Good for newcomers

Comments

@yonadaa
Copy link
Contributor

yonadaa commented Feb 4, 2025

Sometimes my deployments to live chains will fail, even when my private key is funded. For example, I created a fresh project from the React template, and deploying it to Rhodolite failed on the first attempt. Changing the private key to an unused one fixes the issue.

Happy to investigate it more, just wanted to flag it first.

Image
@frolic
Copy link
Member

frolic commented Feb 4, 2025

that makes sense, since deploys are deterministic based on creator + salt!

if you aren't trying to upgrade an existing world and really want to make a new one, you can alternatively pick a new salt for your world with the --salt command

@frolic
Copy link
Member

frolic commented Feb 4, 2025

actually wonder if this is related to or a duplicate of #3557

this is specifically a dev-contracts issue which uses a zero salt (so you don't get noise in worlds.json on redeploys)

@yonadaa
Copy link
Contributor Author

yonadaa commented Feb 5, 2025

that makes sense, since deploys are deterministic based on creator + salt!

Oops, thanks for clearing that up.

To clarify, I am using dev-contracts, which I treat as an idempotent "deploy only what has changed in the current project" command, but I see that's not quite right.

IMO there are three cases to think about here:

  1. Rerunning dev-contracts in a single project without any changes
  2. Rerunning dev-contracts in a single project after making changes
  3. Running dev-contracts in multiple projects

Case 1 (#3557) fails mysteriously, but that's fine because dev-contracts shouldn't do anything. 2 and 3 are more inconvenient, as you have to manually set a salt on each testnet re/deploy.

Curious how you think about all this :)

@frolic
Copy link
Member

frolic commented Feb 5, 2025

Ahh yeah, mud dev-contracts isn't really meant to be used on live chains, unless you really know what you're doing, because it does a lot of redeploying things constantly and could cause cases where you change a table schema for an already registered table and only choice is to redeploy anyway.

mud deploy does the same idempotent deployment, it just expects to be run as-needed/when you're ready to finalize rather than continuously while in development.

So in summary:

  • use mud dev-contracts while developing locally (defaults to --salt 0x)
    • automatically redeploys to the initial world that is created
  • use mud deploy when ready to go live (defaults to random salt)
    • use mud deploy --worldAddress 0x... to do an idempotent redeploy to an existing world

We can add some big fat warnings to mud dev-contracts if we detect deployment to e.g. non-Anvil chains to guide you to the right behavior.

@frolic frolic changed the title Deploys fail when reusing private key with new project add warning about using mud dev-contracts on non-local chains Feb 5, 2025
@frolic frolic added the good first issue Good for newcomers label Feb 5, 2025
@yonadaa
Copy link
Contributor Author

yonadaa commented Feb 6, 2025

I like this way of thinking!

It might also be good to add a testnet deploy command to the template projects, to nudge folks in the right direction.

@frolic
Copy link
Member

frolic commented Feb 6, 2025

you mean like this?

"deploy:garnet": "mud deploy --profile=garnet",
"deploy:local": "mud deploy",
"deploy:redstone": "mud deploy --profile=redstone",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Status: No status
Development

No branches or pull requests

2 participants