ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.15k stars 5.74k forks source link

Stack too deep after adding an public map to a contract #14333

Open migoldfinger opened 1 year ago

migoldfinger commented 1 year ago

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;
...
}
web3-engineer commented 1 year ago

I know you believe that this code is the only necessary one for debugg but can you give me the link of the entire smart contract ? You are calling out parameters that need to be in order with all the data in the smart contract.

migoldfinger commented 1 year ago

Here is the link -> https://github.com/DFX-Protocol/dfx-contracts/blob/stackError/contracts/core/PositionRouter.sol

migoldfinger commented 1 year ago

Since I update the contracts that originally compiled with solidity ^0.6.0 BTW I solved the problem for the moment by adding pragma abicoder v1;