From 2a060552382f221cbdd31dab51d1b680d693176a Mon Sep 17 00:00:00 2001
From: ayushkaul <ayushk.kaul3@gmail.com>
Date: Mon, 27 Jul 2020 16:21:00 +0530
Subject: [PATCH 1/2] fix: overriden owner in upgradable proxy

---
 contracts/common/misc/UpgradableProxy.sol | 20 ++++++++++----------
 test/units/UpgradableProxy.test.js        |  8 ++++----
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/contracts/common/misc/UpgradableProxy.sol b/contracts/common/misc/UpgradableProxy.sol
index b329949f7..86f1f619b 100644
--- a/contracts/common/misc/UpgradableProxy.sol
+++ b/contracts/common/misc/UpgradableProxy.sol
@@ -4,13 +4,13 @@ import {DelegateProxy} from "./DelegateProxy.sol";
 
 contract UpgradableProxy is DelegateProxy {
     event ProxyUpdated(address indexed _new, address indexed _old);
-    event OwnerUpdate(address _new, address _old);
+    event ProxyOwnerUpdate(address _new, address _old);
 
     bytes32 constant IMPLEMENTATION_SLOT = keccak256("matic.network.proxy.implementation");
     bytes32 constant OWNER_SLOT = keccak256("matic.network.proxy.owner");
 
     constructor(address _proxyTo) public {
-        setOwner(msg.sender);
+        setProxyOwner(msg.sender);
         setImplementation(_proxyTo);
     }
 
@@ -21,15 +21,15 @@ contract UpgradableProxy is DelegateProxy {
     }
 
     modifier onlyProxyOwner() {
-        require(loadOwner() == msg.sender, "NOT_OWNER");
+        require(loadProxyOwner() == msg.sender, "NOT_OWNER");
         _;
     }
 
-    function owner() external view returns(address) {
-        return loadOwner();
+    function proxyOwner() external view returns(address) {
+        return loadProxyOwner();
     }
 
-    function loadOwner() internal view returns(address) {
+    function loadProxyOwner() internal view returns(address) {
         address _owner;
         bytes32 position = OWNER_SLOT;
         assembly {
@@ -51,13 +51,13 @@ contract UpgradableProxy is DelegateProxy {
         return _impl;
     }
 
-    function transferOwnership(address newOwner) public onlyProxyOwner {
+    function transferProxyOwnership(address newOwner) public onlyProxyOwner {
         require(newOwner != address(0), "ZERO_ADDRESS");
-        emit OwnerUpdate(newOwner, loadOwner());
-        setOwner(newOwner);
+        emit ProxyOwnerUpdate(newOwner, loadProxyOwner());
+        setProxyOwner(newOwner);
     }
 
-    function setOwner(address newOwner) private {
+    function setProxyOwner(address newOwner) private {
         bytes32 position = OWNER_SLOT;
         assembly {
             sstore(position, newOwner)
diff --git a/test/units/UpgradableProxy.test.js b/test/units/UpgradableProxy.test.js
index 14ddc9da7..24e66ffbf 100644
--- a/test/units/UpgradableProxy.test.js
+++ b/test/units/UpgradableProxy.test.js
@@ -64,7 +64,7 @@ contract('UpgradableProxy', function() {
     })
   })
 
-  describe('transferOwnership', function() {
+  describe('transferProxyOwnership', function() {
     before(doDeploy)
     before(async function() {
       this.newOwner = wallets[1].getChecksumAddressString()
@@ -72,17 +72,17 @@ contract('UpgradableProxy', function() {
 
     describe('when from is not owner', function() {
       it('reverts', async function() {
-        await expectRevert(this.proxy.transferOwnership(this.newOwner, { from: this.newOwner }), 'NOT_OWNER')
+        await expectRevert(this.proxy.transferProxyOwnership(this.newOwner, { from: this.newOwner }), 'NOT_OWNER')
       })
     })
 
     describe('when from is owner', function() {
       it('must update owner', async function() {
-        await this.proxy.transferOwnership(this.newOwner)
+        await this.proxy.transferProxyOwnership(this.newOwner)
       })
 
       it('must have correct owner', async function() {
-        const owner = await this.proxy.owner()
+        const owner = await this.proxy.proxyOwner()
         owner.should.be.equal(this.newOwner)
       })
     })

From 8e1096c79d7a926c39f7609b8ce90efc88087289 Mon Sep 17 00:00:00 2001
From: ayushkaul <ayushk.kaul3@gmail.com>
Date: Mon, 27 Jul 2020 17:06:48 +0530
Subject: [PATCH 2/2] fix: contract change

---
 contracts/staking/validatorShare/ValidatorShareFactory.sol | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contracts/staking/validatorShare/ValidatorShareFactory.sol b/contracts/staking/validatorShare/ValidatorShareFactory.sol
index 6ef549953..85a3f97d6 100644
--- a/contracts/staking/validatorShare/ValidatorShareFactory.sol
+++ b/contracts/staking/validatorShare/ValidatorShareFactory.sol
@@ -10,7 +10,7 @@ contract ValidatorShareFactory {
     function create(uint256 validatorId, address loggerAddress, address registry) public returns (address) {
         ValidatorShareProxy proxy = new ValidatorShareProxy(registry);
 
-        proxy.transferOwnership(msg.sender);
+        proxy.transferProxyOwnership(msg.sender);
 
         address proxyAddr = address(proxy);
         (bool success, bytes memory data) = proxyAddr.call.gas(gasleft())(