OpenZeppelin / OpenZeppelin/openzeppelin-contracts

Better modularization of StorageSlot.sol::getAddressFromSlot()

Open
#5,162 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Solidity
Stars
27.2k
Forks
12.4k
Avg merge
2d 19h
Merged PRs (30d)
33

Description

getAddressFromSlot() is both used to set addresses into precalculated storage slots (returning a reference of the AddressSlot struct), and to get addresses stored into that slot. I guess it would be better to separate the setter from the getter, which I've already done in the code below. There's no need to reassign the storage slot of the struct everytime we need to read the value.
Schermata del 2024-08-25 05-33-10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in StorageSlot.sol at getAddressFromSlot() and inspect its two current call patterns: setting and reading precalculated slots. Compare the separation proposed in the issue's attached example, then run the relevant existing contract tests to confirm both behaviors remain intact and address reads no longer reassign the storage slot.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.