argotorg / argotorg/solidity

The new IR pipeline introduces stack-to-deep errors

Open
#14,358 13 comments 2 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

## Description

Running my Solidity tests [here](https://github.com/pcaversaccio/snekmate/tree/main/test) (commit `2d8b8d1238e7534cef8a4fb1640068cc34259ea8`) using the `--via-ir` option will throw with a stack-too-deep error even though compiling it "normally", i.e using the old bytecode optimiser pipeline, will complete successfully.

### Failure Case

```bash
~$ forge test --via-ir
[⠒] Compiling...
[⠃] Compiling 102 files with 0.8.20
[⠘] Solc 0.8.20 finished in 566.03s
Error:
Compiler run failed:
Error: Yul exception:Variable var_assets is 1 too deep in the stack [ RET var_assets _3 expr_2 _5 _2 expr_1 _6 expr _8 cleaned var_caller _7 _16 _12 var_receiver _20 _21 ]
memoryguard was present.
memoryguard was present.
```

### Success Case
```bash
~$ forge test
[⠰] Compiling...
[⠢] Compiling 102 files with 0.8.20
[⠰] Solc 0.8.20 finished in 175.13s
Compiler run successful!
```

## Environment

- Compiler version: `0.8.20`
- Target EVM version (as per compiler settings): `shanghai`
- Framework/IDE (e.g. Truffle or Remix): `forge`
- EVM execution environment / backend / blockchain client: `foundry` (i.e. `hevm` under the hood)
- Operating system: `WSL` using `Ubuntu`

## Steps to Reproduce

Install Foundry:

```bash
curl -L https://foundry.paradigm.xyz | bash
```

Clone my [repo](https://github.com/pcaversaccio/snekmate) and run `forge` with the `--via-ir` option (caveat: it's time-consuming since the new IR pipeline is very slow):

```bash
git clone git@github.com:pcaversaccio/snekmate.git
cd snekmate
git submodule update --init --recursive
forge test --via-ir
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure by cloning the linked snekmate repository at commit 2d8b8d1238e7534cef8a4fb1640068cc34259ea8 and running forge test --via-ir, then compare it with forge test. Start by tracing the Solidity compiler's via-IR/Yul compilation path and the reported var_assets stack error; done means the test suite compiles successfully with --via-ir on Solidity 0.8.20.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
blockchain, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.