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.

When deploying on main net I get "Exceeds block gas limit"

See original GitHub issue
  • I’ve asked for help in the Truffle Gitter before filing this issue.

Issue

I ran truffle migrate --network main, with my Geth running the main net. At every step, I would get:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Exceeds block gas limit

Steps to Reproduce

Do truffle migrate targeting the main net.

Expected Behaviour

I would have thought that a reasonable amount of gas would be given to the transactions.

Actual Results

  • When it did deployer.deploy(Migrations); I got this block gas limit error.
  • So I changed the line to deployer.deploy(Migrations, { gas: 300000 });
  • Then when it did, behind the scenes, migrations.setCompleted(1), again I got block gas limit.
  • So I did this .setCompleted(1) by hand within Geth
  • Then when it did deployer.deploy(MyContract); I got this block gas limit error.
  • So I changed the line to deployer.deploy(MyContract, { gas: 300000 });
  • Then when it did, behind the scenes, migrations.setCompleted(2), again I got block gas limit.
  • So I did this .setCompleted(2) by hand within Geth

On my Geth console, I noticed the following:

> eth.getBlock("pending").gasLimit
4709181
// Wait for a block
> eth.getBlock("pending").gasLimit
4704588

Environment

  • Operating System: AWS AMI
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty
  • Truffle version:
$ truffle version
Truffle v2.0.7
  • Ethereum client:
$ ~/go-ethereum/build/bin/geth version
Geth
Version: 1.4.12-stable-421df866
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.6
OS: linux
GOPATH=
GOROOT=/usr/lib/go
  • node version:
$ nodejs --version
v4.5.0
  • npm version:
$ npm version
{ npm: '2.15.9',
  ares: '1.10.1-DEV',
  http_parser: '2.7.0',
  icu: '56.1',
  modules: '46',
  node: '4.5.0',
  openssl: '1.0.2h',
  uv: '1.9.1',
  v8: '4.5.103.37',
  zlib: '1.2.8' }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:13
  • Comments:37 (5 by maintainers)

github_iconTop GitHub Comments

59reactions
chevdorcommented, Sep 21, 2016

Your value (500000) seems rather low. The default value is 4712388. Try with the default or lower it to 4612388. Not sure why but it then worked on my end…

34reactions
ledinhhuy88commented, Nov 5, 2017

I had the same issue with truffle 4.0.1

this is my workaround

$ truffle console
truffle(development)> web3.eth.getBlock("pending").gasLimit
6712390

then in the truffle.js:

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      gas: 6712390,
      network_id: "*" // Match any network id
    }
  }
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Out of gas & Exceeds block gas limit, but contract size <24KB
ValueError : Exceeds block gas limit. When I deploy it on the Rinkeby network, I don't get this error, same for BSC testnet....
Read more >
How to get Ethereum Block Gas Limit | by Hideyoshi Moriya
Currently (May 4th 2018), Block Gas Limit in mainnet is about 8000000. In Ropsten, 4712388. It looks like fixed. NOTE: Block Gas Limit...
Read more >
Out of gas & Exceeds block gas limit, but contract size <24KB
I've 2 contracts I'm trying to deploy on mainnet-fork, but I keep getting this error: VirtualMachineError: out of gas.
Read more >
ethereum ganache is failing with "Exceeds block gas limit ...
It's ETH balance (not gas): web3.eth.getBalance(contractOwner).then(console.log); // this returns 99953972490000000000.
Read more >
set gas limit hardhat - You.com | The search engine you control.
When I use a lower value (I slowly approached the 1.00 tx fee value to see what happened below that value), I get...
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