Commit 43dffec
fix(zkstack_cli): regenerate CREATE2 salt on ecosystem init (#4892)
## What ❔
Regenerate the ecosystem CREATE2 salt (`create2_factory_salt`) on every
`zkstack init` instead of reusing the persisted one.
## Why ❔
The salt is generated once at `ecosystem create` time via
`InitialDeploymentConfig::default()` (`H256::random()`) and persisted to
`initial_deployments.yaml`. Every subsequent `zkstack init` simply read
that same salt back:
```rust
let initial_deployment_config = match ecosystem_config.get_initial_deployment_config() {
Ok(config) => config, // reuses the SAME salt
Err(_) => create_initial_deployments_config(shell, &ecosystem_config.config)?,
};
```
Because the salt never changed, running `zkstack init` twice (e.g.
`zkstack init --dev`) redeployed the ecosystem contracts to the **same
CREATE2 addresses**, colliding with the previous deployment and causing
ownership problems. `--dev` had no effect on the salt.
## How ❔
`init.rs` now loads the existing config (preserving customizations like
`create2_factory_addr`, WETH address, governance delays) but overwrites
`create2_factory_salt` with a fresh `H256::random()` and persists it
back, so each init deploys fresh contracts to new addresses.
The change is scoped to the `ecosystem init` path only.
`build-transactions` and `init-core-contracts` intentionally keep the
persisted salt so a deployment can be reproduced deterministically. The
per-chain `RegisterChainL1Config` already generates a fresh salt per
call, so chain registration was not the collision source.
## Checklist
- [x] PR title follows the [contribution
guidelines](https://github.com/matter-labs/zksync-era/blob/main/docs/src/guides/contributing.md).
- [x] Code has been formatted via `zkstack dev fmt`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 70f8271 commit 43dffec
1 file changed
Lines changed: 10 additions & 2 deletions
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
46 | 54 | | |
47 | 55 | | |
48 | 56 | | |
| |||
0 commit comments