-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
memory
--> calldata
for read-only function params
#5293
Conversation
🦋 Changeset detectedLatest commit: abe27cb The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types 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 |
memory
--> calldata
for read-only function params
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 is a good reason why we use memory instead of calldata here: We don't know how these function will be called or how they will be overidden.
For example, in contracts/utils/cryptography/MessageHashUtils.sol
, what makes you think the message
and data
are in calldata? In most cases, this data will be produced onchain, using some variant of abi.encode
.
Similarly for contracts/utils/cryptography/RSA.sol
. The data buffer is likelly to live in memory. Similarly, the public key part (e
and n
) are likelly to be in some form of storage.
For these reason I would strongly oppose forcing the use of calldata when no alternative exist, and were there is any doubts about where the value may come from.
Fixes #5291