OpenZeppelin / OpenZeppelin/openzeppelin-upgrades
Add support of packing / unpacking structure during storage layout verification.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 658
- Forks
- 286
- PR merge metrics
- No merged PRs in 30d
Description
Let's say we have an ERC20Votes contract. This contract contains 3 consecutive slots dedicated to the voting logic:
mapping(address => address) private _delegates;
mapping(address => Checkpoint[]) private _checkpoints;
Checkpoint[] private _totalSupplyCheckpoints;
This storage and the associated logic would benefit from being abstracted away, so it can be reused for ERC721 voting or ERC1155 voting (for example).
This is what this structure proposes. You'll note that, at a low level, the storage is consistent. It is however hidden in structs.
struct Checkpoint {
uint32 index;
uint224 value;
}
struct History {
Checkpoint[] _checkpoints;
}
struct Votes {
mapping(address => address) _delegation;
mapping(address => History) _userCheckpoints;
History _totalCheckpoints;
}
I believe that it would be a great improvement if the plugin was able to flatten the structure so that this would trigger a rename error, but not replace/delete/insert errors.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the storage examples in ERC20Votes.sol and Voting.sol, then inspect the tests on the referenced feature/pack-unpackstorage branch. Determine how the plugin currently verifies storage layouts and compare the expected behavior for packed structures. Done means the linked test cases pass while detecting renames without reporting replacement, deletion, or insertion errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- solidity, typescript
- Domain
- blockchain, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100