Skip to content

Commit

Permalink
Update EIP-7251: add fee limit check to fee overpayment section
Browse files Browse the repository at this point in the history
Merged by EIP-Bot.
  • Loading branch information
mkalinin authored Mar 3, 2025
1 parent 5c4d5a4 commit 38ce04b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion EIPS/eip-7251.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ This proposal maintains the activation and exit churn invariants limiting active
Calls to the system contract require a fee payment defined by the current contract state. Overpaid fees are not returned to the caller. It is not generally possible to compute the exact required fee amount ahead of time. When adding a consolidation request from a contract, the contract can perform a read operation to check for the current fee and then pay exactly the required amount. Here is an example in Solidity:

```
function addConsolidation(bytes memory srcPubkey, bytes memory targetPubkey) private {
function addConsolidation(bytes memory srcPubkey, bytes memory targetPubkey, uint64 requestFeeLimit) private {
assert(srcPubkey.length == 48);
assert(targetPubkey.length == 48);
Expand All @@ -643,6 +643,11 @@ function addConsolidation(bytes memory srcPubkey, bytes memory targetPubkey) pri
}
uint256 fee = uint256(bytes32(feeData));
// Check the fee is not too high.
if (fee > requestFeeLimit) {
revert('fee is too high');
}
// Add the request.
bytes memory callData = bytes.concat(srcPubkey, targetPubkey);
(bool writeOK,) = ConsolidationsContract.call{value: fee}(callData);
Expand All @@ -654,6 +659,8 @@ function addConsolidation(bytes memory srcPubkey, bytes memory targetPubkey) pri

Note: the system contract uses the EVM `CALLER` operation (Solidity: `msg.sender`) to get the address used in the consolidation request, 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 creation of a consolidation request transation and its inclusion into a block, thus, this check is very important to avoid overpayments.

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

### Consolidation queue hard limit
Expand Down

0 comments on commit 38ce04b

Please sign in to comment.