Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas price cannot be set to 0 with miner.gasprice option set to 0 #26285

Closed
XDitto0165 opened this issue Dec 1, 2022 · 7 comments
Closed

Gas price cannot be set to 0 with miner.gasprice option set to 0 #26285

XDitto0165 opened this issue Dec 1, 2022 · 7 comments
Labels

Comments

@XDitto0165
Copy link

XDitto0165 commented Dec 1, 2022

System information

Geth
Version: 1.10.25-stable
Git Commit: 69568c5
Architecture: amd64
Go Version: go1.18.5
Operating System: linux

Expected behaviour

The geth was started with the option miner.gasprice set to 0:
geth --datadir /data2 --nodiscover --networkid 5291592 --netrestrict 10.32.80.0/27 --allow-insecure-unlock --unlock 0x879769d76BEad81e23aDBdd993Ca37872b0e6aa4 --mine --password /data/password.txt --http --http.addr="127.0.0.1" --http.api="eth,web3,net,admin,personal,miner" --http.corsdomain="*" --miner.gasprice 0 --port 30310 --http.port 8555
When run the following command to check gas price:

curl -X POST localhost:8555 -H "Content-Type: application/json" --data '
> {
> "jsonrpc": "2.0",
> "method": "eth_gasPrice",
> "params": [],
> "id": 1
> }
> '

It should return 0 gas price:

{"jsonrpc":"2.0","id":1,"result":"0x0"}

Actual behaviour

When run the following command to check gas price:

curl -X POST localhost:8555 -H "Content-Type: application/json" --data '
> {
> "jsonrpc": "2.0",
> "method": "eth_gasPrice",
> "params": [],
> "id": 1
> }
> '

It returns the default value of 1 trillion gas price

{"jsonrpc":"2.0","id":1,"result":"0x3b9aca00"}
@holiman
Copy link
Contributor

holiman commented Dec 1, 2022

I think eth_gasPrice returns the oracle gas price, as in the price in the latest blocks. So it only indirectly maps to miner.gasprice.

@fjl
Copy link
Contributor

fjl commented Dec 1, 2022

The gas price oracle will ignore transactions below the price configured by --gpo.ignoreprice, and the default value of that option is slightly above zero. You can try setting this to zero, but I'm not sure whether that will make it suggest a price of zero.

In general, the gas price oracle is not designed to work well in an environment where transactions can be submitted with zero fee.

@karalabe
Copy link
Member

karalabe commented Dec 1, 2022

You cannot set the miner.gasPrice to 0, if you try, you'll see a warning in the logs:

WARN [12-01|11:51:18.506] Sanitizing invalid miner gas price       provided=0    updated=1,000,000,000

Geth explicitly does not allow this because accepting 0 priced transactions would mean that you also accept/pool them from the network and propagate them, which is essentially a very potent DoS vector (I can send arbitrary junk tx from arbitrary non-existing account since there's no cost).

@karalabe karalabe closed this as completed Dec 2, 2022
@Inderdeep01
Copy link

Hey, I want to set up private network with zero gas price. Please help me with that.

@sirajongithub
Copy link

sirajongithub commented May 29, 2023

Hello, In the latest geth version 1.12, I am unable to set and use gas price as zero (--miner.gasprice 0). I was able to set and use gas price to 0 until geth version 1.10.15

If I have geth private blockchain network and I don't want to charge anything for any transaction I would set gas price to 0. Is this feature removed in geth version 1.12 ?

https://github.com/SirajChaudhary/setup-a-private-ethereum-blockchain-multinodes-network

@bradbrown-gtmn
Copy link

I also noticed that this seemed to stop working recently. I've used geth's private clique networks to test contract behavior as recently as 5 months ago using 0-gas transactions and I can no longer do this. What gives?

@rmlearney-digicatapult
Copy link

@GTMN-bradbrown we solved this by setting:

baseFeePerGas: 0x1 in genesis.json

and adding the following switch at startup time:

--gpo.ignoreprice 0

This sets a gas price of 2. While not zero, it's a decent workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants