Skip to content

Commit

Permalink
Import RMN 1.5 contracts (#1110)
Browse files Browse the repository at this point in the history
  • Loading branch information
gtklocker authored Jun 27, 2024
1 parent 434129b commit 62c1bab
Show file tree
Hide file tree
Showing 28 changed files with 2,310 additions and 1,147 deletions.
696 changes: 359 additions & 337 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/scripts/native_solc_compile_all_ccip
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ compileContract ccip/test/helpers/BurnMintERC677Helper.sol
compileContract ccip/test/helpers/CommitStoreHelper.sol
compileContract ccip/test/helpers/MessageHasher.sol
compileContract ccip/test/helpers/receivers/MaybeRevertMessageReceiver.sol
compileContract ccip/test/mocks/MockRMN.sol
compileContract ccip/test/mocks/MockRMN1_0.sol
compileContract ccip/test/mocks/MockE2EUSDCTokenMessenger.sol
compileContract ccip/test/mocks/MockE2EUSDCTransmitter.sol
compileContract ccip/test/WETH9.sol
Expand Down
829 changes: 594 additions & 235 deletions contracts/src/v0.8/ccip/RMN.sol

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/interfaces/IRMN.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ interface IRMN {
/// @notice Callers MUST NOT cache the return value as a blessed tagged root could become unblessed.
function isBlessed(TaggedRoot calldata taggedRoot) external view returns (bool);

/// @notice Iff there is an active global curse, or an active legacy curse (for backwards compatibility), this function returns true.
/// @notice Iff there is an active global or legacy curse, this function returns true.
function isCursed() external view returns (bool);

/// @notice Iff there is an active global curse or an active subject curse, this function returns true.
/// @notice Iff there is an active global curse, or an active curse for `subject`, this function returns true.
/// @param subject To check whether a particular chain is cursed, set to bytes16(uint128(chainSelector)).
function isCursed(bytes16 subject) external view returns (bool);
}
13 changes: 7 additions & 6 deletions contracts/src/v0.8/ccip/test/arm/ARMProxy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,36 @@ import {IRMN} from "../../interfaces/IRMN.sol";
import {ARMProxy} from "../../ARMProxy.sol";
import {RMN} from "../../RMN.sol";
import {MockRMN} from "../mocks/MockRMN.sol";
import {RMNSetup} from "./RMNSetup.t.sol";
import {RMNSetup, makeSubjects} from "./RMNSetup.t.sol";

contract ARMProxyTest is RMNSetup {
event ARMSet(address arm);

MockRMN internal s_mockRMN;
ARMProxy internal s_armProxy;

function setUp() public virtual override {
RMNSetup.setUp();
s_mockRMN = new MockRMN();
s_armProxy = new ARMProxy(address(s_rmn));
}

function test_ARMIsCursed_Success() public {
s_armProxy.setARM(address(s_mockRMN));
assertFalse(IRMN(address(s_armProxy)).isCursed());
RMN(address(s_armProxy)).voteToCurse(bytes32(0));
s_mockRMN.setGlobalCursed(true);
assertTrue(IRMN(address(s_armProxy)).isCursed());
}

function test_ARMIsBlessed_Success() public {
s_armProxy.setARM(address(s_mockRMN));
s_mockRMN.setTaggedRootBlessed(IRMN.TaggedRoot({commitStore: address(0), root: bytes32(0)}), true);
assertTrue(IRMN(address(s_armProxy)).isBlessed(IRMN.TaggedRoot({commitStore: address(0), root: bytes32(0)})));
RMN(address(s_armProxy)).voteToCurse(bytes32(0));
s_mockRMN.setTaggedRootBlessed(IRMN.TaggedRoot({commitStore: address(0), root: bytes32(0)}), false);
assertFalse(IRMN(address(s_armProxy)).isBlessed(IRMN.TaggedRoot({commitStore: address(0), root: bytes32(0)})));
}

function test_ARMCallRevertReasonForwarded() public {
bytes memory err = bytes("revert");
s_mockRMN.setRevert(err);
s_mockRMN.setIsCursedRevert(err);
s_armProxy.setARM(address(s_mockRMN));
vm.expectRevert(abi.encodeWithSelector(MockRMN.CustomError.selector, err));
IRMN(address(s_armProxy)).isCursed();
Expand Down
10 changes: 4 additions & 6 deletions contracts/src/v0.8/ccip/test/arm/ARMProxy_standalone.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {ARMProxy} from "../../ARMProxy.sol";
import {Test} from "forge-std/Test.sol";

contract ARMProxyStandaloneTest is Test {
event ARMSet(address arm);

address internal constant EMPTY_ADDRESS = address(0x1);
address internal constant OWNER_ADDRESS = 0xC0ffeeEeC0fFeeeEc0ffeEeEc0ffEEEEC0FfEEee;
address internal constant MOCK_RMN_ADDRESS = 0x1337133713371337133713371337133713371337;
Expand All @@ -23,14 +21,14 @@ contract ARMProxyStandaloneTest is Test {

function test_Constructor() public {
vm.expectEmit();
emit ARMSet(MOCK_RMN_ADDRESS);
emit ARMProxy.ARMSet(MOCK_RMN_ADDRESS);
ARMProxy proxy = new ARMProxy(MOCK_RMN_ADDRESS);
assertEq(proxy.getARM(), MOCK_RMN_ADDRESS);
}

function test_SetARM() public {
vm.expectEmit();
emit ARMSet(MOCK_RMN_ADDRESS);
emit ARMProxy.ARMSet(MOCK_RMN_ADDRESS);
vm.prank(OWNER_ADDRESS);
s_armProxy.setARM(MOCK_RMN_ADDRESS);
assertEq(s_armProxy.getARM(), MOCK_RMN_ADDRESS);
Expand All @@ -57,9 +55,9 @@ contract ARMProxyStandaloneTest is Test {
);
if (expectedSuccess) {
vm.mockCall(MOCK_ARM_ADDRESS, 0, call, ret);
vm.mockCall(MOCK_RMN_ADDRESS, 0, call, ret);
} else {
vm.mockCallRevert(MOCK_ARM_ADDRESS, 0, call, ret);
vm.mockCallRevert(MOCK_RMN_ADDRESS, 0, call, ret);
}
(bool actualSuccess, bytes memory result) = address(s_armProxy).call(call);
vm.clearMockedCalls();
Expand Down
Loading

0 comments on commit 62c1bab

Please sign in to comment.