Skip to content

Commit

Permalink
evm: Use create2
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-riley committed Oct 25, 2024
1 parent 0abb38b commit 678fb68
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
22 changes: 22 additions & 0 deletions evm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ The payload of the Wormhole messages consists of the following fields encoded us
bytes32 payloadHash
```

## Deployment and Administration

### Deploying the Wormhole Transceiver Contract

The contract can be deployed using the following command.

```shell
evm$ RPC_URL= MNEMONIC= OUR_CHAIN_ID= EVM_CHAIN_ID= ADMIN= ROUTER= WORMHOLE= CONSISTENCY_LEVEL= ./sh/deployWormholeTransceiver.sh
```

Note that the deploy scripts uses `create2` to generate a deterministic contract address.

### Configuring Peer Transceivers

To configure a peer Wormhole Transceiver for a given chain, you can use the following command.

```shell
evm$ RPC_URL= MNEMONIC=WT_ADDR= PEER_CHAIN_ID= PEER_ADDR= ./sh/setPeer.sh
```

Note that `PEER_CHAIN_ID` is a Wormhole CHAIN ID and the `PEER_ADDR` is a `UniversalAddress` expressed as a `bytes32` beginning with `0x`.

## Development

### Foundry
Expand Down
5 changes: 3 additions & 2 deletions evm/script/DeployWormholeTransceiver.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {WormholeTransceiver} from "../src/WormholeTransceiver.sol";
import {WormholeTransceiver, wormholeTransceiverVersionString} from "../src/WormholeTransceiver.sol";
import "forge-std/Script.sol";

// DeployWormholeTransceiver is a forge script to deploy the WormholeTransceiver contract. Use ./sh/deployWormholeTransceiver.sh to invoke this.
Expand Down Expand Up @@ -40,8 +40,9 @@ contract DeployWormholeTransceiver is Script {
address wormhole,
uint8 consistencyLevel
) internal returns (address deployedAddress) {
bytes32 salt = keccak256(abi.encodePacked(wormholeTransceiverVersionString));
WormholeTransceiver wormholeTransceiver =
new WormholeTransceiver(ourChain, evmChain, admin, router, wormhole, consistencyLevel);
new WormholeTransceiver{salt: salt}(ourChain, evmChain, admin, router, wormhole, consistencyLevel);

return (address(wormholeTransceiver));
}
Expand Down
1 change: 1 addition & 0 deletions evm/sh/deployWormholeTransceiver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# This script deploys the WormholeTransceiver contract.
# Usage: RPC_URL= MNEMONIC= OUR_CHAIN_ID= EVM_CHAIN_ID= ADMIN= ROUTER= WORMHOLE= CONSISTENCY_LEVEL= ./sh/deployWormholeTransceiver.sh
# To verify the contract add: FORGE_ARGS="--verifier-url 'https://api.routescan.io/v2/network/testnet/evm/${EVM_CHAIN_ID}/etherscan' --etherscan-api-key 'verifyContract'"
# tilt: ROUTER=0x1aBE68277AE236083947f2551FEe8b885efCA8f5 ./sh/deployWormholeTransceiver.sh
#

Expand Down
2 changes: 1 addition & 1 deletion evm/sh/receiveMsg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# This script submits a message to the WormholeTransceiver contract.
# Usage: RPC_URL= MNEMONIC= WT_ADDR= VAA= ./sh/receiveMsg.sh
# tilt: WT_ADDR=0x1aBE68277AE236083947f2551FEe8b885efCA8f5 VAA= ./sh/receiveMsg.sh
# tilt: WT_ADDR=0xdFccc9C59c7361307d47c558ffA75840B32DbA29 VAA= ./sh/receiveMsg.sh
#

[[ -z $WT_ADDR ]] && { echo "Missing WT_ADDR"; exit 1; }
Expand Down
4 changes: 3 additions & 1 deletion evm/src/WormholeTransceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import "wormhole-solidity-sdk/interfaces/IWormhole.sol";
import "./interfaces/IWormholeTransceiver.sol";
import "./libraries/TransceiverHelpers.sol";

string constant wormholeTransceiverVersionString = "WormholeTransceiver-0.0.1";

contract WormholeTransceiver is IWormholeTransceiver {
using BytesParsing for bytes; // Used by _decodePayload

string public constant versionString = "WormholeTransceiver-0.0.1";
string public constant versionString = wormholeTransceiverVersionString;
address public admin;
address public pendingAdmin;

Expand Down

0 comments on commit 678fb68

Please sign in to comment.