Skip to content

abi.decode failing with "Stack too deep" for a list of structs when optimizations are enabled #13597

Open
@thedavidmeister

Description

@thedavidmeister

Description

Abi decoding SomeStruct[] fails with

CompilerError: Stack too deep. Try compiling with `--via-ir` (cli) or the equivalent `viaIR: true` (standard JSON) while enabling the optimizer. Otherwise, try removing local variables. When compiling inline assembly: Variable headStart is 3 slot(s) too deep inside the stack.K

Strangely, wrapping it in a struct with a SomeStruct field on it "fixes" the issue

https://github.com/beehive-innovation/rain-protocol/pull/452/files#diff-e5cf60434f03c13e62d93df0932957c2208a64a15065489486b9aea0d158e723R9

SomeStruct[] memory foo_ = abi.decode(data_, (SomeStruct[]));

fails, as does

struct Foo {
  SomeStruct[] bar;
}

but this passes

struct Foo {
  SomeStruct bar;
  SomeStruct[] baz;
}

The issue only appears with compiler optimizations enabled and appears for both IR and non-IR

Environment

  • Compiler version: 0.8.17
  • Target EVM version (as per compiler settings):
  • Framework/IDE (e.g. Truffle or Remix): hardhat
  • EVM execution environment / backend / blockchain client:
  • Operating system:

Steps to Reproduce

https://github.com/beehive-innovation/rain-protocol/pull/452/files#diff-e5cf60434f03c13e62d93df0932957c2208a64a15065489486b9aea0d158e723R9

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛medium effortDefault level of effortmedium impactDefault level of impactmust haveSomething we consider an essential part of Solidity 1.0.should compile without errorError is reported even though it shouldn't. Source is fine.viairwaiting for more inputIssues waiting for more input by the reporter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions