Skip to content

Commit

Permalink
Merge branch 'ccip-develop' into cherry-pick-handle-errors-handling-f…
Browse files Browse the repository at this point in the history
…or-gnosis-and-arbitrum
  • Loading branch information
simsonraj authored Aug 20, 2024
2 parents e5ea998 + 4e52098 commit fcce450
Show file tree
Hide file tree
Showing 126 changed files with 9,041 additions and 1,476 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-dots-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Updated ZK overflow detection to skip transactions with non-broadcasted attempts. Delayed detection for zkEVM using the MinAttempts config. Updated XLayer to use the same detection logic as zkEVM. #internal
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ helm 3.10.3
zig 0.11.0
golangci-lint 1.59.1
protoc 25.1
python 3.10.5
10 changes: 10 additions & 0 deletions contracts/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ wrappers-all: pnpmdep mockery abigen ## Recompiles solidity contracts and their
# go_generate contains a call to compile all contracts before generating wrappers
go generate ../core/gethwrappers/go_generate.go

# Use this to generate compiled JSON artifacts for gauntlet-plus-plus.
# This is currently only used for CCIP.
# example: make artifact-generate contract=LockReleaseTokenPoolAndProxy solcversion=0.8.24 artifactpath=../../gauntlet-plus-plus/packages-ethereum/operations-ccip/src/artifacts/1.5.0/lock-release-token-pool-and-proxy.json
artifact-generate: export FOUNDRY_PROFILE=ccip
.PHONY: artifact-generate
artifact-generate:
chmod +x ./scripts/generate_compiled_json_ccip.sh
./scripts/generate_compiled_json_ccip.sh $(contract) $(solcversion) $(artifactpath)


