Skip to content

Propagate InsufficientGasLimit errors from v2_dispatch#1688

Merged
yrong merged 4 commits intoron/multi-contract-callsfrom
copilot/sub-pr-1676
Jan 26, 2026
Merged

Propagate InsufficientGasLimit errors from v2_dispatch#1688
yrong merged 4 commits intoron/multi-contract-callsfrom
copilot/sub-pr-1676

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Implements Option A from review feedback: InsufficientGasLimit errors thrown in _dispatchCommand were being caught by v2_dispatch and converted to CommandFailed events, preventing the rethrow logic in v2_submit from ever triggering.

Changes

  • v2_dispatch: Added revert data inspection in catch block to detect and rethrow InsufficientGasLimit errors instead of converting them to CommandFailed events
  • testAgentCallContractRevertedForInsufficientGas: Updated to expect transaction revert instead of successful dispatch with command failure

Behavior

Gas limit violations now propagate through the call stack and revert the entire transaction:

// Before: InsufficientGasLimit caught and converted to CommandFailed
catch {
    emit IGatewayV2.CommandFailed(message.nonce, i);
    // ...
}

// After: InsufficientGasLimit propagates up
catch (bytes memory reason) {
    if (reason.length >= 4 && bytes4(reason) == IGatewayV2.InsufficientGasLimit.selector) {
        revert IGatewayV2.InsufficientGasLimit();
    }
    emit IGatewayV2.CommandFailed(message.nonce, i);
    // ...
}

Other command failures continue to emit CommandFailed events as before.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 26, 2026 14:42
Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>
Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 26, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • foundry.paradigm.xyz
    • Triggering command: /usr/bin/curl curl -L REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Address feedback and apply patch based on Option A for multiple contract calls Propagate InsufficientGasLimit errors from v2_dispatch Jan 26, 2026
Copilot AI requested a review from yrong January 26, 2026 14:45
@yrong yrong marked this pull request as ready for review January 26, 2026 16:31
@yrong yrong merged commit 5385b9b into ron/multi-contract-calls Jan 26, 2026
1 of 2 checks passed
@yrong yrong deleted the copilot/sub-pr-1676 branch January 26, 2026 16:32
yrong added a commit that referenced this pull request Feb 6, 2026
* Multiple calls support

* Support multiple calls

* Add test

* Revamp test

* Improve L1 adapter

* Harden L1 adapter

* Update contracts/src/AgentExecutor.sol

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Revert L2 changes

* Add atomic flag

* [WIP] Address feedback on multiple contract calls implementation (#1685)

* Initial plan

* Fix dispatchSuccess initialization to false

Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>

* Remove trailing blank line in GatewayV2.t.sol (#1686)

* Initial plan

* Remove extra blank line for consistency

Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>

* Propagate InsufficientGasLimit errors from v2_dispatch (#1688)

* Initial plan

* Implement Option A: Propagate InsufficientGasLimit from v2_dispatch

Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>

* Simplify InsufficientGasLimit rethrow logic

Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>

* Fix tests

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>
Co-authored-by: ron <yrong1997@gmail.com>

* Fix tests

* Optimize gas usage for atomic command failures by skipping event emission (#1690)

* Initial plan

* Fix: Check atomic flag before emitting CommandFailed event

Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>

* More tests

* Improve test

* Improve AtomicCommandFailed error

* Remove the atomic control in Comand

* Move multi-call out

* Revert change

* Revert change

* Revert change

* Restore the comments

* Revamp tests

* Refactor Gateway

* Fix tests

* Comments

* Fix mock

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yrong <4383920+yrong@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants