-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Add deprecation warnings for send(), transfer(), ABI coder v1, contract comparisons, virtual modifiers and memory-safe-assembly comment
#16174
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
base: develop
Are you sure you want to change the base?
Conversation
|
Just a quick heads up: note that the issues you listed in the description should not be closed when this PR is merged. They're about feature removals and adding a warning is just an intermediate step, not a complete solution. |
3c00eb6 to
f052fe2
Compare
6d32b8c to
2531e30
Compare
2531e30 to
cb21835
Compare
|
This pull request is stale because it has been open for 14 days with no activity. |
cb21835 to
0c67bef
Compare
|
This pull request is stale because it has been open for 14 days with no activity. |
0c67bef to
2cf221d
Compare
2cf221d to
ab2e083
Compare
| call to the contract with empty calldata. This is the function that is executed | ||
| on plain Ether transfers (e.g. via ``.send()`` or ``.transfer()``). If no such | ||
| function exists, but a payable :ref:`fallback function <fallback-function>` |
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.
Perhaps not in this PR but I think we will have to go through the docs regarding send and transfer and see where we have to update them wrt best practices regarding send and transfer
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.
Yeah, I was thinking about this. We will need to update parts of the docs to reflect the deprecation of these functionalities.
I guess a separate PR for that would be better for organization purposes.
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.
Yeah. It has to be done before we release though. :)
docs/assembly.rst
Outdated
| backward-compatibility with older compiler versions, prefer using the dialect string. | ||
| .. warning:: | ||
| The ``memory-safe-assembly`` special comment will be deprecated in the next breaking version (0.9). | ||
| So, if you are not concerned with backward-compatibility with older compiler versions, prefer using the dialect string. |
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.
Out of curiosity, do we have a backwards-compatible way of handling this?
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.
I don't think so.
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.
No, the comment was the backwards-compatible way to do it.
|
Please go over the docs again, we will deprecate things before 0.9 and with 0.9 or a later version they will be removed. So "Note that XYZ will be deprecated in 0.9" should be "Note that XYZ are deprecated and scheduled for removal in 0.9". I find it a bit problematic to show deprecated code in the examples. This should be updated to be according to best practices. I am not sure if this PR is the right place for it, but if you find it's not, it should be done in a follow-up. Generally I'd have liked that alongside the .. warning::
The following patterns are deprecated and will be removed in v0.9:
- ``address.send()`` - Use ... instead
- ``address.transfer()`` - Use ...Also the code-emitted warnings have to be updated to reflect that things are deprecated now and will be removed in a future breaking release. Please present alternatives there (like for the send stuff to use call) and if possible it would be great to provide a link to the docs where this is described. Otherwise users are left stranded. Think what you would like to see if a compiler presents you with a deprecation warning. Implementation-wise it looks good. |
c203f66 to
3fb9ccd
Compare
matheusaaguiar
left a comment
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.
I have changed according to most of your suggestions @clonker. There are still some places where we need to properly rewrite or erase the docs to reflect the deprecation in the examples (send/transfer and virtual modifiers).
clonker
left a comment
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.
some more comments :)
88b472b to
db310b6
Compare
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.
Unfortunately still some things to do:
Here we have documentation of send and transfer but no mention that they're deprecated:
- docs/units-and-global-variables.rst (Members of Address Types section)
- docs/cheatsheet.rst (Address Related section)
Hope I didn't miss anything else in the documentation beyond these two. Wouldn't hurt to double-check.
Then there needs to be a changelog entry. We should probably also start a docs/090-breaking-changes.rst and document this there.
b59a2b4 to
86da905
Compare
I have started to do that, but will submit in a separate PR along other doc revisions, if you think it is ok. I created #16274 to track the work needed in order to update the docs for the breaking changes of v.0.9. |
clonker
left a comment
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.
Thanks for creating the tracking issue! Some more minor things I found in a final pass.
a260c59 to
069863a
Compare
| 2424_error, | ||
| _assembly.location(), | ||
| "Natspec memory safe annotation for inline assembly is deprecated and scheduled for removal in the next breaking version (0.9)." | ||
| "Natspec 'memory-safe-assembly' special comment for inline assembly is deprecated and scheduled for removal in the next breaking version (0.9)." |
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.
@clonker I've reworded the warning message here to be more in line with the suggestion you made for the changelog entry....what do you think?
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.
Nice! Thinking about it again, it would be even better to mention that the assembly block annotation should be used instead. Like "Use the 'memory-safe' assembly block annotation instead". Or go with the whole sentence as in the docs.
clonker
left a comment
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.
I think in principle it is already good to go but we can still improve things a tiny bit so that the style is uniform, then there are no rough edges left. Then rebase, squash, merge :) for the future I think it would be beneficial to collect the introduced docstrings and/or warnings separately in a comment on the PR, then it's easier to check that the style is uniform. What do you think?
Documentation:
Note that
sendandtransferare deprecated and scheduled for removal in the next breaking version (0.9).
You are encouraged to use the :ref:call function <address_related>with an optionally provided maximum
amount of gas (default forwards all remaining gas) and an empty calldata parameter, e.g.,call{value: amount}("").
Initially I suggested the "you are encouraged to" bit, but perhaps it's better to keep it brief and just say "Use the call function with an ...". I'll leave that up to you.
send/transferis deprecated and scheduled for removal in the next breaking version (0.9).
You are encouraged to use the :ref:call function <address_call_functions>with an optionally provided maximum
amount of gas (default forwards all remaining gas) and an empty calldata parameter, e.g.,call{value: amount}("").
Same as above.
virtualmodifiers are deprecated and scheduled for removal in the next breaking version (0.9).
You might want to unify the style and add a "Note that" or remove it in all places.
The
memory-safe-assemblyspecial comment is deprecated and scheduled for
removal in the next breaking version (0.9).
For new code targeting recent compilers, prefer specifying the assembly block annotation.
Same as above, maybe instead of "prefer specifying" it should be "specify".
The ABI coder v1 is deprecated and scheduled for removal in the next breaking version (0.9).
Optionally you can expand and say "Use ABI coder v2 instead."
Warnings:
Natspec 'memory-safe-assembly' special comment for inline assembly is deprecated and scheduled for removal in the next breaking version (0.9).
Add a sentence what to use instead (ie the assembly block annotation).
ABI coder v1 is deprecated and scheduled for removal in the next breaking version (0.9).
Add a sentence what to use instead (ie ABI coder v2).
Virtual modifiers are deprecated and scheduled for removal in the next breaking version (0.9).
This is good. Although also here one can think about adding that there is no replacement (or is there?). I'll leave that up to you.
Comparison of variables of contract type is deprecated and scheduled for removal in the next breaking version (0.9). Instead, use an explicit cast to address type.
Just a small language / word order thing, I would write "Use an explicit cast to address type and compare the addresses instead."
'send/transfer' is deprecated and scheduled for removal in the next breaking version (0.9). It is encouraged to use 'call{{value: }}()' instead.
Same as the first point in the documentation, I'd unify it and make it more imperative, ie, "Use 'call{{value: }}()' instead".
|
@clonker I think I have addressed all of your points. |
clonker
left a comment
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.
I think it's good now! Just rebase, squash and then for all I'm concerned we can merge this.
cameel
left a comment
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.
I still wanted to make sure everything is fine here before we merge. Here's some quick feedback.
docs/assembly.rst
Outdated
| The ``memory-safe-assembly`` special comment is deprecated and scheduled for | ||
| removal in the next breaking version (0.9). |
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.
I'd not commit to a specific version here (or in error messages). Hopefully we do remove them in 0.9, but plans can change and these kinds of things sometimes stay in longer.
| The ``memory-safe-assembly`` special comment is deprecated and scheduled for | |
| removal in the next breaking version (0.9). | |
| The ``memory-safe-assembly`` special comment is deprecated and scheduled for removal. |
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.
In fact this is actually incorrect in case of contract comparisons. These will not yet be removed in 0.9. Note that the feature is in the "Deprecate Only" column on the 0.9 planning board.
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.
In case it wasn't clear, my comment was not only about this one instance. I see there are still quite a few error messages and notes in docs that explicitly mention 0.9.
docs/cheatsheet.rst
Outdated
| .. warning:: | ||
| ``send`` and ``transfer`` are deprecated and scheduled for removal in the next breaking version (0.9). | ||
| Use the :ref:`call function <address_call_functions>` with an optionally provided maximum amount of | ||
| gas (default forwards all remaining gas) and an empty calldata parameter, e.g., ``call{value: amount}("")``. |
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.
| gas (default forwards all remaining gas) and an empty calldata parameter, e.g., ``call{value: amount}("")``. | |
| gas (by default forwards all remaining gas) and an empty calldata parameter, e.g., ``call{value: amount}("")``. |
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.
Also, this is not exactly true due to the 63/64th gas rule.
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.
Ah. Then this is already wrong, too: https://docs.soliditylang.org/en/v0.8.30/security-considerations.html#reentrancy - which is where I got the idea that it fwds all remaining gas in the first place.
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.
I fixed it here and also in the Security Considerations section.
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 are still quite a few places that say "forwards all remaining gas". Looks like you changed this only in some of them.
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.
Ah. Then this is already wrong, too: https://docs.soliditylang.org/en/v0.8.30/security-considerations.html#reentrancy - which is where I got the idea that it fwds all remaining gas in the first place.
Interesting. I assumed we were more specific about it elsewhere in the docs. Now that I think about it, it's not incorrect, because that's what the compiler actually does - it sets the value to gas(). It's the EVM that ignores our exact value and caps it at 63/64th. Also, it only happens on tangerineWhistle and later EVMs. On older ones you actually do get all the gas forwarded. Maybe that part of the docs intentionally skipped all that complexity. Or maybe it was written before the rule was added.
Still, that's not what the user sees, so I think we should mention it in some way. The call in the end gets only 63/64th and the user in most cases does not even know or care who sets the limit. I'd rewrite the whole note like this:
`send()` and `transfer()` are deprecated and scheduled for removal.
Simple ether transfers can still be performed using the [`call()`](...) function with empty payload, i.e., `call{value: <amount>}("")`.
By default this forwards all the remaining gas, subject to additional limits imposed by some EVM versions (such as the [63/64th rule](https://eips.ethereum.org/EIPS/eip-150) introduced by `tangerineWhistle`).
As with any external call, the `gas` call option can be used to set a lower limit.
While it is possible to recreate the functionality by explicitly setting the limit to the value of the stipend (2300 gas), this value no longer holds its original meaning due to changing opcode costs.
It is recommended to use different means to protect against reentrancy.
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.
I don't think these SMTChecker tests require specifically transfer. We should update them to use call - we'll have to do that sooner or later anyway.
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.
not part of the PR to change this, is it?
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.
I started to work on those in #16291.
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.
not part of the PR to change this, is it?
Could be either way. I'd change this here if I was doing the PR myself, but a separate PR is fine too.
test/externalTests/zeppelin.sh
Outdated
| .setAction(async (args, hre, runSuper) => { | ||
| const result = await runSuper(args); |
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.
Use 4-space indent.
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.
Done.
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.
I mean, for all lines, not just this single one :P
d57fae4 to
7e86c8e
Compare
c55108b to
d97549f
Compare
| m_errorReporter.warning( | ||
| 2424_error, | ||
| _assembly.location(), | ||
| "Natspec 'memory-safe-assembly' special comment for inline assembly is deprecated and " |
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.
If you do not quote memory-safe below, so I would not quote this either.
| "Natspec 'memory-safe-assembly' special comment for inline assembly is deprecated and " | |
| "Natspec memory-safe-assembly special comment for inline assembly is deprecated and " |
send(), transfer(), ABI coder v1, contract comparisons, virtual modifiers and memory-safe-assembly comment
send(), transfer(), ABI coder v1, contract comparisons, virtual modifiers and memory-safe-assembly commentsend(), transfer(), ABI coder v1, contract comparisons, virtual modifiers and memory-safe-assembly comment
Partially solves #15795.
Deprecation warnings for:
.sendand.transferRemove .send and .transfer. #7455./// @solidity memory-safe-assemblynatspec comment.