Skip to content

Commit

Permalink
Merge branch 'develop' into fix/gha-workflow-zizmor
Browse files Browse the repository at this point in the history
  • Loading branch information
erikburt committed Dec 19, 2024
2 parents 172e8fd + 06a4445 commit ddd920c
Show file tree
Hide file tree
Showing 235 changed files with 2,551 additions and 1,856 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-geckos-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#updated Gracefully fail if CL_DATABASE_URL is not set.
5 changes: 5 additions & 0 deletions .changeset/large-fishes-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Fix logic for mapping affected files in CI that affects golangci-lint execution
34 changes: 22 additions & 12 deletions .github/scripts/map-affected-files-to-modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,35 @@ echo "Found modules: $modules"
declare -A unique_modules

for path_to_file in $changed_files; do
echo "Resolving a module affected by a file: '$path_to_file'"
echo "Resolving a module affected by a file: '$path_to_file'"
# the flag that indicates if the path matches any module
is_path_in_modules=false
for module in $modules; do
echo "Validating against module: '$module'"

# if no slash in the path, it is the root
# (i.e. `main.go`, `.gitignore` vs `core/main.go`)
if [[ ! $path_to_file =~ \/ ]]; then
echo "File '$path_to_file' mapped to the "root" module."
unique_modules["."]="."
break
# if a module's name matches with a file path
# add it, to the affected modules array, skipping the root (`.`)
elif [[ $module != "." && $path_to_file =~ ^$module* ]]; then
echo "File '$path_to_file' mapped the module '$module'"
if [[ $module != "." && $path_to_file =~ ^$module* ]]; then
echo -e "File '$path_to_file' mapped to the module '$module'\n"
unique_modules["$module"]="$module"
is_path_in_modules=true
break
fi
done
done
done
# if no matched module default to root module
if [[ $is_path_in_modules == false ]]; then
echo "File '$path_to_file' did not match any module, defaulting to root '.'"
unique_modules["."]="."
is_path_in_modules=false
fi
is_path_in_modules=false
done

