-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add a Slots library, and a transient variant of ReentrancyGuard #4955
Conversation
🦋 Changeset detectedLatest commit: 5a77bc5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/hardhat-ignore-warnings@0.2.9, npm/hardhat@2.17.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Amxx There is a typo in writting
it should be writing
Note that there is a typo in the library name, it should be "transient" and not "transcient". |
/** | ||
* @dev Returns the transient slot \`slot\` as a \`${type}\`. | ||
*/ | ||
function load${capitalize(type)}(bytes32 slot) internal view returns (${type} r) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason in particular to make the return value different to StorageSlot
? The values there are defined as:
struct Uint256Slot {
uint256 value;
}
I definitely think this syntax is better, but I'm wondering if we should prefer one syntax over the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, Solidity supports structs in memory and in storage, but not transient ones. You can't mark it. Only thing we have is low level opcode access through assembly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #4955 (comment)
Co-authored-by: Ernesto García <ernestognw@gmail.com>
Co-authored-by: Ernesto García <ernestognw@gmail.com>
contracts/utils/TransientStorage.sol
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be nicer to provide an API more similar to the StorageSlot
library?
A family of UDVT (one for each underlying type) that encapsulate a transient location with load()
and store()
methods.
contracts/utils/Slots.sol
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ernestognw @frangio Like this new approach?
Note: A few question
|
I actually think it's better to remove those methods, and make the library purely about transient storage. It makes it a more sound abstraction for transient pointers, where there is only one correct dereferencing operation, and where it is not correct to cast into a normal storage pointer. If those are removed Note that "derive" is the correct verb to use. |
THe derivation function have a use for normal storage, see the diff to So if slot is only about transient ... I would move the derivation function out of it into something "generic" |
Fixes #4205
Fixes #4888
Note:
evm
/evmVersion
that affects both the compiler (targeted evm version) and the node (executed evm version)PR Checklist
npx changeset add
)