Skip to content

Commit cbfc544

Browse files
committed
create deployTransceiver script use migrate function to update immutable specialRelayerAddr of deployed Transceiver contract
1 parent 404c0aa commit cbfc544

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

evm/script/DeployTransceiver.s.sol

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: Apache 2
2+
pragma solidity >=0.8.8 <0.9.0;
3+
4+
import {Script, console2} from "forge-std/Script.sol";
5+
import {WormholeTransceiver} from "../src/Transceiver/WormholeTransceiver/WormholeTransceiver.sol";
6+
import {ERC1967Proxy} from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";
7+
8+
contract DeployWormholeTransceiver is Script {
9+
function run(
10+
address nttManager,
11+
address wormholeCoreBridge,
12+
address wormholeRelayerAddr,
13+
address specialRelayerAddr,
14+
uint8 consistencyLevel,
15+
uint256 gasLimit
16+
) public {
17+
vm.startBroadcast();
18+
19+
WormholeTransceiver implementation = new WormholeTransceiver(
20+
nttManager,
21+
wormholeCoreBridge,
22+
wormholeRelayerAddr,
23+
specialRelayerAddr,
24+
consistencyLevel,
25+
gasLimit
26+
);
27+
28+
WormholeTransceiver transceiver =
29+
WormholeTransceiver(address(implementation));
30+
31+
console2.log("WormholeTransceiver address:", address(transceiver));
32+
33+
vm.stopBroadcast();
34+
}
35+
}

evm/src/Transceiver/WormholeTransceiver/WormholeTransceiverState.sol

+4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ abstract contract WormholeTransceiverState is IWormholeTransceiverState, Transce
7575
_initializeTransceiver();
7676
}
7777

78+
function _migrate() internal virtual override {
79+
_setMigratesImmutables(true);
80+
}
81+
7882
function _initializeTransceiver() internal {
7983
TransceiverStructs.TransceiverInit memory init = TransceiverStructs.TransceiverInit({
8084
transceiverIdentifier: WH_TRANSCEIVER_INIT_PREFIX,

evm/test/Upgrades.t.sol

+21
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,27 @@ contract TestUpgrades is Test, IRateLimiterEvents {
389389
);
390390
}
391391

392+
function test_specialRelayerMigration() public {
393+
WormholeTransceiver newImplementation = new MockWormholeTransceiverImmutableAllow(
394+
address(nttManagerChain1),
395+
address(wormhole),
396+
address(relayer),
397+
address(0x8C56eE9cd232d23541a697C0eBd3cA597DE3c88D), // new specialRelayer address
398+
FAST_CONSISTENCY_LEVEL,
399+
GAS_LIMIT
400+
);
401+
402+
// Perform upgrade which will trigger migration
403+
wormholeTransceiverChain1.upgrade(address(newImplementation));
404+
405+
// Verify specialRelayer was set to the expected address
406+
require(
407+
address(wormholeTransceiverChain1.specialRelayer()) == 0x8C56eE9cd232d23541a697C0eBd3cA597DE3c88D,
408+
"SpecialRelayer not set to expected address"
409+
);
410+
}
411+
412+
392413
function test_authNttManager() public {
393414
// User not owner so this should fail
394415
vm.prank(userA);

0 commit comments

Comments
 (0)