0

In my private testnet, I sent a transaction that runs out of gas before completion, which can be seen from gasUsed: 28666 = gas: 28666 and failure status: "0x0",. I thought it would not be incorporated into the blockchain. But it was (in blockNum #1456). It this expected? If yes, wouldn't a spammer keep sending transactions with low gas limit and fill in all blocks?

> eth.getTransaction("0xe97d2b5e6f109c7d299dcd8673474d9853363c611bf1d973062cfcbc26a7ede7")
{
  blockHash: "0x907826c61038402c394d2e297b03643929cef97fb943574e8312a09fa84387c2",
  blockNumber: 1456,
  from: "0xf6de496ec5601d74937ddd77af09c8cd4ba41ab5",
  gas: 28666,
  gasPrice: 22000000000,
  hash: "0xe97d2b5e6f109c7d299dcd8673474d9853363c611bf1d973062cfcbc26a7ede7",
  input: "0xa9059cbb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000029a2241af62c0000",
  nonce: 8,
  r: "0xb9d8c5f664887c10070681f2c35d3baa8f1e4d57439f3e93bafc920b2a126f90",
  s: "0x7e969e860765a7102c8bad833c672df08b5d760f1a2d2aac717857e401653ae8",
  to: "0x091e99d1fbf1d18b7c42aeb6938dec588b2aae9c",
  transactionIndex: 0,
  v: "0x42",
  value: 0
}
> eth.getTransactionReceipt("0xe97d2b5e6f109c7d299dcd8673474d9853363c611bf1d973062cfcbc26a7ede7")
{
  blockHash: "0x907826c61038402c394d2e297b03643929cef97fb943574e8312a09fa84387c2",
  blockNumber: 1456,
  contractAddress: null,
  cumulativeGasUsed: 28666,
  from: "0xf6de496ec5601d74937ddd77af09c8cd4ba41ab5",
  gasUsed: 28666,
  logs: [],
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  status: "0x0",
  to: "0x091e99d1fbf1d18b7c42aeb6938dec588b2aae9c",
  transactionHash: "0xe97d2b5e6f109c7d299dcd8673474d9853363c611bf1d973062cfcbc26a7ede7",
  transactionIndex: 0
}
2

It this expected?

Yes. If failed transactions are not included in a block, a spammer can send fail transactions constantly with a high gas price, which takes priority under default miner settings, to reduce the rate of block creation as miners are "jammed" by those fail transactions.

If yes, wouldn't a spammer keep sending transactions with low gas limit and fill in all blocks?

There is a constant gas cost (21000 gas) for sending a transaction to avoid sending spam transactions without any cost.

Ethereum uses a concept called block gas limit to determine the how many transactions can be included in a block. The block gas limit is ~8M at the moment. So the cost is really high for a spammer to attack the network by creating transactions.

  • Now I understand a spammer can't keep sending transactions since there is a minimal gas cost for each transaction. Still not sure how including failed out-of-gas transactions in the blockchain could prevent spamming more effectively than not including them. – sinoTrinity May 10 '18 at 4:58
  • The only way to update an account's balance is through a transaction. Including failed transactions in the blockchain means that the transaction sender needs to pay for it, which can avoid attackers from sending time consuming transactions repeatedly without any cost. – Kingmoz May 10 '18 at 6:29
  • This penalty still applies when failed transactions are not included, but still charged. No? Maybe is it to prevent miners from cheating by lying about a transaction not paying enough gas when it does? – sinoTrinity May 10 '18 at 16:06
  • 1
    Maybe is it to prevent miners from cheating by lying about a transaction not paying enough gas when it does? - Yes, the best way for other nodes to verify the transaction is to re-run the contract instead of trusting the miner. – Kingmoz May 16 '18 at 6:35

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.