Skip to content

Fix/oft bridge followups - #20

Merged
sirpy merged 10 commits into
masterfrom
fix/oft-bridge-followups
Nov 25, 2026
Merged

sirpy merged 10 commits into
masterfrom
fix/oft-bridge-followups

Conversation

@blueogin

@blueogin blueogin commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Receive side. A limit-blocked receive was handled two different ways depending on whether the payload happened to carry a compose message: a plain transfer was parked as a failed request, while a composed one reverted. The reason was real — a parked request could only _credit, so parking a composed message would silently drop its compose payload — but the result was that payload length decided the recovery semantics.

Send side. _debit pulled the user's tokens into the adapter, approved the MinterBurner, and let it pull them a second time. That meant two token transfers plus an allowance per send, the adapter briefly custodied user funds, and TokensBurned named the adapter as the burn source, so nothing on-chain tied a burn to the account that funded it

About # (link your issue here)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • PR title matches follow: (Feature|Bug|Chore) Task Name
  • My code follows the style guidelines of this project
  • I have followed all the instructions described in the initial task (check Definitions of Done)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added reference to a related issue in the repository
  • I have added a detailed description of the changes proposed in the pull request. I am as descriptive as possible, assisting reviewers as much as possible.
  • I have added screenshots related to my pull request (for frontend tasks)
  • I have pasted a gif showing the feature.
  • @mentions of the person or team responsible for reviewing proposed changes

Summary by Sourcery

Make OFT receive recovery lossless and outbound token burning single-transfer with accurate sender attribution.

Bug Fixes:

  • Ensure limit-blocked composed and plain receives share the same recoverable failure path without losing compose payloads.
  • Prevent duplicate token movement during outbound burns and attribute burn events to the account that funded them.

Enhancements:

  • Replay approved failed receives through the complete OFT receive flow and expose details for parked requests.
  • Have the MinterBurner burn only tokens already transferred to its own balance.

Tests:

  • Expand receive, replay, compose-dispatch, reentrancy, and sender-attributed burn coverage.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 5 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol" line_range="107" />
<code_context>
         uint32 srcEid;
+        uint64 nonce;
+        bytes32 sender;
+        bytes message;
     }
-    /// @dev A mapping for failed requests
</code_context>
<issue_to_address>
**Pending requests become unrecoverable**

When the adapter is upgraded while failed requests stored under the old layout remain pending, `approveFailedRequest` reads the old mapping slots as the new replay fields, so it replays corrupted data and reverts; the original receive remains uncredited. The source-side burn has no matching destination credit.

Migrate or drain old-layout requests before upgrading, or preserve their storage layout and replay compatibility.
</issue_to_address>

### Comment 2
<location path="packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol" line_range="334" />
<code_context>
+        require(msg.sender == address(this), 'only self');
+        // _message[:0] is an empty calldata slice: OFTCore._lzReceive ignores _executor and _extraData,
+        // and a literal cannot be passed where calldata is expected
+        super._lzReceive(_origin, _guid, _message, address(0), _message[:0]);
     }

</code_context>
<issue_to_address>
**Approval bypasses the whitelist**

When a composed request is parked while whitelisting is enabled and its recipient is removed before approval, `approveFailedRequest` checks only `isClosed`, then `replayFailedRequest` calls `super._lzReceive` without rechecking the whitelist; the recipient is credited despite the whitelist policy.

Recheck the recipient's whitelist status when approving or replaying a failed request.

Also at `packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol:510`.
</issue_to_address>

### Comment 3
<location path="packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol" line_range="576" />
<code_context>
+            innerToken.balanceOf(address(minterBurner)) - balanceBefore == amountSentLD,
+            'received amount mismatch'
+        );
+        require(minterBurner.burn(address(minterBurner), amountSentLD), 'GoodDollarOFTAdapter: Burn failed');
+        emit SenderTokensBurned(_from, amountSentLD);
     }
</code_context>
<issue_to_address>
**Mixed upgrades halt outbound sends**

When the adapter and MinterBurner proxies run different implementations during separate upgrades, the new `_debit` and `burn` calling convention is incompatible with either old implementation, so outbound sends revert until both proxies are upgraded.

Make the burn flow compatible across implementation versions or upgrade both proxies atomically before accepting sends.

Also at `packages/bridge-contracts/contracts/oft/GoodDollarOFTMinterBurner.sol:74`.
</issue_to_address>

### Comment 4
<location path="packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol" line_range="107" />
<code_context>
         uint32 srcEid;
+        uint64 nonce;
+        bytes32 sender;
+        bytes message;
     }
-    /// @dev A mapping for failed requests
</code_context>
<issue_to_address>
**Failed-message tests cannot read payload**

When the new unit tests read a parked request through `failedReceiveRequests(guid)`, solidity omits dynamically sized struct members from the autogenerated getter for `failedReceiveRequests`, so the test's `req.message` is undefined and its equality assertions fail. The adapter has no explicit getter for the parked message.

Add an explicit view function that returns the stored message and use it in these assertions, or remove the inaccessible-field assertions.
</issue_to_address>

### Comment 5
<location path="packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol" line_range="105-107" />
<code_context>
         uint64 timestamp;
-        uint256 amount;
         uint32 srcEid;
+        uint64 nonce;
+        bytes32 sender;
+        bytes message;
     }
-    /// @dev A mapping for failed requests
</code_context>
<issue_to_address>
**Legacy request reads return wrong fields**

