All field notes

Security · Retrospective

What a mining-pool operator watches: rented hashpower and a small proof-of-work chain

A white mining machine wired to three glass blocks, with a small hourglass beside them.
Concept illustration · AI-generated

My first job on Trivechain was its mining pool. I built it and I still run it. Most of my time as lead developer now goes into the protocol and the tools around it, but I still look at the chain the way the pool does: as a stream of blocks, each found by someone, and each replaceable until enough work has been piled on top of it.

This month gave me a reason to write some of that down. On 15 and 18 February, the bZx lending protocol on Ethereum lost funds to two attacks built on flash loans: borrow a large amount, use it to move a price, and repay it, all inside a single transaction. The attacker never needed to own the capital, only to hold it for a moment. Proof-of-work chains have their own version of that idea, and it is the one a pool operator on a small chain thinks about: hashpower you can rent by the hour.

The arithmetic of a small chain

A proof-of-work network follows the valid chain with the most accumulated work. Someone who controls more hashpower than all the honest miners together can mine a private chain, spend coins on the public one, and then publish the longer private chain to replace it. On a large network that takes a fleet of hardware. On a small one, the hashpower offered on rental marketplaces for the same algorithm can be larger than the whole network.

This has already happened elsewhere. In January 2019, Ethereum Classic had blocks reorganised by someone with more hashpower than its honest miners, and exchanges were double-spent. Trivechain is a small chain, so I treat that as the case to plan for.

What the pool lets me see

A pool sits at a useful vantage point. These are the signals I find most useful:

  • Who found each block. Most pools write a tag into the coinbase transaction of every block they find, and our explorer matches those tags to names. At the end of January I updated that list, which now labels blocks from the official pool, Swift Pools and pools running the open-source YIIMP software (commit).
  • Blocks with no known tag. One may be a solo miner or a new pool. A run of them, arriving with a jump in difficulty, is the pattern worth stopping for.
  • Difficulty. Trivechain retargets difficulty every block, so a large amount of new hashpower shows up within a few blocks, and its departure shows as a stretch of slow blocks afterwards.
  • Orphans in the pool's own list. These are blocks the pool found that are no longer in the main chain. Most are ordinary races between two miners a few seconds apart, one block deep. A deeper one is not ordinary.
  • Our own share. The official pool is part of the risk too. A pool that finds most of the blocks is one operator away from the same problem, so I watch our share as closely as anyone else's.

The protocol already builds in one precaution. A block reward cannot be spent until 100 blocks have been built on top of it, so a reward from a block that gets replaced never reaches a miner's wallet.

Confirmations are hours of rent

Trivechain produces a block about every 60 seconds. When an exchange waits for 60 confirmations, it is asking an attacker to hold a majority for about an hour. Ten confirmations is about ten minutes.

Confirmations do two different jobs, and it helps to keep them apart. Against an attacker with less than half the hashpower, each extra block makes catching up less likely. Against an attacker with more than half, waiting does not change the outcome. It changes the cost, because the attacker pays rent for every hour they must hold the lead. On a small chain, the better question for an exchange is not "how many blocks?" but "how many hours of rented majority would a deposit of this size pay for?"

What X16Rv2 does and does not buy

Trivechain started on X11, and I worked on its move to X16R. It now runs X16Rv2. X16R chains sixteen hash functions in an order taken from the previous block's hash, which is meant to make a fixed-function mining chip impractical. X16Rv2 changed the recipe again, so hardware tuned to the original no longer fits.

What that buys is real but narrow: mining stays on general-purpose graphics cards, so no single manufacturer's machines can take over the chain. What it does not buy is protection from rented hashpower. A GPU algorithm shared with larger chains has a large market of cards that can be pointed somewhere else for an hour. An algorithm decides who can mine. It does not decide how much hashpower can arrive at once.

What I take from this

Nothing about a small chain's position makes a rented attack free, and nothing rules it out. What we have is attention: watching blocks as they arrive, talking to exchanges about confirmations in terms of time and cost rather than block counts, and keeping our own pool from becoming the concentration we warn others about.