Skip to content

Commit

Permalink
ensure we make progress even in manual exec (#1053)
Browse files Browse the repository at this point in the history
We want to make sure that no progress is ever being reverted. This means
that manual exec will not revert if the tx was untouched
  • Loading branch information
RensR authored Jun 20, 2024
1 parent a4b16c2 commit cf39242
Show file tree
Hide file tree
Showing 14 changed files with 320 additions and 261 deletions.
182 changes: 92 additions & 90 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/scripts/native_solc_compile_all_ccip
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo " └───────────────────────

SOLC_VERSION="0.8.24"
OPTIMIZE_RUNS=26000
OPTIMIZE_RUNS_OFFRAMP=19500
OPTIMIZE_RUNS_OFFRAMP=18000
OPTIMIZE_RUNS_ONRAMP=3600


Expand Down
8 changes: 6 additions & 2 deletions contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,12 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3
// Since it's hard to estimate whether manual execution will succeed, we
// revert the entire transaction if it fails. This will show the user if
// their manual exec will fail before they submit it.
if (manualExecution && newState == Internal.MessageExecutionState.FAILURE) {
// If manual execution fails, we revert the entire transaction.
if (
manualExecution && newState == Internal.MessageExecutionState.FAILURE
&& originalState != Internal.MessageExecutionState.UNTOUCHED
) {
// If manual execution fails, we revert the entire transaction, unless the originalState is UNTOUCHED as we
// would still be making progress by changing the state from UNTOUCHED to FAILURE.
revert ExecutionError(message.messageId, returnData);
}

Expand Down
13 changes: 8 additions & 5 deletions contracts/src/v0.8/ccip/offRamp/EVM2EVMOffRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,12 @@ contract EVM2EVMOffRamp is IAny2EVMOffRamp, AggregateRateLimiter, ITypeAndVersio
// Since it's hard to estimate whether manual execution will succeed, we
// revert the entire transaction if it fails. This will show the user if
// their manual exec will fail before they submit it.
if (manualExecution && newState == Internal.MessageExecutionState.FAILURE) {
// If manual execution fails, we revert the entire transaction.
if (
manualExecution && newState == Internal.MessageExecutionState.FAILURE
&& originalState != Internal.MessageExecutionState.UNTOUCHED
) {
// If manual execution fails, we revert the entire transaction, unless the originalState is UNTOUCHED as we
// would still be making progress by changing the state from UNTOUCHED to FAILURE.
revert ExecutionError(returnData);
}

Expand Down Expand Up @@ -427,10 +431,9 @@ contract EVM2EVMOffRamp is IAny2EVMOffRamp, AggregateRateLimiter, ITypeAndVersio
// 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(err);
}
// If revert is not caused by CCIP receiver, it is unexpected, bubble up the revert.
revert ExecutionError(err);
}
// If message execution succeeded, no CCIP receiver return data is expected, return with empty bytes.
return (Internal.MessageExecutionState.SUCCESS, "");
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/ccip/test/e2e/End2End.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ contract E2E is EVM2EVMOnRampSetup, CommitStoreSetup, EVM2EVMOffRampSetup {
vm.warp(BLOCK_TIME + 2000);

vm.expectEmit();
emit ExecutionStateChanged(
emit EVM2EVMOffRamp.ExecutionStateChanged(
messages[0].sequenceNumber, messages[0].messageId, Internal.MessageExecutionState.SUCCESS, ""
);

vm.expectEmit();
emit ExecutionStateChanged(
emit EVM2EVMOffRamp.ExecutionStateChanged(
messages[1].sequenceNumber, messages[1].messageId, Internal.MessageExecutionState.SUCCESS, ""
);

vm.expectEmit();
emit ExecutionStateChanged(
emit EVM2EVMOffRamp.ExecutionStateChanged(
messages[2].sequenceNumber, messages[2].messageId, Internal.MessageExecutionState.SUCCESS, ""
);

Expand Down
160 changes: 97 additions & 63 deletions contracts/src/v0.8/ccip/test/offRamp/EVM2EVMMultiOffRamp.t.sol

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba
return message;
}

function _generateBasicMessages(
function _generateSingleBasicMessage(
uint64 sourceChainSelector,
address onRamp
) internal view returns (Internal.EVM2EVMMessage[] memory) {
Expand Down
Loading

0 comments on commit cf39242

Please sign in to comment.