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

Rename IRMNV2 => IRMNRemote #1484

Merged
merged 3 commits into from
Oct 3, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.4;
import {Internal} from "../libraries/Internal.sol";

/// @notice This interface contains the only RMN-related functions that might be used on-chain by other CCIP contracts.
interface IRMNV2 {
interface IRMNRemote {
/// @notice signature components from RMN nodes
struct Signature {
bytes32 r;
Expand Down
20 changes: 10 additions & 10 deletions contracts/src/v0.8/ccip/offRamp/OffRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {IFeeQuoter} from "../interfaces/IFeeQuoter.sol";
import {IMessageInterceptor} from "../interfaces/IMessageInterceptor.sol";
import {INonceManager} from "../interfaces/INonceManager.sol";
import {IPoolV1} from "../interfaces/IPool.sol";
import {IRMNV2} from "../interfaces/IRMNV2.sol";
import {IRMNRemote} from "../interfaces/IRMNRemote.sol";
import {IRouter} from "../interfaces/IRouter.sol";
import {ITokenAdminRegistry} from "../interfaces/ITokenAdminRegistry.sol";

Expand Down Expand Up @@ -95,7 +95,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
// solhint-disable-next-line gas-struct-packing
struct StaticConfig {
uint64 chainSelector; // ───╮ Destination chainSelector
IRMNV2 rmn; // ─────────────╯ RMN Verification Contract
IRMNRemote rmnRemote; // ───╯ RMN Verification Contract
address tokenAdminRegistry; // Token admin registry address
address nonceManager; // Nonce manager address
}
Expand Down Expand Up @@ -130,7 +130,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
struct CommitReport {
Internal.PriceUpdates priceUpdates; // Collection of gas and price updates to commit
Internal.MerkleRoot[] merkleRoots; // Collection of merkle roots per source chain to commit
IRMNV2.Signature[] rmnSignatures; // RMN signatures on the merkle roots
IRMNRemote.Signature[] rmnSignatures; // RMN signatures on the merkle roots
uint256 rmnRawVs; // Raw v values of the RMN signatures
}

Expand All @@ -147,7 +147,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
/// @dev ChainSelector of this chain
uint64 internal immutable i_chainSelector;
/// @dev The RMN verification contract
IRMNV2 internal immutable i_rmn;
IRMNRemote internal immutable i_rmnRemote;
/// @dev The address of the token admin registry
address internal immutable i_tokenAdminRegistry;
/// @dev The address of the nonce manager
Expand Down Expand Up @@ -178,7 +178,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
SourceChainConfigArgs[] memory sourceChainConfigs
) MultiOCR3Base() {
if (
address(staticConfig.rmn) == address(0) || staticConfig.tokenAdminRegistry == address(0)
address(staticConfig.rmnRemote) == address(0) || staticConfig.tokenAdminRegistry == address(0)
|| staticConfig.nonceManager == address(0)
) {
revert ZeroAddressNotAllowed();
Expand All @@ -189,7 +189,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
}

i_chainSelector = staticConfig.chainSelector;
i_rmn = staticConfig.rmn;
i_rmnRemote = staticConfig.rmnRemote;
i_tokenAdminRegistry = staticConfig.tokenAdminRegistry;
i_nonceManager = staticConfig.nonceManager;
emit StaticConfigSet(staticConfig);
Expand Down Expand Up @@ -357,7 +357,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
) internal {
uint64 sourceChainSelector = report.sourceChainSelector;
bool manualExecution = manualExecGasExecOverrides.length != 0;
if (i_rmn.isCursed(bytes16(uint128(sourceChainSelector)))) {
if (i_rmnRemote.isCursed(bytes16(uint128(sourceChainSelector)))) {
if (manualExecution) {
// For manual execution we don't want to silently fail so we revert
revert CursedByRMN(sourceChainSelector);
Expand Down Expand Up @@ -785,7 +785,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {

// Verify RMN signatures
if (commitReport.merkleRoots.length > 0) {
i_rmn.verify(address(this), commitReport.merkleRoots, commitReport.rmnSignatures, commitReport.rmnRawVs);
i_rmnRemote.verify(address(this), commitReport.merkleRoots, commitReport.rmnSignatures, commitReport.rmnRawVs);
}

// Check if the report contains price updates
Expand All @@ -811,7 +811,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
Internal.MerkleRoot memory root = commitReport.merkleRoots[i];
uint64 sourceChainSelector = root.sourceChainSelector;

if (i_rmn.isCursed(bytes16(uint128(sourceChainSelector)))) {
if (i_rmnRemote.isCursed(bytes16(uint128(sourceChainSelector)))) {
revert CursedByRMN(sourceChainSelector);
}

Expand Down Expand Up @@ -900,7 +900,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
function getStaticConfig() external view returns (StaticConfig memory) {
return StaticConfig({
chainSelector: i_chainSelector,
rmn: i_rmn,
rmnRemote: i_rmnRemote,
tokenAdminRegistry: i_tokenAdminRegistry,
nonceManager: i_nonceManager
});
Expand Down
16 changes: 8 additions & 8 deletions contracts/src/v0.8/ccip/onRamp/OnRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {IFeeQuoter} from "../interfaces/IFeeQuoter.sol";
import {IMessageInterceptor} from "../interfaces/IMessageInterceptor.sol";
import {INonceManager} from "../interfaces/INonceManager.sol";
import {IPoolV1} from "../interfaces/IPool.sol";
import {IRMNV2} from "../interfaces/IRMNV2.sol";
import {IRMNRemote} from "../interfaces/IRMNRemote.sol";
import {IRouter} from "../interfaces/IRouter.sol";
import {ITokenAdminRegistry} from "../interfaces/ITokenAdminRegistry.sol";

Expand Down Expand Up @@ -60,7 +60,7 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
// solhint-disable-next-line gas-struct-packing
struct StaticConfig {
uint64 chainSelector; // ─────╮ Source chain selector
IRMNV2 rmn; // ───────────────╯ RMN remote address
IRMNRemote rmnRemote; // ─────╯ RMN remote address
address nonceManager; // Nonce manager address
address tokenAdminRegistry; // Token admin registry address
}
Expand Down Expand Up @@ -113,7 +113,7 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
/// @dev The chain ID of the source chain that this contract is deployed to
uint64 private immutable i_chainSelector;
/// @dev The rmn contract
IRMNV2 private immutable i_rmn;
IRMNRemote private immutable i_rmnRemote;
/// @dev The address of the nonce manager
address private immutable i_nonceManager;
/// @dev The address of the token admin registry
Expand All @@ -132,14 +132,14 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
DestChainConfigArgs[] memory destChainConfigArgs
) {
if (
staticConfig.chainSelector == 0 || address(staticConfig.rmn) == address(0)
staticConfig.chainSelector == 0 || address(staticConfig.rmnRemote) == address(0)
|| staticConfig.nonceManager == address(0) || staticConfig.tokenAdminRegistry == address(0)
) {
revert InvalidConfig();
}

i_chainSelector = staticConfig.chainSelector;
i_rmn = staticConfig.rmn;
i_rmnRemote = staticConfig.rmnRemote;
i_nonceManager = staticConfig.nonceManager;
i_tokenAdminRegistry = staticConfig.tokenAdminRegistry;

Expand Down Expand Up @@ -314,7 +314,7 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
function getStaticConfig() external view returns (StaticConfig memory) {
return StaticConfig({
chainSelector: i_chainSelector,
rmn: i_rmn,
rmnRemote: i_rmnRemote,
nonceManager: i_nonceManager,
tokenAdminRegistry: i_tokenAdminRegistry
});
Expand Down Expand Up @@ -351,7 +351,7 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
emit ConfigSet(
StaticConfig({
chainSelector: i_chainSelector,
rmn: i_rmn,
rmnRemote: i_rmnRemote,
nonceManager: i_nonceManager,
tokenAdminRegistry: i_tokenAdminRegistry
}),
Expand Down Expand Up @@ -481,7 +481,7 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
uint64 destChainSelector,
Client.EVM2AnyMessage calldata message
) external view returns (uint256 feeTokenAmount) {
if (i_rmn.isCursed(bytes16(uint128(destChainSelector)))) revert CursedByRMN(destChainSelector);
if (i_rmnRemote.isCursed(bytes16(uint128(destChainSelector)))) revert CursedByRMN(destChainSelector);

return IFeeQuoter(s_dynamicConfig.feeQuoter).getValidatedFee(destChainSelector, message);
}
Expand Down
12 changes: 6 additions & 6 deletions contracts/src/v0.8/ccip/rmn/RMNRemote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.24;

import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol";
import {IRMNV2} from "../interfaces/IRMNV2.sol";
import {IRMNRemote} from "../interfaces/IRMNRemote.sol";

import {OwnerIsCreator} from "../../shared/access/OwnerIsCreator.sol";
import {EnumerableSet} from "../../shared/enumerable/EnumerableSetWithBytes16.sol";
Expand All @@ -19,7 +19,7 @@ bytes16 constant LEGACY_CURSE_SUBJECT = 0x01000000000000000000000000000000;
bytes16 constant GLOBAL_CURSE_SUBJECT = 0x01000000000000000000000000000001;

/// @notice This contract supports verification of RMN reports for any Any2EVM OffRamp.
contract RMNRemote is OwnerIsCreator, ITypeAndVersion, IRMNV2 {
contract RMNRemote is OwnerIsCreator, ITypeAndVersion, IRMNRemote {
using EnumerableSet for EnumerableSet.Bytes16Set;

error AlreadyCursed(bytes16 subject);
Expand Down Expand Up @@ -85,7 +85,7 @@ contract RMNRemote is OwnerIsCreator, ITypeAndVersion, IRMNV2 {
// │ Verification │
// ================================================================

/// @inheritdoc IRMNV2
/// @inheritdoc IRMNRemote
function verify(
address offrampAddress,
Internal.MerkleRoot[] calldata merkleRoots,
Expand Down Expand Up @@ -224,20 +224,20 @@ contract RMNRemote is OwnerIsCreator, ITypeAndVersion, IRMNV2 {
emit Uncursed(subjects);
}

/// @inheritdoc IRMNV2
/// @inheritdoc IRMNRemote
function getCursedSubjects() external view returns (bytes16[] memory subjects) {
return s_cursedSubjects.values();
}

/// @inheritdoc IRMNV2
/// @inheritdoc IRMNRemote
function isCursed() external view returns (bool) {
if (s_cursedSubjects.length() == 0) {
return false;
}
return s_cursedSubjects.contains(LEGACY_CURSE_SUBJECT) || s_cursedSubjects.contains(GLOBAL_CURSE_SUBJECT);
}

/// @inheritdoc IRMNV2
/// @inheritdoc IRMNRemote
function isCursed(bytes16 subject) external view returns (bool) {
if (s_cursedSubjects.length() == 0) {
return false;
Expand Down
8 changes: 4 additions & 4 deletions contracts/src/v0.8/ccip/test/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.24;
// Imports to any non-library are not allowed due to the significant cascading
// compile time increase they cause when imported into this base test.

import {IRMNV2} from "../interfaces/IRMNV2.sol";
import {IRMNRemote} from "../interfaces/IRMNRemote.sol";
import {Internal} from "../libraries/Internal.sol";
import {RateLimiter} from "../libraries/RateLimiter.sol";
import {MockRMN} from "./mocks/MockRMN.sol";
Expand Down Expand Up @@ -71,7 +71,7 @@ contract BaseTest is Test {
address internal constant ADMIN = 0x11118e64e1FB0c487f25dD6D3601FF6aF8d32E4e;

MockRMN internal s_mockRMN;
IRMNV2 internal s_mockRMNRemote;
IRMNRemote internal s_mockRMNRemote;

// nonce for pseudo-random number generation, not to be exposed to test suites
uint256 private randNonce;
Expand All @@ -92,9 +92,9 @@ contract BaseTest is Test {

// setup mock RMN & RMNRemote
s_mockRMN = new MockRMN();
s_mockRMNRemote = IRMNV2(makeAddr("MOCK RMN REMOTE"));
s_mockRMNRemote = IRMNRemote(makeAddr("MOCK RMN REMOTE"));
vm.etch(address(s_mockRMNRemote), bytes("fake bytecode"));
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSelector(IRMNV2.verify.selector), bytes(""));
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSelector(IRMNRemote.verify.selector), bytes(""));
_setMockRMNGlobalCurse(false);
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSignature("isCursed(bytes16)"), abi.encode(false)); // no curses by defaule
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/test/e2e/MultiRampsEnd2End.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {IRMN} from "../../interfaces/IRMN.sol";

import {AuthorizedCallers} from "../../../shared/access/AuthorizedCallers.sol";
import {NonceManager} from "../../NonceManager.sol";
import {IRMNV2} from "../../interfaces/IRMNV2.sol";
import {IRMNRemote} from "../../interfaces/IRMNRemote.sol";
import {LockReleaseTokenPool} from "../../pools/LockReleaseTokenPool.sol";
import {TokenAdminRegistry} from "../../tokenAdminRegistry/TokenAdminRegistry.sol";
import "../helpers/MerkleHelper.sol";
Expand Down Expand Up @@ -150,7 +150,7 @@ contract MultiRampsE2E is OnRampSetup, OffRampSetup {
merkleRoots[1] = MerkleHelper.getMerkleRoot(hashedMessages2);

// TODO make these real sigs :)
IRMNV2.Signature[] memory rmnSignatures = new IRMNV2.Signature[](0);
IRMNRemote.Signature[] memory rmnSignatures = new IRMNRemote.Signature[](0);

Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](2);
roots[0] = Internal.MerkleRoot({
Expand Down
26 changes: 13 additions & 13 deletions contracts/src/v0.8/ccip/test/offRamp/OffRamp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.24;

import {IFeeQuoter} from "../../interfaces/IFeeQuoter.sol";
import {IMessageInterceptor} from "../../interfaces/IMessageInterceptor.sol";
import {IRMNV2} from "../../interfaces/IRMNV2.sol";
import {IRMNRemote} from "../../interfaces/IRMNRemote.sol";
import {IRouter} from "../../interfaces/IRouter.sol";
import {ITokenAdminRegistry} from "../../interfaces/ITokenAdminRegistry.sol";

Expand Down Expand Up @@ -33,7 +33,7 @@ contract OffRamp_constructor is OffRampSetup {
function test_Constructor_Success() public {
OffRamp.StaticConfig memory staticConfig = OffRamp.StaticConfig({
chainSelector: DEST_CHAIN_SELECTOR,
rmn: s_mockRMNRemote,
rmnRemote: s_mockRMNRemote,
tokenAdminRegistry: address(s_tokenAdminRegistry),
nonceManager: address(s_inboundNonceManager)
});
Expand Down Expand Up @@ -102,7 +102,7 @@ contract OffRamp_constructor is OffRampSetup {
// Static config
OffRamp.StaticConfig memory gotStaticConfig = s_offRamp.getStaticConfig();
assertEq(staticConfig.chainSelector, gotStaticConfig.chainSelector);
assertEq(address(staticConfig.rmn), address(gotStaticConfig.rmn));
assertEq(address(staticConfig.rmnRemote), address(gotStaticConfig.rmnRemote));
assertEq(staticConfig.tokenAdminRegistry, gotStaticConfig.tokenAdminRegistry);

// Dynamic config
Expand Down Expand Up @@ -154,7 +154,7 @@ contract OffRamp_constructor is OffRampSetup {
s_offRamp = new OffRampHelper(
OffRamp.StaticConfig({
chainSelector: DEST_CHAIN_SELECTOR,
rmn: s_mockRMNRemote,
rmnRemote: s_mockRMNRemote,
tokenAdminRegistry: address(s_tokenAdminRegistry),
nonceManager: address(s_inboundNonceManager)
}),
Expand All @@ -180,7 +180,7 @@ contract OffRamp_constructor is OffRampSetup {
s_offRamp = new OffRampHelper(
OffRamp.StaticConfig({
chainSelector: DEST_CHAIN_SELECTOR,
rmn: s_mockRMNRemote,
rmnRemote: s_mockRMNRemote,
tokenAdminRegistry: address(s_tokenAdminRegistry),
nonceManager: address(s_inboundNonceManager)
}),
Expand All @@ -200,7 +200,7 @@ contract OffRamp_constructor is OffRampSetup {
s_offRamp = new OffRampHelper(
OffRamp.StaticConfig({
chainSelector: DEST_CHAIN_SELECTOR,
rmn: IRMNV2(ZERO_ADDRESS),
rmnRemote: IRMNRemote(ZERO_ADDRESS),
tokenAdminRegistry: address(s_tokenAdminRegistry),
nonceManager: address(s_inboundNonceManager)
}),
Expand All @@ -220,7 +220,7 @@ contract OffRamp_constructor is OffRampSetup {
s_offRamp = new OffRampHelper(
OffRamp.StaticConfig({
chainSelector: 0,
rmn: s_mockRMNRemote,
rmnRemote: s_mockRMNRemote,
tokenAdminRegistry: address(s_tokenAdminRegistry),
nonceManager: address(s_inboundNonceManager)
}),
Expand All @@ -240,7 +240,7 @@ contract OffRamp_constructor is OffRampSetup {
s_offRamp = new OffRampHelper(
OffRamp.StaticConfig({
chainSelector: DEST_CHAIN_SELECTOR,
rmn: s_mockRMNRemote,
rmnRemote: s_mockRMNRemote,
tokenAdminRegistry: ZERO_ADDRESS,
nonceManager: address(s_inboundNonceManager)
}),
Expand All @@ -260,7 +260,7 @@ contract OffRamp_constructor is OffRampSetup {
s_offRamp = new OffRampHelper(
OffRamp.StaticConfig({
chainSelector: DEST_CHAIN_SELECTOR,
rmn: s_mockRMNRemote,
rmnRemote: s_mockRMNRemote,
tokenAdminRegistry: address(s_tokenAdminRegistry),
nonceManager: ZERO_ADDRESS
}),
Expand Down Expand Up @@ -3367,7 +3367,7 @@ contract OffRamp_commit is OffRampSetup {

function test_OnlyTokenPriceUpdates_Success() public {
// force RMN verification to fail
vm.mockCallRevert(address(s_mockRMNRemote), abi.encodeWithSelector(IRMNV2.verify.selector), bytes(""));
vm.mockCallRevert(address(s_mockRMNRemote), abi.encodeWithSelector(IRMNRemote.verify.selector), bytes(""));

Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](0);
OffRamp.CommitReport memory commitReport = OffRamp.CommitReport({
Expand All @@ -3390,7 +3390,7 @@ contract OffRamp_commit is OffRampSetup {

function test_OnlyGasPriceUpdates_Success() public {
// force RMN verification to fail
vm.mockCallRevert(address(s_mockRMNRemote), abi.encodeWithSelector(IRMNV2.verify.selector), bytes(""));
vm.mockCallRevert(address(s_mockRMNRemote), abi.encodeWithSelector(IRMNRemote.verify.selector), bytes(""));

Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](0);
OffRamp.CommitReport memory commitReport = OffRamp.CommitReport({
Expand Down Expand Up @@ -3561,7 +3561,7 @@ contract OffRamp_commit is OffRampSetup {

function test_FailedRMNVerification_Reverts() public {
// force RMN verification to fail
vm.mockCallRevert(address(s_mockRMNRemote), abi.encodeWithSelector(IRMNV2.verify.selector), bytes(""));
vm.mockCallRevert(address(s_mockRMNRemote), abi.encodeWithSelector(IRMNRemote.verify.selector), bytes(""));

OffRamp.CommitReport memory commitReport = _constructCommitReport();
vm.expectRevert();
Expand Down Expand Up @@ -3769,7 +3769,7 @@ contract OffRamp_afterOC3ConfigSet is OffRampSetup {
s_offRamp = new OffRampHelper(
OffRamp.StaticConfig({
chainSelector: DEST_CHAIN_SELECTOR,
rmn: s_mockRMNRemote,
rmnRemote: s_mockRMNRemote,
tokenAdminRegistry: address(s_tokenAdminRegistry),
nonceManager: address(s_inboundNonceManager)
}),
Expand Down
Loading
Loading