Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create deployTransceiver script to use migrate function to update immutable specialRelayerAddr of deployed Transceiver contract #577

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions evm/script/DeployTransceiver.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: Apache 2
pragma solidity >=0.8.8 <0.9.0;

import {Script, console2} from "forge-std/Script.sol";
import {WormholeTransceiver} from "../src/Transceiver/WormholeTransceiver/WormholeTransceiver.sol";
import {ERC1967Proxy} from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";

contract DeployWormholeTransceiver is Script {
function run(
address nttManager,
address wormholeCoreBridge,
address wormholeRelayerAddr,
address specialRelayerAddr,
uint8 consistencyLevel,
uint256 gasLimit
) public {
vm.startBroadcast();

WormholeTransceiver implementation = new WormholeTransceiver(
nttManager,
wormholeCoreBridge,
wormholeRelayerAddr,
specialRelayerAddr,
consistencyLevel,
gasLimit
);

WormholeTransceiver transceiver =
WormholeTransceiver(address(implementation));

console2.log("WormholeTransceiver address:", address(transceiver));

vm.stopBroadcast();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ abstract contract WormholeTransceiverState is IWormholeTransceiverState, Transce
_initializeTransceiver();
}

function _migrate() internal virtual override {
_setMigratesImmutables(true);
}

function _initializeTransceiver() internal {
TransceiverStructs.TransceiverInit memory init = TransceiverStructs.TransceiverInit({
transceiverIdentifier: WH_TRANSCEIVER_INIT_PREFIX,
Expand Down
21 changes: 21 additions & 0 deletions evm/test/Upgrades.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,27 @@ contract TestUpgrades is Test, IRateLimiterEvents {
);
}

function test_specialRelayerMigration() public {
WormholeTransceiver newImplementation = new MockWormholeTransceiverImmutableAllow(
address(nttManagerChain1),
address(wormhole),
address(relayer),
address(0x8C56eE9cd232d23541a697C0eBd3cA597DE3c88D), // new specialRelayer address
FAST_CONSISTENCY_LEVEL,
GAS_LIMIT
);

// Perform upgrade which will trigger migration
wormholeTransceiverChain1.upgrade(address(newImplementation));

// Verify specialRelayer was set to the expected address
require(
address(wormholeTransceiverChain1.specialRelayer()) == 0x8C56eE9cd232d23541a697C0eBd3cA597DE3c88D,
"SpecialRelayer not set to expected address"
);
}


function test_authNttManager() public {
// User not owner so this should fail
vm.prank(userA);
Expand Down
Loading