feat(bridge): let the upgrade script set implementation immutables - #265
Open
poszu wants to merge 1 commit into
Open
feat(bridge): let the upgrade script set implementation immutables#265poszu wants to merge 1 commit into
poszu wants to merge 1 commit into
Conversation
`BRIDGE_CONTRACT` and `CHAIN_ID` are immutables, so they live in implementation bytecode rather than storage. `run(address)` reads them off the current implementation and redeploys the same values -- correct for an ordinary code upgrade, but it means a value that needs to change cannot be: the upgrade faithfully reproduces whatever is already there. Adds a `run(address,address,uint256)` overload taking the pod bridge address and chain id explicitly. `run(address)` is unchanged and still carries the current values over, so upgrade_bridge.sh keeps working. Both delegate to a shared `_upgrade`. Both paths now assert, after the swap, that the immutables took effect and that the stored `domainSeparator` still matches CHAIN_ID and version. `domainSeparator` is storage, computed at the last version update, so changing CHAIN_ID strands it until the next `updateValidatorConfig`, and claims in the interim would verify against a separator that no longer corresponds to the chain id. Better to fail the script than leave that live. Co-Authored-By: Claude Opus 5 (1M context) <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.
UpgradeBridge.s.solcannot change an implementation immutable.BRIDGE_CONTRACTandCHAIN_IDlive in implementation bytecode rather than storage, andrun(address)reads them off the current implementation before redeploying. That is correct for an ordinary code upgrade, but it means a value that needs to change cannot be — the upgrade faithfully reproduces whatever is already there.Change
run(address,address,uint256)overload taking the pod bridge address and chain id explicitly.run(address)unchanged — it still carries the current implementation's values over, soupgrade_bridge.shand existing flows keep working. Both overloads delegate to a shared_upgrade.domainSeparatorstill matchesCHAIN_IDandversion.That last assertion is the non-obvious one.
domainSeparatoris storage, computed at the last_updateVersion. ChangingCHAIN_IDtherefore strands it until the nextupdateValidatorConfig, and claims in the interim would verify against a separator that no longer corresponds to the chain id — a silent failure rather than a loud one. Failing the script is the better outcome.Verification
forge buildis clean and both overloads appear in the ABI (run(address),run(address,address,uint256)). Exercised against a live proxy on Arbitrum Sepolia — dry run first, then broadcast — with the immutables applied and the domain-separator assertion passing.The change is narrow by construction: masking the four immutable spans,
forge build'sdeployedBytecodeis byte-identical to already-deployed implementations, so the immutables are the only thing an upgrade through this path alters.No test references this script, and the change is confined to a deployment script, so the suite is unaffected.
🤖 Generated with Claude Code