2

I have setup a private POA Ethereum network for testing purpose. From this link: Is gas burned in a PoA network? it stated that the gas will be circulated in the network (i.e. fed back to the signer's account.) However, it seems some of the gas does vanish in my case...

I setup two nodes, with 0xb8fd21c7427a7208e34ecce2e70deb6453009a81 as the signer and 0x72f233e8ec0550734361a4c8f2a944eab855af8a as the other node. Their initial balances are both 5e+24:

> eth.getBalance(eth.accounts[0])
5e+24
> eth.getBalance('0xb8fd21c7427a7208e34ecce2e70deb6453009a81')
5e+24

I connect to node2 and then try to send a transaction to the signer with zero value as:

eth.sendTransaction({
...... to: '0xb8fd21c7427a7208e34ecce2e70deb6453009a81',
...... from: eth.accounts[0],
...... value: 0
...... });

and then obtain the results as follow:

> eth.getBalance(eth.accounts[0])
4.999999999978976845715e+24
> eth.getBalance('0xb8fd21c7427a7208e34ecce2e70deb6453009a81')
5.000000000021e+24

It seems that the gas is deducted from the node and added back to the signer.

I then tried to connect to the signer and send the similar transaction as follow:

eth.sendTransaction({
...... to: '0x72f233e8ec0550734361a4c8f2a944eab855af8a',
...... from: eth.accounts[0],
...... value: 0
...... });

The result obtained is as follow:

> eth.getBalance(eth.accounts[0])
5.000000000020999999853e+24
> eth.getBalance('0x72f233e8ec0550734361a4c8f2a944eab855af8a')
4.999999999978976845715e+24

There is a slight decrease of balance for the signer as observed. Is there anything I miss checking for the 'vanished' ether used as gas in this case? Thanks for the help.

Updated 1: genesis updated to try to lower the alloc balance to simplify the output The updated genesis.json is as follow:

{
  "config": {
    "chainId": 12345,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "muirGlacierBlock": 0,
    "berlinBlock": 0,
    "londonBlock": 0,
    "arrowGlacierBlock": 0,
    "grayGlacierBlock": 0,
    "clique": {
      "period": 5,
      "epoch": 30000
    }
  },
  "difficulty": "1",
  "gasLimit": "800000000",
  "extradata": "0x0000000000000000000000000000000000000000000000000000000000000000b8fd21c7427a7208e34ecce2e70deb6453009a810000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "alloc": {
    "b8fd21c7427a7208e34ecce2e70deb6453009a81": { "balance": "5000000000000000000000000" },
    "72f233e8ec0550734361a4c8f2a944eab855af8a": { "balance": "5000000000000000000000000" }
  }
}

I tried to limit them to have both 5ETH as the balance. I then connect to node1 (expected signer) to send a transaction with zero value to node2. The tx receipt is as follow:

{
  blockHash: "0x78d94ccafc57233337d4e3e9fb3cc6ef9c308839aff97d5055e4ed69b6d73b8f",
  blockNumber: 22,
  contractAddress: null,
  cumulativeGasUsed: 21000,
  effectiveGasPrice: 1052987959,
  from: "0xb8fd21c7427a7208e34ecce2e70deb6453009a81",
  gasUsed: 21000,
  logs: [],
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  status: "0x1",
  to: "0x72f233e8ec0550734361a4c8f2a944eab855af8a",
  transactionHash: "0xf2cdb757f1c143df1ec474920905d2f69bea15f9f4376893da19b1833c273f82",
  transactionIndex: 0,
  type: "0x2"
}

I followed Naveed Ali's answer to log the ethSpentOnGas and obtain this value: 22112747139000

And checking the balances of the nodes:

eth.getBalance('0xb8fd21c7427a7208e34ecce2e70deb6453009a81')
4999998887252861000
eth.getBalance('0x72f233e8ec0550734361a4c8f2a944eab855af8a')
5000000000000000000

It seems that the ETH spent on gas is not added back to the signer's address. But at the same time their sum is not as expected: expected: 5000000000000000000 reality: 5000021000000000000 Not sure if my config was wrong that the signer become some other address. So I tried to update my findings and see if I config it wrongly.

Thank you very much!

1 Answer 1

1

Your observe 'vanished' Ether to transaction fees which are associated with sending the transactions. Even in a POA network, transaction fees are still used to incentivize the validators for including transactions in the blocks which they are sealing.

In your case, signer is also the validator, so transaction fee is ultimately paid back to the signer.

In first transaction, where you are sending ether from the non signer node to the signer node, the transaction fee is deducted from the non signer node and sent back to signer node. due to this non-signer node's balance goes down and the signer node's balance goes up.

In second transaction, in which you are sending ether from signer node to non signer node, the transaction fee is paid by signer node, but also receives it back being the validator. The slight difference in balance for the signer is due to rounding errors when calculating and adding back the transaction fees.

To verify if the vanished Ether is due to transaction fees, check the gas used by the transaction and the gas price to see if the Ether spent on gas and the Ether deducted from the account balances matches. To do this, you can use the following commands:

1: Get transaction receipt by tx hash

let receipt = eth.getTransactionReceipt("<tx_hash>")

2: Calculate ether spent on gas

var used= receipt.gasUsed;
var price= eth.getTransaction("<tx_hash>").gasPrice;
var ethSpentOnGas = used* price;

3: Now compare the Eth that was spent on gas with the Eth deducted from account balances

console.log("eth spent on the gas:", ethSpentOnGas);

I hope this clears your query.

1
  • I have slightly updated the the config, wishing to get the result which is easier to check. It seems that my expected signer actually did not get the eth spent on gas. The difference is a bit weird. I am going to further edit the question to see if there's any other problem.
    – ralphchan
    Commented Apr 13, 2023 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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