trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.03k stars 2.31k forks source link

"Upfront cost exceeds account balance" on Besu private zero gas network #6190

Open gomezgoiri opened 10 months ago

gomezgoiri commented 10 months ago

Issue

I want to deploy a smart contract in a free gas private network with Truffle. Although Besu seems to work as expected, Truffle returns the following error if the deploying account has zero balance: Upfront cost exceeds account balance error.

Steps to Reproduce

I've found this error with many configurations (IBFT2, QBFT, different Besu versions), but here I'll describe the simplest way to reproduce it:

  1. Create a free gas network using Quorum-dev-quickstart: npx quorum-dev-quickstart@latest --clientType besu --orchestrate false --quorumKeyManager false --privacy false --monitoring none --blockscout false
  2. Run the network: docker compose up -d
  3. Deploy any smart contract. To test it, you can use this project.

Expected Behavior

Get information about the deployed contracts and their addresses.

Actual Results

Truffle returns the following error: Upfront cost exceeds account balance.

Environment

haltman-at commented 9 months ago

Thanks for the report! We'll have to try to see what's going on here.

yunxi-zhang commented 5 months ago

@gomezgoiri, sharing my solution here, as I've just hit the same error as you described here, but the difference is I setup my Besu development private network from scratch instead of using Quorum-dev-quickstart. What I've done is I manually added my wallet address with a predefined balance to the genesis file in the "alloc" section.

So, the alloc section in my genesis file looks like below, the last part is my wallet address - 78214bfdbf9a2cd021c51c22ac8476a7d2b72ddd and predefined the balance value.

 "alloc" : {
    "fe3b557e8fb62b89f4916b721be55ceb828dbd73" : {
      "privateKey" : "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
      "comment" : "private key and this comment are ignored.  In a real chain, the private key should NOT be stored",
      "balance" : "0xad78ebc5ac6200000"
    },
    "627306090abaB3A6e1400e9345bC60c78a8BEf57" : {
      "privateKey" : "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
      "comment" : "private key and this comment are ignored.  In a real chain, the private key should NOT be stored",
      "balance" : "90000000000000000000000"
    },
    "f17f52151EbEF6C7334FAD080c5704D77216b732" : {
      "privateKey" : "ae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f",
      "comment" : "private key and this comment are ignored.  In a real chain, the private key should NOT be stored",
      "balance" : "90000000000000000000000"
    },
    "78214bfdbf9a2cd021c51c22ac8476a7d2b72ddd" : {
      "balance" : "90000000000000000000000"
    }
  } 

Hope this helps :-).

gomezgoiri commented 5 months ago

Thanks @yunxi-zhang, but your solution does not really address my actual problem of deploying a contract to a zero gas network using any account with Truffle :disappointed:

Anyway, few days after I opened this issue Consensys announced that they were sunsetting Truffle, so I moved to Hardhat where everything works fine‎ ‎️‍🌈