Skip to content

Commit

Permalink
Update fee overpayment in eip7002
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalinin authored Feb 28, 2025
1 parent 437d026 commit e2a53ed
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions EIPS/eip-7002.md
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,11 @@ function addWithdrawal(bytes memory pubkey, uint64 amount) private {
}
uint256 fee = uint256(bytes32(feeData));
// Check the fee is not too high.
if (fee > FEE_THRESHOLD) {
revert('fee is too high');
}
// Add the request.
bytes memory callData = abi.encodePacked(pubkey, amount);
(bool writeOK,) = WithdrawalsContract.call{value: fee}(callData);
Expand All @@ -697,6 +702,8 @@ function addWithdrawal(bytes memory pubkey, uint64 amount) private {

Note: the system contract uses the EVM `CALLER` operation (Solidity: `msg.sender`) as the target address for withdrawals, i.e. the address that calls the system contract must match the 0x01 withdrawal credential recorded in the beacon state.

Note: the above code reverts if the fee is too high, the fee can change significantly between withdrawal request transation creating and its inclusion into a block, thus, this check is very important to avoid overpayments.

Using an EOA to request withdrawals will always result in overpayment of fees. There is no way for an EOA to use a wrapper contract to request a withdrawal. And even if a way existed, the gas cost of returning the overage would likely be higher than the overage itself. If requesting withdrawals to an EOA through the system contract is desired, we recommend that users perform transaction simulations to estimate a reasonable fee amount to send.

## Copyright
Expand Down

0 comments on commit e2a53ed

Please sign in to comment.