# Understanding Gas Limits: Exploring the 63/64 Rule

## Gas Allocation Limits: Understanding the Maximum Gas for Callee Calls

The ***caller*** of a contract specifies the amount of gas given to the ***callee*** when making a function call. However, there is a limit on how much gas can be provided.\
\
After the "Tangerine Whistle" hard fork (which introduced [EIP-150](https://eips.ethereum.org/EIPS/eip-150)), the maximum amount of gas that a ***caller*** can give to a ***callee*** is calculated as follows:

$$
gasAvailable - (1/64 \* gasAvailable)
$$

This means that the ***caller*** can only allocate a maximum of approximately 98.43% (63/64) of the total gas available to the ***callee***. The remaining gas (approximately 1.56% or 1/64) is reserved for the caller's own use.\
\
This restriction is in place to prevent certain types of attacks (such as ***Call Stack Depth Attack***) and to ensure that the ***caller*** always retains a small portion of the total gas for its own execution.\
\
This is because [EIP-150](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md) ensure the ***caller*** is left with at least 1/64 of the gas available, regardless of what happens to the call.

{% hint style="info" %}
Understanding this limitation helps developers and users plan their gas allocation appropriately and consider the available gas when making function calls between contracts.
{% endhint %}

## The 63/64 Rule Explained: Balancing Gas Provision for Caller-Callee Transactions &#x20;

The introduction of the 63/64 rule in Ethereum was intended to address a specific issue that existed in previous implementations. Previously, the ***caller*** of a contract could send the entire amount of gas available to them when making a function call to a ***callee***.

However, this created a potential problem. Since the gas cost of a call is relatively low, it allowed for a situation where contracts could call other contracts recursively, potentially leading to an infinite loop or excessive stack usage. This posed a risk of causing a ***Call Stack Depth Attack*****&#x20;** that led to a **"stack too deep"** issue in the implementation of Ethereum nodes, which could lead to instability and unexpected behavior.

A maximum depth limit of 1024 was imposed on the call stack. This means that after reaching a depth of 1024 calls, the last call would throw an exception, preventing further recursion.\
\
By introducing the 63/64 rule, the ***caller*** is now limited in how much gas they can provide to the ***callee***, ensuring that a portion of the gas is reserved for the caller's own execution. This limitation helps prevent excessive recursion and mitigates the risk of encountering stack-related issues in Ethereum node implementations.

{% hint style="info" %}
The solution involves reserving a portion of the available gas in the ***caller*** contract, specifically 1/64 of the total available gas. As the recursive calls continue, the amount of gas available diminishes rapidly, naturally limiting the depth of recursion. Although there is still a maximum call depth limit of 1024 in the node implementation, it is practically unreachable due to the diminishing gas.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mau-eth.gitbook.io/mau/gas-griefing/understanding-gas-limits-exploring-the-63-64-rule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
