chore(cairo): bound openzeppelin_interfaces to the 2.x line - #733
Merged
Conversation
src/your_contract.cairo and tests/test_contract.cairo both depend on
the exact module path openzeppelin_interfaces::token::erc20. That
path is version-dependent (a sibling repo confirmed
openzeppelin_interfaces::erc20, without ::token::, also compiles at
some versions), so an unbounded floor (">=2.0.0") lets a future 3.x
release silently move/remove the segment and break the build on
scarb update or lockfile regen. Bound to the 2.x line so resolution
can't cross that boundary without a deliberate manifest change.
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
packages/snfoundry/contracts/Scarb.tomldeclaredopenzeppelin_interfaces = ">=2.0.0"— an unbounded floor.src/your_contract.cairo:12andtests/test_contract.cairo:3both depend on an exact module path:We currently resolve
openzeppelin_interfaces2.1.0, which has the::token::segment, so it works today. A sibling repo confirmedopenzeppelin_interfaces::erc20(without::token::) also compiles at some versions — the path is version-dependent, not stable. If OpenZeppelin publishes a 3.x that moves or removes that segment, anyone runningscarb updateor regenerating a deletedScarb.lockwould silently resolve onto it and the contract would stop compiling. Our shippedScarb.lockpins 2.1.0 (and is included in the published create-stark template), so the default path is safe today — this change closes the update path that would break it.Change
Bound
openzeppelin_interfacesto the 2.x line:Verified this range syntax is accepted by scarb 2.20.0 (see verification output below) — did not guess.
Only this one line in
Scarb.tomlchanged.Scarb.lockis untouched (see verification below): 2.1.0 already satisfies the new range, so nothing re-resolves.Verification (all run locally against scarb 2.20.0)
scarb build→ exit 0snforge test→ all tests pass (2 passed — PR test(cairo): add should_panic coverage to the contract gate #731, which adds the other 2, has not merged todevelopyet; either 2 or 4 passing is expected depending on merge order)scarb fmt --check→ exit 0git diff -- packages/snfoundry/contracts/Scarb.lock→ emptyResolved OZ versions in
Scarb.lockbefore and after (unchanged):Other unbounded floors in this file (reported, not changed)
The same unbounded-floor pattern exists on the other dependencies. Listing them with whether our source has a comparable hard coupling to a specific module path, so a reviewer has the data to decide a follow-up without widening this PR:
openzeppelin_access(>=3.0.0)src/your_contract.cairo:11importsopenzeppelin_access::ownable::OwnableComponent. Same class of risk asopenzeppelin_interfaces.openzeppelin_token(>=3.0.0)src/your_contract.cairoortests/test_contract.cairo— it's a transitive/declared dependency only, not referenced by an exact module path in our source. Lower risk from this specific angle.openzeppelin_utils(>=2.0.0, dev-dependency)tests/test_contract.cairo:4importsopenzeppelin_utils::serde::SerializedAppend. Same class of risk, but scoped to dev-dependencies/tests only.starknet(>=2.18.0)src/your_contract.cairo:13,17importstarknet::storage::{...}andstarknet::{ContractAddress, get_caller_address, get_contract_address}. This is the corestarknetcrate itself (not OpenZeppelin), so its stability/versioning guarantees are different in kind from the OZ crates — flagging for the reviewer to weigh separately.Not touched in this PR per scope.
Hard constraints followed
openzeppelin_interfacesline inpackages/snfoundry/contracts/Scarb.tomlchanged.Scarb.lockis byte-identical todevelop.your_contract.cairoand test files untouched.packages/nextjs/contracts/deployedContracts.tsuntouched.