diff --git a/contracts/gas-snapshots/ccip.gas-snapshot b/contracts/gas-snapshots/ccip.gas-snapshot index 882ee341864..52ec9697a8d 100644 --- a/contracts/gas-snapshots/ccip.gas-snapshot +++ b/contracts/gas-snapshots/ccip.gas-snapshot @@ -491,10 +491,13 @@ OffRamp_setDynamicConfig:test_FeeQuoterZeroAddress_Revert() (gas: 11465) OffRamp_setDynamicConfig:test_NonOwner_Revert() (gas: 13975) OffRamp_setDynamicConfig:test_SetDynamicConfigWithInterceptor_Success() (gas: 47491) OffRamp_setDynamicConfig:test_SetDynamicConfig_Success() (gas: 25464) -OffRamp_trialExecute:test_trialExecute() (gas: 271771) -OffRamp_trialExecute:test_trialExecute_RateLimitError() (gas: 127497) -OffRamp_trialExecute:test_trialExecute_TokenHandlingErrorIsCaught() (gas: 138807) -OffRamp_trialExecute:test_trialExecute_TokenPoolIsNotAContract() (gas: 289492) +OffRamp_trialExecute:test_trialExecute() (gas: 271751) +OffRamp_trialExecute:test_trialExecute_CallWithExactGasRevertsAndSenderIsNotGasEstimator() (gas: 60045) +OffRamp_trialExecute:test_trialExecute_RateLimitError() (gas: 127460) +OffRamp_trialExecute:test_trialExecute_RevertsWhen_NoEnoughGasForCallSigAndSenderIsGasEstimator() (gas: 65552) +OffRamp_trialExecute:test_trialExecute_RevertsWhen_NoGasForCallExactCheckAndSenderIsGasEstimator() (gas: 65686) +OffRamp_trialExecute:test_trialExecute_TokenHandlingErrorIsCaught() (gas: 138682) +OffRamp_trialExecute:test_trialExecute_TokenPoolIsNotAContract() (gas: 289388) OnRampTokenPoolReentrancy:test_OnRampTokenPoolReentrancy_Success() (gas: 251706) OnRamp_applyAllowlistUpdates:test_applyAllowlistUpdates_InvalidAllowListRequestDisabledAllowListWithAdds() (gas: 17227) OnRamp_applyAllowlistUpdates:test_applyAllowlistUpdates_Revert() (gas: 67101) diff --git a/contracts/src/v0.8/ccip/offRamp/OffRamp.sol b/contracts/src/v0.8/ccip/offRamp/OffRamp.sol index fbe154be735..4ffeabf95ff 100644 --- a/contracts/src/v0.8/ccip/offRamp/OffRamp.sol +++ b/contracts/src/v0.8/ccip/offRamp/OffRamp.sol @@ -193,8 +193,8 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base { i_rmnRemote = staticConfig.rmnRemote; i_tokenAdminRegistry = staticConfig.tokenAdminRegistry; i_nonceManager = staticConfig.nonceManager; - emit StaticConfigSet(staticConfig); + _setDynamicConfig(dynamicConfig); _applySourceChainConfigUpdates(sourceChainConfigs); } diff --git a/contracts/src/v0.8/ccip/test/offRamp/OffRamp/OffRamp.trialExecute.t.sol b/contracts/src/v0.8/ccip/test/offRamp/OffRamp/OffRamp.trialExecute.t.sol index 807cea5e268..22d2a497a70 100644 --- a/contracts/src/v0.8/ccip/test/offRamp/OffRamp/OffRamp.trialExecute.t.sol +++ b/contracts/src/v0.8/ccip/test/offRamp/OffRamp/OffRamp.trialExecute.t.sol @@ -1,13 +1,14 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.24; +import {CallWithExactGas} from "../../../../shared/call/CallWithExactGas.sol"; +import {IERC20} from "../../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol"; import {Internal} from "../../../libraries/Internal.sol"; import {RateLimiter} from "../../../libraries/RateLimiter.sol"; +import {MultiOCR3Base} from "../../../ocr/MultiOCR3Base.sol"; import {OffRamp} from "../../../offRamp/OffRamp.sol"; import {OffRampSetup} from "./OffRampSetup.t.sol"; -import {IERC20} from "../../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol"; - contract OffRamp_trialExecute is OffRampSetup { function setUp() public virtual override { super.setUp(); @@ -117,4 +118,75 @@ contract OffRamp_trialExecute is OffRampSetup { assertEq(uint256(Internal.MessageExecutionState.FAILURE), uint256(newState)); assertEq(abi.encodeWithSelector(OffRamp.NotACompatiblePool.selector, address(0)), err); } + + function test_trialExecute_CallWithExactGasRevertsAndSenderIsNotGasEstimator() public { + uint256[] memory amounts = new uint256[](2); + amounts[0] = 1000; + amounts[1] = 50; + Internal.Any2EVMRampMessage memory message = + _generateAny2EVMMessageWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1, amounts); + + bytes[] memory offchainTokenData = new bytes[](message.tokenAmounts.length); + uint32[] memory tokenGasOverrides = new uint32[](0); + + vm.mockCallRevert( + address(s_offRamp), + abi.encodeWithSelector(s_offRamp.executeSingleMessage.selector, message, offchainTokenData, tokenGasOverrides), + abi.encodeWithSelector(CallWithExactGas.NOT_ENOUGH_GAS_FOR_CALL_SIG, "") + ); + + IERC20 dstToken0 = IERC20(s_destTokens[0]); + + (Internal.MessageExecutionState newState, bytes memory err) = + s_offRamp.trialExecute(message, offchainTokenData, tokenGasOverrides); + assertEq(uint256(Internal.MessageExecutionState.FAILURE), uint256(newState)); + } + + function test_trialExecute_RevertsWhen_NoGasForCallExactCheckAndSenderIsGasEstimator() public { + uint256[] memory amounts = new uint256[](2); + amounts[0] = 1000; + amounts[1] = 50; + Internal.Any2EVMRampMessage memory message = + _generateAny2EVMMessageWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1, amounts); + + bytes[] memory offchainTokenData = new bytes[](message.tokenAmounts.length); + uint32[] memory tokenGasOverrides = new uint32[](0); + + vm.mockCallRevert( + address(s_offRamp), + abi.encodeWithSelector(s_offRamp.executeSingleMessage.selector, message, offchainTokenData, tokenGasOverrides), + abi.encodeWithSelector(CallWithExactGas.NO_GAS_FOR_CALL_EXACT_CHECK_SIG, "") + ); + + IERC20 dstToken0 = IERC20(s_destTokens[0]); + + vm.expectRevert(MultiOCR3Base.InsufficientGasForCallWithExact.selector); + changePrank(address(1)); + (Internal.MessageExecutionState newState, bytes memory err) = + s_offRamp.trialExecute(message, offchainTokenData, tokenGasOverrides); + } + + function test_trialExecute_RevertsWhen_NoEnoughGasForCallSigAndSenderIsGasEstimator() public { + uint256[] memory amounts = new uint256[](2); + amounts[0] = 1000; + amounts[1] = 50; + Internal.Any2EVMRampMessage memory message = + _generateAny2EVMMessageWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1, amounts); + + bytes[] memory offchainTokenData = new bytes[](message.tokenAmounts.length); + uint32[] memory tokenGasOverrides = new uint32[](0); + + vm.mockCallRevert( + address(s_offRamp), + abi.encodeWithSelector(s_offRamp.executeSingleMessage.selector, message, offchainTokenData, tokenGasOverrides), + abi.encodeWithSelector(CallWithExactGas.NOT_ENOUGH_GAS_FOR_CALL_SIG, "") + ); + + IERC20 dstToken0 = IERC20(s_destTokens[0]); + + vm.expectRevert(MultiOCR3Base.InsufficientGasForCallWithExact.selector); + changePrank(address(1)); + (Internal.MessageExecutionState newState, bytes memory err) = + s_offRamp.trialExecute(message, offchainTokenData, tokenGasOverrides); + } }