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

deployer should reuse deterministic world or change salt #3227

Open
holic opened this issue Sep 24, 2024 · 1 comment
Open

deployer should reuse deterministic world or change salt #3227

holic opened this issue Sep 24, 2024 · 1 comment

Comments

@holic
Copy link
Member

holic commented Sep 24, 2024

If I deploy a world with mud dev-contracts to a long-running anvil instance, then restart and deploy again, it'll reuse the salt and thus get the same world address. However, the second world deploy will fail.

It should either detect this and pick a new salt or reuse the already-deployed world.

We should also see if we can improve the error message from these instances, because it's really unclear

Error while attempting deploy 

ContractFunctionExecutionError: The contract function "deployWorld" reverted.

Contract Call:
  address:   0x573802f86c51B61d7Cf620952217eC6Ce0537d2E
  function:  deployWorld(bytes salt)
  args:                 (0x)
  sender:    0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

Docs: https://viem.sh/docs/contract/writeContract
Version: 2.21.6
@holic
Copy link
Member Author

holic commented Sep 24, 2024

We could potentially add this to the factory, like

address expectedWorldAddress = Create2.computeAddress(...);
if (expectedWorldAddress.code.length > 0) {
  revert WorldExists(expectedWorldAddress);
}

but could do something similar in the deployer just before deploying to avoid modifying audited code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant