argotorg / argotorg/solidity

Stack too deep after adding an public map to a contract

Open
#14,333 3 comments 1 reaction 0 assignees View on GitHub
bug :bug:
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

I have a contract that has a lot of logic. I came to the point when I get Stack too deep exception.
In my search for the reason I came to a thing I can not get my head around.
The contract is way bigger but I copied the relevant part. The thing is how is it even possible that a defined public property effects the stack? And what would be possible solutions?
I already tried compile with and without viaIR.
```
contract PositionRouter
{
using Address for address;
using SafeERC20 for IERC20;

struct DecreasePositionRequest {
address account;
address[] path;
address indexToken;
uint256 collateralDelta;
uint256 sizeDelta;
bool isLong;
address receiver;
uint256 acceptablePrice;
uint256 minOut;
uint256 executionFee;
uint256 blockNumber;
uint256 blockTime;
bool withdrawETH;
address callbackTarget;
}
// Enabling this leads to Stack too deep
// mapping (bytes32 => DecreasePositionRequest) public decreasePositionRequests;
...
}

Contributor guide

Open the contributing guide

Research direction

Start with the reduced PositionRouter example and compare compilation with the public decreasePositionRequests mapping enabled or commented out, both with and without viaIR. Confirm the stack-too-deep failure and determine whether the behavior is expected or indicates a Solidity compiler issue; done means documenting the cause and a supported solution.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.