NEWTON

NEWTON


Popular tags

    Nethermind's warp error: JavaScript heap out of memory

    Asked

    1 month ago

    19

    views


    0

    When I try to transpile my contract using warp transpiler I get an error: JavaScript heap out of memory

    JavaScript heap out of memory error in Nethermind's warp transpiler

    can anyone help?

    update: I ran this command

    export NODE_OPTIONS=--max-old-space-size=4096
    

    before transpiling still show the same error

    • Node version is v16.16.0
    • warp version 2.4.1
    • I tried using node 18 but still same error occured
    • I'm using an M1 Mac, 8gb RAM

    I'm transpiling llampay contracts : https://github.com/LlamaPay/llamapay/tree/master/contracts

    The original LlamaPay has some unsupported features in Warp. And I fixed them:

      transpilerwarpjavascriptnethermind

    Newton

    asked

    1 month ago


    1 answers

    0

    Accepted answer

    Hi, the probable cause of this error appears to be the JavaScript engine and not Warp.

    Here are some links that can help you fix it:

    1. https://stackoverflow.com/questions/38558989/node-js-heap-out-of-memory
    2. https://www.makeuseof.com/javascript-heap-out-of-memory-error-fix/

    Found the case of the error. getLlamaPayContractByIndex is a static array of size one billion 😱 . I think Warp is not ready for those numbers yet, also the way we currently handle storage as memory is somehow inneficient because we are "simulating" the evm in StarkNet. Also the constant was the one giving an error. Specifically when you do type(LlamaPay)

    Bug fix: use a lower size storage var, or make it a dynamic array in the `LlamaPayFactory".

    The fixed contract (works now)

    //SPDX-License-Identifier: None
    pragma solidity ^0.8.0;
    import {LlamaPay} from "./LlamaPay.sol";
    import {IERC20} from "./IERC20.sol";
    
    
    contract LlamaPaxyFactory {
        uint256 public getLlamaPayContractCount;
        address[] public getLlamaPayContractByIndex; 
    
        event LlamaPayCreated(address token, address llamaPay);
    
        function createLlamaPayContract(address _token) external returns (address llamaPayContract) {
    
            llamaPayContract = address(new LlamaPay());
            require(llamaPayContract != address(0));
            getLlamaPayContractByIndex[getLlamaPayContractCount] = llamaPayContract;
            unchecked{
                ++getLlamaPayContractCount;
            }
    
            emit LlamaPayCreated(_token, llamaPayContract);
        }
    }
    

    Newton

    answered

    1 month ago

    Your answer

    NEWTON

    NEWTON