hyperledger / besu

An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu

Home Page:https://www.hyperledger.org/projects/besu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Besu discards Transaction with Zero Gas Price on Free-Gas Network

unlogicalcode opened this issue · comments

Description

As an Besu, I want to deploy a SmartContract on a free-gas Network so that I can use Besu as a Node for my private Blockchain.

Acceptance Criteria

  • SmartContract Transaction with gas price of zero can be deployed.

Steps to Reproduce (Bug)

  1. Set up Besu with a private Network with Clique Consensus and zero Base Fee
  2. Send a ContractCreation Transaction to Besu
  3. See Besu denying the Transaction with Reason {"jsonrpc":"2.0","id":1,"error":{"code":-32009,"message":"Gas price below configured minimum gas price"}

Expected behavior: Transaction gets accepted an the Contract is created

Actual behavior: Besu denying the Transaction with Reason {"jsonrpc":"2.0","id":1,"error":{"code":-32009,"message":"Gas price below configured minimum gas price"}

Frequency: Every ContractCreation request

Logs (if a bug)

besu.log
genesis.json

config.toml

data-path="/data"
rpc-http-enabled=true
rpc-http-api=[
    "ETH",
    "NET",
    "CLIQUE",
]
rpc-http-port=8545
rpc-http-cors-origins=["all"]

host-allowlist=["*"]

genesis-file="/genesis.json"

min-gas-price=0
api-gas-price-max=0

network-id=1337

docker-compose.yml

---
services:
  besu0:
    image: hyperledger/besu:24.5.1
    command: --config-file=/config.toml --p2p-port=30304 --logging=ALL --min-gas-price=0 --api-gas-price-max=0
    ports:
      - 8545:8545
      - 30304:30304
    networks:
      besu-p2p:
       ipv4_address: 10.5.0.2
    volumes:
      - ./besu-config.toml:/config.toml:ro
      - ./genesis.json:/genesis.json:ro
      - ./node-data:/data:rw
  besu1:
    image: hyperledger/besu:24.5.1
    depends_on:
      - besu0
    command: --config-file=/config.toml --p2p-port=30305 --bootnodes=enode://1c6c4139e6863cee7cfcc55326fea3d91d1e78649cef1a5a969c3c02098deb083d76537655732dfc32e7dae7334fac333429309ff2a0f903f56bfe47451b282b@10.5.0.2:30304 --min-gas-price=0 --api-gas-price-max=0
    ports:
      - 8546:8545
      - 30305:30305
    networks:
      besu-p2p:
       ipv4_address: 10.5.0.3
    volumes:
      - ./besu-config.toml:/config.toml:ro
      - ./genesis.json:/genesis.json:ro
      - ./node-data1:/data:rw
networks:
  besu-p2p:
    driver: bridge
    ipam:
      config:
        - subnet: 10.5.0.0/16
          gateway: 10.5.0.1

Gas Price Calls from both Nodes in the Cluster:

joshua@LJ243WK6LG ~/g/o/besu-clique (master)> curl -X POST --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":53}' http://127.0.0.1:8545
{"jsonrpc":"2.0","id":53,"result":"0x0"}⏎                                                                                                                                                                                                                                                                                                                                                                                                 joshua@mac~/g/o/besu-clique (master)> 
joshua@mac ~/g/o/besu-clique (master)> 
joshua@mac ~/g/o/besu-clique (master)> curl -X POST --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":53}' http://127.0.0.1:8546
{"jsonrpc":"2.0","id":53,"result":"0x0"}⏎                                                                                                                                                                                                                                                                                                                                                                                                 joshua@mac ~/g/o/besu-clique (master)> 

Versions (Add all that apply)

  • Software version: [besu --version] 24.5.1 docker container
  • OS Name & Version: [cat /etc/*release] docker
  • Kernel Version: [uname -a] docker
  • Docker Version: [docker version] Docker Desktop 4.30.0 (149282),
Server: Docker Desktop 4.30.0 (149282)
 Engine:
  Version:          26.1.1
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.9
  Git commit:       ac2de55
  Built:            Tue Apr 30 11:48:04 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.31
  GitCommit:        e377cd56a71523140ca6ae87e30244719194a521
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
  • Consensus Client & Version if using Proof of Stake: [e.g. Teku, Lighthouse, Prysm, Nimbus, Lodestar]

Smart contract information (If you're reporting an issue arising from deploying or calling a smart contract, please supply related information)

Contract is deployed with eth_sendRawTransaction and works elsewhere.

Additional Information (Add any of the following or anything else that may be relevant)

  • Besu setup info - genesis file, config options -> attached
  • System info - memory, CPU -> Apple MacBook Pro M3

Issue also appears with Version 23.4.1 of the Docker container.

Can you show us all the parameters you are sending in eth_sendRawTransaction?
I use Hardhat to deploy contracts in a zero fee network and I need to define {gasPrice: null, gasLimit: null,}

I can deploy contracts with zero fees.

Hi sure, this is the decoded Raw Transaction:

{
  "chainId": "1337",
  "type": "LegacyTransaction",
  "valid": true,
  "hash": "0xc49cd7262c2b45fdaf69954703ea440a42bfaaf354648a3ab59933d185780320",
  "nonce": "0",
  "gasPrice": "0",
  "gasLimit": "1500000",
  "from": "0xBC892d2496cf2651dE0C5d768f38dc1244afb94A",
  "v": "0a95",
  "r": "60a999ea52f052eb5fd1e45567beccc8e0e8ee5cb2b71ead64dcf3fb29f5b2de",
  "s": "1bfbc22f8450dc97998733cf4ffcb2b0c37b00e4a80366d2cc496ac7e74d3d3f",
  "value": "0",
  "input": "replaced_contract_data",
  "functionHash": "60a0604052",
  "possibleFunctions": []
}

But, you saying, that you set the Gas Limit also to "null" could be a Clue.

I tried it with a Gas-Limit of 0:

{
  "chainId": "1337",
  "type": "LegacyTransaction",
  "valid": true,
  "hash": "0x39695439c00d4046154e2a0f7d46cbb8f42f28c39328bfa9a8ea5f74c22a2740",
  "nonce": "0",
  "gasPrice": "0",
  "gasLimit": "0",
  "from": "0xBC892d2496cf2651dE0C5d768f38dc1244afb94A",
  "v": "0a96",
  "r": "bf308cf3c87d87329228886097d0563ba80bbd35061cdf43f1aa0c72625b701a",
  "s": "43725993621aa9e610b90eb1d94244358cd9c0875a6a9d7e2c587b65bac42fb5",
  "value": "0",
  "input": "replaced_contract_data",
  "functionHash": "60a0604052",
  "possibleFunctions": []
}

Sadly, this also does produce the same Result.

Are you following all that is said here?
https://besu.hyperledger.org/private-networks/how-to/configure/free-gas

In my Hardhat configuration I also have this:
gasPrice: 0,
gas: 0x1ffffffffffffe,
gasMultiplier: 0,

Yes, I follow the free gas Configuration. Thats also why I attached all my Configurations and the docker-compose and so on, since I might are overlooking something. Even tough I triple checked every Step before reporting the Issue.

The Contract isn't deployed via HardHat tho. It is a Contract developed with hardhat. But it is embedded within a Java Appliction. This Application sends the Contract as the Input of the Eth Raw Transaction.
From what I see from the decoded Transaction above it should work. But sadly it doesn't.
Do the decoded Eth Transactions generated by HardHat maybe look differently?

When I do transactions defined in the server, Python in my case, I also set these parameters:

'maxFeePerGas': 0,
'maxPriorityFeePerGas': 0,

See if it works.

Yes, those are already set to 0. As you can see in the Raw Transaction. The Transaction is sent with a GasPrice of 0, but Besu denies it because of the Gas Price too low Message. Also when you ask Besu it says that the GasPrice is 0.

We currently work around this Issue by actually using Gas.
Funds come from a Wallet which has Balance set via the Genesis File.

I'm doing 0 gas transactions in a private Besu network. Here's an example of a transaction from an address that has 0 ETH:

{
"accessList": [],
"blockHash": "0xaa7747f6ab909432bf320b39ae210880a30b7bfad92764436b9941c45bbb8262",
"blockNumber": "0x3b5a7",
"chainId": "0x539",
"from": "0xcb88953e60948e3a76fa658d65b7c2d5043c6409",
"gas": "0x444e6",
"gasPrice": "0x0",
"maxPriorityFeePerGas": "0x0",
"maxFeePerGas": "0x0",
"hash": "0x4140de7ef4d2eef855d5c8553430f3b094a419c0e98b9cb20d091c7588fe5f82",
"input": "REPLACED",
"nonce": "0x18",
"to": "0xbcc4324ffc1fd079ae9c3e9daed82e184740a2bf",
"transactionIndex": "0x0",
"type": "0x2",
"value": "0x0",
"yParity": "0x1",
"v": "0x1",
"r": "0xe28504d4f3c92baa058e412375b8f0cfd766b2244132a64d84d3ac6f2492c117",
"s": "0x6d8477c19a78ef1bae628e8b67d9c35c3da53b08768fce991eaf7d229bda2f0"
}

Is it maybe the transaction type? I'm doing EIP-1559 transactions.

https://github.com/hyperledger/besu-docs/blob/main/docs/public-networks/concepts/transactions/types.md

I am facing the same issue. @unlogicalcode, were you able to find a workaround?

@guillermovahi @unlogicalcode is it possible to share the trace logs of your besu node while you deploy your smart contracts?

@unlogicalcode are you starting all nodes in the network with --min-gas-price=0?

If so, there're instances where gasPrice and gasLimit are not properly passed from Java applications, please review if using hex or not within your web3j or ethers library