When an off-chain consumer continues using the pre-upgrade ABI for the public mapping getter, legacy RPC clients decode `failedReceiveRequests(bytes32)` using the old tuple (`failed`, `toAddress`, `timestamp`, `amount`, `srcEid`), but the public getter now returns fields from the new struct layout. The call still decodes, but clients show incorrect request metadata and can make recovery decisions from it.

Preserve the old getter’s return shape or provide a clearly versioned compatibility API and update consumers to the new ABI.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 5 findings to address first, and the changed mapping value layout makes previously parked requests unreadable to this implementation, so their already-consumed LayerZero messages cannot be approved and the intended token credit may remain stuck; the diff says those records must be drained before upgrading a deployment that has them. The bridge replay and burn paths also affect token issuance and destruction, which cannot be undone merely by reverting after a credit or burn has executed.

Blocking findings: packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol:107, packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol:334, packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol:576, packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol:107, packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol:107


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to run its full agentic suite in this review.

Copilot review overview

4 open issues
What changed in this PR

Updates the GoodDollar OFT adapter/minter-burner flow to (a) burn only tokens already held by the MinterBurner (no transferFrom/allowance path) and (b) “park + replay” failed receives by storing the full OFT message (including composed payloads) and replaying through the normal OFT receive logic.

Changes:

  • Modify GoodDollarOFTMinterBurner.burn() to burn only the contract’s own balance and require pre-delivery of tokens.
  • Change failed-receive parking to store message + origin fields and add replay/decoding helpers (including composed-message support).
  • Update endpoint mock and tests to cover composed replays, new failed-request details decoding, and new burn attribution behavior.
File Description
packages/​bridge-contracts/​test/​GoodDollarOFT.test.ts Updates/extends tests for new burn semantics, failed-receive parking layout, replay behavior, and composed message handling.
packages/​bridge-contracts/​test/​GoodDollarOFT.reentrancy.test.ts Adjusts reentrancy expectations to match replay-based approvals.
packages/​bridge-contracts/​contracts/​test/​LayerZeroEndpointMock.sol Adds compose dispatch recording and event emission for composed-message replay tests.
packages/​bridge-contracts/​contracts/​oft/​GoodDollarOFTMinterBurner.sol Refactors burn path to debit only MinterBurner-held balance; removes allowance-based burning.
packages/​bridge-contracts/​contracts/​oft/​GoodDollarOFTAdapter.sol Changes failed-request storage layout; adds replay + decode utilities; changes debit path to transfer directly to MinterBurner and emits sender-attribution event.

Review effort: Lite

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

sirpy commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@copilot the guid of a failed request should be kept so it can work with optimistic approval.
when approving a request it doesnt credit the user, it should just make sure that next time it is retried through layerzero it iwll not go through the limit checks

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

Copilot AI commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@copilot the guid of a failed request should be kept so it can work with optimistic approval.
when approving a request it doesnt credit the user, it should just make sure that next time it is retried...

Implemented in e2ae9ee. Approval now records the GUID for a one-time retry without crediting tokens; the subsequent LayerZero delivery bypasses receive limits and performs the normal credit/compose flow. Failed-request metadata remains minimal, with the reason emitted.

_origin.srcEid
);
emit ReceiveRequestFailed(_guid, toAddress, amountLD, _origin.srcEid, reason);
revert BRIDGE_LIMITS(reason);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should still revert

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A revert rolls back the GUID write in the same transaction, so it cannot both persist failedReceiveRequests[_guid] and revert. Should I prioritize reversion (dropping on-chain failed-request persistence/optimistic timing), or keep the GUID parked so approval can authorize a retry?

*/
uint256[50] private __gap;
} No newline at end of file
uint256[49] private __gap;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not deployed yet. no need

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored the original uint256[50] gap in the follow-up commit; the validation build passes.

@sirpy

sirpy commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@copilot fix review comments

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Copilot AI requested a review from sirpy November 25, 2026 13:31
@sirpy

sirpy commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@copilot revert back to 64d8236

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

Copilot AI commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@copilot revert back to 64d8236

Reverted the repository state after 64d8236 back to that exact commit in e0bb484. Targeted OFT tests pass: 50 passing.

@sirpy

sirpy commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@copilot why is extradata of failed message not saved for replay?
@sourcery-ai review

Copilot AI commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@copilot why is extradata of failed message not saved for replay?
@sourcery-ai review

_extraData is omitted from FailedReceiveRequest for three reasons:

  1. Unused on replay: OFTCoreUpgradeable._lzReceive ignores both _executor and _extraData (bytes calldata /*_extraData*/). Even for composed messages, the compose payload is carried inside _message, not _extraData.
  2. Unauthenticated data: In LayerZero V2, _extraData is supplied by the executor at delivery time and is not part of the DVN-verified payload hash.
  3. Storage/gas cost: Skipping it avoids unnecessary storage writes during _lzReceive, keeping parking within the executor's gas budget.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

token.burn(_amount);
require(token.balanceOf(address(this)) == balanceBefore - _amount, 'burned amount mismatch');

emit TokensBurned(_from, _amount, msg.sender);
sirpy and others added 2 commits November 25, 2026 16:34
Delete parked failed receive request to reclaim storage.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Clarify the documentation for the burn function regarding the _from parameter and its purpose.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@sirpy
sirpy merged commit 2472f13 into master Nov 25, 2026
3 checks passed
@sirpy

sirpy commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@copilot why do we need failedRequestDetails? is it used anywhere? why was it added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants