Repository navigation
Conversation
SocketDst.execute() called the destination plug's inbound() directly, so a plug revert rolled back the whole transaction: the replay guard, fee accounting and ExecutionSuccess were all undone, leaving the message retryable forever with no terminal state. One bad message could also revert a whole SocketBatcher.executeBatch(). Wrap the plug call in try/catch in _execute(): success still updates execution fees and emits ExecutionSuccess; failure emits ExecutionFailed (for revert strings) or ExecutionFailedBytes (for custom errors / raw revert data) and the message stays consumed via messageExecuted. The new events are declared on ISocket next to ExecutionSuccess. No change to SocketBatcher is needed: once execute() no longer reverts on plug failure, the batch loop continues past the failed message. Fixes SocketDotTech#437
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SocketDst.execute()marks a message executed and then calls the destination plug'sinbound()directly. If the plug reverts, the whole transaction reverts, somessageExecuted[msgId] = true, fee accounting, andExecutionSuccessare all rolled back. The message is left retryable forever with no terminal state, and one bad message can revert an entireSocketBatcher.executeBatch(), rolling back earlier successful executions in the same batch.This contradicts the comment on
_execute()itself, which says message execution failure is not blocking the system.Fixes #437.
Fix
contracts/socket/SocketDst.sol: wrap the plug call in_execute()intry/catch. On success the behavior is unchanged (fees updated,ExecutionSuccessemitted). On failure the message stays consumed (messageExecutedwas set before verification) and the failure is recorded:ExecutionFailedfor revert strings,ExecutionFailedBytesfor custom errors / raw revert data.contracts/interfaces/ISocket.sol: declareExecutionFailed(bytes32 msgId, string result)andExecutionFailedBytes(bytes32 msgId, bytes result)next toExecutionSuccess, so the failed terminal state is protocol-level instead of only existing as local declarations in tests.SocketBatcher: onceexecute()no longer reverts on plug failure, the batch loop continues past the failed message on its own. Reverts for other reasons (e.g.MessageAlreadyExecuted, verification failures) still abort the batch, as before.Tests
Both failure modes were reproduced before the fix (the plug revert bubbled up through
Socket.execute()and reverted the whole call) and pass after it:test/socket/SocketDst.t.sol—testExecuteMessageWithFailingPlug:Counter.remoteSubOperationwith an amount above the destination counter. Assertsexecute()does not revert,ExecutionFailedBytesis emitted with theInvalidAmount()selector,messageExecutedstays true, the destination counter is untouched, and a retry reverts withMessageAlreadyExecuted.test/socket/SocketBatcher.t.sol—testExecuteBatchContinuesAfterFailingPlug: a good add (100) followed by a failing sub (150, counter is 100 after the add) in oneexecuteBatch. Asserts the batch completes, the good message executes (counter = 100), the failing one emitsExecutionFailedBytes, both messages are consumed, and retrying the failed one reverts withMessageAlreadyExecuted.Full suite: 140 passed, 6 failed — the 6 failures are pre-existing on
master(verified by running the suite on the pristine tree): 2testFail*tests removed in newer forge, and 4 fork tests that need RPC env vars (MAINNET_RPC,SEPOLIA_RPC,OPTIMISM_SEPOLIA_RPC).Open question for maintainers
The exact fee policy on failed destination execution is a protocol decision. This PR follows the shape suggested in the issue: execution fees are credited only on success, so an executor that spends gas on a failed plug call gets no fee credit for it. Happy to change that if the intended policy is different.
Notes
fx-portal/contractssubmodule URL is dead (repo moved to0xPolygon/fx-portal, 404 at the old path). I populatedlib/contractslocally from0xPolygon/fx-portalat the pinned commit to build/test; no submodule config is changed in this PR.