hyperledger / besu

An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu
https://www.hyperledger.org/projects/besu
Apache License 2.0
1.43k stars 757 forks source link

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

Open unlogicalcode opened 1 month ago

unlogicalcode commented 1 month ago

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

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)

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)

unlogicalcode commented 1 month ago

Issue also appears with Version 23.4.1 of the Docker container.

aiza-fp commented 1 month ago

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.

unlogicalcode commented 1 month ago

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.

unlogicalcode commented 1 month ago

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.

aiza-fp commented 1 month ago

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,

unlogicalcode commented 1 month ago

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?

aiza-fp commented 1 month ago

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.

unlogicalcode commented 1 month ago

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.

unlogicalcode commented 1 month ago

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

aiza-fp commented 1 month ago

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

guillermovahi commented 3 weeks ago

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

krsh24 commented 2 weeks ago

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

garnonay commented 1 week ago

@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