argotorg / argotorg/solidity

Lift restrictions against allocating the last storage slot

Open
#15,911 4 comments 0 reactions 0 assignees View on GitHub
low effort low impact must have eventually
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

Currently, defining a storage variable that covers the last storage slot results in a compilation error. Either when contract's variables are so large that they cover the whole storage (this is already possible) or when the layout base is shifted so much that reasonably-sized variables reach the last slot (which will be possible after #597).

It's not clear why the restriction was added. It may have been done to keep the last slot reserved, but this wasn't documented anywhere, so it could just as well have been be a mistake.

We should remove the restriction.

### Steps to reproduce
#### Oversized array
```solidity
contract C {
uint[2**256] x;
}
```
```
Error: Array length too large, maximum is 2**256 - 1.
--> test.sol:2:10:
|
2 | uint[2**256] x;
| ^^^^^^
```

#### Layout
```solidity
contract D layout at 2**256 - 1 {
uint x;
}
```
```
Error: Contract extends past the end of storage when this base slot value is specified.
--> test.sol:1:22:
|
1 | contract D layout at 2**256 - 1 {
| ^^^^^^^^^^
```

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Start by tracing the two reported compiler diagnostics for the oversized array and the layout base at 2**256 - 1, then verify that both examples compile without the last-slot restriction and that storage bounds remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
blockchain, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.