fix(ops): recover real address on dojo-utils already-deployed path#64
Closed
kariy wants to merge 1 commit into
Closed
fix(ops): recover real address on dojo-utils already-deployed path#64kariy wants to merge 1 commit into
kariy wants to merge 1 commit into
Conversation
`dojo-utils::Deployer::deploy_via_udc` computes the deterministic
UDC-derived contract address, checks whether a contract is already
deployed there via `is_deployed`, and returns early with
`Ok((Felt::ZERO, TransactionResult::Noop))` when it is. The real
address is computed and then dropped — callers see zero.
That's a real problem for us: `saya-ops core-contract deploy --salt X`
is meant to be idempotent, but the second invocation with the same salt
emits `contract_address: "0x0"` in both text and JSON output. Consumers
(including our docker-compose init container) then write 0x0 into the
bootstrap manifest and the next step (setup-program) panics on a
nonexistent contract.
Workaround in saya-ops: when we see `(Felt::ZERO, Noop)`, recompute the
address ourselves via `starknet::core::utils::get_contract_address`
using the same inputs dojo-utils used. That's exactly what dojo-utils
computed and discarded.
Verified against a local katana L2 that had already been deployed
against with salt 0x7ee from a prior run:
Before fix: contract_address: "0x0"
After fix: contract_address: "0x37189b1807f1358074b70b3dc8ab79167bbf72cff1296286052f6dfe31c8f15"
This is a local defense; the proper fix is in dojo-utils (return
`(real_address, Noop)` instead of `(ZERO, Noop)`). Filing that
separately against dojoengine/dojo.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
Member
Author
|
Superseded by the root-cause fix in dojo: dojoengine/dojo#3404. Once that merges and saya's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
saya-ops core-contract deploy --salt Xis not idempotent after PR #63. The second invocation with the same salt emitscontract_address: "0x0"in both text and JSON output:Downstream scripts (our docker-compose init container, our own
tests/saya-tee/if it were to re-run) write0x0into bootstrap manifests and the next step (setup-program) panics because there's no contract at the zero address.Root cause
dojo-utils::Deployer::deploy_via_udc_getcallcomputes the deterministic UDC-derived contract address, checksis_deployed, and returnsOk(None)when the contract exists.deploy_via_udcmaps that toOk((Felt::ZERO, TransactionResult::Noop)):dojo-utils internally traces
contract_address="0x037189b18..."at that point but throws it away.Fix
Workaround in saya-ops: when
deploy_via_udcreturns(Felt::ZERO, Noop), recompute the address locally viastarknet::core::utils::get_contract_addressusing the same inputs dojo-utils used (salt + class_hash + constructor_calldata + deployer_address=Felt::ZERO). That's exactly what dojo-utils computed and discarded, so we end up with the real address.Only 13 lines, gated on the specific
(ZERO, Noop)condition so it's a no-op on any other path.Verification
Against a local katana L2 with a previously-deployed TEE registry at salt 0x7ee:
Follow-up
The proper fix is in
dojoengine/dojo— havedeploy_via_udcreturn(real_address, Noop)instead of(ZERO, Noop). Filing that separately once this lands; once merged upstream and saya'sdojo-utilsgit dep advances, the workaround here can be removed.Test plan
cargo check -p saya-ops/cargo build -p saya-opscleankatana --devwith a previously-deployed saltdocker/scripts/deploy-contracts.shcan pick this up once merged, making the compose bundle idempotent across restarts🤖 Generated with Claude Code