Skip to content

Commit b31f768

Browse files
authored
Update wormhole receiver contract (#398)
- Add chainId - Remove receiver ownership
1 parent 45ce077 commit b31f768

File tree

7 files changed

+14
-42
lines changed

7 files changed

+14
-42
lines changed

ethereum/contracts/wormhole-receiver/ReceiverGetters.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ pragma solidity ^0.8.0;
66
import "./ReceiverState.sol";
77

88
contract ReceiverGetters is ReceiverState {
9-
function owner() public view returns (address) {
10-
return _state.owner;
11-
}
12-
139
function getGuardianSet(
1410
uint32 index
1511
) public view returns (ReceiverStructs.GuardianSet memory) {
@@ -34,6 +30,10 @@ contract ReceiverGetters is ReceiverState {
3430
return _state.initializedImplementations[impl];
3531
}
3632

33+
function chainId() public view returns (uint16) {
34+
return _state.provider.chainId;
35+
}
36+
3737
function governanceChainId() public view returns (uint16) {
3838
return _state.provider.governanceChainId;
3939
}

ethereum/contracts/wormhole-receiver/ReceiverGovernance.sol

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,6 @@ abstract contract ReceiverGovernance is
5656
updateGuardianSetIndex(upgrade.newGuardianSetIndex);
5757
}
5858

59-
function upgradeImplementation(address newImplementation) public onlyOwner {
60-
address currentImplementation = _getImplementation();
61-
62-
_upgradeTo(newImplementation);
63-
64-
// Call initialize function of the new implementation
65-
(bool success, bytes memory reason) = newImplementation.delegatecall(
66-
abi.encodeWithSignature("initialize()")
67-
);
68-
69-
require(success, string(reason));
70-
71-
emit ContractUpgraded(currentImplementation, newImplementation);
72-
}
73-
7459
function verifyGovernanceVM(
7560
ReceiverStructs.VM memory vm
7661
) internal view returns (bool, string memory) {
@@ -100,19 +85,4 @@ abstract contract ReceiverGovernance is
10085

10186
return (true, "");
10287
}
103-
104-
function transferOwnership(address newOwner) public onlyOwner {
105-
require(newOwner != address(0), "new owner cannot be the zero address");
106-
107-
address currentOwner = owner();
108-
109-
setOwner(newOwner);
110-
111-
emit OwnershipTransfered(currentOwner, newOwner);
112-
}
113-
114-
modifier onlyOwner() {
115-
require(owner() == msg.sender, "caller is not the owner");
116-
_;
117-
}
11888
}

ethereum/contracts/wormhole-receiver/ReceiverSetters.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ pragma solidity ^0.8.0;
66
import "./ReceiverState.sol";
77

88
contract ReceiverSetters is ReceiverState {
9-
function setOwner(address owner_) internal {
10-
_state.owner = owner_;
11-
}
12-
139
function updateGuardianSetIndex(uint32 newIndex) internal {
1410
_state.guardianSetIndex = newIndex;
1511
}
@@ -35,6 +31,10 @@ contract ReceiverSetters is ReceiverState {
3531
_state.consumedGovernanceActions[hash] = true;
3632
}
3733

34+
function setChainId(uint16 chainId) internal {
35+
_state.provider.chainId = chainId;
36+
}
37+
3838
function setGovernanceChainId(uint16 chainId) internal {
3939
_state.provider.governanceChainId = chainId;
4040
}

ethereum/contracts/wormhole-receiver/ReceiverSetup.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@ contract ReceiverSetup is ReceiverSetters, ERC1967Upgrade {
1212
function setup(
1313
address implementation,
1414
address[] memory initialGuardians,
15+
uint16 chainId,
1516
uint16 governanceChainId,
1617
bytes32 governanceContract
1718
) public {
1819
require(initialGuardians.length > 0, "no guardians specified");
1920

20-
setOwner(msg.sender);
21-
2221
ReceiverStructs.GuardianSet memory initialGuardianSet = ReceiverStructs
2322
.GuardianSet({keys: initialGuardians, expirationTime: 0});
2423

2524
storeGuardianSet(initialGuardianSet, 0);
2625
// initial guardian set index is 0, which is the default value of the storage slot anyways
2726

27+
setChainId(chainId);
28+
2829
setGovernanceChainId(governanceChainId);
2930
setGovernanceContract(governanceContract);
3031

ethereum/contracts/wormhole-receiver/ReceiverState.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ contract ReceiverEvents {
2121
contract ReceiverStorage {
2222
struct WormholeState {
2323
ReceiverStructs.Provider provider;
24-
// contract deployer
25-
address owner;
2624
// Mapping of guardian_set_index => guardian set
2725
mapping(uint32 => ReceiverStructs.GuardianSet) guardianSets;
2826
// Current active guardian set index

ethereum/contracts/wormhole-receiver/ReceiverStructs.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pragma solidity ^0.8.0;
55

66
interface ReceiverStructs {
77
struct Provider {
8+
uint16 chainId;
89
uint16 governanceChainId;
910
bytes32 governanceContract;
1011
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const WormholeReceiver = artifacts.require("WormholeReceiver");
99

1010
// CONFIG
1111
const initialSigners = JSON.parse(process.env.INIT_SIGNERS);
12+
const wormholeReceiverChainId = process.env.WORMHOLE_RECEIVER_CHAIN_ID;
1213
const governanceChainId = process.env.INIT_GOV_CHAIN_ID;
1314
const governanceContract = process.env.INIT_GOV_CONTRACT; // bytes32
1415

@@ -25,6 +26,7 @@ module.exports = async function (deployer, network) {
2526
.setup(
2627
ReceiverImplementation.address,
2728
initialSigners,
29+
wormholeReceiverChainId,
2830
governanceChainId,
2931
governanceContract
3032
)

0 commit comments

Comments
 (0)