help:
@echo ""
@echo " .__ .__ .__ .__ __"
Expand Down
316 changes: 159 additions & 157 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(
async (_, __, runSuper) => {
const paths = await runSuper()
const noTests = paths.filter((p: string) => !p.endsWith('.t.sol'))
return noTests.filter(
const noCCIPTests = noTests.filter(
(p: string) => !p.includes('/v0.8/ccip/test'),
)
return noCCIPTests.filter(
(p: string) => !p.includes('src/v0.8/vendor/forge-std'),
)
},
Expand Down
17 changes: 13 additions & 4 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,43 @@
"prepare": "chmod +x .husky/prepare.sh && ./.husky/prepare.sh",
"prepublishOnly": "pnpm compile && ./scripts/prepublish_generate_abi_folder",
"publish-beta": "pnpm publish --tag beta",
"publish-prod": "npm dist-tag add @chainlink/contracts-ccip@1.2.1 latest",
"publish-prod": "npm dist-tag add @chainlink/contracts-ccip@1.5.0 latest",
"solhint:ccip": "solhint --max-warnings 0 \"./src/v0.8/ccip/**/*.sol\"",
"solhint": "solhint --max-warnings 0 \"./src/v0.8/**/*.sol\""
},
"files": [
"src/v0.8/ccip/**/*.sol",
"!src/v0.8/ccip/test/**/*",
"src/v0.8/ccip/test/mocks/**/*",
"src/v0.8/shared/access/ConfirmedOwner.sol",
"src/v0.8/shared/access/ConfirmedOwnerWithProposal.sol",
"src/v0.8/shared/access/OwnerIsCreator.sol",
"src/v0.8/shared/access/AuthorizedCallers.sol",
"src/v0.8/shared/call/CallWithExactGas.sol",
"src/v0.8/shared/enumerable/EnumerableMapBytes32.sol",
"src/v0.8/shared/enumerable/EnumerableMapAddresses.sol",
"src/v0.8/shared/interfaces/IOwnable.sol",
"src/v0.8/shared/interfaces/ITypeAndVersion.sol",
"src/v0.8/shared/interfaces/IERC677Receiver.sol",
"src/v0.8/shared/interfaces/AggregatorV3Interface.sol",
"src/v0.8/shared/token/ERC20/IBurnMintERC20.sol",
"src/v0.8/shared/token/ERC677/IERC677.sol",
"src/v0.8/shared/token/ERC677/IERC677Receiver.sol",
"src/v0.8/shared/token/ERC677/ERC677.sol",
"src/v0.8/shared/token/ERC677/BurnMintERC677.sol",
"src/v0.8/shared/util/SortedSetValidationUtil.sol",
"src/v0.8/liquiditymanager/interfaces/ILiquidityContainer.sol",
"src/v0.8/keystone/interfaces/ICapabilityConfiguration.sol",
"src/v0.8/vendor/openzeppelin-solidity",
"src/v0.8/vendor/Context.sol",
"src/v0.8/vendor/Pausable.sol",
"abi/v0.8/",
"src/v0.8/ccip/LICENSE.md",
"src/v0.8/ccip/LICENSE-MIT.md",
"src/v0.8/ccip/v1.4-CCIP-License-grants.md"
"src/v0.8/ccip/v1.5-CCIP-License-grants.md",
"!src/v0.8/ccip/test/**/*",
"src/v0.8/ccip/test/mocks/**/*",
"!src/v0.8/ccip/test/mocks/test/*",
"!src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol",
"!src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol"
],
"pnpm": {
"_comment": "See https://github.com/ethers-io/ethers.js/discussions/2849#discussioncomment-2696454",
Expand Down
73 changes: 73 additions & 0 deletions contracts/scripts/generate_compiled_json_ccip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash

set -e

ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; cd ../../ && pwd -P )"

contractName="$1"
SOLC_VERSION="$2"
destPath="$3"
path="$ROOT"/contracts/solc/v$SOLC_VERSION/"$contractName"

if [ -z "$contractName" ]; then
echo "Error: contractName is not set."
exit 1
fi

if [ -z "$contractName" ]; then
echo "Error: solc version is not set."
exit 1
fi

if [ -z "$destPath" ]; then
echo "Error: destination path is not set."
exit 1
fi

if [ ! -e "$destPath" ]; then
echo "Error: $destPath does not exist."
exit 1
fi


metadata=$(cat "$path/${contractName}_meta.json")
fileName=$(echo "$metadata" | jq -r '.settings.compilationTarget | keys[0]')
combined=$(cat "$path/combined.json")

abi=$(cat "$path/${contractName}.abi")
bytecode_object="0x$(cat "$path/${contractName}.bin" | tr -d '\n')"
bytecode_sourceMap=$(echo "$combined" | jq -r ".contracts[\"$fileName:$contractName\"].srcmap")

deployedBytecode_object="0x$(cat "$path/${contractName}.bin-runtime" | tr -d '\n')"
deployedBytecode_sourceMap=$(echo "$combined" | jq -r ".contracts[\"$fileName:$contractName\"].\"srcmap-runtime\"")

methodIdentifiers=$(echo "$combined" | jq -r ".contracts[\"$fileName:$contractName\"].hashes")
rawMetadata=$(echo "$metadata" | jq -c '.')

result=$(jq -n \
--argjson abi "$abi" \
--arg object "$bytecode_object" \
--arg sourceMap "$bytecode_sourceMap" \
--arg deployedObject "$deployedBytecode_object" \
--arg deployedSourceMap "$deployedBytecode_sourceMap" \
--argjson methodIdentifiers "$methodIdentifiers" \
--arg rawMetadata "$rawMetadata" \
--argjson metadata "$metadata" \
'{
abi: $abi,
bytecode: {
object: $object,
sourceMap: $sourceMap
},
deployedBytecode: {
object: $deployedObject,
sourceMap: $deployedSourceMap
},
methodIdentifiers: $methodIdentifiers,
rawMetadata: $rawMetadata,
metadata: $metadata
}'
)

echo "$result" > "$destPath"
echo "Generated artifacts at $(realpath $destPath)"
1 change: 1 addition & 0 deletions contracts/scripts/native_solc_compile_all_ccip
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ compileContract () {
solc --overwrite --optimize --optimize-runs $optimize_runs --metadata-hash none \
-o "$ROOT"/contracts/solc/v$SOLC_VERSION/"$contract" \
--abi --bin --allow-paths "$ROOT"/contracts/src/v0.8 \
--bin-runtime --hashes --metadata --metadata-literal --combined-json abi,hashes,metadata,srcmap,srcmap-runtime \
--evm-version paris \
"$ROOT"/contracts/src/v0.8/"$1"
}
Expand Down
8 changes: 4 additions & 4 deletions contracts/src/v0.8/ccip/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Parameters