# if the path is empty (for any reason), it will not get to the loop,
# so if the unique_modules array is empty, default to the root module
if [[ ${#unique_modules[@]} -eq 0 ]]; then
echo "No files were changed, defaulting to the root module '.'"
unique_modules["."]="."
fi

# Convert keys (module names) of the associative array to an indexed array
affected_modules=("${!unique_modules[@]}")
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/crib-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
echo $GITHUB_WORKSPACE
- name: Deploy and validate CRIB Environment for Core
uses: smartcontractkit/.github/actions/crib-deploy-environment@57f99fbea73056c490c766d50ef582a13ec4f3bb # crib-deploy-environment@7.2.0
uses: smartcontractkit/.github/actions/crib-deploy-environment@815e0d550527897746e889441407926d7e28169c # crib-deploy-environment@7.4.0
id: deploy-crib
with:
github-token: ${{ steps.token.outputs.access-token }}
Expand Down
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
timeout: 15m0s
timeout: 15m
allow-parallel-runners: true
linters:
enable:
Expand Down Expand Up @@ -97,7 +97,7 @@ linters-settings:
- name: waitgroup-by-value
- name: unconditional-recursion
- name: struct-tag
# - name: string-format
- name: string-format
- name: string-of-int
- name: range-val-address
- name: range-val-in-closure
Expand Down
5 changes: 5 additions & 0 deletions contracts/.changeset/new-elephants-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': patch
---

fix test naming
1,085 changes: 367 additions & 718 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/rmn/RMNRemote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ contract RMNRemote is Ownable2StepMsgSender, ITypeAndVersion, IRMNRemote, IRMN {

/// @inheritdoc IRMNRemote
function verify(
address offrampAddress,
address offRampAddress,
Internal.MerkleRoot[] calldata merkleRoots,
Signature[] calldata signatures
) external view {
Expand All @@ -110,7 +110,7 @@ contract RMNRemote is Ownable2StepMsgSender, ITypeAndVersion, IRMNRemote, IRMN {
destChainId: block.chainid,
destChainSelector: i_localChainSelector,
rmnRemoteContractAddress: address(this),
offrampAddress: offrampAddress,
offrampAddress: offRampAddress,
rmnHomeContractConfigDigest: s_config.rmnHomeContractConfigDigest,
merkleRoots: merkleRoots
})
Expand Down
70 changes: 24 additions & 46 deletions contracts/src/v0.8/ccip/test/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,37 @@ 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 {IRMNRemote} from "../interfaces/IRMNRemote.sol";

import {Router} from "../Router.sol";
import {Internal} from "../libraries/Internal.sol";
import {RateLimiter} from "../libraries/RateLimiter.sol";
import {MockRMN} from "./mocks/MockRMN.sol";
import {WETH9} from "./WETH9.sol";

import {Test} from "forge-std/Test.sol";

contract BaseTest is Test {
// Addresses
address internal constant OWNER = 0x00007e64E1fB0C487F25dd6D3601ff6aF8d32e4e;
address internal constant STRANGER = address(999999);

address internal constant USER_1 = address(1);
// Timing
uint256 internal constant BLOCK_TIME = 1234567890;
uint32 internal constant TWELVE_HOURS = 60 * 60 * 12;

// Message info
uint64 internal constant SOURCE_CHAIN_SELECTOR = 1;
uint64 internal constant DEST_CHAIN_SELECTOR = 2;
uint32 internal constant GAS_LIMIT = 200_000;

// Timing
uint256 internal constant BLOCK_TIME = 1234567890;
uint32 internal constant TWELVE_HOURS = 60 * 60 * 12;

// Onramp
uint96 internal constant MAX_MSG_FEES_JUELS = 1_000e18;
uint32 internal constant DEST_GAS_OVERHEAD = 300_000;
uint16 internal constant DEST_GAS_PER_PAYLOAD_BYTE = 16;

uint16 internal constant DEFAULT_TOKEN_FEE_USD_CENTS = 50;
uint32 internal constant DEFAULT_TOKEN_DEST_GAS_OVERHEAD = 90_000;
uint32 internal constant DEFAULT_TOKEN_BYTES_OVERHEAD = 32;
uint8 internal constant DEFAULT_TOKEN_DECIMALS = 18;
uint16 internal constant GAS_FOR_CALL_EXACT_CHECK = 5_000;

bool private s_baseTestInitialized;

// OffRamp
uint32 internal constant MAX_DATA_SIZE = 30_000;
uint16 internal constant MAX_TOKENS_LENGTH = 5;
uint16 internal constant GAS_FOR_CALL_EXACT_CHECK = 5_000;
uint32 internal constant MAX_GAS_LIMIT = 4_000_000;

MockRMN internal s_mockRMN;
IRMNRemote internal s_mockRMNRemote;

// nonce for pseudo-random number generation, not to be exposed to test suites
uint256 private s_randNonce;
Router internal s_sourceRouter;
Router internal s_destRouter;

function setUp() public virtual {
// BaseTest.setUp is often called multiple times from tests' setUp due to inheritance.
Expand All @@ -64,19 +49,18 @@ contract BaseTest is Test {
// Set the block time to a constant known value
vm.warp(BLOCK_TIME);

// setup mock RMN & RMNRemote
s_mockRMN = new MockRMN();
// setup RMNRemote
s_mockRMNRemote = IRMNRemote(makeAddr("MOCK RMN REMOTE"));
vm.etch(address(s_mockRMNRemote), bytes("fake bytecode"));
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSelector(IRMNRemote.verify.selector), bytes(""));
_setMockRMNGlobalCurse(false);
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSignature("isCursed()"), abi.encode(false));
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSignature("isCursed(bytes16)"), abi.encode(false)); // no curses by defaule
}

function _setMockRMNGlobalCurse(
bool isCursed
) internal {
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSignature("isCursed()"), abi.encode(isCursed));
s_sourceRouter = new Router(address(new WETH9()), address(s_mockRMNRemote));
vm.label(address(s_sourceRouter), "sourceRouter");
// Deploy a destination router
s_destRouter = new Router(address(new WETH9()), address(s_mockRMNRemote));
vm.label(address(s_destRouter), "destRouter");
}

function _setMockRMNChainCurse(uint64 chainSelector, bool isCursed) internal {
Expand Down Expand Up @@ -108,18 +92,12 @@ contract BaseTest is Test {
return priceUpdates;
}

/// @dev returns a pseudo-random bytes32
function _randomBytes32() internal returns (bytes32) {
return keccak256(abi.encodePacked(++s_randNonce));
}

/// @dev returns a pseudo-random number
function _randomNum() internal returns (uint256) {
return uint256(_randomBytes32());
}

/// @dev returns a pseudo-random address
function _randomAddress() internal returns (address) {
return address(uint160(_randomNum()));
function _generateSourceTokenData() internal pure returns (Internal.SourceTokenData memory) {
return Internal.SourceTokenData({
sourcePoolAddress: abi.encode(address(12312412312)),
destTokenAddress: abi.encode(address(9809808909)),
extraData: "",
destGasAmount: DEFAULT_TOKEN_DEST_GAS_OVERHEAD
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {NonceManager} from "../../NonceManager.sol";
import {OnRampSetup} from "../onRamp/OnRamp/OnRampSetup.t.sol";

contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
function test_SingleRampUpdate_success() public {
function test_SingleRampUpdate() public {
address prevOnRamp = makeAddr("prevOnRamp");
address prevOffRamp = makeAddr("prevOffRamp");
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
Expand Down Expand Up @@ -80,7 +80,7 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
assertEq(vm.getRecordedLogs().length, 0);
}

function test_applyPreviousRampsUpdates_RevertWhen_PreviousRampAlreadySetOnRamp() public {
function test_RevertWhen_applyPreviousRampsUpdatesWhen_PreviousRampAlreadySetOnRamp() public {
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
address prevOnRamp = makeAddr("prevOnRamp");
previousRamps[0] = NonceManager.PreviousRampsArgs({
Expand All @@ -101,7 +101,7 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);
}

function test_applyPreviousRampsUpdates_RevertWhen_PreviousRampAlreadySetOffRamp() public {
function test_RevertWhen_applyPreviousRampsUpdatesWhen_PreviousRampAlreadySetOffRamp() public {
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
address prevOffRamp = makeAddr("prevOffRamp");
previousRamps[0] = NonceManager.PreviousRampsArgs({
Expand All @@ -122,7 +122,7 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);
}

function test_applyPreviousRampsUpdates_RevertWhen_PreviousRampAlreadySetOnRampAndOffRamp_Revert() public {
function test_RevertWhen_applyPreviousRampsUpdatesWhen_PreviousRampAlreadySetOnRampAndOffRamp_Revert() public {
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
address prevOnRamp = makeAddr("prevOnRamp");
address prevOffRamp = makeAddr("prevOffRamp");
Expand Down
10 changes: 5 additions & 5 deletions contracts/src/v0.8/ccip/test/TokenSetup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {BurnMintTokenPool} from "../pools/BurnMintTokenPool.sol";
import {LockReleaseTokenPool} from "../pools/LockReleaseTokenPool.sol";
import {TokenPool} from "../pools/TokenPool.sol";
import {TokenAdminRegistry} from "../tokenAdminRegistry/TokenAdminRegistry.sol";
import {BaseTest} from "./BaseTest.t.sol";
import {MaybeRevertingBurnMintTokenPool} from "./helpers/MaybeRevertingBurnMintTokenPool.sol";
import {RouterSetup} from "./router/Router/RouterSetup.t.sol";

import {IERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";

contract TokenSetup is RouterSetup {
contract TokenSetup is BaseTest {
address[] internal s_sourceTokens;
address[] internal s_destTokens;

Expand Down Expand Up @@ -46,7 +46,7 @@ contract TokenSetup is RouterSetup {
}

LockReleaseTokenPool pool = new LockReleaseTokenPool(
IERC20(token), DEFAULT_TOKEN_DECIMALS, new address[](0), address(s_mockRMN), true, router
IERC20(token), DEFAULT_TOKEN_DECIMALS, new address[](0), address(s_mockRMNRemote), true, router
);

if (isSourcePool) {
Expand All @@ -64,7 +64,7 @@ contract TokenSetup is RouterSetup {
}

BurnMintTokenPool pool = new MaybeRevertingBurnMintTokenPool(
BurnMintERC20(token), DEFAULT_TOKEN_DECIMALS, new address[](0), address(s_mockRMN), router
BurnMintERC20(token), DEFAULT_TOKEN_DECIMALS, new address[](0), address(s_mockRMNRemote), router
);
BurnMintERC20(token).grantMintAndBurnRoles(address(pool));

Expand All @@ -77,7 +77,7 @@ contract TokenSetup is RouterSetup {
}

function setUp() public virtual override {
RouterSetup.setUp();
super.setUp();

bool isSetup = s_sourceTokens.length != 0;
if (isSetup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract DefensiveExampleTest is OnRampSetup {
assertEq(IERC20(token).balanceOf(address(s_receiver)), receiverBalancePre - amount);
}

function test_HappyPath_Success() public {
function test_HappyPath() public {
bytes32 messageId = keccak256("messageId");
address token = address(s_destFeeToken);
uint256 amount = 111333333777;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
}
}

function test_ccipSend_reverts_insufficientFee_weth() public {
function test_RevertWhen_ccipSends_insufficientFee_weth() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down Expand Up @@ -127,7 +127,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
s_etherSenderReceiver.ccipSend{value: AMOUNT}(DESTINATION_CHAIN_SELECTOR, message);
}

function test_ccipSend_reverts_insufficientFee_feeToken() public {
function test_RevertWhen_ccipSends_insufficientFee_feeToken() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down Expand Up @@ -155,7 +155,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
s_etherSenderReceiver.ccipSend{value: AMOUNT}(DESTINATION_CHAIN_SELECTOR, message);
}

function test_ccipSend_reverts_insufficientFee_native() public {
function test_RevertWhen_ccipSends_insufficientFee_native() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand All @@ -181,7 +181,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
s_etherSenderReceiver.ccipSend{value: AMOUNT + FEE_WEI - 1}(DESTINATION_CHAIN_SELECTOR, message);
}

function test_ccipSend_success_nativeExcess() public {
function test_ccipSend_nativeExcess() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down Expand Up @@ -218,7 +218,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
assertEq(actualMsgId, expectedMsgId, "message id must be correct");
}

function test_ccipSend_success_native() public {
function test_ccipSend_native() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down Expand Up @@ -251,7 +251,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
assertEq(actualMsgId, expectedMsgId, "message id must be correct");
}

function test_ccipSend_success_feeToken() public {
function test_ccipSend_feeToken() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down Expand Up @@ -287,7 +287,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
assertEq(routerAllowance, FEE_JUELS, "router allowance must be feeJuels");
}

function test_ccipSend_success_weth() public {
function test_ccipSend_weth() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract EtherSenderReceiverTest_validateFeeToken is EtherSenderReceiverTestSetu
s_etherSenderReceiver.validateFeeToken{value: AMOUNT}(message);
}

function test_validateFeeToken_reverts_feeToken_tokenAmountNotEqualToMsgValue() public {
function test_RevertWhen_validateFeeTokens_feeToken_tokenAmountNotEqualToMsgValue() public {
Client.EVMTokenAmount[] memory tokenAmount = new Client.EVMTokenAmount[](1);
tokenAmount[0] = Client.EVMTokenAmount({token: address(s_weth), amount: AMOUNT});
Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ERC165Checker} from
"../../../../vendor/openzeppelin-solidity/v5.0.2/contracts/utils/introspection/ERC165Checker.sol";

contract CCIPClientExample_sanity is OnRampSetup {
function test_ImmutableExamples_Success() public {
function test_ImmutableExamples() public {
CCIPClientExample exampleContract = new CCIPClientExample(s_sourceRouter, IERC20(s_sourceFeeToken));
deal(address(exampleContract), 100 ether);
deal(s_sourceFeeToken, address(exampleContract), 100 ether);
Expand Down
Loading

0 comments on commit ddd920c

Please sign in to comment.