Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mark used storage slots in L2ScrollMessenger #941

Merged
merged 1 commit into from
Sep 11, 2023

Conversation

Thegaram
Copy link
Contributor

Purpose or design rationale of this PR

Describe your change. Make sure to answer these three questions: What does this PR do? Why does it do it? How does it do it?

#850 removed some storage variables from L2ScrollMessenger. If we add some new storage variables in a future upgrade, they might use the same slots and might end up with unexpected initial values. This PR marks these two slots as used.

Layout of old version (4a30566):

> forge inspect L2ScrollMessenger storage-layout --pretty
| Name                    | Type                        | Slot | Offset | Bytes | Contract                                       |
|-------------------------|-----------------------------|------|--------|-------|------------------------------------------------|
| _initialized            | uint8                       | 0    | 0      | 1     | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| _initializing           | bool                        | 0    | 1      | 1     | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __gap                   | uint256[50]                 | 1    | 0      | 1600  | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| _owner                  | address                     | 51   | 0      | 20    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __gap                   | uint256[49]                 | 52   | 0      | 1568  | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| _paused                 | bool                        | 101  | 0      | 1     | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __gap                   | uint256[49]                 | 102  | 0      | 1568  | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| _status                 | uint256                     | 151  | 0      | 32    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __gap                   | uint256[49]                 | 152  | 0      | 1568  | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| xDomainMessageSender    | address                     | 201  | 0      | 20    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| counterpart             | address                     | 202  | 0      | 20    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| feeVault                | address                     | 203  | 0      | 20    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __gap                   | uint256[47]                 | 204  | 0      | 1504  | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| isL2MessageSent         | mapping(bytes32 => bool)    | 251  | 0      | 32    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| isL1MessageExecuted     | mapping(bytes32 => bool)    | 252  | 0      | 32    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| l1MessageFailedTimes    | mapping(bytes32 => uint256) | 253  | 0      | 32    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| maxFailedExecutionTimes | uint256                     | 254  | 0      | 32    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |

Layout of new version (c543d6f):

> forge inspect L2ScrollMessenger storage-layout --pretty
| Name                 | Type                     | Slot | Offset | Bytes | Contract                                       |
|----------------------|--------------------------|------|--------|-------|------------------------------------------------|
| _initialized         | uint8                    | 0    | 0      | 1     | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| _initializing        | bool                     | 0    | 1      | 1     | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __gap                | uint256[50]              | 1    | 0      | 1600  | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| _owner               | address                  | 51   | 0      | 20    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __gap                | uint256[49]              | 52   | 0      | 1568  | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| _paused              | bool                     | 101  | 0      | 1     | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __gap                | uint256[49]              | 102  | 0      | 1568  | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| _status              | uint256                  | 151  | 0      | 32    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __gap                | uint256[49]              | 152  | 0      | 1568  | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| xDomainMessageSender | address                  | 201  | 0      | 20    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| counterpart          | address                  | 202  | 0      | 20    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| feeVault             | address                  | 203  | 0      | 20    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| rateLimiter          | address                  | 204  | 0      | 20    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __gap                | uint256[46]              | 205  | 0      | 1472  | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| isL2MessageSent      | mapping(bytes32 => bool) | 251  | 0      | 32    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| isL1MessageExecuted  | mapping(bytes32 => bool) | 252  | 0      | 32    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |
| __used               | uint256[2]               | 253  | 0      | 64    | src/L2/L2ScrollMessenger.sol:L2ScrollMessenger |

PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • fix: A bug fix

Deployment tag versioning

Has tag in common/version.go been updated or have you added bump-version label to this PR?

  • No, this PR doesn't involve a new deployment, git tag, docker image tag
  • Yes

Breaking change label

Does this PR have the breaking-change label?

  • No, this PR is not a breaking change
  • Yes

@github-actions
Copy link

LCOV of commit c543d6f during Contracts #34

Summary coverage rate:
  lines......: 51.6% (1013 of 1963 lines)
  functions..: 65.6% (227 of 346 functions)
  branches...: no data found

Files changed coverage rate: n/a

@Thegaram Thegaram merged commit fc53572 into develop Sep 11, 2023
4 checks passed
@Thegaram Thegaram deleted the mark-used-slots-in-l2-messenger branch September 11, 2023 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants