Skip to content

Commit b845301

Browse files
committedFeb 24, 2024
sibling -> peer
1 parent 076f44c commit b845301

34 files changed

+275
-300
lines changed
 

‎evm/src/NttManager.sol

+21-21
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ contract NttManager is
7575
bytes32 private constant MESSAGE_SEQUENCE_SLOT =
7676
bytes32(uint256(keccak256("ntt.messageSequence")) - 1);
7777

78-
bytes32 private constant SIBLINGS_SLOT = bytes32(uint256(keccak256("ntt.siblings")) - 1);
78+
bytes32 private constant PEERS_SLOT = bytes32(uint256(keccak256("ntt.peers")) - 1);
7979

8080
bytes32 private constant THRESHOLD_SLOT = bytes32(uint256(keccak256("ntt.threshold")) - 1);
8181

@@ -106,8 +106,8 @@ contract NttManager is
106106
}
107107
}
108108

109-
function _getSiblingsStorage() internal pure returns (mapping(uint16 => bytes32) storage $) {
110-
uint256 slot = uint256(SIBLINGS_SLOT);
109+
function _getPeersStorage() internal pure returns (mapping(uint16 => bytes32) storage $) {
110+
uint256 slot = uint256(PEERS_SLOT);
111111
assembly ("memory-safe") {
112112
$.slot := slot
113113
}
@@ -265,7 +265,7 @@ contract NttManager is
265265
recipientChain,
266266
transceiverInstructions[transceiverInfos[transceiverAddr].index],
267267
nttManagerMessage,
268-
getSibling(recipientChain)
268+
getPeer(recipientChain)
269269
);
270270
}
271271
}
@@ -572,10 +572,10 @@ contract NttManager is
572572
return sequence;
573573
}
574574

