Forráskód Böngészése

Update wormhole receiver contract

- Add chainId
- Remove receiver ownership
Ali Behjati 3 éve
szülő
commit
3773163e28

+ 4 - 4
ethereum/contracts/wormhole-receiver/ReceiverGetters.sol

@@ -6,10 +6,6 @@ pragma solidity ^0.8.0;
 import "./ReceiverState.sol";
 
 contract ReceiverGetters is ReceiverState {
-    function owner() public view returns (address) {
-        return _state.owner;
-    }
-
     function getGuardianSet(
         uint32 index
     ) public view returns (ReceiverStructs.GuardianSet memory) {
@@ -34,6 +30,10 @@ contract ReceiverGetters is ReceiverState {
         return _state.initializedImplementations[impl];
     }
 
+    function chainId() public view returns (uint16) {
+        return _state.provider.chainId;
+    }
+
     function governanceChainId() public view returns (uint16) {
         return _state.provider.governanceChainId;
     }

+ 0 - 30
ethereum/contracts/wormhole-receiver/ReceiverGovernance.sol

@@ -56,21 +56,6 @@ abstract contract ReceiverGovernance is
         updateGuardianSetIndex(upgrade.newGuardianSetIndex);
     }
 
-    function upgradeImplementation(address newImplementation) public onlyOwner {
-        address currentImplementation = _getImplementation();
-
-        _upgradeTo(newImplementation);
-
-        // Call initialize function of the new implementation
-        (bool success, bytes memory reason) = newImplementation.delegatecall(
-            abi.encodeWithSignature("initialize()")
-        );
-
-        require(success, string(reason));
-
-        emit ContractUpgraded(currentImplementation, newImplementation);
-    }
-
     function verifyGovernanceVM(
         ReceiverStructs.VM memory vm
     ) internal view returns (bool, string memory) {
@@ -100,19 +85,4 @@ abstract contract ReceiverGovernance is
 
         return (true, "");
     }
-
-    function transferOwnership(address newOwner) public onlyOwner {
-        require(newOwner != address(0), "new owner cannot be the zero address");
-
-        address currentOwner = owner();
-
-        setOwner(newOwner);
-
-        emit OwnershipTransfered(currentOwner, newOwner);
-    }
-
-    modifier onlyOwner() {
-        require(owner() == msg.sender, "caller is not the owner");
-        _;
-    }
 }

+ 4 - 4
ethereum/contracts/wormhole-receiver/ReceiverSetters.sol

@@ -6,10 +6,6 @@ pragma solidity ^0.8.0;
 import "./ReceiverState.sol";
 
 contract ReceiverSetters is ReceiverState {
-    function setOwner(address owner_) internal {
-        _state.owner = owner_;
-    }
-
     function updateGuardianSetIndex(uint32 newIndex) internal {
         _state.guardianSetIndex = newIndex;
     }
@@ -35,6 +31,10 @@ contract ReceiverSetters is ReceiverState {
         _state.consumedGovernanceActions[hash] = true;
     }
 
+    function setChainId(uint16 chainId) internal {
+        _state.provider.chainId = chainId;
+    }
+
     function setGovernanceChainId(uint16 chainId) internal {
         _state.provider.governanceChainId = chainId;
     }

+ 3 - 2
ethereum/contracts/wormhole-receiver/ReceiverSetup.sol

@@ -12,19 +12,20 @@ contract ReceiverSetup is ReceiverSetters, ERC1967Upgrade {
     function setup(
         address implementation,
         address[] memory initialGuardians,
+        uint16 chainId,
         uint16 governanceChainId,
         bytes32 governanceContract
     ) public {
         require(initialGuardians.length > 0, "no guardians specified");
 
-        setOwner(msg.sender);
-
         ReceiverStructs.GuardianSet memory initialGuardianSet = ReceiverStructs
             .GuardianSet({keys: initialGuardians, expirationTime: 0});
 
         storeGuardianSet(initialGuardianSet, 0);
         // initial guardian set index is 0, which is the default value of the storage slot anyways
 
+        setChainId(chainId);
+
         setGovernanceChainId(governanceChainId);
         setGovernanceContract(governanceContract);
 

+ 0 - 2
ethereum/contracts/wormhole-receiver/ReceiverState.sol

@@ -21,8 +21,6 @@ contract ReceiverEvents {
 contract ReceiverStorage {
     struct WormholeState {
         ReceiverStructs.Provider provider;
-        // contract deployer
-        address owner;
         // Mapping of guardian_set_index => guardian set
         mapping(uint32 => ReceiverStructs.GuardianSet) guardianSets;
         // Current active guardian set index

+ 1 - 0
ethereum/contracts/wormhole-receiver/ReceiverStructs.sol

@@ -5,6 +5,7 @@ pragma solidity ^0.8.0;
 
 interface ReceiverStructs {
     struct Provider {
+        uint16 chainId;
         uint16 governanceChainId;
         bytes32 governanceContract;
     }

+ 2 - 0
ethereum/migrations/prod-receiver/2_deploy_wormhole_receiver.js

@@ -9,6 +9,7 @@ const WormholeReceiver = artifacts.require("WormholeReceiver");
 
 // CONFIG
 const initialSigners = JSON.parse(process.env.INIT_SIGNERS);
+const wormholeReceiverChainId = process.env.WORMHOLE_RECEIVER_CHAIN_ID;
 const governanceChainId = process.env.INIT_GOV_CHAIN_ID;
 const governanceContract = process.env.INIT_GOV_CONTRACT; // bytes32
 
@@ -25,6 +26,7 @@ module.exports = async function (deployer, network) {
     .setup(
       ReceiverImplementation.address,
       initialSigners,
+      wormholeReceiverChainId,
       governanceChainId,
       governanceContract
     )