This will be a series of increasingly difficult Bitcoin math puzzles, designed to walk through the game theory of various bitcoin scenarios in a formal way. We're currently taking a look at selfish mining.
There are two miners, Alice and Bob. Bob is an honest miner and always mines on the public (longest) chain. Alice is a potentially honest, potentially selfish miner who can decide to mine on the public chain, or to secretly work on a private chain, only to publicly broadcast her private chain later.
For the purposes of this problem, we'll use the notation set forth in these posts: #1473180, #1475564, and #1477308.
In particular, we'll assume the following:
- Alice has a hash rate of , measured in EH/s
- Bob has a hash rate of , measured in EH/s
- Alice's hash rate is less than Bob's:
- The effective difficulty is , measured in EH. Effective difficulty is the average number of exahashes required to find a block
- The block reward for a found block is , measured in sats (includes any transaction fees, which we'll assume are constant and deterministic)
- The cost to produce 1 exahash is , measured in sats per EH, for both Alice and Bob
- The discount rate is , measured in percent per year, for both Alice and Bob
For now, we'll ignore difficulty adjustments, ignore block subsidy halvings, and ignore latency.
PreliminariesPreliminaries
Based on the above assumptions, we can say the following:
- Alice's block finding rate is
- Bob's block finding rate is
- At any given moment, the probability that Alice finds the next block is
- At any given moment, the probability that Bob finds the next block is
- The average amount of time for Alice to find a block is
- The average amount of time for Bob to find a block is
Description of selfish miningDescription of selfish mining
Whenever Alice and Bob are both mining on the same public chain, we'll call that chain C.
If Bob finds the next block, the chain becomes C-B. He immediately publishes it, and both Alice and Bob will mine on that new chain. Since they're both mining on the same chain, we rename C-B → C.
If Alice finds the next block, she now has chain C-A. Since Alice is selfish, she can decide whether to publish it or not.
- If she publishes it, the public chain becomes
C-Aand both Alice and Bob will mine on it, so we renameC-A → C. - If, however, Alice decides to hide her private chain, the two miners are now mining on different chains. Alice is now mining on
C-Aand Bob is now mining onC. If Bob finds the next block after that, Alice now hasC-Aand Bob hasC-B. However, if Alice finds the next block after that, she now hasC-A-Awhile Bob still hasC. Alice can again decide whether she wants to publishC-A-A, or to keep it private.
In other words, Bob always publishes any block he finds, and always mines on top of the longest chain. Alice, when she finds a block, may decide whether to keep her chain private and mine on it secretly, or to publicize her chain.
In this series of problems, we're going to derive conditions under which Alice has an incentive to not publish her chain, but rather to mine privately.
Value function and state notationValue function and state notation
The strategic state space can be described by two numbers, a and b. a measures how many blocks Alice has mined on top of C in her private chain, and b measures how many blocks Bob has mined on top of C in the public chain (only when the private chain and the public chain diverge).
So for example:
- If Alice is mining on
C-Awhile Bob is mining onC, then(a,b)=(1,0). - If Alice is mining on
C-Awhile Bob is mining onC-B, then(a,b)=(1,1). - If Alice is mining on
C-A-Awhile Bob is mining onC, then(a,b)=(2,0). - If Alice and Bob are both mining on
C, then(a,b)=(0,0). - In fact, if at any time Alice and Bob are both mining on the same public chain, then
(a,b)=(0,0). - If Alice ever publishes her private chain which is ahead of the public chain, the state resets to
(a,b)=(0,0)because Bob always mines on the longest published chain.
Let be Alice's value function in state (a,b) (i.e. the net present value of mining while the state is a, b).
Let be Alice's value function of publishing her private chain while in state (a,b). We note that:
This is because if Alice publishes when , then her chain becomes the longest public chain (which Bob now mines on), and she earns the accumulated rewards she had hidden up to this point. But if she publishes when , her chain is not the longest and will not be accepted as the public chain.
ProblemsProblems
- Write a Bellman equation for the value function . Hint: It should include the terms , , , , and .
Bounty: 500 sats (payable by zap) to the best answer after 24 hours. This means you have to not only give a correct answer, but also document your reasoning. Suspected AI use will be ignored.
If I make a mistake in my puzzles, please do let me know. We're working this through together!
Hint on Bellman equations
If the current state is that gives flow utility , and two possible events could happen, event 1 and event 2, with Poisson rates and , and event 1 pushes you into state while event 2 pushes you into state , the Bellman equation would be:
Nit: when
a = b, it is an alternative longest chain, but most nodes would have seen Bob’s chain already and therefore would not switch to her chaintip.Alice and Bob produce about
dexahashes until a new block is found. Alice is producing $xd$ of those hashes. Therefore, she is expected to expend $u(x) = -xdc$ until a block is found either by Alice or Bob.rV(0,0)=−xdc+λA[V(1,0)−V(0,0)]+λB[V(0,1)−V(0,0)]
If Bob finds the next block, Bob immediately publishes his block, and both Alice and Bob resume mining on top of a shared chaintip. Therefore, the state $V(0, 1) = V(0, 0)$ and the transition results only in the aforementioned cost and no value addition: $λ_{B}[V(0, 1) - V(0, 0)] = λ_{B}[V(0, 0) - V(0, 0)] = 0$
rV(0,0)=−xdc+λA[V(1,0)−V(0,0)]+0
If Alice finds a block, she pulls ahead and gains one block reward, i.e., $λ_{A}[V(1, 0) - V(0, 0)] = λ_{A}R×1$.
rV(0,0)=−xdc+λAR
TBH, I’m writing this up a bit too quickly, and I’m not sure whether the flow of utility shouldn’t rather be per second, so please don’t be shocked if I’m completely lost—this was just a quick and dirty guess. ;)
Edit: I’m also not sure why the inline math is not rendering as expected. :(
Time for dinner, tho.
You are quite close.
Inline math needs double dollar signs:
$$ y = f(x) $$Thanks, I feel I understand much better what you meant with V(x) and P(x), then.
Adding to above reasoning, I replace the flow cost with the corrected value: u(x)=−hAc
Yet, I am still not sure how to exactly compose the value of Alice finding the next block. It seems to me that it is dependent on whether Alice will publish once she gets ahead. From what I know this would depend on Alice’s hashrate. I therefore introduce another term, a binary decision function that returns 0 or 1 if Alice would publish the state based on a, b, and x: D(a, b, x):
rV(0,0)=−hAc+λA{D(1,0,x)[P(1,0)−V(0,0)]+[1−D(1,0,x)][V(1,0)−V(0,0)]}
If she publishes, she is one block ahead and gets one block reward:
[P(1,0)−V(0,0)]=R
rV(0,0)=−hAc+λA{D(1,0,x)R+[1−D(1,0,x)][V(1,0)−V(0,0)]}
If she does not publish, she gains the reward of mining with a one-block lead
V(1, 0), which in turn would either resolve to Bob catching up or Alice pulling ahead further, but is left as a black box because it was given in the problem statement.Yes, this is correct! Congrats
The challenge going forward will be characterizing the function you introduced, D(a,b).
Just as a quick note, I would have written it like this, but your introduction of D(a,b) is also correct.
Aye! Expressing it with a maximum function is much more elegant. Thanks for the guidance. This series is fun.
Oh and thanks on clearing up what I was doing wrong about the inline math. Looks much better now. :)
I understand some of these words.
It's a bit advanced in terms of notation. But the answer doesn't require any tricky computation. Once a person understands how to write a Bellman equation, the answer becomes fairly straightforward.