575-
/// @dev Verify that the sibling address saved for `sourceChainId` matches the `siblingAddress`.
576-
function _verifySibling(uint16 sourceChainId, bytes32 siblingAddress) internal view {
577-
if (getSibling(sourceChainId) != siblingAddress) {
578-
revert InvalidSibling(sourceChainId, siblingAddress);
575+
/// @dev Verify that the peer address saved for `sourceChainId` matches the `peerAddress`.
576+
function _verifyPeer(uint16 sourceChainId, bytes32 peerAddress) internal view {
577+
if (getPeer(sourceChainId) != peerAddress) {
578+
revert InvalidPeer(sourceChainId, peerAddress);
579579
}
580580
}
581581

@@ -714,25 +714,25 @@ contract NttManager is
714714
return _getMessageAttestationsStorage()[digest].executed;
715715
}
716716

717-
function getSibling(uint16 chainId_) public view returns (bytes32) {
718-
return _getSiblingsStorage()[chainId_];
717+
function getPeer(uint16 chainId_) public view returns (bytes32) {
718+
return _getPeersStorage()[chainId_];
719719
}
720720

721-
/// @notice this sets the corresponding sibling.
722-
/// @dev The nttManager that executes the message sets the source nttManager as the sibling.
723-
function setSibling(uint16 siblingChainId, bytes32 siblingContract) public onlyOwner {
724-
if (siblingChainId == 0) {
725-
revert InvalidSiblingChainIdZero();
721+
/// @notice this sets the corresponding peer.
722+
/// @dev The nttManager that executes the message sets the source nttManager as the peer.
723+
function setPeer(uint16 peerChainId, bytes32 peerContract) public onlyOwner {
724+
if (peerChainId == 0) {
725+
revert InvalidPeerChainIdZero();
726726
}
727-
if (siblingContract == bytes32(0)) {
728-
revert InvalidSiblingZeroAddress();
727+
if (peerContract == bytes32(0)) {
728+
revert InvalidPeerZeroAddress();
729729
}
730730

731-
bytes32 oldSiblingContract = _getSiblingsStorage()[siblingChainId];
731+
bytes32 oldPeerContract = _getPeersStorage()[peerChainId];
732732

733-
_getSiblingsStorage()[siblingChainId] = siblingContract;
733+
_getPeersStorage()[peerChainId] = peerContract;
734734

735-
emit SiblingUpdated(siblingChainId, oldSiblingContract, siblingContract);
735+
emit PeerUpdated(peerChainId, oldPeerContract, peerContract);
736736
}
737737

738738
function transceiverAttestedToMessage(bytes32 digest, uint8 index) public view returns (bool) {
@@ -745,7 +745,7 @@ contract NttManager is
745745
bytes32 sourceNttManagerAddress,
746746
TransceiverStructs.NttManagerMessage memory payload
747747
) external onlyTransceiver {
748-
_verifySibling(sourceChainId, sourceNttManagerAddress);
748+
_verifyPeer(sourceChainId, sourceNttManagerAddress);
749749

750750
bytes32 nttManagerMessageHash =
751751
TransceiverStructs.nttManagerMessageDigest(sourceChainId, payload);

‎evm/src/WormholeTransceiver.sol

+30-33
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ contract WormholeTransceiver is Transceiver, IWormholeTransceiver, IWormholeRece
2828
/// This is bytes4(keccak256("WormholeTransceiverInit"))
2929
bytes4 constant WH_TRANSCEIVER_INIT_PREFIX = 0xc83e3d2e;
3030

31-
/// @dev Prefix for all Wormhole sibling registration payloads
32-
/// This is bytes4(keccak256("WormholeSiblingRegistration"))
33-
bytes4 constant WH_SIBLING_REGISTRATION_PREFIX = 0xd0d292f1;
31+
/// @dev Prefix for all Wormhole peer registration payloads
32+
/// This is bytes4(keccak256("WormholePeerRegistration"))
33+
bytes4 constant WH_PEER_REGISTRATION_PREFIX = 0xd0d292f1;
3434

3535
IWormhole public immutable wormhole;
3636
IWormholeRelayer public immutable wormholeRelayer;
@@ -46,8 +46,8 @@ contract WormholeTransceiver is Transceiver, IWormholeTransceiver, IWormholeRece
4646
bytes32 private constant WORMHOLE_CONSUMED_VAAS_SLOT =
4747
bytes32(uint256(keccak256("whTransceiver.consumedVAAs")) - 1);
4848

49-
bytes32 private constant WORMHOLE_SIBLINGS_SLOT =
50-
bytes32(uint256(keccak256("whTransceiver.siblings")) - 1);
49+
bytes32 private constant WORMHOLE_PEERS_SLOT =
50+
bytes32(uint256(keccak256("whTransceiver.peers")) - 1);
5151

5252
bytes32 private constant WORMHOLE_RELAYING_ENABLED_CHAINS_SLOT =
5353
bytes32(uint256(keccak256("whTransceiver.relayingEnabledChains")) - 1);
@@ -71,12 +71,12 @@ contract WormholeTransceiver is Transceiver, IWormholeTransceiver, IWormholeRece
7171
}
7272
}
7373

74-
function _getWormholeSiblingsStorage()
74+
function _getWormholePeersStorage()
7575
internal
7676
pure
7777
returns (mapping(uint16 => bytes32) storage $)
7878
{
79-
uint256 slot = uint256(WORMHOLE_SIBLINGS_SLOT);
79+
uint256 slot = uint256(WORMHOLE_PEERS_SLOT);
8080
assembly ("memory-safe") {
8181
$.slot := slot
8282
}
@@ -211,7 +211,7 @@ contract WormholeTransceiver is Transceiver, IWormholeTransceiver, IWormholeRece
211211
if (!weIns.shouldSkipRelayerSend && _shouldRelayViaStandardRelaying(recipientChain)) {
212212
wormholeRelayer.sendPayloadToEvm{value: deliveryPayment}(
213213
recipientChain,
214-
fromWormholeFormat(getWormholeSibling(recipientChain)),
214+
fromWormholeFormat(getWormholePeer(recipientChain)),
215215
encodedTransceiverPayload,
216216
0,
217217
GAS_LIMIT
@@ -236,8 +236,8 @@ contract WormholeTransceiver is Transceiver, IWormholeTransceiver, IWormholeRece
236236
uint16 sourceChain,
237237
bytes32 deliveryHash
238238
) external payable onlyRelayer {
239-
if (getWormholeSibling(sourceChain) != sourceAddress) {
240-
revert InvalidWormholeSibling(sourceChain, sourceAddress);
239+
if (getWormholePeer(sourceChain) != sourceAddress) {
240+
revert InvalidWormholePeer(sourceChain, sourceAddress);
241241
}
242242

243243
// VAA replay protection
@@ -301,9 +301,9 @@ contract WormholeTransceiver is Transceiver, IWormholeTransceiver, IWormholeRece
301301
revert InvalidVaa(reason);
302302
}
303303

304-
// ensure that the message came from a registered sibling contract
304+
// ensure that the message came from a registered peer contract
305305
if (!_verifyBridgeVM(vm)) {
306-
revert InvalidWormholeSibling(vm.emitterChainId, vm.emitterAddress);
306+
revert InvalidWormholePeer(vm.emitterChainId, vm.emitterAddress);
307307
}
308308

309309
// save the VAA hash in storage to protect against replay attacks.
@@ -320,7 +320,7 @@ contract WormholeTransceiver is Transceiver, IWormholeTransceiver, IWormholeRece
320320

321321
function _verifyBridgeVM(IWormhole.VM memory vm) internal view returns (bool) {
322322
checkFork(wormholeTransceiver_evmChainId);
323-
return getWormholeSibling(vm.emitterChainId) == vm.emitterAddress;
323+
return getWormholePeer(vm.emitterChainId) == vm.emitterAddress;
324324
}
325325

326326
function isVAAConsumed(bytes32 hash) public view returns (bool) {
@@ -333,49 +333,46 @@ contract WormholeTransceiver is Transceiver, IWormholeTransceiver, IWormholeRece
333333

334334
/// @notice Get the corresponding Transceiver contract on other chains that have been registered via governance.
335335
/// This design should be extendable to other chains, so each Transceiver would be potentially concerned with Transceivers on multiple other chains
336-
/// Note that siblings are registered under wormhole chainID values
337-
function getWormholeSibling(uint16 chainId) public view returns (bytes32) {
338-
return _getWormholeSiblingsStorage()[chainId];
336+
/// Note that peers are registered under wormhole chainID values
337+
function getWormholePeer(uint16 chainId) public view returns (bytes32) {
338+
return _getWormholePeersStorage()[chainId];
339339
}
340340

341-
function setWormholeSibling(
342-
uint16 siblingChainId,
343-
bytes32 siblingContract
344-
) external onlyOwner {
345-
_setWormholeSibling(siblingChainId, siblingContract);
341+
function setWormholePeer(uint16 peerChainId, bytes32 peerContract) external onlyOwner {
342+
_setWormholePeer(peerChainId, peerContract);
346343
}
347344

348-
function _setWormholeSibling(uint16 chainId, bytes32 siblingContract) internal {
345+
function _setWormholePeer(uint16 chainId, bytes32 peerContract) internal {
349346
if (chainId == 0) {
350347
revert InvalidWormholeChainIdZero();
351348
}
352-
if (siblingContract == bytes32(0)) {
353-
revert InvalidWormholeSiblingZeroAddress();
349+
if (peerContract == bytes32(0)) {
350+
revert InvalidWormholePeerZeroAddress();
354351
}
355352

356-
bytes32 oldSiblingContract = _getWormholeSiblingsStorage()[chainId];
353+
bytes32 oldPeerContract = _getWormholePeersStorage()[chainId];
357354

358-
// We don't want to allow updating a sibling since this adds complexity in the accountant
359-
// If the owner makes a mistake with sibling registration they should deploy a new Wormhole
355+
// We don't want to allow updating a peer since this adds complexity in the accountant
356+
// If the owner makes a mistake with peer registration they should deploy a new Wormhole
360357
// transceiver and register this new transceiver with the NttManager
361-
if (oldSiblingContract != bytes32(0)) {
362-
revert SiblingAlreadySet(chainId, oldSiblingContract);
358+
if (oldPeerContract != bytes32(0)) {
359+
revert PeerAlreadySet(chainId, oldPeerContract);
363360
}
364361

365-
_getWormholeSiblingsStorage()[chainId] = siblingContract;
362+
_getWormholePeersStorage()[chainId] = peerContract;
366363

367364
// Publish a message for this transceiver registration
368365
TransceiverStructs.TransceiverRegistration memory registration = TransceiverStructs
369366
.TransceiverRegistration({
370-
transceiverIdentifier: WH_SIBLING_REGISTRATION_PREFIX,
367+
transceiverIdentifier: WH_PEER_REGISTRATION_PREFIX,
371368
transceiverChainId: chainId,
372-
transceiverAddress: siblingContract
369+
transceiverAddress: peerContract
373370
});
374371
wormhole.publishMessage(
375372
0, TransceiverStructs.encodeTransceiverRegistration(registration), consistencyLevel
376373
);
377374

378-
emit SetWormholeSibling(chainId, siblingContract);
375+
emit SetWormholePeer(chainId, peerContract);
379376
}
380377

381378
function isWormholeRelayingEnabled(uint16 chainId) public view returns (bool) {

‎evm/src/interfaces/INttManager.sol

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ interface INttManager {
2626
/// @param mode The mode.
2727
error InvalidMode(uint8 mode);
2828

29-
/// @notice the sibling for the chain does not match the configuration.
29+
/// @notice the peer for the chain does not match the configuration.
3030
/// @param chainId ChainId of the source chain.
31-
/// @param siblingAddress Address of the sibling nttManager contract.
32-
error InvalidSibling(uint16 chainId, bytes32 siblingAddress);
33-
error InvalidSiblingChainIdZero();
31+
/// @param peerAddress Address of the peer nttManager contract.
32+
error InvalidPeer(uint16 chainId, bytes32 peerAddress);
33+
error InvalidPeerChainIdZero();
3434

35-
/// @notice Sibling cannot be the zero address.
36-
error InvalidSiblingZeroAddress();
35+
/// @notice Peer cannot be the zero address.
36+
error InvalidPeerZeroAddress();
3737

3838
/// @notice The number of thresholds should not be zero.
3939
error ZeroThreshold();
@@ -61,9 +61,9 @@ interface INttManager {
6161
bytes memory encodedInstructions
6262
) external payable returns (uint64 msgId);
6363

64-
function getSibling(uint16 chainId_) external view returns (bytes32);
64+
function getPeer(uint16 chainId_) external view returns (bytes32);
6565

66-
function setSibling(uint16 siblingChainId, bytes32 siblingContract) external;
66+
function setPeer(uint16 peerChainId, bytes32 peerContract) external;
6767

6868
/// @notice Check if a message has been approved. The message should have at least
6969
/// the minimum threshold of attestations fron distinct transceivers.

‎evm/src/interfaces/INttManagerEvents.sol

+5-7
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ interface INttManagerEvents {
1515
bytes32 recipient, uint256 amount, uint16 recipientChain, uint64 msgSequence
1616
);
1717

18-
/// @notice Emitted when the sibling contract is updated.
18+
/// @notice Emitted when the peer contract is updated.
1919
/// @dev Topic0
2020
/// 0x51b8437a7e22240c473f4cbdb4ed3a4f4bf5a9e7b3c511d7cfe0197325735700.
21-
/// @param chainId_ The chain ID of the sibling contract.
22-
/// @param oldSiblingContract The old sibling contract address.
23-
/// @param siblingContract The new sibling contract address.
24-
event SiblingUpdated(
25-
uint16 indexed chainId_, bytes32 oldSiblingContract, bytes32 siblingContract
26-
);
21+
/// @param chainId_ The chain ID of the peer contract.
22+
/// @param oldPeerContract The old peer contract address.
23+
/// @param peerContract The new peer contract address.
24+
event PeerUpdated(uint16 indexed chainId_, bytes32 oldPeerContract, bytes32 peerContract);
2725

2826
/// @notice Emitted when a message has been attested to.
2927
/// @dev Topic0

‎evm/src/interfaces/IWormholeTransceiver.sol

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface IWormholeTransceiver {
1212
event SendTransceiverMessage(
1313
uint16 recipientChain, TransceiverStructs.TransceiverMessage message
1414
);
15-
event SetWormholeSibling(uint16 chainId, bytes32 siblingContract);
15+
event SetWormholePeer(uint16 chainId, bytes32 peerContract);
1616
event SetIsWormholeRelayingEnabled(uint16 chainId, bool isRelayingEnabled);
1717
event SetIsSpecialRelayingEnabled(uint16 chainId, bool isRelayingEnabled);
1818
event SetIsWormholeEvmChain(uint16 chainId);
@@ -21,15 +21,15 @@ interface IWormholeTransceiver {
2121
error CallerNotRelayer(address caller);
2222
error UnexpectedAdditionalMessages();
2323
error InvalidVaa(string reason);
24-
error InvalidWormholeSibling(uint16 chainId, bytes32 siblingAddress);
25-
error SiblingAlreadySet(uint16 chainId, bytes32 siblingAddress);
24+
error InvalidWormholePeer(uint16 chainId, bytes32 peerAddress);
25+
error PeerAlreadySet(uint16 chainId, bytes32 peerAddress);
2626
error TransferAlreadyCompleted(bytes32 vaaHash);
27-
error InvalidWormholeSiblingZeroAddress();
27+
error InvalidWormholePeerZeroAddress();
2828
error InvalidWormholeChainIdZero();
2929

3030
function receiveMessage(bytes memory encodedMessage) external;
3131
function isVAAConsumed(bytes32 hash) external view returns (bool);
32-
function getWormholeSibling(uint16 chainId) external view returns (bytes32);
32+
function getWormholePeer(uint16 chainId) external view returns (bytes32);
3333
function isWormholeRelayingEnabled(uint16 chainId) external view returns (bool);
3434
function isSpecialRelayingEnabled(uint16 chainId) external view returns (bool);
3535
function isWormholeEvmChain(uint16 chainId) external view returns (bool);

0 commit comments

Comments
 (0)