Add support for `calldata` input and output in `abi.decode()`
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
## Abstract
Currently `abi.decode()` works with `memory` argument and not with `calldata`, if `calldata` is provided it is being copied to memory and then decoded. Let's make `abi.decode()` to support both arguments and returns as `calldata`.
## Motivation
`Calldata` abstraction is cool, slicing is cool. We need `abi.decode()` to fully support decoding from `calldata` to `calldata`!
## Specification
```solidity
function f(bytes calldata data) external {
(
address[] calldata targets,
bytes[] calldata calldatas
) = abi.decode(data[1:], (address[], bytes[]));
// ...
}
```
## Backwards Compatibility
Contributor guide
Research direction
Start by tracing the compiler's handling of abi.decode() for calldata input and output, using the specification's bytes calldata example as the target behavior. Done means the example decodes directly from calldata into address[] calldata and bytes[] calldata without copying the input to memory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- solidity
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100