question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ganache freezes at eth_estimateGas during delegatecalls

See original GitHub issue

Solution

Run contract calls with an explicit gasLimit

async () {
    await contract.functionWithDelegateCall(
        args,
        { gasLimit: 4000000 }
    )
}()

Steps to Reproduce (for bugs)

# Run ganache in development mode, connected to mainchain
ganache-cli -f https://mainnet.infura.io/v3/<project_id> -i 1583817378
const ethers = require('ethers')
const CTokenAbi = require('https://compound.finance/developers/abi/mainnet/cBAT')
const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545");
const wallet = new ethers.Wallet(
    "0x94a9f52a9ef7933f3865a91766cb5e12d25f62d6aecf1d768508d95526bfee29",
    provider
);

const cDaiContract = new ethers.Contract(
        addresses.compound.cDai,
        CTokenAbi,
        wallet
)

// Freeze
let daiBorrowBalance = await cDaiContract.borrowBalanceCurrent(
        wallet.address
)

// Doesn't freeze
let daiBorrowBalance = await cDaiContract.borrowBalanceCurrent(
        wallet.address,
        { gasLimit: 4000000 }
)

Context

I’m forking off from mainnet and am playing around with compound-finance’s protocol and there’s a lotta delegatecalls on makerdao and compound finance (ds-proxy) and https://eips.ethereum.org/EIPS/eip-897

Sometimes it just hangs there for some reason with no real explaination

Your Environment

  • Version of Truffle used: v5.1.16
  • NodeJS Version: v12.16.1
  • Operating System and version (include distro if Linux): MacOS Catalina
  • Ganache CLI v6.9.1 (ganache-core: 2.10.2)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
davidmurdochcommented, Dec 21, 2021

gas and gasLimit are different names for the same thing 😁.

It worked because the transaction is probably running out of gas instead of the node process running out of memory (which is what that error message you posted is about), or the tx does something based on the amount of gas available/provided. By default we provide a lot of gas. In beta.2 the gas limit for eth_estimateGas is 50,000,000 in previous versions it was habaneros Number.MAX_SAFE_INTEGER. The reason estimate gas has this issue is because when we track gas usage when estimating the tx we store certain operations in memory to make the estimation in ~two passes instead of always having to binary search for the estimate like most others – and it seems we have some work to do to optimize our memory usage here.

Though there may be some other changes that are causing these memory-related errors, as this is the third one I’ve seen reported recently. (/cc @cds-amal, @kevinweaver)

2reactions
davidmurdochcommented, Jun 23, 2020

There are improvements coming to forking’s performance soon that should hopefully solve this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ganache (from Truffle) hangs when started - Stack Overflow
When I run the file "ganache-1.0.1-x86_64.AppImage" that I downloaded from GitHub, Ganache just hangs showing the following screen with no ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found