fix(starknet): enforce strict fee equality in StarkNetBitcoinDepositor#937
Open
Mavline wants to merge 1 commit intothreshold-network:mainfrom
Open
fix(starknet): enforce strict fee equality in StarkNetBitcoinDepositor#937Mavline wants to merge 1 commit intothreshold-network:mainfrom
Mavline wants to merge 1 commit intothreshold-network:mainfrom
Conversation
Replace weak fee check (>=) with strict equality (==) to prevent callers from accidentally losing excess ETH. StarkGate bridge does not refund excess ETH, so any overpayment is permanently lost. This aligns StarkNet depositor with all Wormhole-based depositors in the same codebase which already use require(msg.value == cost). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Replace the weak fee check (
>=) with strict equality (==) inStarkNetBitcoinDepositor._transferTbtc()to prevent callers from accidentally losing excess ETH sent above the required StarkGate bridge fee.Problem
StarkNetBitcoinDepositor._transferTbtc()usesrequire(msg.value >= fee)(line 113), then forwards allmsg.valueto StarkGate viastarkGateBridge.deposit{value: msg.value}(...). StarkGate does not refund excess ETH — any amount above the estimated fee is permanently lost.All Wormhole-based depositors in the same codebase already use strict equality:
L1BTCDepositorWormhole.sol:193—require(msg.value == cost)BTCDepositorWormhole.sol:114—require(msg.value == wormholeMessageFee)The StarkNet depositor is the only implementation using
>=, creating an inconsistent and unsafe pattern.Fix
Single-line change:
require(msg.value >= fee)→require(msg.value == fee, "Incorrect L1->L2 message fee").This ensures callers send exactly the required fee, consistent with all other depositor implementations. Callers that already send the exact fee are unaffected; callers that overpay will now get a clear revert instead of silent ETH loss.