Repository navigation
Conversation
- Skip zero-value recipient mint in _credit when fee == amount and document destination-side fee semantics - Extend OPTIMISTIC_WINDOW from 3 days to 7 days - Document that approveFailedRequest intentionally skips onlyWhitelisted re-check - Defer _resetDailyLimitsIfNeeded to accepted receives in _lzReceive and add msgType 2 (SEND_AND_CALL) enforced options - Delete storage in rejectFailedRequest, require failed flag in failedRequestDetails, and check failed before timestamp in approveFailedRequest - Sync LayerZero endpoint delegate in transferOwnership and disable renounceOwnership - Enforce minAmount <= accountDailyLimit, align production txLimit in oft.config.json, and check whitelist + dust-align maxAmount in quoteOFT - Add nonReentrant on _send/_lzReceive, require non-zero token in GoodDollarOFTMinterBurner.initialize, and refine FailedReceiveRequest upgrade note Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="packages/bridge-contracts/scripts/oft/layerzero.config.ts" line_range="33-38" />
<code_context>
returns (OFTLimit memory oftLimit, OFTFeeDetail[] memory oftFeeDetails, OFTReceipt memory oftReceipt)
{
uint256 maxAmount;
- if (!isClosed) {
</code_context>
<issue_to_address>
**Composed actions remain unexecuted**
When a caller sends a composed transfer relying on enforced options without supplying its own `LZ_COMPOSE` option, the `msgType: 2` entry enforces only `LZ_RECEIVE` gas, while LayerZero runs the compose callback separately. The payload can be queued without enforced gas for that callback, so the composed action does not complete.
Add an enforced `LZ_COMPOSE` gas option for `msgType: 2`.
</issue_to_address>
### Comment 2
<location path="packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol" line_range="491" />
<code_context>
uint256 accountLeft = limits.accountDailyLimit > accountUsed ? limits.accountDailyLimit - accountUsed : 0;
if (dailyLeft < maxAmount) maxAmount = dailyLeft;
if (accountLeft < maxAmount) maxAmount = accountLeft;
+ maxAmount = _removeDust(maxAmount);
}
oftLimit = OFTLimit(bridgeLimits.minAmount, maxAmount);
</code_context>
<issue_to_address>
**Quoted minimum sends revert**
When the owner configures a `minAmount` that is not aligned to the shared-decimal conversion rate, `quoteOFT` reports the raw minimum, but `_send` removes dust before checking it. The quoted minimum can therefore round below the threshold and revert; when the effective cap equals that minimum, the quote can also report a maximum below its minimum, leaving no valid send amount.
Reject non-dust-aligned `minAmount` values when setting bridge limits.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and the adapter changes how bridged token transfers are checked and credited, and those transfers can mint or burn tokens that cannot be recovered by reverting the contract code. A mistake in the limits, fee, or receive path could therefore leave funds transferred or minted incorrectly; reverting would stop future effects but not undo completed transfers.
Blocking findings: packages/bridge-contracts/scripts/oft/layerzero.config.ts:38, packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol:491
| { | ||
| msgType: 2, | ||
| optionType: ExecutorOptionType.LZ_RECEIVE, | ||
| gas: 250000, | ||
| value: 0, | ||
| }, |
There was a problem hiding this comment.
🟡 Medium · Composed actions remain unexecuted
When a caller sends a composed transfer relying on enforced options without supplying its own LZ_COMPOSE option, the msgType: 2 entry enforces only LZ_RECEIVE gas, while LayerZero runs the compose callback separately. The payload can be queued without enforced gas for that callback, so the composed action does not complete.
Add an enforced LZ_COMPOSE gas option for msgType: 2.
Prompt for AI agents
In `packages/bridge-contracts/scripts/oft/layerzero.config.ts` at lines 33-38:
**Composed actions remain unexecuted**
When a caller sends a composed transfer relying on enforced options without supplying its own `LZ_COMPOSE` option, the `msgType: 2` entry enforces only `LZ_RECEIVE` gas, while LayerZero runs the compose callback separately. The payload can be queued without enforced gas for that callback, so the composed action does not complete.
Add an enforced `LZ_COMPOSE` gas option for `msgType: 2`.| uint256 accountLeft = limits.accountDailyLimit > accountUsed ? limits.accountDailyLimit - accountUsed : 0; | ||
| if (dailyLeft < maxAmount) maxAmount = dailyLeft; | ||
| if (accountLeft < maxAmount) maxAmount = accountLeft; | ||
| maxAmount = _removeDust(maxAmount); |
There was a problem hiding this comment.
🟡 Medium · Quoted minimum sends revert
When the owner configures a minAmount that is not aligned to the shared-decimal conversion rate, quoteOFT reports the raw minimum, but _send removes dust before checking it. The quoted minimum can therefore round below the threshold and revert; when the effective cap equals that minimum, the quote can also report a maximum below its minimum, leaving no valid send amount.
Reject non-dust-aligned minAmount values when setting bridge limits.
Prompt for AI agents
In `packages/bridge-contracts/contracts/oft/GoodDollarOFTAdapter.sol` at line 491:
**Quoted minimum sends revert**
When the owner configures a `minAmount` that is not aligned to the shared-decimal conversion rate, `quoteOFT` reports the raw minimum, but `_send` removes dust before checking it. The quoted minimum can therefore round below the threshold and revert; when the effective cap equals that minimum, the quote can also report a maximum below its minimum, leaving no valid send amount.
Reject non-dust-aligned `minAmount` values when setting bridge limits.- Override _debitView to deduct bridge fees and dust-align amountReceivedLD so minAmountLD slippage protection, OFTSent, and quoteOFT reflect exact net bridged amounts - Transfer bridge fees directly to feeRecipient in _debit and burn only net amountReceivedLD via minterBurner - Populate oftFeeDetails in quoteOFT when bridge fees are non-zero - Enforce send-side bridge limits against net bridged amountReceivedLD - Mint full received _amountLD in _credit (no destination-side fee deduction) - Update and expand unit tests for source-chain fee deduction, slippage protection, dust handling, and quoteOFT Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Implements fixes, documentation updates, and regression tests addressing the logic audit of
GoodDollarOFTAdapter,GoodDollarOFTMinterBurner, and LayerZero/bridge configuration.Changes by Audit Finding
Source-chain bridge fee deduction (
GoodDollarOFTAdapter)_debitViewto deduct_takeFee(amountSentLD)on the source chain and dust-alignamountReceivedLD = _removeDust(amountSentLD - fee). Any sub-shared-decimal rounding dust from fee calculation stays infee = amountSentLD - amountReceivedLD(transferred tofeeRecipient), ensuring 1:1 cross-chain supply conservation and realminAmountLDslippage protection (SlippageExceeded)._debitto transferamountReceivedLDtominterBurnerand burn it (skipping when0), and transferfeedirectly from_fromtofeeRecipient(verifying exact balance delta and emittingFeeCollected)._creditto mint the full received_amountLDon the destination chain (no destination-side fee deduction, so in-flight and 7-day parked requests are immune to post-send fee changes).oftFeeDetailsinquoteOFTwithOFTFeeDetail(int256(fee), "Bridge fee")whenfee > 0._sendto enforce bridge limits against the net bridgedamountReceivedLDso transfers whose post-fee amount falls belowminAmountrevert cleanly on the source chain instead of being parked on destination.Optimistic window vs. DAO governance latency (
GoodDollarOFTAdapter)OPTIMISTIC_WINDOWfrom3 daysto7 days(keeping all other approval/rejection/pause access controls unchanged).approveFailedRequestwhitelist behavior (GoodDollarOFTAdapter)approveFailedRequestNatSpec that skippingbridgeLimits.onlyWhitelistedon approval is intentional: whitelist eligibility is already enforced when_lzReceiveparks the request, onlyisClosedgates approval, andrejectFailedRequestis available if the owner wants to block a parked request.Missing
SEND_AND_CALLenforced options & parking gas/state mutation (layerzero.config.ts,GoodDollarOFTAdapter)LZ_RECEIVEgas (250000) formsgType: 2(SEND_AND_CALL) inscripts/oft/layerzero.config.tsalongsidemsgType: 1(SEND)._resetDailyLimitsIfNeeded(bridgeReceiveDailyLimit, account)into theelse(accepted) branch of_lzReceive. Because_checkBridgeLimitsalready evaluates expired 24h windows in read-only mode, this avoids up to ~25k wasted cold SSTORE gas on the parking path and prevents parked receives from mutatinglastTransferReset.Stale storage on rejected requests & check ordering (
GoodDollarOFTAdapter)rejectFailedRequesttodelete failedReceiveRequests[_guid](matchingapproveFailedRequest) so rejected payloads do not linger in storage and gas refunds are reclaimed.failedRequestDetailsto requirerequest.failed && request.message.length >= 40so rejected requests revert with'no parked message'instead of returning stale details.approveFailedRequestto checkrequire(request.failed, 'request not failed')before the optimistic window timestamp check.Ownership transfer vs. LayerZero Endpoint delegate &
renounceOwnership(GoodDollarOFTAdapter)transferOwnership(address newOwner)to also callendpoint.setDelegate(newOwner), preventing the previous owner from retaining LayerZero Endpoint configuration control after ownership transfers.renounceOwnership()to always revert ('renounceOwnership disabled') so upgrades, pause controls, and failed-request rejection cannot be permanently bricked.Limit validation, production config &
quoteOFTaccuracy (GoodDollarOFTAdapter,oft.config.json)require(_limits.minAmount <= _limits.accountDailyLimit, 'minAmount > accountDailyLimit')insetBridgeLimits.production-xdcandproduction-celotxLimitinscripts/oft/oft.config.jsonfrom"100000"to"50000"to matchaccountDailyLimit("50000").quoteOFTto use_checkBridgeClosedAndWhitelisted(msg.sender)(returningmaxAmountLD = 0for non-whitelisted callers whenonlyWhitelistedis enabled) and dust-alignmaxAmountvia_removeDust(maxAmount).Defense-in-depth & initialization hardening (
GoodDollarOFTAdapter,GoodDollarOFTMinterBurner)nonReentrantto_sendand_lzReceive(no conflict withapproveFailedRequestsincereplayFailedRequestinvokessuper._lzReceive).require(address(token) != address(0), 'token required')inGoodDollarOFTMinterBurner.initialize.UPGRADE NOTEcomment onFailedReceiveRequestto accurately describe legacy storage slot decoding.Testing
GoodDollarOFT.test.ts: 54 passing (covering source-chain fee deduction,SlippageExceededonminAmountLD,quoteOFToftFeeDetails& whitelist/dust alignment, dust rounding intofeeRecipient, zero-burn skip whenminFee >= amount, 7-day optimistic window, parking not mutatinglastTransferReset,rejectFailedRequeststorage deletion +failedRequestDetailsrevert,transferOwnershipdelegate sync +renounceOwnershipdisabled,minAmount > accountDailyLimit, andGoodDollarOFTMinterBurnerzero-token init).GoodDollarOFT.reentrancy.test.ts(mock token): 1 passing.GoodDollarOFTAdaptercompiled size: 23.284 KB (under the 24.576 KB EIP-170 limit).