fix(ci): order openzeppelin remappings so both shipyard-core import styles resolve - #28
Merged
Merged
Conversation
shipyard-core imports OpenZeppelin two ways, "openzeppelin-contracts/token/..." and "openzeppelin-contracts/contracts/token/...", so foundry.toml maps both prefixes to the same target. Forge's import resolver takes the first remapping that matches rather than the longest, so with the bare prefix listed first every "openzeppelin-contracts/contracts/..." import resolved to a doubled lib/openzeppelin-contracts/contracts/contracts/... path and the build failed on EnumerableSet.sol in DynamicTraits.sol and OnchainTraits.sol. Putting the longer prefix first fixes resolution. Paths for the bare style are unchanged, so no compiled output moves. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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
Forge Tests has been red on
main. On a fresh clone with submodules initialized,FOUNDRY_PROFILE=CI forge buildfails:Note the doubled
contracts/contracts/segment.Cause
lib/shipyard-coreat the pinned commit imports OpenZeppelin two different ways:openzeppelin-contracts/token/ERC721/ERC721.solopenzeppelin-contracts/contracts/utils/structs/EnumerableSet.solfoundry.tomlmaps both prefixes to the same target to cover that:solc resolves overlapping remappings by longest matching prefix, so both styles work when solc is invoked directly. Forge's own import resolver takes the first remapping that matches instead, and it builds the source graph before handing sources to solc. With the bare prefix first,
openzeppelin-contracts/contracts/utils/structs/EnumerableSet.solbecomeslib/openzeppelin-contracts/contracts/+contracts/utils/structs/EnumerableSet.sol, which does not exist, so the file never makes it into the compilation unit.I confirmed the split by running solc 0.8.20 directly with the same pair of remappings in both orders: both compile. Only the Forge resolver is order sensitive.
Fix
List the longer prefix first, with a comment so the pair does not get re-sorted later.
The bare-style imports resolve to exactly the same paths as before, because
openzeppelin-contracts/token/...never matched the longer prefix. Nothing moves in the compiled output, the pinned solc stays at 0.8.20, and no submodule pointer changes.Why not bump the submodules
That was the other option, and I tried it. Upstream shipyard-core did fix this at the source in ProjectOpenSea/shipyard-core#29, but that PR normalizes every OpenZeppelin import to
@openzeppelin/contracts/...and bumps OpenZeppelin to v5.5.0 in the same change, so there is no commit that fixes the imports alone. Taking it here pulls in:^0.8.24, so this repo's pinnedsolc = '0.8.20'has to move too. That changes the bytecode of every project generated from the template.Update IERC7496 and DynamicTraits based on ethereum/ERCs PR 1400.src/Dockmaster.solstops compiling against it:Error (7576): Undeclared identifieron_traits[tokenId]at Dockmaster.sol:244.solady/src/...rather thansolady/...) and seaport-types, which means editing the template's own imports as well.That is a dependency modernization worth doing on its own, with a migration for
Dockmaster.soland a deliberate choice of compiler pin. Bundling it into a CI fix would ship a bytecode change and a breaking OpenZeppelin major to every generated repo. I would rather unbreak CI first.Verification
Fresh clone at this branch,
git submodule update --init --recursive, then:FOUNDRY_PROFILE=CI forge build- exit 0, compiler run successfulFOUNDRY_PROFILE=ci forge build --sizes(the workflow's build step) - exit 0FOUNDRY_PROFILE=CI forge test -vvv- 4 passed, 0 failedforge fmt --check- cleanForge 1.5.1-stable, solc 0.8.20.
This touches only
foundry.toml, so it does not overlap #27.🤖 Generated with Claude Code