Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EIP-7251: add fee limit check to fee overpayment section #9439

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading