Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Rename CoreRelayer -> WormholeRelayer *if we want to* #110

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Fundamentally, the relayer service should require no additional trust assumption

Generic relayers consist of three components:

1. `CoreRelayer` contract lives on all chains that integrators interact with to request for a generic relayer to deliver a cross-chain message.
1. `WormholeRelayer` contract lives on all chains that integrators interact with to request for a generic relayer to deliver a cross-chain message.
2. `GasOracle` contract lives on all chains that provides an estimate to the gas costs associated with a particular cross-chain message. This is a critical function to ensure that users/applications are appropriately covering the costs that relayers face when submitting a transaction on the destination chain.
3. Off-chain Relayer that listens for VAAs that it is assigned to, redeems the VAA from the Guardian Network, and submits the VAA on the destination chain.

Expand Down
4 changes: 2 additions & 2 deletions ethereum/contracts/mock/AttackForwardIntegration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ contract AttackForwardIntegration is IWormholeReceiver {
// This just needs to be enough to pay for the call to the destination address.
uint32 SAFE_DELIVERY_GAS_CAPTURE = 30000;

constructor(IWormhole initWormhole, IWormholeRelayer initCoreRelayer, uint16 chainId, address initAttackerReward) {
constructor(IWormhole initWormhole, IWormholeRelayer initWormholeRelayer, uint16 chainId, address initAttackerReward) {
attackerReward = initAttackerReward;
wormhole = initWormhole;
core_relayer = initCoreRelayer;
core_relayer = initWormholeRelayer;
targetChainId = chainId;
}

Expand Down
8 changes: 4 additions & 4 deletions ethereum/contracts/relayProvider/RelayProviderGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ abstract contract RelayProviderGovernance is RelayProviderGetters, RelayProvider
event RewardAddressUpdated(address indexed newAddress);
event DeliveryAddressUpdated(uint16 indexed targetChainId, bytes32 indexed newAddress);
event DeliverGasOverheadUpdated(uint32 indexed oldGasOverhead, uint32 indexed newGasOverhead);
event CoreRelayerUpdated(address coreRelayer);
event WormholeRelayerUpdated(address coreRelayer);
event ApprovedSenderUpdated(address sender, bool approved);
event AssetConversionBufferUpdated(uint16 targetChain, uint16 buffer, uint16 bufferDenominator);

function updateCoreRelayer(address payable newAddress) public onlyOwner {
setCoreRelayer(newAddress);
emit CoreRelayerUpdated(newAddress);
function updateWormholeRelayer(address payable newAddress) public onlyOwner {
setWormholeRelayer(newAddress);
emit WormholeRelayerUpdated(newAddress);
}

function updateApprovedSender(address sender, bool approved) public onlyOwner {
Expand Down
2 changes: 1 addition & 1 deletion ethereum/contracts/relayProvider/RelayProviderSetters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract RelayProviderSetters is Context, RelayProviderState {
_state.chainId = thisChain;
}

function setCoreRelayer(address payable coreRelayer) internal {
function setWormholeRelayer(address payable coreRelayer) internal {
_state.coreRelayer = coreRelayer;
}

Expand Down
2 changes: 1 addition & 1 deletion ethereum/contracts/relayProvider/RelayProviderState.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract RelayProviderStorage {
mapping(uint16 => uint16) assetConversionBuffer;
// Dictionary of wormhole chain id -> assetConversionBufferDenominator
mapping(uint16 => uint16) assetConversionBufferDenominator;
// Reward address for the relayer. The CoreRelayer contract transfers the reward for relaying messages here.
// Reward address for the relayer. The WormholeRelayer contract transfers the reward for relaying messages here.
address payable rewardAddress;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ pragma solidity ^0.8.0;
import "../interfaces/IWormholeRelayer.sol";
import "../interfaces/IWormholeReceiver.sol";
import "../interfaces/IDelivery.sol";
import "./CoreRelayerGovernance.sol";
import "./CoreRelayerStructs.sol";
import "./WormholeRelayerGovernance.sol";
import "./WormholeRelayerStructs.sol";

contract CoreRelayer is CoreRelayerGovernance {
contract WormholeRelayer is WormholeRelayerGovernance {
enum DeliveryStatus {
SUCCESS,
RECEIVER_FAILURE,
Expand Down Expand Up @@ -280,7 +280,7 @@ contract CoreRelayer is CoreRelayerGovernance {
}

function verifyRelayerVM(IWormhole.VM memory vm) internal view returns (bool) {
return registeredCoreRelayerContract(vm.emitterChainId) == vm.emitterAddress;
return registeredWormholeRelayerContract(vm.emitterChainId) == vm.emitterAddress;
}

function getDefaultRelayProvider() public view returns (IRelayProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ pragma solidity ^0.8.0;

import "../interfaces/IWormhole.sol";
import "../interfaces/IRelayProvider.sol";
import "./CoreRelayerStructs.sol";
import "./WormholeRelayerStructs.sol";

import "./CoreRelayerState.sol";
import "./WormholeRelayerState.sol";
import "../libraries/external/BytesLib.sol";

contract CoreRelayerGetters is CoreRelayerState {
contract WormholeRelayerGetters is WormholeRelayerState {
using BytesLib for bytes;

function governanceActionIsConsumed(bytes32 hash) public view returns (bool) {
Expand Down Expand Up @@ -49,15 +49,15 @@ contract CoreRelayerGetters is CoreRelayerState {
return evmChainId() != block.chainid;
}

function registeredCoreRelayerContract(uint16 chain) public view returns (bytes32) {
return _state.registeredCoreRelayerContract[chain];
function registeredWormholeRelayerContract(uint16 chain) public view returns (bytes32) {
return _state.registeredWormholeRelayerContract[chain];
}

function defaultRelayProvider() internal view returns (IRelayProvider) {
return IRelayProvider(_state.defaultRelayProvider);
}

function getForwardInstruction() internal view returns (CoreRelayerStructs.ForwardInstruction memory) {
function getForwardInstruction() internal view returns (WormholeRelayerStructs.ForwardInstruction memory) {
return _state.forwardInstruction;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol";

import "../libraries/external/BytesLib.sol";

import "./CoreRelayerGetters.sol";
import "./CoreRelayerSetters.sol";
import "./CoreRelayerStructs.sol";
import "./CoreRelayerMessages.sol";
import "./WormholeRelayerGetters.sol";
import "./WormholeRelayerSetters.sol";
import "./WormholeRelayerStructs.sol";
import "./WormholeRelayerMessages.sol";

import "../interfaces/IWormhole.sol";
import "./CoreRelayerLibrary.sol";
import "./WormholeRelayerLibrary.sol";

abstract contract CoreRelayerGovernance is
CoreRelayerGetters,
CoreRelayerSetters,
CoreRelayerMessages,
abstract contract WormholeRelayerGovernance is
WormholeRelayerGetters,
WormholeRelayerSetters,
WormholeRelayerMessages,
ERC1967Upgrade
{
using BytesLib for bytes;
Expand All @@ -31,7 +31,7 @@ abstract contract CoreRelayerGovernance is

event ContractUpgraded(address indexed oldContract, address indexed newContract);

// "CoreRelayer" (left padded)
// "WormholeRelayer" (left padded)
bytes32 constant module = 0x000000000000000000000000000000000000000000436f726552656c61796572;

function submitContractUpgrade(bytes memory _vm) public {
Expand All @@ -46,29 +46,29 @@ abstract contract CoreRelayerGovernance is

setConsumedGovernanceAction(vm.hash);

CoreRelayerLibrary.ContractUpgrade memory contractUpgrade = CoreRelayerLibrary.parseUpgrade(vm.payload, module);
WormholeRelayerLibrary.ContractUpgrade memory contractUpgrade = WormholeRelayerLibrary.parseUpgrade(vm.payload, module);
if (contractUpgrade.chain != chainId()) {
revert WrongChainId(contractUpgrade.chain);
}

upgradeImplementation(contractUpgrade.newContract);
}

function registerCoreRelayerContract(bytes memory vaa) public {
function registerWormholeRelayerContract(bytes memory vaa) public {
(IWormhole.VM memory vm, bool valid, string memory reason) = verifyGovernanceVM(vaa);
if (!valid) {
revert InvalidGovernanceVM(string(reason));
}

setConsumedGovernanceAction(vm.hash);

CoreRelayerLibrary.RegisterChain memory rc = CoreRelayerLibrary.parseRegisterChain(vm.payload, module);
WormholeRelayerLibrary.RegisterChain memory rc = WormholeRelayerLibrary.parseRegisterChain(vm.payload, module);

if ((rc.chain != chainId() || isFork()) && rc.chain != 0) {
revert InvalidChainId(rc.chain);
}

setRegisteredCoreRelayerContract(rc.emitterChain, rc.emitterAddress);
setRegisteredWormholeRelayerContract(rc.emitterChain, rc.emitterAddress);
}

function setDefaultRelayProvider(bytes memory vaa) public {
Expand All @@ -79,8 +79,8 @@ abstract contract CoreRelayerGovernance is

setConsumedGovernanceAction(vm.hash);

CoreRelayerLibrary.UpdateDefaultProvider memory provider =
CoreRelayerLibrary.parseUpdateDefaultProvider(vm.payload, module);
WormholeRelayerLibrary.UpdateDefaultProvider memory provider =
WormholeRelayerLibrary.parseUpdateDefaultProvider(vm.payload, module);

if ((provider.chain != chainId() || isFork()) && provider.chain != 0) {
revert InvalidChainId(provider.chain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ pragma solidity ^0.8.0;

import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol";

import "./CoreRelayer.sol";
import "./WormholeRelayer.sol";

contract CoreRelayerImplementation is CoreRelayer {
contract WormholeRelayerImplementation is WormholeRelayer {
error ImplementationAlreadyInitialized();

function initialize() public virtual initializer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.0;

import "../libraries/external/BytesLib.sol";

library CoreRelayerLibrary {
library WormholeRelayerLibrary {
using BytesLib for bytes;

error WrongModule(bytes32 module);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ pragma solidity ^0.8.0;

import "../libraries/external/BytesLib.sol";

import "./CoreRelayerGetters.sol";
import "./CoreRelayerStructs.sol";
import "./WormholeRelayerGetters.sol";
import "./WormholeRelayerStructs.sol";
import "../interfaces/IWormholeRelayer.sol";

contract CoreRelayerMessages is CoreRelayerStructs, CoreRelayerGetters {
contract WormholeRelayerMessages is WormholeRelayerStructs, WormholeRelayerGetters {
using BytesLib for bytes;

error InvalidPayloadId(uint8 payloadId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ pragma solidity ^0.8.0;

import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

contract CoreRelayerProxy is ERC1967Proxy {
contract WormholeRelayerProxy is ERC1967Proxy {
constructor(address implementation, bytes memory initData) ERC1967Proxy(implementation, initData) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

pragma solidity ^0.8.0;

import "./CoreRelayerState.sol";
import "./WormholeRelayerState.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "./CoreRelayerStructs.sol";
import "./WormholeRelayerStructs.sol";
import {IWormhole} from "../interfaces/IWormhole.sol";

contract CoreRelayerSetters is CoreRelayerState, Context {
contract WormholeRelayerSetters is WormholeRelayerState, Context {
error InvalidEvmChainId();

function setInitialized(address implementation) internal {
Expand Down Expand Up @@ -43,11 +43,11 @@ contract CoreRelayerSetters is CoreRelayerState, Context {
_state.defaultRelayProvider = defaultRelayProvider;
}

function setRegisteredCoreRelayerContract(uint16 chainId, bytes32 relayerAddress) internal {
_state.registeredCoreRelayerContract[chainId] = relayerAddress;
function setRegisteredWormholeRelayerContract(uint16 chainId, bytes32 relayerAddress) internal {
_state.registeredWormholeRelayerContract[chainId] = relayerAddress;
}

function setForwardInstruction(CoreRelayerStructs.ForwardInstruction memory request) internal {
function setForwardInstruction(WormholeRelayerStructs.ForwardInstruction memory request) internal {
_state.forwardInstruction = request;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

pragma solidity ^0.8.0;

import "./CoreRelayerGovernance.sol";
import "./WormholeRelayerGovernance.sol";

import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol";

contract CoreRelayerSetup is CoreRelayerSetters, ERC1967Upgrade {
contract WormholeRelayerSetup is WormholeRelayerSetters, ERC1967Upgrade {
error ImplementationAddressIsZero();
error WormholeAddressIsZero();
error DefaultRelayProviderAddressIsZero();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

pragma solidity ^0.8.0;

import "./CoreRelayerStructs.sol";
import "./WormholeRelayerStructs.sol";

contract CoreRelayerStorage {
contract WormholeRelayerStorage {
struct Provider {
uint16 chainId;
address payable wormhole;
Expand All @@ -27,16 +27,16 @@ contract CoreRelayerStorage {
// address of the default relay provider on this chain
address defaultRelayProvider;
// Request which will be forwarded from the current delivery.
CoreRelayerStructs.ForwardInstruction forwardInstruction;
WormholeRelayerStructs.ForwardInstruction forwardInstruction;
// mapping of initialized implementations
mapping(address => bool) initializedImplementations;
// mapping of relayer contracts on other chains
mapping(uint16 => bytes32) registeredCoreRelayerContract;
mapping(uint16 => bytes32) registeredWormholeRelayerContract;
// storage gap to reduce risk of storage collisions
uint256[50] ______gap;
}
}

contract CoreRelayerState {
CoreRelayerStorage.State _state;
contract WormholeRelayerState {
WormholeRelayerStorage.State _state;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.0;

import "../interfaces/IWormholeRelayer.sol";

abstract contract CoreRelayerStructs {
abstract contract WormholeRelayerStructs {
struct DeliveryInstructionsContainer {
uint8 payloadId; //1
bool sufficientlyFunded;
Expand Down
Loading