-
Notifications
You must be signed in to change notification settings - Fork 0
/
eip-3.md
22 lines (12 loc) · 2.18 KB
/
eip-3.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Summary
The EIP-3 proposal suggests adding a new opcode called CALLDEPTH to the Ethereum Virtual Machine (EVM). This opcode would return the remaining available call stack depth, which is the limit specifying how deep contracts can call other contracts. Currently, the call stack depth limit is 256, and if a contract invokes another contract and the limit has been reached, the operation will fail. This behavior can be exploited in a call stack attack, where an attacker creates a suitable depth of the stack and then invokes the targeted contract. If the targeted contract calls another contract and the call fails, the consequences could be damaging if the return value is not properly checked.
The CALLDEPTH opcode would provide a cheap and simple way to protect against call stack attacks. It would allow contracts to check the remaining call stack depth before making a call, and if the depth is too low, the contract can choose to abort the call or take other defensive measures. The proposal suggests that a value of 0 returned by CALLDEPTH would indicate that the call stack is exhausted, and no further calls can be made.
The implementation of CALLDEPTH is not included in the proposal, but it is expected to be fairly simple since the call stack depth limit is already present in the EVM during execution. The proposal also mentions that there is a library available for checking call stack depth experimentally, but it is quite costly in gas.
In summary, the addition of the CALLDEPTH opcode would provide a cheap and simple way to protect against call stack attacks by allowing contracts to check the remaining call stack depth before making a call. This would help prevent malicious users from exploiting the call stack depth limit and causing damage to contracts.
## Videos
- [Example Video Title](https://www.youtube.com/watch?v=TDGq4aeevgY)
## Projects
- [Example Project Name](https://xxxx.xxx/xxxxx) Project Description (one sentence) ![this is an img's alt for the project logo](https://xxxx.xxx/project-logo.xxx)
## Further Reading
- [EVM Codes](https://evm.codes/)
- [Example Article Title](https://xxxx.xxx/xxxxx) ![this is an img's alt for the article cover](https://xxxx.xxx/article-cover.xxx)