Skip to content

Commit

Permalink
feat: CCIP-2612 update behavior of _trialExecute to return error resp…
Browse files Browse the repository at this point in the history
…onse on failure (#1183)

CCIP-2612 update behavior of _trialExecute to return error response on
failure

## Motivation


## Solution

---------

Co-authored-by: app-token-issuer-infra-releng[bot] <120227048+app-token-issuer-infra-releng[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 2f2dc93 commit f420af8
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 55 deletions.
64 changes: 32 additions & 32 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ EVM2EVMMultiOffRamp_ccipReceive:test_Reverts() (gas: 15659)
EVM2EVMMultiOffRamp_commit:test_InvalidIntervalMinLargerThanMax_Revert() (gas: 67189)
EVM2EVMMultiOffRamp_commit:test_InvalidInterval_Revert() (gas: 59695)
EVM2EVMMultiOffRamp_commit:test_InvalidRootRevert() (gas: 58775)
EVM2EVMMultiOffRamp_commit:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6531262)
EVM2EVMMultiOffRamp_commit:test_NoConfig_Revert() (gas: 6114492)
EVM2EVMMultiOffRamp_commit:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6394845)
EVM2EVMMultiOffRamp_commit:test_NoConfig_Revert() (gas: 5978075)
EVM2EVMMultiOffRamp_commit:test_OnlyGasPriceUpdates_Success() (gas: 108372)
EVM2EVMMultiOffRamp_commit:test_OnlyPriceUpdateStaleReport_Revert() (gas: 118374)
EVM2EVMMultiOffRamp_commit:test_OnlyTokenPriceUpdates_Success() (gas: 108415)
Expand All @@ -156,25 +156,25 @@ EVM2EVMMultiOffRamp_commit:test_StaleReportWithRoot_Success() (gas: 227655)
EVM2EVMMultiOffRamp_commit:test_UnauthorizedTransmitter_Revert() (gas: 119676)
EVM2EVMMultiOffRamp_commit:test_Unhealthy_Revert() (gas: 77602)
EVM2EVMMultiOffRamp_commit:test_ValidPriceUpdateThenStaleReportWithRoot_Success() (gas: 209115)
EVM2EVMMultiOffRamp_commit:test_WrongConfigWithoutSigners_Revert() (gas: 6525651)
EVM2EVMMultiOffRamp_commit:test_WrongConfigWithoutSigners_Revert() (gas: 6389234)
EVM2EVMMultiOffRamp_commit:test_ZeroEpochAndRound_Revert() (gas: 47782)
EVM2EVMMultiOffRamp_constructor:test_Constructor_Success() (gas: 6117538)
EVM2EVMMultiOffRamp_constructor:test_SourceChainSelector_Revert() (gas: 157533)
EVM2EVMMultiOffRamp_constructor:test_ZeroChainSelector_Revert() (gas: 104021)
EVM2EVMMultiOffRamp_constructor:test_ZeroNonceManager_Revert() (gas: 101901)
EVM2EVMMultiOffRamp_constructor:test_ZeroOnRampAddress_Revert() (gas: 160038)
EVM2EVMMultiOffRamp_constructor:test_ZeroRMNProxy_Revert() (gas: 101791)
EVM2EVMMultiOffRamp_constructor:test_ZeroTokenAdminRegistry_Revert() (gas: 101858)
EVM2EVMMultiOffRamp_constructor:test_Constructor_Success() (gas: 5981117)
EVM2EVMMultiOffRamp_constructor:test_SourceChainSelector_Revert() (gas: 157317)
EVM2EVMMultiOffRamp_constructor:test_ZeroChainSelector_Revert() (gas: 103806)
EVM2EVMMultiOffRamp_constructor:test_ZeroNonceManager_Revert() (gas: 101686)
EVM2EVMMultiOffRamp_constructor:test_ZeroOnRampAddress_Revert() (gas: 159823)
EVM2EVMMultiOffRamp_constructor:test_ZeroRMNProxy_Revert() (gas: 101576)
EVM2EVMMultiOffRamp_constructor:test_ZeroTokenAdminRegistry_Revert() (gas: 101643)
EVM2EVMMultiOffRamp_execute:test_IncorrectArrayType_Revert() (gas: 17277)
EVM2EVMMultiOffRamp_execute:test_LargeBatch_Success() (gas: 1559403)
EVM2EVMMultiOffRamp_execute:test_MultipleReportsWithPartialValidationFailures_Success() (gas: 343591)
EVM2EVMMultiOffRamp_execute:test_MultipleReportsWithPartialValidationFailures_Success() (gas: 342891)
EVM2EVMMultiOffRamp_execute:test_MultipleReports_Success() (gas: 260175)
EVM2EVMMultiOffRamp_execute:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6581613)
EVM2EVMMultiOffRamp_execute:test_NoConfig_Revert() (gas: 6164562)
EVM2EVMMultiOffRamp_execute:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6445196)
EVM2EVMMultiOffRamp_execute:test_NoConfig_Revert() (gas: 6028145)
EVM2EVMMultiOffRamp_execute:test_NonArray_Revert() (gas: 27678)
EVM2EVMMultiOffRamp_execute:test_SingleReport_Success() (gas: 165178)
EVM2EVMMultiOffRamp_execute:test_UnauthorizedTransmitter_Revert() (gas: 149134)
EVM2EVMMultiOffRamp_execute:test_WrongConfigWithSigners_Revert() (gas: 6943688)
EVM2EVMMultiOffRamp_execute:test_WrongConfigWithSigners_Revert() (gas: 6807271)
EVM2EVMMultiOffRamp_execute:test_ZeroReports_Revert() (gas: 17151)
EVM2EVMMultiOffRamp_executeSingleMessage:test_MessageSender_Revert() (gas: 18413)
EVM2EVMMultiOffRamp_executeSingleMessage:test_NonContractWithTokens_Success() (gas: 249368)
Expand All @@ -188,25 +188,25 @@ EVM2EVMMultiOffRamp_executeSingleMessage:test_executeSingleMessage_WithTokens_Su
EVM2EVMMultiOffRamp_executeSingleMessage:test_executeSingleMessage_WithValidation_Success() (gas: 93582)
EVM2EVMMultiOffRamp_executeSingleReport:test_DisabledSourceChain_Revert() (gas: 35083)
EVM2EVMMultiOffRamp_executeSingleReport:test_EmptyReport_Revert() (gas: 23910)
EVM2EVMMultiOffRamp_executeSingleReport:test_InvalidSourcePoolAddress_Success() (gas: 451623)
EVM2EVMMultiOffRamp_executeSingleReport:test_InvalidSourcePoolAddress_Success() (gas: 451358)
EVM2EVMMultiOffRamp_executeSingleReport:test_ManualExecutionNotYetEnabled_Revert() (gas: 54472)
EVM2EVMMultiOffRamp_executeSingleReport:test_MismatchingDestChainSelector_Revert() (gas: 35906)
EVM2EVMMultiOffRamp_executeSingleReport:test_MismatchingDestChainSelector_Revert() (gas: 35917)
EVM2EVMMultiOffRamp_executeSingleReport:test_MismatchingOnRampRoot_Revert() (gas: 154363)
EVM2EVMMultiOffRamp_executeSingleReport:test_NonExistingSourceChain_Revert() (gas: 35317)
EVM2EVMMultiOffRamp_executeSingleReport:test_ReceiverError_Success() (gas: 181595)
EVM2EVMMultiOffRamp_executeSingleReport:test_RetryFailedMessageWithoutManualExecution_Revert() (gas: 190875)
EVM2EVMMultiOffRamp_executeSingleReport:test_ReceiverError_Success() (gas: 181347)
EVM2EVMMultiOffRamp_executeSingleReport:test_RetryFailedMessageWithoutManualExecution_Revert() (gas: 190627)
EVM2EVMMultiOffRamp_executeSingleReport:test_RootNotCommitted_Revert() (gas: 48050)
EVM2EVMMultiOffRamp_executeSingleReport:test_RouterYULCall_Revert() (gas: 436532)
EVM2EVMMultiOffRamp_executeSingleReport:test_RouterYULCall_Revert() (gas: 443030)
EVM2EVMMultiOffRamp_executeSingleReport:test_SingleMessageNoTokensOtherChain_Success() (gas: 251770)
EVM2EVMMultiOffRamp_executeSingleReport:test_SingleMessageNoTokensUnordered_Success() (gas: 173962)
EVM2EVMMultiOffRamp_executeSingleReport:test_SingleMessageNoTokens_Success() (gas: 193657)
EVM2EVMMultiOffRamp_executeSingleReport:test_SingleMessageToNonCCIPReceiver_Success() (gas: 259648)
EVM2EVMMultiOffRamp_executeSingleReport:test_SingleMessagesNoTokensSuccess_gas() (gas: 129574)
EVM2EVMMultiOffRamp_executeSingleReport:test_SingleMessagesNoTokensSuccess_gas() (gas: 129585)
EVM2EVMMultiOffRamp_executeSingleReport:test_SkippedIncorrectNonceStillExecutes_Success() (gas: 391710)
EVM2EVMMultiOffRamp_executeSingleReport:test_SkippedIncorrectNonce_Success() (gas: 65899)
EVM2EVMMultiOffRamp_executeSingleReport:test_TokenDataMismatch_Revert() (gas: 80955)
EVM2EVMMultiOffRamp_executeSingleReport:test_TwoMessagesWithTokensAndGE_Success() (gas: 535423)
EVM2EVMMultiOffRamp_executeSingleReport:test_TwoMessagesWithTokensSuccess_gas() (gas: 480334)
EVM2EVMMultiOffRamp_executeSingleReport:test_TwoMessagesWithTokensSuccess_gas() (gas: 480345)
EVM2EVMMultiOffRamp_executeSingleReport:test_UnexpectedTokenData_Revert() (gas: 35763)
EVM2EVMMultiOffRamp_executeSingleReport:test_UnhealthySingleChainCurse_Revert() (gas: 520344)
EVM2EVMMultiOffRamp_executeSingleReport:test_Unhealthy_Revert() (gas: 517712)
Expand All @@ -218,16 +218,16 @@ EVM2EVMMultiOffRamp_getExecutionState:test_GetDifferentChainExecutionState_Succe
EVM2EVMMultiOffRamp_getExecutionState:test_GetExecutionState_Success() (gas: 87407)
EVM2EVMMultiOffRamp_manuallyExecute:test_ManualExecGasLimitMismatchSingleReport_Revert() (gas: 75594)
EVM2EVMMultiOffRamp_manuallyExecute:test_ManualExecInvalidGasLimit_Revert() (gas: 26461)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_DoesNotRevertIfUntouched_Success() (gas: 163329)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_FailedTx_Revert() (gas: 207875)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_DoesNotRevertIfUntouched_Success() (gas: 163081)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_FailedTx_Revert() (gas: 207379)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_ForkedChain_Revert() (gas: 26001)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_GasLimitMismatchMultipleReports_Revert() (gas: 152861)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_LowGasLimit_Success() (gas: 507728)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_ReentrancyFails() (gas: 2308170)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_Success() (gas: 209881)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_WithGasOverride_Success() (gas: 210458)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_WithMultiReportGasOverride_Success() (gas: 669850)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_WithPartialMessages_Success() (gas: 299725)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_LowGasLimit_Success() (gas: 507480)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_ReentrancyFails() (gas: 2307922)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_Success() (gas: 209633)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_WithGasOverride_Success() (gas: 210210)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_WithMultiReportGasOverride_Success() (gas: 668610)
EVM2EVMMultiOffRamp_manuallyExecute:test_manuallyExecute_WithPartialMessages_Success() (gas: 299477)
EVM2EVMMultiOffRamp_releaseOrMintTokens:test_TokenHandlingError_Reverts() (gas: 160598)
EVM2EVMMultiOffRamp_releaseOrMintTokens:test__releaseOrMintTokens_PoolIsNotAPool_Reverts() (gas: 24128)
EVM2EVMMultiOffRamp_releaseOrMintTokens:test_releaseOrMintTokens_InvalidDataLengthReturnData_Revert() (gas: 59102)
Expand All @@ -242,9 +242,9 @@ EVM2EVMMultiOffRamp_setDynamicConfig:test_PriceRegistryZeroAddress_Revert() (gas
EVM2EVMMultiOffRamp_setDynamicConfig:test_RouterZeroAddress_Revert() (gas: 14051)
EVM2EVMMultiOffRamp_setDynamicConfig:test_SetDynamicConfigWithValidator_Success() (gas: 55768)
EVM2EVMMultiOffRamp_setDynamicConfig:test_SetDynamicConfig_Success() (gas: 33778)
EVM2EVMMultiOffRamp_trialExecute:test_RateLimitError_Success() (gas: 238254)
EVM2EVMMultiOffRamp_trialExecute:test_TokenHandlingErrorIsCaught_Success() (gas: 246917)
EVM2EVMMultiOffRamp_trialExecute:test_TokenPoolIsNotAContract_Success() (gas: 300099)
EVM2EVMMultiOffRamp_trialExecute:test_RateLimitError_Success() (gas: 237989)
EVM2EVMMultiOffRamp_trialExecute:test_TokenHandlingErrorIsCaught_Success() (gas: 246652)
EVM2EVMMultiOffRamp_trialExecute:test_TokenPoolIsNotAContract_Success() (gas: 299484)
EVM2EVMMultiOffRamp_trialExecute:test_trialExecute_Success() (gas: 280579)
EVM2EVMMultiOffRamp_verify:test_Blessed_Success() (gas: 176586)
EVM2EVMMultiOffRamp_verify:test_NotBlessedWrongChainSelector_Success() (gas: 178657)
Expand Down
19 changes: 4 additions & 15 deletions contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ contract EVM2EVMMultiOffRamp is ITypeAndVersion, MultiOCR3Base {
}

_setExecutionState(sourceChainSelector, message.header.sequenceNumber, Internal.MessageExecutionState.IN_PROGRESS);

(Internal.MessageExecutionState newState, bytes memory returnData) = _trialExecute(message, offchainTokenData);
_setExecutionState(sourceChainSelector, message.header.sequenceNumber, newState);

Expand Down Expand Up @@ -479,21 +480,9 @@ contract EVM2EVMMultiOffRamp is ITypeAndVersion, MultiOCR3Base {
) internal returns (Internal.MessageExecutionState, bytes memory) {
try this.executeSingleMessage(message, offchainTokenData) {}
catch (bytes memory err) {
bytes4 errorSelector = bytes4(err);
if (
ReceiverError.selector == errorSelector || TokenHandlingError.selector == errorSelector
|| Internal.InvalidEVMAddress.selector == errorSelector || InvalidDataLength.selector == errorSelector
|| CallWithExactGas.NoContract.selector == errorSelector || NotACompatiblePool.selector == errorSelector
|| IMessageInterceptor.MessageValidationError.selector == errorSelector
) {
// If CCIP receiver execution is not successful, bubble up receiver revert data,
// prepended by the 4 bytes of ReceiverError.selector, TokenHandlingError.selector or InvalidPoolAddress.selector.
// Max length of revert data is Router.MAX_RET_BYTES, max length of err is 4 + Router.MAX_RET_BYTES
return (Internal.MessageExecutionState.FAILURE, err);
} else {
// If revert is not caused by CCIP receiver, it is unexpected, bubble up the revert.
revert ExecutionError(message.header.messageId, err);
}
// return the message execution state as FAILURE and the revert data
// Max length of revert data is Router.MAX_RET_BYTES, max length of err is 4 + Router.MAX_RET_BYTES
return (Internal.MessageExecutionState.FAILURE, err);
}
// If message execution succeeded, no CCIP receiver return data is expected, return with empty bytes.
return (Internal.MessageExecutionState.SUCCESS, "");
Expand Down
13 changes: 7 additions & 6 deletions contracts/src/v0.8/ccip/test/offRamp/EVM2EVMMultiOffRamp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -909,12 +909,13 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup {
Internal.ExecutionReportSingleChain memory executionReport =
_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages);

vm.expectRevert(
abi.encodeWithSelector(
EVM2EVMMultiOffRamp.ExecutionError.selector,
messages[0].header.messageId,
abi.encodeWithSelector(CallWithExactGas.NotEnoughGasForCall.selector)
)
vm.expectEmit();
emit EVM2EVMMultiOffRamp.ExecutionStateChanged(
messages[0].header.sourceChainSelector,
messages[0].header.sequenceNumber,
messages[0].header.messageId,
Internal.MessageExecutionState.FAILURE,
abi.encodeWithSelector(CallWithExactGas.NotEnoughGasForCall.selector)
);
s_offRamp.executeSingleReport(executionReport, new uint256[](0));
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ccip_config: ../../../contracts/solc/v0.8.24/CCIPConfig/CCIPConfig.abi ../../../
commit_store: ../../../contracts/solc/v0.8.24/CommitStore/CommitStore.abi ../../../contracts/solc/v0.8.24/CommitStore/CommitStore.bin ddc26c10c2a52b59624faae9005827b09b98db4566887a736005e8cc37cf8a51
commit_store_helper: ../../../contracts/solc/v0.8.24/CommitStoreHelper/CommitStoreHelper.abi ../../../contracts/solc/v0.8.24/CommitStoreHelper/CommitStoreHelper.bin ebd8aac686fa28a71d4212bcd25a28f8f640d50dce5e50498b2f6b8534890b69
ether_sender_receiver: ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.abi ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.bin 09510a3f773f108a3c231e8d202835c845ded862d071ec54c4f89c12d868b8de
evm_2_evm_multi_offramp: ../../../contracts/solc/v0.8.24/EVM2EVMMultiOffRamp/EVM2EVMMultiOffRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMMultiOffRamp/EVM2EVMMultiOffRamp.bin a9f1db6b9415c11b0467fe40eddc48075f8261f312d0a4b78aff05cfd78e7594
evm_2_evm_multi_offramp: ../../../contracts/solc/v0.8.24/EVM2EVMMultiOffRamp/EVM2EVMMultiOffRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMMultiOffRamp/EVM2EVMMultiOffRamp.bin 25a7bf3aa46252844c7afabc15db1051e7b6a717e296fc4c6e2f2f93d16033c5
evm_2_evm_multi_onramp: ../../../contracts/solc/v0.8.24/EVM2EVMMultiOnRamp/EVM2EVMMultiOnRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMMultiOnRamp/EVM2EVMMultiOnRamp.bin 918036eebe888df142047ebb3c93ddd9e3d47749bfa25e32dc89f96e1c5f43a4
evm_2_evm_offramp: ../../../contracts/solc/v0.8.24/EVM2EVMOffRamp/EVM2EVMOffRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMOffRamp/EVM2EVMOffRamp.bin a8c23c9280a713544eae0a0b8841a9caf97e616338d31ebc62501d8b4ab0eed6
evm_2_evm_onramp: ../../../contracts/solc/v0.8.24/EVM2EVMOnRamp/EVM2EVMOnRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMOnRamp/EVM2EVMOnRamp.bin 116d5cb8447a1af61664a8d1db2d76086c042a3228337bc5cd49b9abd3e815f7
Expand Down

0 comments on commit f420af8

Please sign in to comment.