From e4a15fbecdfcaa2bc6a988b02af33ea43c99508d Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Wed, 5 Jan 2022 16:28:57 +0100 Subject: [PATCH] fix: Add new event AddressSetAsProxy for imple address updates --- .../interfaces/IPoolAddressesProvider.sol | 37 ++++++++++++++----- .../configuration/PoolAddressesProvider.sol | 13 ++++--- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/contracts/interfaces/IPoolAddressesProvider.sol b/contracts/interfaces/IPoolAddressesProvider.sol index 2fc18d482..528551ccc 100644 --- a/contracts/interfaces/IPoolAddressesProvider.sol +++ b/contracts/interfaces/IPoolAddressesProvider.sol @@ -67,17 +67,36 @@ interface IPoolAddressesProvider { * @notice Emitted when a new proxy is created. * @param id The identifier of the proxy * @param proxyAddress The address of the created proxy contract + * @param implementationAddress The address of the implementation contract */ - event ProxyCreated(bytes32 indexed id, address indexed proxyAddress); + event ProxyCreated( + bytes32 indexed id, + address indexed proxyAddress, + address indexed implementationAddress + ); /** - * @notice Emitted when a new contract address is registered. + * @notice Emitted when a new non-proxied contract address is registered. * @param id The identifier of the contract - * @param implementationAddress The address of the implementation contract - * @param hasProxy True if the address is registered behind a proxy, false otherwise + * @param oldAddress The address of the old contract + * @param newAddress The address of the new contract */ - event AddressSet(bytes32 indexed id, address indexed implementationAddress, bool hasProxy); - + event AddressSet(bytes32 indexed id, address indexed oldAddress, address indexed newAddress); + + /** + * @notice Emitted when a new proxied contract address is registered. + * @param id The identifier of the contract + * @param proxyAddress The address of the proxy contract + * @param oldImplementationAddress The address of the old implementation contract + * @param newImplementationAddress The address of the new implementation contract + */ + event AddressSetAsProxy( + bytes32 indexed id, + address proxyAddress, + address indexed oldImplementationAddress, + address indexed newImplementationAddress + ); + /** * @notice Returns the id of the Aave market to which this contract points to. * @return The market id @@ -102,13 +121,13 @@ interface IPoolAddressesProvider { /** * @notice General function to update the implementation of a proxy registered with * certain `id`. If there is no proxy registered, it will instantiate one and - * set as implementation the `impl`. + * set as implementation the `newImplementationAddress`. * @dev IMPORTANT Use this function carefully, only for ids that don't have an explicit * setter function, in order to avoid unexpected consequences * @param id The id - * @param implementationAddress The address of the new implementation + * @param newImplementationAddress The address of the new implementation */ - function setAddressAsProxy(bytes32 id, address implementationAddress) external; + function setAddressAsProxy(bytes32 id, address newImplementationAddress) external; /** * @notice Sets an address for an id replacing the address saved in the addresses map. diff --git a/contracts/protocol/configuration/PoolAddressesProvider.sol b/contracts/protocol/configuration/PoolAddressesProvider.sol index 6581b84ff..816e140de 100644 --- a/contracts/protocol/configuration/PoolAddressesProvider.sol +++ b/contracts/protocol/configuration/PoolAddressesProvider.sol @@ -49,18 +49,21 @@ contract PoolAddressesProvider is Ownable, IPoolAddressesProvider { /// @inheritdoc IPoolAddressesProvider function setAddress(bytes32 id, address newAddress) external override onlyOwner { + address oldAddress = _addresses[id]; _addresses[id] = newAddress; - emit AddressSet(id, newAddress, false); + emit AddressSet(id, oldAddress, newAddress); } /// @inheritdoc IPoolAddressesProvider - function setAddressAsProxy(bytes32 id, address implementationAddress) + function setAddressAsProxy(bytes32 id, address newImplementationAddress) external override onlyOwner { - _updateImpl(id, implementationAddress); - emit AddressSet(id, implementationAddress, true); + address proxyAddress = _addresses[id]; + address oldImplementationAddress = _getProxyImplementation(id); + _updateImpl(id, newImplementationAddress); + emit AddressSetAsProxy(id, proxyAddress, oldImplementationAddress, newImplementationAddress); } /// @inheritdoc IPoolAddressesProvider @@ -169,7 +172,7 @@ contract PoolAddressesProvider is Ownable, IPoolAddressesProvider { _addresses[id] = proxyAddress = address(proxy); proxy.initialize(newAddress, params); - emit ProxyCreated(id, proxyAddress); + emit ProxyCreated(id, proxyAddress, newAddress); } else { proxy.upgradeToAndCall(newAddress, params); }