Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 100949b

Browse files
authoredFeb 20, 2024··
Add WormholeEndpoint Special Relayer (#129)
* Add special relayer quoting logic to handle specialized target chain deliveries * Fix tests * Remove unnecesary token param from function calls * Use word size instead of bool * Fix integration tests
1 parent 6c84ade commit 100949b

14 files changed

+179
-72
lines changed
 

‎src/Endpoint.sol

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ abstract contract Endpoint is PausableOwnable {
2424
EndpointStructs.EndpointInstruction memory endpointInstruction
2525
) internal view virtual returns (uint256);
2626

27+
function getManagerToken() public view virtual returns (address);
28+
2729
/// @notice pause the endpoint
2830
function _pauseEndpoint() internal {
2931
_pause();

‎src/EndpointAndManager.sol

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ abstract contract EndpointAndManager is Endpoint, Manager, Implementation {
5858
);
5959
}
6060

61+
function getManagerToken() public view override returns (address) {
62+
return token;
63+
}
64+
6165
function _deliverToManager(
6266
uint16 sourceChainId,
6367
bytes32 sourceManagerAddress,

‎src/EndpointStandalone.sol

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
pragma solidity >=0.8.8 <0.9.0;
33

44
import "./Endpoint.sol";
5+
import "./interfaces/IManager.sol";
56
import "./interfaces/IManagerStandalone.sol";
67
import "./interfaces/IEndpointStandalone.sol";
78
import "./libraries/Implementation.sol";
@@ -18,9 +19,12 @@ abstract contract EndpointStandalone is
1819
/// @dev updating bridgeManager requires a new Endpoint deployment.
1920
/// Projects should implement their own governance to remove the old Endpoint contract address and then add the new one.
2021
address public immutable manager;
22+
address public immutable managerToken;
2123

2224
constructor(address _manager) {
2325
manager = _manager;
26+
// TODO: ERC-165 check on the manager contract, otherwise revert
27+
managerToken = IManager(manager).token();
2428
}
2529

2630
modifier onlyManager() {
@@ -54,6 +58,7 @@ abstract contract EndpointStandalone is
5458
/// @dev When we add new immutables, this function should be updated
5559
function _checkImmutables() internal view override {
5660
assert(this.manager() == manager);
61+
assert(this.managerToken() == managerToken);
5762
}
5863

5964
function upgrade(address newImplementation) external onlyOwner {
@@ -90,4 +95,8 @@ abstract contract EndpointStandalone is
9095
sourceChainId, sourceManagerAddress, payload
9196
);
9297
}
98+
99+
function getManagerToken() public view override returns (address) {
100+
return managerToken;
101+
}
93102
}

‎src/WormholeEndpoint.sol

+54-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "wormhole-solidity-sdk/interfaces/IWormhole.sol";
77

88
import "./libraries/EndpointHelpers.sol";
99
import "./interfaces/IWormholeEndpoint.sol";
10+
import "./interfaces/ISpecialRelayer.sol";
1011
import "./Endpoint.sol";
1112

1213
abstract contract WormholeEndpoint is Endpoint, IWormholeEndpoint, IWormholeReceiver {
@@ -24,6 +25,7 @@ abstract contract WormholeEndpoint is Endpoint, IWormholeEndpoint, IWormholeRece
2425

2526
IWormhole public immutable wormhole;
2627
IWormholeRelayer public immutable wormholeRelayer;
28+
ISpecialRelayer public immutable specialRelayer;
2729
uint256 public immutable wormholeEndpoint_evmChainId;
2830

2931
struct WormholeEndpointInstruction {
@@ -41,6 +43,9 @@ abstract contract WormholeEndpoint is Endpoint, IWormholeEndpoint, IWormholeRece
4143
bytes32 public constant WORMHOLE_RELAYING_ENABLED_CHAINS_SLOT =
4244
bytes32(uint256(keccak256("whEndpoint.relayingEnabledChains")) - 1);
4345

46+
bytes32 public constant SPECIAL_RELAYING_ENABLED_CHAINS_SLOT =
47+
bytes32(uint256(keccak256("whEndpoint.specialRelayingEnabledChains")) - 1);
48+
4449
bytes32 public constant WORMHOLE_EVM_CHAIN_IDS =
4550
bytes32(uint256(keccak256("whEndpoint.evmChainIds")) - 1);
4651

@@ -71,18 +76,29 @@ abstract contract WormholeEndpoint is Endpoint, IWormholeEndpoint, IWormholeRece
7176
function _getWormholeRelayingEnabledChainsStorage()
7277
internal
7378
pure
74-
returns (mapping(uint16 => bool) storage $)
79+
returns (mapping(uint16 => uint256) storage $)
7580
{
7681
uint256 slot = uint256(WORMHOLE_RELAYING_ENABLED_CHAINS_SLOT);
7782
assembly ("memory-safe") {
7883
$.slot := slot
7984
}
8085
}
8186

87+
function _getSpecialRelayingEnabledChainsStorage()
88+
internal
89+
pure
90+
returns (mapping(uint16 => uint256) storage $)
91+
{
92+
uint256 slot = uint256(SPECIAL_RELAYING_ENABLED_CHAINS_SLOT);
93+
assembly ("memory-safe") {
94+
$.slot := slot
95+
}
96+
}
97+
8298
function _getWormholeEvmChainIdsStorage()
8399
internal
84100
pure
85-
returns (mapping(uint16 => bool) storage $)
101+
returns (mapping(uint16 => uint256) storage $)
86102
{
87103
uint256 slot = uint256(WORMHOLE_EVM_CHAIN_IDS);
88104
assembly ("memory-safe") {
@@ -97,17 +113,22 @@ abstract contract WormholeEndpoint is Endpoint, IWormholeEndpoint, IWormholeRece
97113
_;
98114
}
99115

100-
constructor(address wormholeCoreBridge, address wormholeRelayerAddr) {
116+
constructor(
117+
address wormholeCoreBridge,
118+
address wormholeRelayerAddr,
119+
address specialRelayerAddr
120+
) {
101121
wormhole = IWormhole(wormholeCoreBridge);
102122
wormholeRelayer = IWormholeRelayer(wormholeRelayerAddr);
123+
specialRelayer = ISpecialRelayer(specialRelayerAddr);
103124
wormholeEndpoint_evmChainId = block.chainid;
104125
}
105126

106-
function checkInvalidRelayingConfig(uint16 chainId) internal view returns (bool) {
127+
function _checkInvalidRelayingConfig(uint16 chainId) internal view returns (bool) {
107128
return isWormholeRelayingEnabled(chainId) && !isWormholeEvmChain(chainId);
108129
}
109130

110-
function shouldRelayViaStandardRelaying(uint16 chainId) internal view returns (bool) {
131+
function _shouldRelayViaStandardRelaying(uint16 chainId) internal view returns (bool) {
111132
return isWormholeRelayingEnabled(chainId) && isWormholeEvmChain(chainId);
112133
}
113134

@@ -122,13 +143,16 @@ abstract contract WormholeEndpoint is Endpoint, IWormholeEndpoint, IWormholeRece
122143
return 0;
123144
}
124145

125-
if (checkInvalidRelayingConfig(targetChain)) {
146+
if (_checkInvalidRelayingConfig(targetChain)) {
126147
revert InvalidRelayingConfig(targetChain);
127148
}
128149

129-
if (shouldRelayViaStandardRelaying(targetChain)) {
150+
if (_shouldRelayViaStandardRelaying(targetChain)) {
130151
(uint256 cost,) = wormholeRelayer.quoteEVMDeliveryPrice(targetChain, 0, GAS_LIMIT);
131152
return cost;
153+
} else if (isSpecialRelayingEnabled(targetChain)) {
154+
uint256 cost = specialRelayer.quoteDeliveryPrice(getManagerToken(), targetChain, 0);
155+
return cost;
132156
} else {
133157
return 0;
134158
}
@@ -151,14 +175,19 @@ abstract contract WormholeEndpoint is Endpoint, IWormholeEndpoint, IWormholeRece
151175
WormholeEndpointInstruction memory weIns =
152176
parseWormholeEndpointInstruction(instruction.payload);
153177

154-
if (!weIns.shouldSkipRelayerSend && shouldRelayViaStandardRelaying(recipientChain)) {
178+
if (!weIns.shouldSkipRelayerSend && _shouldRelayViaStandardRelaying(recipientChain)) {
155179
wormholeRelayer.sendPayloadToEvm{value: deliveryPayment}(
156180
recipientChain,
157181
fromWormholeFormat(getWormholeSibling(recipientChain)),
158182
encodedEndpointPayload,
159183
0,
160184
GAS_LIMIT
161185
);
186+
} else if (!weIns.shouldSkipRelayerSend && isSpecialRelayingEnabled(recipientChain)) {
187+
uint64 sequence = wormhole.publishMessage(0, encodedEndpointPayload, CONSISTENCY_LEVEL);
188+
specialRelayer.requestDelivery{value: deliveryPayment}(
189+
getManagerToken(), recipientChain, 0, sequence
190+
);
162191
} else {
163192
wormhole.publishMessage(0, encodedEndpointPayload, CONSISTENCY_LEVEL);
164193
}
@@ -285,27 +314,40 @@ abstract contract WormholeEndpoint is Endpoint, IWormholeEndpoint, IWormholeRece
285314
}
286315

287316
function isWormholeRelayingEnabled(uint16 chainId) public view returns (bool) {
288-
return _getWormholeRelayingEnabledChainsStorage()[chainId];
317+
return toBool(_getWormholeRelayingEnabledChainsStorage()[chainId]);
289318
}
290319

291320
function _setIsWormholeRelayingEnabled(uint16 chainId, bool isEnabled) internal {
292321
if (chainId == 0) {
293322
revert InvalidWormholeChainIdZero();
294323
}
295-
_getWormholeRelayingEnabledChainsStorage()[chainId] = isEnabled;
324+
_getWormholeRelayingEnabledChainsStorage()[chainId] = toWord(isEnabled);
296325

297326
emit SetIsWormholeRelayingEnabled(chainId, isEnabled);
298327
}
299328

329+
function isSpecialRelayingEnabled(uint16 chainId) public view returns (bool) {
330+
return toBool(_getSpecialRelayingEnabledChainsStorage()[chainId]);
331+
}
332+
333+
function _setIsSpecialRelayingEnabled(uint16 chainId, bool isEnabled) internal {
334+
if (chainId == 0) {
335+
revert InvalidWormholeChainIdZero();
336+
}
337+
_getSpecialRelayingEnabledChainsStorage()[chainId] = toWord(isEnabled);
338+
339+
emit SetIsSpecialRelayingEnabled(chainId, isEnabled);
340+
}
341+
300342
function isWormholeEvmChain(uint16 chainId) public view returns (bool) {
301-
return _getWormholeEvmChainIdsStorage()[chainId];
343+
return toBool(_getWormholeEvmChainIdsStorage()[chainId]);
302344
}
303345

304346
function _setIsWormholeEvmChain(uint16 chainId) internal {
305347
if (chainId == 0) {
306348
revert InvalidWormholeChainIdZero();
307349
}
308-
_getWormholeEvmChainIdsStorage()[chainId] = true;
350+
_getWormholeEvmChainIdsStorage()[chainId] = TRUE;
309351

310352
emit SetIsWormholeEvmChain(chainId);
311353
}

‎src/WormholeEndpointAndManager.sol

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ contract WormholeEndpointAndManager is EndpointAndManager, WormholeEndpoint {
1111
uint16 chainId,
1212
uint64 rateLimitDuration,
1313
address wormholeCoreBridge,
14-
address wormholeRelayerAddr
14+
address wormholeRelayerAddr,
15+
address specialRelayerAddr
1516
)
1617
EndpointAndManager(token, mode, chainId, rateLimitDuration)
17-
WormholeEndpoint(wormholeCoreBridge, wormholeRelayerAddr)
18+
WormholeEndpoint(wormholeCoreBridge, wormholeRelayerAddr, specialRelayerAddr)
1819
{}
1920

2021
function setSibling(uint16 siblingChainId, bytes32 siblingContract) public override onlyOwner {

‎src/WormholeEndpointStandalone.sol

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ contract WormholeEndpointStandalone is WormholeEndpoint, EndpointStandalone {
88
constructor(
99
address manager,
1010
address wormholeCoreBridge,
11-
address wormholeRelayerAddr
12-
) EndpointStandalone(manager) WormholeEndpoint(wormholeCoreBridge, wormholeRelayerAddr) {}
11+
address wormholeRelayerAddr,
12+
address specialRelayerAddr
13+
)
14+
EndpointStandalone(manager)
15+
WormholeEndpoint(wormholeCoreBridge, wormholeRelayerAddr, specialRelayerAddr)
16+
{}
1317

1418
function setWormholeSibling(
1519
uint16 siblingChainId,

‎src/interfaces/ISpecialRelayer.sol

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-License-Identifier: Apache 2
2+
pragma solidity >=0.8.8 <0.9.0;
3+
4+
interface ISpecialRelayer {
5+
function quoteDeliveryPrice(
6+
address sourceContract,
7+
uint16 targetChain,
8+
uint256 additionalValue
9+
) external view returns (uint256 nativePriceQuote);
10+
11+
function requestDelivery(
12+
address sourceContract,
13+
uint16 targetChain,
14+
uint256 additionalValue,
15+
uint64 sequence
16+
) external payable;
17+
}

‎src/interfaces/IWormholeEndpoint.sol

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface IWormholeEndpoint {
1212
event SendEndpointMessage(uint16 recipientChain, EndpointStructs.EndpointMessage message);
1313
event SetWormholeSibling(uint16 chainId, bytes32 oldSiblingContract, bytes32 siblingContract);
1414
event SetIsWormholeRelayingEnabled(uint16 chainId, bool isRelayingEnabled);
15+
event SetIsSpecialRelayingEnabled(uint16 chainId, bool isRelayingEnabled);
1516
event SetIsWormholeEvmChain(uint16 chainId);
1617

1718
error InvalidRelayingConfig(uint16 chainId);
@@ -27,5 +28,6 @@ interface IWormholeEndpoint {
2728
function isVAAConsumed(bytes32 hash) external view returns (bool);
2829
function getWormholeSibling(uint16 chainId) external view returns (bytes32);
2930
function isWormholeRelayingEnabled(uint16 chainId) external view returns (bool);
31+
function isSpecialRelayingEnabled(uint16 chainId) external view returns (bool);
3032
function isWormholeEvmChain(uint16 chainId) external view returns (bool);
3133
}

‎src/libraries/EndpointHelpers.sol

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
// SPDX-License-Identifier: Apache 2
22
pragma solidity >=0.8.8 <0.9.0;
33

4+
uint256 constant FALSE = 0;
5+
uint256 constant TRUE = 1;
6+
7+
error InvalidBoolValue(uint256 value);
8+
9+
function toBool(uint256 value) pure returns (bool) {
10+
if (value == 0) return false;
11+
if (value == 1) return true;
12+
revert InvalidBoolValue(value);
13+
}
14+
15+
function toWord(bool value) pure returns (uint256) {
16+
if (value) {
17+
return TRUE;
18+
} else {
19+
return FALSE;
20+
}
21+
}
22+
423
error InvalidFork(uint256 evmChainId, uint256 blockChainId);
524

625
function checkFork(uint256 evmChainId) view {

‎test/IntegrationRelayer.t.sol

+7-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ contract TestEndToEndRelayer is
101101
wormholeEndpointChain1 = new WormholeEndpointStandalone(
102102
address(managerChain1),
103103
address(chainInfosTestnet[chainId1].wormhole),
104-
address(relayerSource)
104+
address(relayerSource),
105+
address(0x0)
105106
);
106107

107108
wormholeEndpointChain1 = WormholeEndpointStandalone(
@@ -130,7 +131,8 @@ contract TestEndToEndRelayer is
130131
wormholeEndpointChain2 = new WormholeEndpointStandalone(
131132
address(managerChain2),
132133
address(chainInfosTestnet[chainId2].wormhole),
133-
address(relayerTarget)
134+
address(relayerTarget),
135+
address(0x0)
134136
);
135137

136138
wormholeEndpointChain2 = WormholeEndpointStandalone(
@@ -434,7 +436,7 @@ contract TestRelayerEndToEndManual is
434436
managerChain1.initialize();
435437

436438
wormholeEndpointChain1 = new WormholeEndpointStandalone(
437-
address(managerChain1), address(wormhole), address(relayer)
439+
address(managerChain1), address(wormhole), address(relayer), address(0x0)
438440
);
439441
wormholeEndpointChain1 = WormholeEndpointStandalone(
440442
address(new ERC1967Proxy(address(wormholeEndpointChain1), ""))
@@ -457,7 +459,8 @@ contract TestRelayerEndToEndManual is
457459
wormholeEndpointChain2 = new WormholeEndpointStandalone(
458460
address(managerChain2),
459461
address(wormhole),
460-
address(relayer) // TODO - add support for this later
462+
address(relayer), // TODO - add support for this later
463+
address(0x0) // TODO - add support for this later
461464
);
462465
wormholeEndpointChain2 = WormholeEndpointStandalone(
463466
address(new ERC1967Proxy(address(wormholeEndpointChain2), ""))

‎test/IntegrationStandalone.t.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ contract TestEndToEndBase is Test, IManagerEvents, IRateLimiterEvents {
6767
managerChain1.initialize();
6868

6969
WormholeEndpointStandalone wormholeEndpointChain1Implementation = new WormholeEndpointStandalone(
70-
address(managerChain1), address(wormhole), address(relayer)
70+
address(managerChain1), address(wormhole), address(relayer), address(0x0)
7171
);
7272
wormholeEndpointChain1 = WormholeEndpointStandalone(
7373
address(new ERC1967Proxy(address(wormholeEndpointChain1Implementation), ""))
@@ -89,7 +89,7 @@ contract TestEndToEndBase is Test, IManagerEvents, IRateLimiterEvents {
8989
managerChain2.initialize();
9090

9191
WormholeEndpointStandalone wormholeEndpointChain2Implementation = new WormholeEndpointStandalone(
92-
address(managerChain2), address(wormhole), address(relayer)
92+
address(managerChain2), address(wormhole), address(relayer), address(0x0)
9393
);
9494
wormholeEndpointChain2 = WormholeEndpointStandalone(
9595
address(new ERC1967Proxy(address(wormholeEndpointChain2Implementation), ""))
@@ -406,7 +406,7 @@ contract TestEndToEndBase is Test, IManagerEvents, IRateLimiterEvents {
406406

407407
// Dual endpoint setup
408408
WormholeEndpointStandalone wormholeEndpointChain1_2 = new WormholeEndpointStandalone(
409-
address(managerChain1), address(wormhole), address(relayer)
409+
address(managerChain1), address(wormhole), address(relayer), address(0x0)
410410
);
411411

412412
wormholeEndpointChain1_2 = WormholeEndpointStandalone(
@@ -419,7 +419,7 @@ contract TestEndToEndBase is Test, IManagerEvents, IRateLimiterEvents {
419419

420420
// Dual endpoint setup
421421
WormholeEndpointStandalone wormholeEndpointChain2_2 = new WormholeEndpointStandalone(
422-
address(managerChain2), address(wormhole), address(relayer)
422+
address(managerChain2), address(wormhole), address(relayer), address(0x0)
423423
);
424424

425425
wormholeEndpointChain2_2 = WormholeEndpointStandalone(

‎test/Manager.t.sol

+15-13
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ contract EndpointAndManagerContract is EndpointAndManager, IEndpointReceiver {
6161
}
6262

6363
function _sendMessage(
64-
uint16 recipientChain,
65-
uint256 deliveryPayment,
66-
address caller,
67-
EndpointStructs.EndpointInstruction memory instruction,
68-
bytes memory payload
64+
uint16, /* recipientChain */
65+
uint256, /* deliveryPayment */
66+
address, /* caller */
67+
EndpointStructs.EndpointInstruction memory, /* instruction */
68+
bytes memory /* payload */
6969
) internal pure override {
7070
// do nothing
7171
}
@@ -114,13 +114,6 @@ contract TestManager is Test, IManagerEvents, IRateLimiterEvents {
114114

115115
manager = ManagerStandalone(address(new ERC1967Proxy(address(implementation), "")));
116116
manager.initialize();
117-
118-
// deploy sample token contract
119-
// deploy wormhole contract
120-
// wormhole = deployWormholeForTest();
121-
// deploy endpoint contracts
122-
// instantiate endpoint manager contract
123-
// manager = new ManagerContract();
124117
}
125118

126119
// === pure unit tests
@@ -199,10 +192,19 @@ contract TestManager is Test, IManagerEvents, IRateLimiterEvents {
199192
}
200193

201194
function test_endpointIncompatibleManager() public {
195+
// Endpoint instantiation reverts if the manager doesn't have the proper token method
196+
vm.expectRevert(bytes(""));
197+
new DummyEndpoint(address(0xBEEF));
198+
}
199+
200+
function test_endpointWrongManager() public {
202201
// TODO: this is accepted currently. should we include a check to ensure
203202
// only endpoints whose manager is us can be registered? (this would be
204203
// a convenience check, not a security one)
205-
DummyEndpoint e = new DummyEndpoint(address(0xBEEF));
204+
DummyToken t = new DummyToken();
205+
ManagerStandalone altManager =
206+
new ManagerStandalone(address(t), Manager.Mode.LOCKING, chainId, 1 days);
207+
DummyEndpoint e = new DummyEndpoint(address(altManager));
206208
manager.setEndpoint(address(e));
207209
}
208210

‎test/Upgrades.t.sol

+32-30
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,11 @@ contract WormholeEndpointStandaloneMigrateBasic is WormholeEndpointStandalone {
9393
constructor(
9494
address manager,
9595
address wormholeCoreBridge,
96-
address wormholeRelayerAddr
97-
) WormholeEndpointStandalone(manager, wormholeCoreBridge, wormholeRelayerAddr) {}
98-
99-
function _migrate() internal pure override {
100-
revert("Proper migrate called");
101-
}
102-
}
103-
104-
contract WormholeEndpointStandaloneImmutableCheck is WormholeEndpointStandalone {
105-
constructor(
106-
address wormholeCoreBridge,
107-
address wormholeRelayerAddr
108-
) WormholeEndpointStandalone(address(0x1), wormholeCoreBridge, wormholeRelayerAddr) {}
96+
address wormholeRelayerAddr,
97+
address specialRelayerAddr
98+
)
99+
WormholeEndpointStandalone(manager, wormholeCoreBridge, wormholeRelayerAddr, specialRelayerAddr)
100+
{}
109101

110102
function _migrate() internal pure override {
111103
revert("Proper migrate called");
@@ -114,9 +106,13 @@ contract WormholeEndpointStandaloneImmutableCheck is WormholeEndpointStandalone
114106

115107
contract WormholeEndpointStandaloneImmutableAllow is WormholeEndpointStandalone {
116108
constructor(
109+
address manager,
117110
address wormholeCoreBridge,
118-
address wormholeRelayerAddr
119-
) WormholeEndpointStandalone(address(0x1), wormholeCoreBridge, wormholeRelayerAddr) {}
111+
address wormholeRelayerAddr,
112+
address specialRelayerAddr
113+
)
114+
WormholeEndpointStandalone(manager, wormholeCoreBridge, wormholeRelayerAddr, specialRelayerAddr)
115+
{}
120116

121117
// Allow for the immutables to be migrated
122118
function _migrate() internal override {
@@ -133,8 +129,11 @@ contract WormholeEndpointStandaloneLayoutChange is WormholeEndpointStandalone {
133129
constructor(
134130
address manager,
135131
address wormholeCoreBridge,
136-
address wormholeRelayerAddr
137-
) WormholeEndpointStandalone(manager, wormholeCoreBridge, wormholeRelayerAddr) {}
132+
address wormholeRelayerAddr,
133+
address specialRelayerAddr
134+
)
135+
WormholeEndpointStandalone(manager, wormholeCoreBridge, wormholeRelayerAddr, specialRelayerAddr)
136+
{}
138137

139138
function setData() public {
140139
a = address(0x1);
@@ -185,7 +184,7 @@ contract TestUpgrades is Test, IManagerEvents, IRateLimiterEvents {
185184
managerChain1.initialize();
186185

187186
WormholeEndpointStandalone wormholeEndpointChain1Implementation = new WormholeEndpointStandalone(
188-
address(managerChain1), address(wormhole), address(relayer)
187+
address(managerChain1), address(wormhole), address(relayer), address(0x0)
189188
);
190189
wormholeEndpointChain1 = WormholeEndpointStandalone(
191190
address(new ERC1967Proxy(address(wormholeEndpointChain1Implementation), ""))
@@ -207,7 +206,7 @@ contract TestUpgrades is Test, IManagerEvents, IRateLimiterEvents {
207206
managerChain2.initialize();
208207

209208
WormholeEndpointStandalone wormholeEndpointChain2Implementation = new WormholeEndpointStandalone(
210-
address(managerChain2), address(wormhole), address(relayer)
209+
address(managerChain2), address(wormhole), address(relayer), address(0x0)
211210
);
212211
wormholeEndpointChain2 = WormholeEndpointStandalone(
213212
address(new ERC1967Proxy(address(wormholeEndpointChain2Implementation), ""))
@@ -248,7 +247,7 @@ contract TestUpgrades is Test, IManagerEvents, IRateLimiterEvents {
248247
function test_basicUpgradeEndpoint() public {
249248
// Basic call to upgrade with the same contact as well
250249
WormholeEndpointStandalone wormholeEndpointChain1Implementation = new WormholeEndpointStandalone(
251-
address(managerChain1), address(wormhole), address(relayer)
250+
address(managerChain1), address(wormhole), address(relayer), address(0x0)
252251
);
253252
wormholeEndpointChain1.upgrade(address(wormholeEndpointChain1Implementation));
254253

@@ -276,7 +275,7 @@ contract TestUpgrades is Test, IManagerEvents, IRateLimiterEvents {
276275
function test_doubleUpgradeEndpoint() public {
277276
// Basic call to upgrade with the same contact as well
278277
WormholeEndpointStandalone wormholeEndpointChain1Implementation = new WormholeEndpointStandalone(
279-
address(managerChain1), address(wormhole), address(relayer)
278+
address(managerChain1), address(wormhole), address(relayer), address(0x0)
280279
);
281280
wormholeEndpointChain1.upgrade(address(wormholeEndpointChain1Implementation));
282281

@@ -307,7 +306,7 @@ contract TestUpgrades is Test, IManagerEvents, IRateLimiterEvents {
307306
function test_storageSlotEndpoint() public {
308307
// Basic call to upgrade with the same contact as ewll
309308
WormholeEndpointStandalone newImplementation = new WormholeEndpointStandaloneLayoutChange(
310-
address(managerChain1), address(wormhole), address(relayer)
309+
address(managerChain1), address(wormhole), address(relayer), address(0x0)
311310
);
312311
wormholeEndpointChain1.upgrade(address(newImplementation));
313312

@@ -336,7 +335,7 @@ contract TestUpgrades is Test, IManagerEvents, IRateLimiterEvents {
336335
function test_callMigrateEndpoint() public {
337336
// Basic call to upgrade with the same contact as well
338337
WormholeEndpointStandaloneMigrateBasic wormholeEndpointChain1Implementation = new WormholeEndpointStandaloneMigrateBasic(
339-
address(managerChain1), address(wormhole), address(relayer)
338+
address(managerChain1), address(wormhole), address(relayer), address(0x0)
340339
);
341340

342341
vm.expectRevert("Proper migrate called");
@@ -361,12 +360,13 @@ contract TestUpgrades is Test, IManagerEvents, IRateLimiterEvents {
361360
basicFunctionality();
362361
}
363362

364-
function test_mmutableBlockUpdateFailureEndpoint() public {
363+
function test_immutableBlockUpdateFailureEndpoint() public {
365364
// Don't allow upgrade to work with a change immutable
366365

367366
address oldManager = wormholeEndpointChain1.manager();
368-
WormholeEndpointStandaloneImmutableCheck wormholeEndpointChain1Implementation =
369-
new WormholeEndpointStandaloneImmutableCheck(address(wormhole), address(relayer));
367+
WormholeEndpointStandaloneMigrateBasic wormholeEndpointChain1Implementation = new WormholeEndpointStandaloneMigrateBasic(
368+
address(managerChain2), address(wormhole), address(relayer), address(0x0)
369+
);
370370

371371
vm.expectRevert(); // Reverts with a panic on the assert. So, no way to tell WHY this happened.
372372
wormholeEndpointChain1.upgrade(address(wormholeEndpointChain1Implementation));
@@ -392,14 +392,16 @@ contract TestUpgrades is Test, IManagerEvents, IRateLimiterEvents {
392392
}
393393

394394
function test_immutableBlockUpdateSuccessEndpoint() public {
395-
WormholeEndpointStandaloneImmutableAllow wormholeEndpointChain1Implementation =
396-
new WormholeEndpointStandaloneImmutableAllow(address(wormhole), address(relayer));
395+
WormholeEndpointStandaloneImmutableAllow wormholeEndpointChain1Implementation = new WormholeEndpointStandaloneImmutableAllow(
396+
address(managerChain1), address(wormhole), address(relayer), address(0x0)
397+
);
397398

398399
//vm.expectRevert(); // Reverts with a panic on the assert. So, no way to tell WHY this happened.
399400
wormholeEndpointChain1.upgrade(address(wormholeEndpointChain1Implementation));
400401

401402
require(
402-
wormholeEndpointChain1.manager() == address(0x1), "Manager updated when it shouldn't be"
403+
wormholeEndpointChain1.manager() == address(managerChain1),
404+
"Manager updated when it shouldn't be"
403405
);
404406
}
405407

@@ -453,7 +455,7 @@ contract TestUpgrades is Test, IManagerEvents, IRateLimiterEvents {
453455

454456
// Basic call so that we can easily see what the new endpoint is.
455457
WormholeEndpointStandalone wormholeEndpointChain1Implementation = new WormholeEndpointStandalone(
456-
address(managerChain1), address(wormhole), address(relayer)
458+
address(managerChain1), address(wormhole), address(relayer), address(0x0)
457459
);
458460
wormholeEndpointChain1.upgrade(address(wormholeEndpointChain1Implementation));
459461
basicFunctionality(); // Ensure that the upgrade was proper

‎test/mocks/DummyEndpoint.sol

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ contract DummyEndpoint is EndpointStandalone, IEndpointReceiver {
2020
}
2121

2222
function _sendMessage(
23-
uint16 recipientChain,
24-
uint256 deliveryPayment,
25-
address caller,
26-
EndpointStructs.EndpointInstruction memory instruction,
27-
bytes memory payload
23+
uint16, /* recipientChain */
24+
uint256, /* deliveryPayment */
25+
address, /* caller */
26+
EndpointStructs.EndpointInstruction memory, /* instruction */
27+
bytes memory /* payload */
2828
) internal override {
2929
// do nothing
3030
}

0 commit comments

Comments
 (0)
Please sign in to comment.