[Ethereum] Understanding transaction broadcast better

peerstransactions

I'm trying to understand better how the Ethereum protocol works, and in particular, how transactions are broadcasted across peers.

I created a test transaction with very little gas price to test what would happen, then I used web3.eth to send the transaction. As expected, the transaction never makes it to a block, it's still showing under eth.pendingTransactions. The part I don't understand is why I can't see the transaction on Etherscan pending transactions here.

Did my geth client ever broadcast that low gas price transaction to my peers? Did those peers also broadcast that transaction to their peers? Did the Etherscan node receive my transaction at some point, and then eventually drop it, or did my transaction never make it to the Etherscan node?

Does this behavior (e.g., how long to keep a transaction in pending transactions) vary per client? E.g., parity vs geth. Or is that something that is defined in the protocol and all clients implement the same behavior?

Finally, I did read this question about the difference between pendingTransactions and getBlock('pending').transactions, but I'm still unclear on something. Why doesn't my local pending transaction show in the pending block? In other words:

> eth.getBlock('pending').transactions.indexOf(eth.pendingTransactions[0])

-1

I would have expected that my client's understand of the "pending" block at least includes the local pending transactions.

Best Answer

Second question first: pendingTransactions are transactions held in memory, while getBlock('pending').transactions are the transactions included in the block being mined.

A full node checks blocks and transactions validity before relaying them. However it doesn't have to be a miner. No mining, therefore no transactions in getBlock('pending').transactions.

As for the first question, etherscan is a node with a handy web interface. Transactions that are broadcast to it can be displayed as pending even though it's not mining. You don't mention how long you left the transaction pending, but eventually it should reach etherscan. I look quickly but couldn't find transactions broadcasting statistics. It may be linked to that.

Another limitation is the pending transaction pool of your peers. Remember the infamous ICOs clogging up the network. If your peers have a full queue they may just drop your transaction.

Related Topic