ethereum-optimism / ethereum-optimism/optimism

Incorrect __gap Size in ERC721Bridge.sol

Open
#14,330 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
6.5k
Forks
4k
Avg merge
2d 18h
Merged PRs (30d)
134

Description

**Bug Description**

The `__gap` size in `ERC721Bridge.sol` is incorrect. Given that the total consumed storage is 3 slots (2 bytes + 30 bytes, 20 bytes, and 20 bytes), the gap should be 47, not 46, to align with the rule that the next contract storage slot should start at a 50-slot boundary.

Breakdown of Storage Variables per Slot:
- 1st Slot: [uint8 _initialized](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/ecd2ca2cd7cac116f7a37d0e474bbb3d7d5e1c4d/contracts/proxy/utils/Initializable.sol#L62), [bool _initializing](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/ecd2ca2cd7cac116f7a37d0e474bbb3d7d5e1c4d/contracts/proxy/utils/Initializable.sol#L67), [bytes30 spacer_0_2_30](https://github.com/ethereum-optimism/optimism/blob/op-contracts-v180-blueprints-script/packages/contracts-bedrock/src/universal/ERC721Bridge.sol#L13) (Total: 32 bytes)
- 2nd Slot: [address messenger](https://github.com/ethereum-optimism/optimism/blob/op-contracts-v180-blueprints-script/packages/contracts-bedrock/src/universal/ERC721Bridge.sol#L17) (20 bytes)
- 3rd Slot: [address otherBridge](https://github.com/ethereum-optimism/optimism/blob/op-contracts-v180-blueprints-script/packages/contracts-bedrock/src/universal/ERC721Bridge.sol#L21) (20 bytes)

**Steps to Reproduce**

no steps

**Expected behavior**

Update the storage gap from `46` to `47` to ensure proper alignment with the storage slot allocation rules.

**Environment Information:**

Contract Version Reference
- OpenZeppelin: ecd2ca2cd7cac116f7a37d0e474bbb3d7d5e1c4d
- OP Contracts: v180-blueprints-script (latest?)

**Configurations:**

**Logs:**

**Additional context**

---

⚠️ **Notice:** Issues that do not include the following sections will be subject to closure:
- Bug Description
- Steps to Reproduce
- Environment Information

Please ensure all required sections are filled out accurately to expedite the debugging process and improve issue resolution efficiency.

Contributor guide

Open the contributing guide

Research direction

Start in packages/contracts-bedrock/src/universal/ERC721Bridge.sol and inspect the storage declarations and __gap value. Compare the documented three-slot layout with the intended 50-slot boundary. Done means the gap value and related storage-layout expectations are consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.