18

I'm testing Ethereum with a complex contract which requires quite a lot of gas. And I'm testing (and will be running) a private network with controlled miners, so I don't need them getting any reward, and my "coin" is not ether.

Currently I'm working with near-infinite Ether on my account, but removing gas alltogether (or forcing my miners to use 0 gas) would be great. Unless there's some side-effect which I'm missing, I think for my case (self-controlled mined) I don't need gas for anything.

Thanks!

  • 3
    if you have an infinite amount of gas then due to the halting problem you cannot be sure that your smart contract will always terminate. Isn't that an issue? – Cedric Martin Mar 11 '16 at 2:46
  • As @CedricMartin points out, without a gas limit, you could easily write a transaction that loops infinitely, and locks up your nodes permanently. – Nick Johnson Sep 9 '16 at 10:06
  • So, finally did we get any way to remove the concept of gas form Ethereum private-net? – Aniket Feb 7 '17 at 12:58
8

I would set your gas price to a really low number on your private miners using the gasprice command line option. More info here:

https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options

  • That helps, however I have "infinite" Ether, so price is not a problem, the problem is that I still need to set my "maximum gas I'm willing to pay" for each transaction. More or less it works for testing, however sometimes I get that I'm over the maximum allowed gas (I think that's something i can change in the genesis) and it changes from one transaction to another. – BiS Mar 9 '16 at 23:41
  • With it changes from one transaction to another it means that I if I set gas limit to 8millions some transactions work, in other transactions I have to set it to 1million or it will say that I'm over the limit. I guess it scales with the predicted/compiled amount of work (my transactions have for loops, thats why the real cost its usually high), but I don't know for sure. At the end working with pseudo-infinite values works okay of course, but it's not the most elegant solution IMO. Plus I fear that my transactions MAY go over the limit if I have too much information in the contract. – BiS Mar 9 '16 at 23:51
6

I could not find anything, so I guess there's no way to do it. So self-answering me for those who want to do this, the best workaround I could find is:

  1. Set the gas limit to a stupidly-high limit @ the genesis block (my contract wouldn't deploy within default limit).
  2. Allocate infinite amounts of ether for every/master account and then transfer to all your other accounts ( + Charlie's suggestion of cheap miners).
  3. Set your master account as the etherbase for all your miners (and periodically refund ether back to others, maybe there's some other way like giving free ether inside your contracts, not sure if possible)

It works, although is not the best scenario for my use case.

  • 1
    You can also accept your own answer. – soc1c Mar 11 '16 at 20:04
  • Yep but it's not the solution for what I was looking for, just a workaround which allows me to survive for now :) – BiS Mar 12 '16 at 12:50
  • I am removing (from the sources) all gas usage in 1.7.2 version of geth and it is a lot of work. – Nulik Dec 6 '17 at 1:18
4

Since this is primarily for testing, if some Python is ok to use, I would suggest using pyethereum tester because it is easy to set the block gas limit really high, the gas price to zero, and mine quickly.

This may also be helpful: ​​How can I stop the block gas limit on a private chain dropping to the public chain default?

3

Apart from the other answers, which are all correct for Ethereum, but not ideal for my case. For those who are looking for something similar to my requirements for private-networks, take a look at Monax.

2

You could use EthereumJ and set all the variables to zero in this file https://github.com/ethereum/ethereumj/blob/develop/ethereumj-core/src/main/java/org/ethereum/vm/GasCost.java That makes everything free. Anyway gas is calculated/converted in the Ethereum Virtual Machine so you need to edit the source of whatever client you choose.

0

I hope I can comment on @Bis,, @eth and @TJEvrtGuy78's answer, then I don't have to make my voice heard through an answer since I don't have that much reputation(I don't even have enough reputation to up-vote an answer)

Context - I am also setting up a private network to run smart-contract where all the miners belong to me).

I don't think hacking an Ethereum client like EthereumJ is a good idea, because that will break the compatibility. And using a pyethereum tester is also not a good option, because that will lose the scalability.

After all, a private network should not be just acting like a test network, it can also be a production network.

As far as I search for now, my private Ethereum network is mining a block per 2 seconds. Considering the decay of reward, a network can run at least 3 years with reward. And even if the reward becomes zero in the future, we can also gather the Ether to one account, so that the miner and transaction originator is using same account, every operation will go into a zero-sum game.

The key point of the answer to this question should be sharing one account across everywhere in the network. I don't think the gas limit is necessary unless the gas number of target contract is really high. And according to my experiment, prefunding is also not necessary, one hour warm-up will produce enough coins.

After all, I am just summarizing all your answers with my experience.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.