Commit 9b64ea8
fix(dojo-utils): return real address on already-deployed path (#3404)
* fix(dojo-utils): return real contract_address on already-deployed path
`Deployer::deploy_via_udc` computes the deterministic UDC-derived
contract address, checks `is_deployed` at that address, and when the
contract is already there returns `Ok((Felt::ZERO, Noop))`. The real
address is computed then dropped. Callers relying on the return value
(including everything that expects idempotent deploys) see zero.
The `deploy_via_udc_getcall` signature reinforces this — it returns
`Option<(Felt, Call)>` where `None` means "already deployed", and the
address computed along the way is lost.
Change:
- `deploy_via_udc_getcall` now returns `(Felt, Option<Call>)`. The
address is always surfaced; the Option<Call> encodes whether a
deploy call is needed.
- `deploy_via_udc` unwraps that to `(address, TransactionResult::Noop)`
on the already-deployed path, with the correct address.
The one external caller in `sozo-ops::migrate` was pattern-matching
`Some((_, call))` / `None` and discarding the address — it adapts to
the new shape trivially (`let (_, call) = ...await?; deploy_call = call`),
in fact becoming shorter and clearer.
Breaking change for any direct consumer of `deploy_via_udc_getcall`,
but the return type change is mechanical to fix at each site.
Reproduction before this change: run `saya-ops core-contract deploy
--salt X` twice against the same L2. First run succeeds, second run
returns contract_address="0x0" in its JSON output, which propagates
into any downstream orchestration and causes subsequent txns targeting
the deployed contract to fail with "Requested contract address 0x0 is
not deployed."
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test(dojo-utils): regression test for deploy_via_udc idempotency
Spins up a katana_runner, deploys the predeclared account class at a
fixed salt, then verifies both `deploy_via_udc_getcall` and
`deploy_via_udc` return the real contract address on the
already-deployed path.
Before this change the tests would fail with address=Felt::ZERO on the
second call; after, both paths return the deterministic UDC-derived
address and deploy_via_udc returns TransactionResult::Noop.
Uses the same harness pattern as the existing waiter tests
(\`#[katana_runner::test]\` + \`RunnerCtx\`) so no new dev-deps needed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* style(dojo-utils): rustfmt per nightly-2024-08-28
CI's fmt check uses the pinned nightly-2024-08-28 rustfmt which collapses
the chained-await blocks and the multi-line assert_eq! in the new test
onto single lines. Purely cosmetic.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a6c6047 commit 9b64ea8
2 files changed
Lines changed: 91 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
45 | | - | |
| 50 | + | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
| |||
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
56 | | - | |
| 61 | + | |
57 | 62 | | |
58 | 63 | | |
59 | | - | |
| 64 | + | |
60 | 65 | | |
61 | | - | |
62 | | - | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
| |||
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
73 | | - | |
| 78 | + | |
74 | 79 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| |||
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
917 | 917 | | |
918 | 918 | | |
919 | 919 | | |
920 | | - | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
921 | 924 | | |
922 | 925 | | |
923 | 926 | | |
924 | 927 | | |
925 | 928 | | |
926 | 929 | | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
| 930 | + | |
| 931 | + | |
937 | 932 | | |
938 | 933 | | |
939 | 934 | | |
| |||
0 commit comments