Pool, MEM

Bharat Gandhi
4 min readApr 30, 2021

Understanding what it takes to actually get a transaction going on ETH

Intro: What is Ethereum & ETH?
Ethereum is this huge network of computers, donating their resources to perform tasks. These computers need incentives in order to do these tasks, they are paid in Ether or ETH (1ETH = $2763 at the time of writing). Diff b/w Ether & Ethereum can be confusing but Ethereum is the network and Ether is the programmable money, paid to use this network. This pay ment is GAS. ⛽

What is GAS?
Just like your card needs Gas to go on, Transacting on Ethereum needs you to put in Gas. It’s a fraction of Ether to reward the transaction processor. Much like you pay transaction fee to the bank on a wire, you are paying the network or the node on the network that gets your transaction posted on the blockchain. The smallest unit of Ether is Wei such that 1ETH = 1*10¹⁸ Wei.

Breakdown of Etherum to the smallest unit Wei

MEMPOOL

Ethereum processes transactions every ~10 seconds. Now once you post a transaction to the ethereum network it goes into an intermediary space where transactions get picked to be posted on chain. This is the MEMPOOL. It’s sort of like a waiting area for transactions to become “real” or posted on the blockchain.

OG Deadpool was a list of people likely to die, Mempool is a list of transactions likely to be “LIVE” on chain

If you submit a transaction to the Ethereum blockchain, it goes to a node. Let’s call it the Gateway node. The gateway node adds your transaction to it’s mempool and tells it’s nearby nodes (nearby in the network) about your transaction. They add it to to their mempool too. Now, nodes pick transactions based on their gas prices. You need to to reward the node better than other transaction requests, right? Higher the reward, the greater incentive it is for the node to process that transaction.

At a given time, there are ~150,000 transactions in the global mempool at a given time and ~150 get mined in an ETH block (0.1%). The gas price helps determine the next 150, every 10 seconds. Basically, it is a live auction of the next block, happening in real time. If your gas prices are low and the number of transactions in the mempool are high, your transaction maybe processing for a long time, with the transaction stuck and sometimes, it ends up like this redditor:

40Gwei ≤$2 at the time

Therefore, it becomes extremely important to give a gas price that does not get your transaction stuck, failed or even delayed.

For Dapp developers it becomes increasingly important to understand the state of the mempool and get an accurate gas estimation. In order get a state of the mempool you need to operate nodes, which cover most of the chain and do not go down during a network congestion, which is very inconvenient.

MEMPOOL has Pirates

When a transaction is due to process, it has these details:

  1. a unique number called a nonce (eg. 32)
  2. an address (hash) of the destination (eg. 0x63hsyafeb…..)
  3. gas price (45 Gwei)
  4. How much ETH is being sent (12 ETH)

Since this information is public in the mempool, if someone can keep all details of your transaction the same but change the destination address and increase the gas price. They incentivize the node to process their transaction and send themselves the currency.

  1. a unique number called a nonce (eg. 32)
  2. an address (hash) of the destination (eg. 0x74sdbvq32..) Hacker’s NEW address
  3. gas price (99 Gwei) Increased Gas
  4. How much ETH is being sent (12 ETH)

This is called Frontrunning. It is extremely stupid to do this in most transactions, but not in high value transactions. Hacker’s may lose a lot of Gas money chasing these transactions but if they hit a big transaction with a lot of value, they will transfer themselves a lot of money by frontrunning the transaction.

The mempool is a fascinating place and exist since the inception of the blockchain. The scaling challenge of Ethereum is currently being solved using ETH2.0 or Serentity. In the coming 2 years, the chain would make changes to move to a proof of stake model in an effort to reduce fees, increase scalability and security of the protocol. The mempool would be an interesting place where before chain things happen as De-Fi and DeX’s scale.

This post was inspired this fascinating article that captures a frontrunning incident and $12000.

--

--

Bharat Gandhi

Product Management, Entrepreneurship, All things Tech & Business. Cornell Tech’s Connective Media class of 2021