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

EIP-1285: Increase Gcallstipend in the CALL OPCODE #1285

Closed
ben-kaufman opened this issue Aug 1, 2018 · 6 comments
Closed

EIP-1285: Increase Gcallstipend in the CALL OPCODE #1285

ben-kaufman opened this issue Aug 1, 2018 · 6 comments
Labels

Comments

@ben-kaufman
Copy link
Contributor

ben-kaufman commented Aug 1, 2018

eip: 1285
title: Increase Gcallstipend gas in the CALL OPCODE
author: Ben Kaufman <ben@daostack.io>
status: Draft
type: Standards Track
category: Core
created: 2018-08-01

Simple Summary

Increase the Gcallstipend fee parameter in the CALL OPCODE from 2,300 to 3,500 gas units.

Abstract

Currently, the CALL OPCODE forwards a stipend of 2,300 gas units for a non zero value CALL operations where a contract is called. This stipend is given to the contract to allow execution of its fallback function. The stipend given is intentionally small in order to prevent the called contract from spending the call gas or performing an attack (like re-entrancy).
While the stipend is small it should still give the sufficient gas required for some cheap OPCODES like LOG, but it's not enough for some more complex and modern logics to be implemented.
This EIP proposes to increase the given stipend from 2,300 to 3,500 to increase the usability of the fallback function.

Motivation

The main motivation behind this EIP is to allow simple fallback functions to be implemented for contracts following the "Proxy" pattern. Simply explained, a "Proxy Contract" is a contract which use DELEGATECALL in its fallback function to behave according to the logic of another contract and serve as an independent instance for the logic of the contract it points to.
This pattern is very useful for saving gas per deployment (as Proxy contracts are very lean) and it opens the ability to experiment with upgradability of contracts.
On average, the DELEGATECALL functionality of a proxy contract costs about 1,000 gas units.
When a contract transfers ETH to a proxy contract, the proxy logic will consume about 1,000 gas units before the fallback function of the logic contract will be executed. This leaves merely about 1,300 gas units for the execution of the logic. This is a severe limitation as it is not enough for an average LOG operation (it might be enough for a LOG with one parameter).
By slightly increasing the gas units given in the stipend we allow proxy contracts have proper fallback logic without increasing the attack surface of the calling contract.

Specification

Increase the Gcallstipend fee parameter in the CALL OPCODE from 2,300 to 3,500 gas units (further specification will be provided later).

Rationale

The rational for increasing the Gcallstipend gas parameter by 1,200 gas units comes from the cost of performing DELEGATECALL and SLOAD with a small margin for some small additional operations. All while still keeping the stipend relatively small.

Backwards Compatibility

This EIP requires a backwards incompatible change for the Gcallstipend gas parameter in the CALL OPCODE.

@Arachnid
Copy link
Contributor

Arachnid commented Aug 1, 2018

This seems reasonable to me. If you want it to be considered as an EIP, you should open a pull request.

@ben-kaufman
Copy link
Contributor Author

Thanks for the feedback @Arachnid. I just wanted to get some feedback before creating a PR.

@veox
Copy link
Contributor

veox commented Aug 2, 2018

On average, the DELEGATECALL functionality of a proxy contract costs about 1,000 gas units.

Could you link (here in the issue; likely excessive in the EIP document) to a particular implementation where this is true?

@GNSPS
Copy link

GNSPS commented Aug 2, 2018

https://gist.github.com/GNSPS/ba7b88565c947cfd781d44cf469c2ddb#gistcomment-2383950

@ben-kaufman ben-kaufman changed the title EIP: Increase Gcallstipend in the CALL OPCODE EIP-1285: Increase Gcallstipend in the CALL OPCODE Aug 4, 2018
@github-actions
Copy link

github-actions bot commented Dec 4, 2021

There has been no activity on this issue for two months. It will be closed in a week if no further activity occurs. If you would like to move this EIP forward, please respond to any outstanding feedback or add a comment indicating that you have addressed all required feedback and are ready for a review.

@github-actions github-actions bot added the stale label Dec 4, 2021
@github-actions
Copy link

This issue was closed due to inactivity. If you are still pursuing it, feel free to reopen it and respond to any feedback or request a review in a comment.

nxqbao added a commit to axieinfinity/ronin-dpos-contracts that referenced this issue Dec 20, 2022
### Description
- On RON transfer to unknown addresses, the gas forwarded is limited to
`3500`. This follows these recommendations: [Link
1](ethereum/EIPs#1285), [Link
2](https://ethereum.stackexchange.com/questions/59197/transfer-function-gas-limit-why-2-300),
[Link
3](https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/)

### Checklist
- [x] I have clearly commented on all the main functions following the
[NatSpec
Format](https://docs.soliditylang.org/en/v0.8.0/natspec-format.html)
- [x] The box that allows repo maintainers to update this PR is checked
- [x] I tested locally to make sure this feature/fix works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants