Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/ai/contract-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,14 @@ path, and runs tests in `test/{L1,dispute,cannon}/`. It verifies that upgrades w
real deployed state — the actual upgrade path, not just a clean deployment. Requires
`ETH_RPC_URL`. Run it when modifying upgradeable contracts or the upgrade flow itself.

The chain it reads from the superchain registry is set by `FORK_BASE_CHAIN` (default `mainnet`)
and `FORK_OP_CHAIN` (default `op`), not by the RPC. To fork Sepolia, set both the RPC and the
selector, or the fixture reads mainnet addresses that have no code on Sepolia:

```bash
ETH_RPC_URL=<sepolia-rpc> FORK_BASE_CHAIN=sepolia mise x -- just test-upgrade
```

## CI Checks

All of these must pass:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ Nothing on-chain retires the old contracts. Each chain's old `ETHLockbox` still

### Upgrade Both Chains Together

Both chains run on the same shared contracts, so they upgrade as a pair. Once the shared contracts are on a newer release, running an older OPCM on either chain fails with `OPContractsManagerUtils_DowngradeNotAllowed`.
Both chains run on the same shared contracts, so they upgrade as a pair. Running an older OPCM on either chain fails with `OPContractsManagerUtils_DowngradeNotAllowed` for any proxy a newer OPCM upgraded, but the dispute game implementations are not version-checked, so always upgrade both chains with the same OPCM.

Upgrading one chain also reconfigures the other. `upgrade` registers every game type on the shared `DisputeGameFactory` again from that upgrade's `disputeGameConfigs`. So a task scoped to one chain sets the implementations, prestates, bonds, and respected game type for the whole set. Follow three rules when authoring an upgrade task:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ pause는 저절로 만료됩니다. 만료 후 `paused`는 `false`를 반환하

### 두 체인을 함께 업그레이드

두 체인은 동일한 공유 컨트랙트에서 실행되므로 한 쌍으로 업그레이드됩니다. 공유 컨트랙트가 더 새로운 릴리스로 업그레이드되면, 어느 체인에서든 더 오래된 OPCM을 실행하면 `OPContractsManagerUtils_DowngradeNotAllowed`로 실패합니다.
두 체인은 동일한 공유 컨트랙트에서 실행되므로 한 쌍으로 업그레이드됩니다. 어느 체인에서든 더 오래된 OPCM을 실행하면 더 새로운 OPCM이 업그레이드한 proxy에 대해서는 `OPContractsManagerUtils_DowngradeNotAllowed`로 실패하지만, 분쟁 게임 구현은 버전을 검사하지 않으므로 항상 두 체인을 같은 OPCM으로 업그레이드하세요.

한 체인을 업그레이드하면 다른 체인도 재구성됩니다. `upgrade`는 해당 업그레이드의 `disputeGameConfigs`로 공유 `DisputeGameFactory`에 모든 game type을 다시 등록합니다. 따라서 한 체인을 대상으로 한 task가 세트 전체의 구현, prestate, 본드, respected game type을 설정합니다. 업그레이드 task를 작성할 때 다음 세 가지 규칙을 따르십시오.

Expand Down
2 changes: 2 additions & 0 deletions packages/contracts-bedrock/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ print-pinned-block-number:
# Prepares the environment for upgrade path variant of contract tests and coverage.
# Env Vars:
# - ETH_RPC_URL must be set to a production (Sepolia or Mainnet) RPC URL.
# - FORK_BASE_CHAIN (default mainnet) and FORK_OP_CHAIN (default op) select the registry entry and
# must match the RPC's network: set FORK_BASE_CHAIN=sepolia for a Sepolia RPC.
# - FORK_BLOCK_NUMBER can be set in the env, or else will fallback to the default block number.
# Reusing the default block number greatly speeds up the test execution time by caching the
# rpc call responses in ~/.foundry/cache/rpc. The default block will need to be updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ library UpgradeUtils {
}