Licensor: SmartContract Chainlink Limited SEZC

Licensed Work: Cross-Chain Interoperability Protocol v1.4
Licensed Work: Cross-Chain Interoperability Protocol v1.5
The Licensed Work is (c) 2023 SmartContract Chainlink Limited SEZC

Additional Use Grant: Any uses listed and defined at [v1.4-CCIP-License-grants](
./v1.4-CCIP-License-grants)
Additional Use Grant: Any uses listed and defined at [v1.5-CCIP-License-grants](
./v1.5-CCIP-License-grants.md)

Change Date: May 23, 2027
Change Date: Aug 16, 2028

Change License: MIT

Expand Down
32 changes: 24 additions & 8 deletions contracts/src/v0.8/ccip/capability/CCIPConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,36 @@ contract CCIPConfig is ITypeAndVersion, ICapabilityConfiguration, OwnerIsCreator
}

/// @notice Returns all the chain configurations.
/// @return The chain configurations.
// TODO: will this eventually hit the RPC max response size limit?
function getAllChainConfigs() external view returns (CCIPConfigTypes.ChainConfigInfo[] memory) {
/// @return paginatedChainConfigs chain configurations.
function getAllChainConfigs(
uint256 pageIndex,
uint256 pageSize
) external view returns (CCIPConfigTypes.ChainConfigInfo[] memory) {
uint256 totalItems = s_remoteChainSelectors.length(); // Total number of chain selectors
uint256 startIndex = pageIndex * pageSize;

if (pageSize == 0 || startIndex >= totalItems) {
return new CCIPConfigTypes.ChainConfigInfo[](0); // Return an empty array if pageSize is 0 or pageIndex is out of bounds
}

uint256 endIndex = startIndex + pageSize;
if (endIndex > totalItems) {
endIndex = totalItems;
}

CCIPConfigTypes.ChainConfigInfo[] memory paginatedChainConfigs =
new CCIPConfigTypes.ChainConfigInfo[](endIndex - startIndex);

uint256[] memory chainSelectors = s_remoteChainSelectors.values();
CCIPConfigTypes.ChainConfigInfo[] memory chainConfigs =
new CCIPConfigTypes.ChainConfigInfo[](s_remoteChainSelectors.length());
for (uint256 i = 0; i < chainSelectors.length; ++i) {
for (uint256 i = startIndex; i < endIndex; ++i) {
uint64 chainSelector = uint64(chainSelectors[i]);
chainConfigs[i] = CCIPConfigTypes.ChainConfigInfo({
paginatedChainConfigs[i - startIndex] = CCIPConfigTypes.ChainConfigInfo({
chainSelector: chainSelector,
chainConfig: s_chainConfigurations[chainSelector]
});
}
return chainConfigs;

return paginatedChainConfigs;
}

/// @notice Returns the OCR configuration for the given don ID and plugin type.
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/ccip/libraries/Internal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ library Internal {
// CCIP_LOCK_OR_BURN_V1_RET_BYTES bytes. If more data is required, the TokenTransferFeeConfig.destBytesOverhead
// has to be set for the specific token.
bytes extraData;
uint32 destGasAmount; // The amount of gas available for the releaseOrMint and transfer calls on the offRamp
uint32 destGasAmount; // The amount of gas available for the releaseOrMint and balanceOf calls on the offRamp
}

/// @notice Report that is submitted by the execution DON at the execution phase. (including chain selector data)
Expand Down
11 changes: 9 additions & 2 deletions contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ contract EVM2EVMMultiOffRamp is ITypeAndVersion, MultiOCR3Base {
uint64 indexed sequenceNumber,
bytes32 indexed messageId,
Internal.MessageExecutionState state,
bytes returnData
bytes returnData,
uint256 gasUsed
);
event SourceChainSelectorAdded(uint64 sourceChainSelector);
event SourceChainConfigSet(uint64 indexed sourceChainSelector, SourceChainConfig sourceConfig);
Expand Down Expand Up @@ -372,6 +373,7 @@ contract EVM2EVMMultiOffRamp is ITypeAndVersion, MultiOCR3Base {
// Execute messages
bool manualExecution = manualExecGasLimits.length != 0;
for (uint256 i = 0; i < numMsgs; ++i) {
uint256 gasStart = gasleft();
Internal.Any2EVMRampMessage memory message = report.messages[i];

Internal.MessageExecutionState originalState =
Expand Down Expand Up @@ -465,7 +467,12 @@ contract EVM2EVMMultiOffRamp is ITypeAndVersion, MultiOCR3Base {
}

emit ExecutionStateChanged(
sourceChainSelector, message.header.sequenceNumber, message.header.messageId, newState, returnData
sourceChainSelector,
message.header.sequenceNumber,
message.header.messageId,
newState,
returnData,
gasStart - gasleft()
);
}
}
Expand Down
5 changes: 5 additions & 0 deletions contracts/src/v0.8/ccip/pools/LegacyPoolWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ abstract contract LegacyPoolWrapper is TokenPool {
emit LegacyPoolChanged(oldPrevPool, prevPool);
}

/// @notice Returns the address of the previous pool.
function getPreviousPool() external view returns (address) {
return address(s_previousPool);
}

function _hasLegacyPool() internal view returns (bool) {
return address(s_previousPool) != address(0);
}
Expand Down
25 changes: 5 additions & 20 deletions contracts/src/v0.8/ccip/test/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ contract BaseTest is Test {
// Onramp
uint96 internal constant MAX_NOP_FEES_JUELS = 1e27;
uint96 internal constant MAX_MSG_FEES_JUELS = 1e18;
uint32 internal constant DEST_GAS_OVERHEAD = 350_000;
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 = 85_000;
uint32 internal constant DEFAULT_TOKEN_DEST_GAS_OVERHEAD = 90_000;
uint32 internal constant DEFAULT_TOKEN_BYTES_OVERHEAD = 32;

bool private s_baseTestInitialized;
Expand All @@ -61,8 +61,6 @@ contract BaseTest is Test {
// OffRamp
uint32 internal constant MAX_DATA_SIZE = 30_000;
uint16 internal constant MAX_TOKENS_LENGTH = 5;
uint32 internal constant MAX_TOKEN_POOL_RELEASE_OR_MINT_GAS = 200_000;
uint32 internal constant MAX_TOKEN_POOL_TRANSFER_GAS = 50_000;
uint16 internal constant GAS_FOR_CALL_EXACT_CHECK = 5000;
uint32 internal constant PERMISSION_LESS_EXECUTION_THRESHOLD_SECONDS = 500;
uint32 internal constant MAX_GAS_LIMIT = 4_000_000;
Expand All @@ -89,15 +87,15 @@ contract BaseTest is Test {
s_mockRMN = new MockRMN();
}

function getOutboundRateLimiterConfig() internal pure returns (RateLimiter.Config memory) {
function _getOutboundRateLimiterConfig() internal pure returns (RateLimiter.Config memory) {
return RateLimiter.Config({isEnabled: true, capacity: 100e28, rate: 1e15});
}

function getInboundRateLimiterConfig() internal pure returns (RateLimiter.Config memory) {
function _getInboundRateLimiterConfig() internal pure returns (RateLimiter.Config memory) {
return RateLimiter.Config({isEnabled: true, capacity: 222e30, rate: 1e18});
}

function getSingleTokenPriceUpdateStruct(
function _getSingleTokenPriceUpdateStruct(
address token,
uint224 price
) internal pure returns (Internal.PriceUpdates memory) {
Expand All @@ -109,17 +107,4 @@ contract BaseTest is Test {

return priceUpdates;
}

function getSingleGasPriceUpdateStruct(
uint64 chainSelector,
uint224 usdPerUnitGas
) internal pure returns (Internal.PriceUpdates memory) {
Internal.GasPriceUpdate[] memory gasPriceUpdates = new Internal.GasPriceUpdate[](1);
gasPriceUpdates[0] = Internal.GasPriceUpdate({destChainSelector: chainSelector, usdPerUnitGas: usdPerUnitGas});

Internal.PriceUpdates memory priceUpdates =
Internal.PriceUpdates({tokenPriceUpdates: new Internal.TokenPriceUpdate[](0), gasPriceUpdates: gasPriceUpdates});

return priceUpdates;
}
}
Loading

0 comments on commit fcce450

Please sign in to comment.