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

Cap max accounts in svm extra args #16175

Merged
merged 5 commits into from
Feb 4, 2025
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
10 changes: 10 additions & 0 deletions contracts/.changeset/slow-gorillas-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@chainlink/contracts': patch
---

#internal cap max accounts in svm extra args


PR issue: CCIP-5111

Solidity Review issue: CCIP-3966
100 changes: 50 additions & 50 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BurnMintWithLockReleaseFlagTokenPool_lockOrBurn:test_LockOrBurn_CorrectReturnDat
BurnToAddressMintTokenPool_lockOrBurn:test_LockOrBurn() (gas: 235440)
BurnWithFromMintTokenPool_lockOrBurn:test_PoolBurn() (gas: 239012)
BurnWithFromMintTokenPool_lockOrBurn:test_Setup() (gas: 24169)
CCIPClientExample_sanity:test_ImmutableExamples() (gas: 2079619)
CCIPClientExample_sanity:test_ImmutableExamples() (gas: 2079575)
CCIPHome__validateConfig:test__validateConfig() (gas: 300016)
CCIPHome__validateConfig:test__validateConfigLessTransmittersThanSigners() (gas: 332965)
CCIPHome__validateConfig:test__validateConfigSmallerFChain() (gas: 459322)
Expand All @@ -25,7 +25,7 @@ CCIPHome_setCandidate:test_setCandidate() (gas: 1365392)
CCIPHome_supportsInterface:test_supportsInterface() (gas: 9885)
DefensiveExampleTest:test_HappyPath() (gas: 200535)
DefensiveExampleTest:test_Recovery() (gas: 424996)
E2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1514547)
E2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1514514)
ERC165CheckerReverting_supportsInterfaceReverting:test__supportsInterfaceReverting() (gas: 10517)
EtherSenderReceiverTest_ccipReceive:test_ccipReceive_fallbackToWethTransfer() (gas: 96964)
EtherSenderReceiverTest_ccipReceive:test_ccipReceive_happyPath() (gas: 49797)
Expand Down Expand Up @@ -63,12 +63,12 @@ FactoryBurnMintERC20_transfer:test_Transfer() (gas: 42505)
FeeQuoter_applyDestChainConfigUpdates:test_applyDestChainConfigUpdates() (gas: 149279)
FeeQuoter_applyDestChainConfigUpdates:test_applyDestChainConfigUpdatesZeroInput() (gas: 12515)
FeeQuoter_applyFeeTokensUpdates:test_ApplyFeeTokensUpdates() (gas: 162585)
FeeQuoter_applyPremiumMultiplierWeiPerEthUpdates:test_applyPremiumMultiplierWeiPerEthUpdatesMultipleTokens() (gas: 54881)
FeeQuoter_applyPremiumMultiplierWeiPerEthUpdates:test_applyPremiumMultiplierWeiPerEthUpdatesSingleToken() (gas: 45364)
FeeQuoter_applyPremiumMultiplierWeiPerEthUpdates:test_applyPremiumMultiplierWeiPerEthUpdatesZeroInput() (gas: 12468)
FeeQuoter_applyPremiumMultiplierWeiPerEthUpdates:test_applyPremiumMultiplierWeiPerEthUpdatesMultipleTokens() (gas: 54859)
FeeQuoter_applyPremiumMultiplierWeiPerEthUpdates:test_applyPremiumMultiplierWeiPerEthUpdatesSingleToken() (gas: 45342)
FeeQuoter_applyPremiumMultiplierWeiPerEthUpdates:test_applyPremiumMultiplierWeiPerEthUpdatesZeroInput() (gas: 12446)
FeeQuoter_applyTokenTransferFeeConfigUpdates:test_ApplyTokenTransferFeeConfig() (gas: 88736)
FeeQuoter_applyTokenTransferFeeConfigUpdates:test_ApplyTokenTransferFeeZeroInput() (gas: 13218)
FeeQuoter_constructor:test_Setup() (gas: 5447819)
FeeQuoter_constructor:test_Setup() (gas: 5466278)
FeeQuoter_convertTokenAmount:test_ConvertTokenAmount() (gas: 68417)
FeeQuoter_getDataAvailabilityCost:test_EmptyMessageCalculatesDataAvailabilityCost() (gas: 98860)
FeeQuoter_getDataAvailabilityCost:test_SimpleMessageCalculatesDataAvailabilityCost() (gas: 21439)
Expand All @@ -88,11 +88,11 @@ FeeQuoter_getTokenTransferCost:test_SmallTokenTransferChargesMinFeeAndGas() (gas
FeeQuoter_getTokenTransferCost:test_ZeroAmountTokenTransferChargesMinFeeAndGas() (gas: 25230)
FeeQuoter_getTokenTransferCost:test_ZeroFeeConfigChargesMinFee() (gas: 37788)
FeeQuoter_getTokenTransferCost:test_getTokenTransferCost_selfServeUsesDefaults() (gas: 26924)
FeeQuoter_getValidatedFee:test_EmptyMessage() (gas: 84896)
FeeQuoter_getValidatedFee:test_HighGasMessage() (gas: 242832)
FeeQuoter_getValidatedFee:test_EmptyMessage() (gas: 84963)
FeeQuoter_getValidatedFee:test_HighGasMessage() (gas: 242854)
FeeQuoter_getValidatedFee:test_MessageWithDataAndTokenTransfer() (gas: 143454)
FeeQuoter_getValidatedFee:test_SingleTokenMessage() (gas: 114959)
FeeQuoter_getValidatedFee:test_SolChainFamilySelector() (gas: 61180)
FeeQuoter_getValidatedFee:test_SolChainFamilySelector() (gas: 61307)
FeeQuoter_getValidatedFee:test_ZeroDataAvailabilityMultiplier() (gas: 66298)
FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPrice() (gas: 58927)
FeeQuoter_getValidatedTokenPrice:test_GetValidatedTokenPriceFromFeed() (gas: 65137)
Expand All @@ -109,20 +109,20 @@ FeeQuoter_onReport:test_onReport() (gas: 88964)
FeeQuoter_onReport:test_onReport_withKeystoneForwarderContract() (gas: 122592)
FeeQuoter_parseSVMExtraArgsFromBytes:test_SVMExtraArgsV1() (gas: 23255)
FeeQuoter_parseSVMExtraArgsFromBytes:test_SVMExtraArgsV1TagSelector() (gas: 3157)
FeeQuoter_processChainFamilySelector:test_processChainFamilySelectorEVM() (gas: 19479)
FeeQuoter_processChainFamilySelector:test_processChainFamilySelectorSVM_NoTokenTransfer() (gas: 22666)
FeeQuoter_processChainFamilySelector:test_processChainFamilySelectorSVM_WithTokenTransfer() (gas: 22655)
FeeQuoter_processMessageArgs:test_processMessageArgs_WitEVMExtraArgsV2() (gas: 29047)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithConvertedTokenAmount() (gas: 33060)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithCorrectPoolReturnData() (gas: 77633)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithEVMExtraArgsV1() (gas: 28678)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithEmptyEVMExtraArgs() (gas: 26538)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithLinkTokenAmount() (gas: 22722)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithSVMExtraArgsV1() (gas: 63617)
FeeQuoter_resolveGasLimitForDestination:test_EVMExtraArgsDefault() (gas: 17135)
FeeQuoter_resolveGasLimitForDestination:test_EVMExtraArgsV1() (gas: 16202)
FeeQuoter_processChainFamilySelector:test_processChainFamilySelector_EVM() (gas: 19466)
FeeQuoter_processChainFamilySelector:test_processChainFamilySelector_SVM_NoTokenTransfer() (gas: 22476)
FeeQuoter_processChainFamilySelector:test_processChainFamilySelector_SVM_WithTokenTransfer() (gas: 22458)
FeeQuoter_processMessageArgs:test_processMessageArgs_WitEVMExtraArgsV2() (gas: 29014)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithConvertedTokenAmount() (gas: 33049)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithCorrectPoolReturnData() (gas: 77622)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithEVMExtraArgsV1() (gas: 28645)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithEmptyEVMExtraArgs() (gas: 26505)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithLinkTokenAmount() (gas: 22711)
FeeQuoter_processMessageArgs:test_processMessageArgs_WithSVMExtraArgsV1() (gas: 63549)
FeeQuoter_resolveGasLimitForDestination:test_EVMExtraArgsDefault() (gas: 17113)
FeeQuoter_resolveGasLimitForDestination:test_EVMExtraArgsV1() (gas: 16180)
FeeQuoter_resolveGasLimitForDestination:test_EVMExtraArgsV1TagSelector() (gas: 3169)
FeeQuoter_resolveGasLimitForDestination:test_EVMExtraArgsV2() (gas: 16328)
FeeQuoter_resolveGasLimitForDestination:test_EVMExtraArgsV2() (gas: 16306)
FeeQuoter_resolveGasLimitForDestination:test_EVMExtraArgsV2TagSelector() (gas: 3168)
FeeQuoter_supportsInterface:test_SupportsInterface() (gas: 13264)
FeeQuoter_updatePrices:test_OnlyGasPrice() (gas: 23934)
Expand Down Expand Up @@ -211,10 +211,10 @@ NonceManager_getIncrementedOutboundNonce:test_getIncrementedOutboundNonce() (gas
NonceManager_getIncrementedOutboundNonce:test_incrementInboundNonce() (gas: 38746)
NonceManager_getIncrementedOutboundNonce:test_incrementInboundNonce_SkippedIncorrectNonce() (gas: 23739)
NonceManager_getIncrementedOutboundNonce:test_incrementNoncesInboundAndOutbound() (gas: 71886)
NonceManager_getOutboundNonce:test_getOutboundNonce_Upgrade() (gas: 105945)
NonceManager_getOutboundNonce:test_getOutboundNonce_UpgradeNonceNewSenderStartsAtZero() (gas: 168148)
NonceManager_getOutboundNonce:test_getOutboundNonce_UpgradeNonceStartsAtV1Nonce() (gas: 198559)
NonceManager_getOutboundNonce:test_getOutboundNonce_UpgradeSenderNoncesReadsPreviousRamp() (gas: 146214)
NonceManager_getOutboundNonce:test_getOutboundNonce_Upgrade() (gas: 105912)
NonceManager_getOutboundNonce:test_getOutboundNonce_UpgradeNonceNewSenderStartsAtZero() (gas: 168104)
NonceManager_getOutboundNonce:test_getOutboundNonce_UpgradeNonceStartsAtV1Nonce() (gas: 198482)
NonceManager_getOutboundNonce:test_getOutboundNonce_UpgradeSenderNoncesReadsPreviousRamp() (gas: 146181)
OffRampWithMessageTransformer_executeSingleReport:test_executeSingleReport() (gas: 307118)
OffRampWithMessageTransformer_setMessageTransformer:test_setMessageTransformer() (gas: 701222)
OffRamp_applySourceChainConfigUpdates:test_AddMultipleChains() (gas: 626140)
Expand Down Expand Up @@ -285,34 +285,34 @@ OffRamp_trialExecute:test_trialExecute_SenderIsNotGasEstimator_CallWithExactGasR
OffRamp_trialExecute:test_trialExecute_TokenHandlingErrorIsCaught() (gas: 131998)
OffRamp_trialExecute:test_trialExecute_TokenPoolIsNotAContract() (gas: 286580)
OnRampTokenPoolReentrancy:test_OnRampTokenPoolReentrancy() (gas: 245211)
OnRampWithMessageTransformer_executeSingleMessage:test_forwardFromRouter() (gas: 122477)
OnRampWithMessageTransformer_executeSingleMessage:test_forwardFromRouter() (gas: 122444)
OnRampWithMessageTransformer_setMessageTransformer:test_setMessageTransformer() (gas: 701204)
OnRamp_applyAllowlistUpdates:test_applyAllowlistUpdates() (gas: 325996)
OnRamp_applyAllowlistUpdates:test_applyAllowlistUpdates_InvalidAllowListRequestDisabledAllowListWithAdds() (gas: 17190)
OnRamp_applyDestChainConfigUpdates:test_ApplyDestChainConfigUpdates() (gas: 65874)
OnRamp_constructor:test_Constructor() (gas: 2694309)
OnRamp_forwardFromRouter:test_ForwardFromRouter() (gas: 146075)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2() (gas: 146887)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2AllowOutOfOrderTrue() (gas: 116066)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessCustomExtraArgs() (gas: 146473)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessEmptyExtraArgs() (gas: 144729)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessLegacyExtraArgs() (gas: 146714)
OnRamp_forwardFromRouter:test_ForwardFromRouter_ConfigurableSourceRouter() (gas: 144032)
OnRamp_forwardFromRouter:test_ShouldIncrementNonceOnlyOnOrdered() (gas: 188546)
OnRamp_forwardFromRouter:test_ShouldIncrementSeqNumAndNonce() (gas: 214923)
OnRamp_forwardFromRouter:test_ShouldStoreLinkFees() (gas: 147720)
OnRamp_forwardFromRouter:test_forwardFromRouter_WithInterception() (gas: 275420)
OnRamp_forwardFromRouter:test_ForwardFromRouter() (gas: 146042)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2() (gas: 146854)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2AllowOutOfOrderTrue() (gas: 116033)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessCustomExtraArgs() (gas: 146440)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessEmptyExtraArgs() (gas: 144696)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessLegacyExtraArgs() (gas: 146681)
OnRamp_forwardFromRouter:test_ForwardFromRouter_ConfigurableSourceRouter() (gas: 144021)
OnRamp_forwardFromRouter:test_ShouldIncrementNonceOnlyOnOrdered() (gas: 188447)
OnRamp_forwardFromRouter:test_ShouldIncrementSeqNumAndNonce() (gas: 214824)
OnRamp_forwardFromRouter:test_ShouldStoreLinkFees() (gas: 147687)
OnRamp_forwardFromRouter:test_forwardFromRouter_WithInterception() (gas: 275387)
OnRamp_getFee:test_EmptyMessage() (gas: 100129)
OnRamp_getFee:test_GetFeeOfZeroForTokenMessage() (gas: 89370)
OnRamp_getFee:test_GetFeeOfZeroForTokenMessage() (gas: 89348)
OnRamp_getFee:test_SingleTokenMessage() (gas: 115447)
OnRamp_getTokenPool:test_GetTokenPool() (gas: 35404)
OnRamp_setDynamicConfig:test_setDynamicConfig() (gas: 56650)
OnRamp_withdrawFeeTokens:test_WithdrawFeeTokens() (gas: 125835)
PingPong_ccipReceive:test_CcipReceive() (gas: 167476)
PingPong_ccipReceive:test_CcipReceive() (gas: 167465)
PingPong_setOutOfOrderExecution:test_OutOfOrderExecution() (gas: 20284)
PingPong_setPaused:test_Pausing() (gas: 17760)
PingPong_startPingPong:test_StartPingPong_With_OOO() (gas: 146627)
PingPong_startPingPong:test_StartPingPong_With_Sequenced_Ordered() (gas: 172258)
PingPong_startPingPong:test_StartPingPong_With_OOO() (gas: 146616)
PingPong_startPingPong:test_StartPingPong_With_Sequenced_Ordered() (gas: 172247)
RMNHome_getConfigDigests:test_getConfigDigests() (gas: 1081176)
RMNHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive() (gas: 1086556)
RMNHome_revokeCandidate:test_revokeCandidate() (gas: 28085)
Expand Down Expand Up @@ -342,17 +342,17 @@ RegistryModuleOwnerCustom_registerAdminViaGetCCIPAdmin:test_registerAdminViaGetC
RegistryModuleOwnerCustom_registerAdminViaOwner:test_registerAdminViaOwner() (gas: 129941)
Router_applyRampUpdates:test_applyRampUpdates_OffRampUpdatesWithRouting() (gas: 10864375)
Router_applyRampUpdates:test_applyRampUpdates_OnRampDisable() (gas: 56445)
Router_ccipSend:test_CCIPSendLinkFeeNoTokenSuccess_gas() (gas: 126090)
Router_ccipSend:test_CCIPSendLinkFeeOneTokenSuccess_gas() (gas: 213515)
Router_ccipSend:test_CCIPSendLinkFeeNoTokenSuccess_gas() (gas: 126079)
Router_ccipSend:test_CCIPSendLinkFeeOneTokenSuccess_gas() (gas: 213504)
Router_ccipSend:test_InvalidMsgValue() (gas: 27856)
Router_ccipSend:test_NativeFeeToken() (gas: 186866)
Router_ccipSend:test_NativeFeeToken() (gas: 186855)
Router_ccipSend:test_NativeFeeTokenInsufficientValue() (gas: 62696)
Router_ccipSend:test_NativeFeeTokenOverpay() (gas: 188261)
Router_ccipSend:test_NativeFeeTokenOverpay() (gas: 188250)
Router_ccipSend:test_NativeFeeTokenZeroValue() (gas: 54788)
Router_ccipSend:test_NonLinkFeeToken() (gas: 221193)
Router_ccipSend:test_WrappedNativeFeeToken() (gas: 189083)
Router_ccipSend:test_ccipSend_nativeFeeNoTokenSuccess_gas() (gas: 135248)
Router_ccipSend:test_ccipSend_nativeFeeOneTokenSuccess_gas() (gas: 222716)
Router_ccipSend:test_NonLinkFeeToken() (gas: 221182)
Router_ccipSend:test_WrappedNativeFeeToken() (gas: 189072)
Router_ccipSend:test_ccipSend_nativeFeeNoTokenSuccess_gas() (gas: 135237)
Router_ccipSend:test_ccipSend_nativeFeeOneTokenSuccess_gas() (gas: 222705)
Router_constructor:test_Constructor() (gas: 13170)
Router_getArmProxy:test_getArmProxy() (gas: 10573)
Router_getFee:test_GetFeeSupportedChain() (gas: 52367)
Expand Down
25 changes: 14 additions & 11 deletions contracts/src/v0.8/ccip/FeeQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
error InvalidFeeRange(uint256 minFeeUSDCents, uint256 maxFeeUSDCents);
error InvalidChainFamilySelector(bytes4 chainFamilySelector);
error InvalidTokenReceiver();
error TooManySVMExtraArgsAccounts(uint256 numAccounts, uint256 maxAccounts);
error InvalidSVMExtraArgsWritableBitmap(uint64 accountIsWritableBitmap, uint256 numAccounts);

event FeeTokenAdded(address indexed feeToken);
event FeeTokenRemoved(address indexed feeToken);
Expand Down Expand Up @@ -1004,6 +1006,12 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
if (numberOfTokens > 0 && svmExtraArgsV1.tokenReceiver == bytes32(0)) {
revert InvalidTokenReceiver();
}
if (svmExtraArgsV1.accounts.length > Client.SVM_EXTRA_ARGS_MAX_ACCOUNTS) {
revert TooManySVMExtraArgsAccounts(svmExtraArgsV1.accounts.length, Client.SVM_EXTRA_ARGS_MAX_ACCOUNTS);
}
if (svmExtraArgsV1.accountIsWritableBitmap >> svmExtraArgsV1.accounts.length != 0) {
revert InvalidSVMExtraArgsWritableBitmap(svmExtraArgsV1.accountIsWritableBitmap, svmExtraArgsV1.accounts.length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

}
gasLimit = svmExtraArgsV1.computeUnits;
} else {
revert InvalidChainFamilySelector(destChainConfig.chainFamilySelector);
Expand Down Expand Up @@ -1042,8 +1050,7 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,

if (msgFeeJuels > i_maxFeeJuelsPerMsg) revert MessageFeeTooHigh(msgFeeJuels, i_maxFeeJuelsPerMsg);

(convertedExtraArgs, isOutOfOrderExecution) =
_processChainFamilySelector(destChainSelector, sourceTokenAmounts.length > 0, extraArgs);
(convertedExtraArgs, isOutOfOrderExecution) = _processChainFamilySelector(destChainSelector, extraArgs);

destExecDataPerToken = _processPoolReturnData(destChainSelector, onRampTokenTransfers, sourceTokenAmounts);

Expand All @@ -1052,26 +1059,22 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,

/// @notice Parses the extra Args based on the chain family selector. Isolated into a separate function
/// as it was the only way to prevent a stack too deep error, and makes future chain family additions easier.
// solhint-disable-next-line chainlink-solidity/explicit-returns
function _processChainFamilySelector(
uint64 destChainSelector,
bool isMessageWithTokenTransfer,
bytes calldata extraArgs
) internal view returns (bytes memory, bool) {
) internal view returns (bytes memory validatedExtraArgs, bool allowOutOfOrderExecution) {
// Since this function is called after getFee, which already validates the params, no validation is necessary.
DestChainConfig memory destChainConfig = s_destChainConfigs[destChainSelector];
if (destChainConfig.chainFamilySelector == Internal.CHAIN_FAMILY_SELECTOR_EVM) {
// Since the message is called after getFee, which already validates the params, no validation is necessary.
Client.EVMExtraArgsV2 memory parsedExtraArgs =
_parseUnvalidatedEVMExtraArgsFromBytes(extraArgs, destChainConfig.defaultTxGasLimit);

return (Client._argsToBytes(parsedExtraArgs), parsedExtraArgs.allowOutOfOrderExecution);
}
if (destChainConfig.chainFamilySelector == Internal.CHAIN_FAMILY_SELECTOR_SVM) {
bytes32 tokenReceiver = _parseSVMExtraArgsFromBytes(
extraArgs, destChainConfig.maxPerMsgGasLimit, destChainConfig.enforceOutOfOrder
).tokenReceiver;
if (isMessageWithTokenTransfer && tokenReceiver == bytes32(0)) {
revert InvalidTokenReceiver();
}
// If extraArgs passes the parsing it's valid and can be returned unchanged.
_parseSVMExtraArgsFromBytes(extraArgs, destChainConfig.maxPerMsgGasLimit, destChainConfig.enforceOutOfOrder);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! 👍🏼


// ExtraArgs are required on SVM, meaning the supplied extraArgs are either invalid and we would have reverted
// or we have valid extraArgs and we can return them without having to re-encode them.
Expand Down
3 changes: 3 additions & 0 deletions contracts/src/v0.8/ccip/libraries/Client.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ library Client {
// bytes4(keccak256("CCIP SVMExtraArgsV1"));
bytes4 public constant SVM_EXTRA_ARGS_V1_TAG = 0x1f3b3aba;

/// @dev The maximum number of accounts that can be passed in SVMExtraArgs.
uint256 public constant SVM_EXTRA_ARGS_MAX_ACCOUNTS = 64;

/// @param gasLimit: gas limit for the callback on the destination chain.
/// @param allowOutOfOrderExecution: if true, it indicates that the message can be executed in any order relative to
/// other messages from the same sender. This value's default varies by chain. On some chains, a particular value is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ contract SiloedLockReleaseTokenPool is TokenPool, ITypeAndVersion {
SiloConfig storage remoteConfig = s_chainConfigs[releaseOrMintIn.remoteChainSelector];

// Since remoteConfig.isSiloed is used more than once, caching in memory saves gas instead of multiple SLOADs.
bool isSiloed = remoteConfig.isSiloed;
bool chainIsSiloed = remoteConfig.isSiloed;

// Prevent A silent underflow by explicitly ensuring that enough funds are available to release
uint256 availableLiquidity = isSiloed ? remoteConfig.tokenBalance : s_unsiloedTokenBalance;
uint256 availableLiquidity = chainIsSiloed ? remoteConfig.tokenBalance : s_unsiloedTokenBalance;
if (localAmount > availableLiquidity) revert InsufficientLiquidity(availableLiquidity, localAmount);

// Tracking balances independently by chain is a security measure to prevent liquidity for one chain from being
// released by another chain.
if (isSiloed) {
if (chainIsSiloed) {
remoteConfig.tokenBalance -= localAmount;
} else {
s_unsiloedTokenBalance -= localAmount;
Expand Down
Loading
Loading