/// @notice Returns the gas limits for all upgrade transaction types.
/// @dev Calibration: see `_buildImplementationDeploymentConfigs` in GenerateNUTBundle.s.sol.
/// @dev Calibration: each limit must be at least `computeRecommendedGasLimit` of the measured
/// gas. `test_l2ForkUpgrade_isolatedGas_succeeds` in L2ForkUpgrade.t.sol enforces this.
/// @return Gas limits struct.
function gasLimits() internal pure returns (GasLimits memory) {
return GasLimits({ l2cmDeployment: 8_900_000, upgradeExecution: 4_000_000 });
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"sourceCodeHash": "0x1f2793450fa627428450c2040cab19a63db235f2cccdae63baa4959bec7f9d8c"
},
"src/L1/opcm/OPContractsManagerV2.sol:OPContractsManagerV2": {
"initCodeHash": "0x936a28f9627d5b895c105ec8a91331d99efadaa7c69a8fd876a135435b5085dd",
"sourceCodeHash": "0x9128176d512b3571833cbf7c97db655825a199f6a71ab1cb9ff524d3bd0d1df8"
"initCodeHash": "0x92b72d9b81f0d4f148006f4210f626e8711e8d888fb90f1dc53dba21e921dae1",
"sourceCodeHash": "0x3011b890acbcaf45f869c36672bfc3f6a71d14fcc9543a0fccdf40d34307c50e"
},
"src/L2/BaseFeeVault.sol:BaseFeeVault": {
"initCodeHash": "0x18650c65fa6f23fefc6f0c5fff605f12be99fce0bfbcbc0644403138e4c8bb12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,8 @@ contract OPContractsManagerMigrator is OPContractsManagerUtilsCaller {
);

// Reuse the existing DelayedWETH from chainSystemConfigs[0] rather than deploying a
// new one. The migrated chains share a SystemConfig, and by extension share its
// DelayedWETH. Deploying a new one would create a divergence — SystemConfig would
// still point to the old one, and future upgrades (which load DelayedWETH from
// SystemConfig) would reference a different DelayedWETH than the shared DGF games.
// new one. Each chain keeps its own SystemConfig, and migrate points every one of them
// at this DelayedWETH.
IDelayedWETH delayedWETH = IDelayedWETH(payable(_input.chainSystemConfigs[0].delayedWETH()));

// Separate context to avoid stack too deep (isolate the implementations variable).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,6 @@ abstract contract OPContractsManagerUtilsCaller {
);
}

/// @notice Helper function to check if an instruction matches a given key and data.
/// @param _instruction The instruction to check.
/// @param _key The key of the instruction to check for.
/// @param _data The data of the instruction to check for.
/// @return True if the instruction matches, false otherwise.
function _isMatchingInstruction(
IOPContractsManagerUtils.ExtraInstruction memory _instruction,
string memory _key,
bytes memory _data
)
internal
view
returns (bool)
{
return abi.decode(
_staticcall(abi.encodeCall(IOPContractsManagerUtils.isMatchingInstruction, (_instruction, _key, _data))),
(bool)
);
}

/// @notice Helper function to load data from a source contract as bytes.
/// @param _source The source contract to load the data from.
/// @param _selector The selector of the function to call on the source contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ contract OPContractsManagerV2 is ISemver, OPContractsManagerUtilsCaller {
bool useCustomGasToken;
// Withdrawal timing configuration. Stored per chain on the portal, the
// AnchorStateRegistry and the DelayedWETH, and bounded by the implementations' min/max
// immutables.
// immutables. After migrate, the AnchorStateRegistry and DelayedWETH are shared, so their
// delays apply to the whole set.
uint256 proofMaturityDelaySeconds;
uint256 disputeGameFinalityDelaySeconds;
uint256 withdrawalDelaySeconds;
Expand Down Expand Up @@ -186,9 +187,9 @@ contract OPContractsManagerV2 is ISemver, OPContractsManagerUtilsCaller {
/// - Major bump: New required sequential upgrade
/// - Minor bump: Replacement OPCM for same upgrade
/// - Patch bump: Development changes (expected for normal dev work)
/// @custom:semver 10.0.1
/// @custom:semver 10.0.2
function version() public pure returns (string memory) {
return "10.0.1";
return "10.0.2";
}

/// @param _standardValidator The standard validator for this OPCM release.
Expand Down Expand Up @@ -372,11 +373,10 @@ contract OPContractsManagerV2 is ISemver, OPContractsManagerUtilsCaller {
// NOTE (IMPORTANT FOR DEVELOPERS): You MAY need to allow permitted instructions here for
// your specific upgrade. For example, if you are adding a new contract that needs to be
// deployed you will need to add an allowance so that the proxy can be deployed.
// Allowances MUST always be restricted to one specific upgrade. Here we maintain this
// restriction by checking that the version is less than the NEXT release version. Once
// developers start working on the next release this will automatically become false so
// even if the code is somehow forgotten it will not actually apply to the deployment. Make
// sure to REMOVE the allowance once the upgrade is complete.
// An allowance needed for only one upgrade MUST be restricted to that upgrade with an
// explicit release check (for example, on the major version of _version()), and MUST be
// removed once the upgrade is complete. An allowance kept for every upgrade MUST say why
// it is permanent, like the two below.

// Allow overriding the starting respected game type during upgrades. This is needed when
// disabling the currently-respected game type, since the validation requires the starting
Expand Down
Loading