Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(Proxy): remove unneeded fallback function
https://forum.openzeppelin.com/t/proxy-sol-fallback/36951/8


The fallback alone would indeed be enough.

 Fallback is not limited to` msg.value == 0` (if its marked `payable`). Both functions can support value.

The difference between receive and fallback is in the msg.data. If the calldata is empty and if there is a receive function, it fill be used. Otherwise, fallback is used. This means that regardless of the value, fallback will be called if there is some data. `fallback` is also the one that is called if there is no data, but receive is not defined.

So why do we have a receive function that is not really needed? To silent solidity warnings that sometimes happen when you have a fallback function but no receive function.
- @Amxx 

see <OpenZeppelin/openzeppelin-contracts#4434 (comment)>
  • Loading branch information
sambacha authored Jul 18, 2023
commit df7d215bd19d51059db8122c1f15d39b150f4b6c
10 changes: 1 addition & 9 deletions src/Proxy.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)

pragma solidity 0.8.19;
pragma solidity ^0.8.19;

/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
Expand Down Expand Up @@ -68,14 +68,6 @@ abstract contract Proxy {
_fallback();
}

/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}

/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
Expand Down