I am also wondering how this actually works since there hasn't been
any official documentation about it. However, given the already available information
on the website, 'cause all miners shares and hashrate are public and some questions
answered on Twitter by @wk057 and @GrassFedBitcoin;
I think I can already have a full picture of it.
The reward system consist of three main concepts:
- shares earn by each user,
- total shares on the pool,
- and earnings based on shares.
Earnings
Earnings are the simplest thing to explain. If a user has s
shares and the pool
has a total of total_shares
(the sum of all user shares) the moment a block is found, the user earns
s * (block_reward) / total_shares
where block_reward
means subsidy plus fees.
Share Window
The share window Z
is the maximum number of shares the pool will consider at any time. That is only up to the newest Z
shares are considered for the reward distribution.
This number is 8 times the current block difficulty Z = 8 * network_difficulty
. I will show below that this factor 8
translates into the number of blocks for which each share
is expected to generate an earning.
Once the pool is running for quite some time the number of accumulated shares is enough to have total_shares = Z
hence in the examples below
we will consider that to be the case. Though in general this is not
the case at the beginning of the pool operation.
User's shares
One share is equivalent to the work needed to mine a block with difficulty 1.
Ocean, like any other pool, challenges the individual miners with some difficulty d
and each time a hash is accepted d
shares are added to this miner's account.
Because there is a maximum number Z
of shares considered for the
distribution of rewards,
when a miner starts contributing with a constant hashrate H
,
his share number starts growing linearly until a maximum is reached,
this is when the sum of shares in the pool up to Z
starting from the
most recent leaves out the oldest shares generated by the user.
In the plot, I call T
the relaxation time which is in fact the temporal dimension
of the share window, or simply the time difference between the newest and the oldest share
in the share window.
For as long as the pool has a constant hashrate H_pool
,
T
can be
understood as the expected time for the pool to produce Z
shares:
T = W1 * Z / H_pool
where W1=0x100010001
is (by the definition of difficulty 1), the expected work needed
to solve a difficulty 1 block.
Also in the plot, we see the miner with a constant hashrate H
reaches a share number <S>_T
which is the expected
number of shares this miner will receive after T
seconds of work:
<S>_T = H * T / W1
= Z * H / H_pool
If a miner with hashrate H
reaches the expected maximum number of shares and then leaves the pool
forever, his shares will linearly decrease as the oldest shares are thrown away from the share window.
We can understand the distribution of rewards from the point of view
of individual shares.
For instance, assuming a constant hashrate of the pool,
a share earned at any time will stay valid for a
time frame of about T
. Now consider the expected number of blocks found by the pool
in this time frame <N>_T
:
<N>_T = H_pool * T / W1 / network_difficulty
= Z / network_difficulty
= 8
hence each share won by a miner is expected to reward him 8 earnings
before it is thrown away from the share window.
Fairness
A pool has a fair earning distribution if the expected earning(W)
for a certain amount of work W
diluted over time is:
earning(W) = block_reward * W / (W1 * network_difficulty)
assuming a constant block_reward
and
network_difficulty
.
We stress that the denominator W1 * network_difficulty
is the expected work needed to mine a block, approximately the
number of hashes tried by the entire network in 10 minutes.
We had seen that each individual share earned by a miner in the Ocean pool is obtained after W1
of work on average
and it earns the miner a 1/Z
fraction of the reward
in an expected number of 8 blocks found by the pool
from the moment the share is added until it is dropped from the
share window. Therefore we have earnings per share computed as:
earning_per_share = 1/Z * 8 * block_reward
= block_reward / network_difficulty
= earning(W1)
thus the earning distribution is fair according to our definition,
independently of the miner's online time, hashrate,
the pool's hashrate or the network global parameters.
Eventually, if we know a miner's share function in time we can compute the total expected
reward for his shares.
For instance in a time interval [0, t]
the share function is s(t)
,
we split the interval into M
small pieces of length dt = t / M
.
Then the probability of finding a block in each of these time intervals is
p = H_pool * dt/ (W1 * network_difficulty)
.
The reward for the miner in the entire time period is a random variable R
which is the sum
of the reward for the miner in each of the tiny time intervals:
R = sum_i r_i
where r_i = b_i * block_reward * s(t_i) / Z
, in which b_i
denotes a Bernoulli variable that takes values
1 with probability p
and 0 with probability 1-p
.
So the expected value of the reward for the single miner becomes:
<R> = sum_i <r_i>
= block_reward * H_pool / (Z * W1 * network_difficulty) sum_i s(t_i) dt
that converges to a Riemann integral in the limit
of M -> infinity
, the integral is the area under
the curve of shares vs time.
We can use this relation to compute the total earnings of a miner in different example
situations.
Example 1. Alice mining always
Let the hashrate of the pool be H_pool = 1.25 EH/s
, consider Alice a miner with a hashrate
of H_alice = 250 PH/s
, which corresponds to a 20% of the pool's hashrate.
And let network_difficulty = 80T
.
The share window of the pool is Z = 8*network_difficulty = 640T
and the time window
would correspond to T = Z * W1/H_pool = 330 Ms
or about 25 days.
Alice has been mining non-stop since the beginning, so she has already reached the maximum
number of shares in the window: S_alice = H_alice * T / W1 = 128T
.
If a block is found, Alice will get S_alice / Z = 20%
of the block reward.
That means on average in a time frame t
Alice does a total work W_total = H_alice * t
and the pool finds <N>_t = H_pool * t/ (W1 * network_difficulty)
blocks so Alice earns
<R>_t = <N>_t * block_reward * S_alice / Z
= block_reward * W_total / (network_difficulty * W1)
= earning(W_total)
which is fair for Alice.
To put some numbers into it, it means that for blocks with
block_reward = 7 BTC
, Alice is earning on average 0.003 BTC
every 10 minutes or 0.44 BTC/day
, and this number only depends on Alice hashrate
and the network parameters (block_reward
and network_difficulty
).
Example 2. Charlie the small miner
Now consider a small miner that arrives to the pool,
it is small so the total hashrate of the pool doesn't change.
Let's say Charlie has H_charlie = 1 TH/s
.
At a constant hashrate and difficulty, Charlie would have to wait
for at least T
seconds or 25 days until it can reach the maximum number of shares,
see fig 3. If after some time dt
Charlie leaves the pool, his shares will
start to fall linearly to zero in a time period of 25 days (relax time T
).
During all the time Charlie was hashing for the pool, he contributed to
a total of W_total = H_charlie * (T + dt)
.
The expected earnings of Charlie in the three regions in fig. 3 are
(using the integral under the curve):
<R1> = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*T/2)
<R2> = H_pool * block_reward / (Z * W1 * network_difficulty) * S* dt
<R3> = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*T/2)
where S = H_charlie * T / W1
is the maximum number of shares of Charlie.
When these three are summed up we find
<R1 + R2 + R3> = block_reward * S / network_difficulty * (1 + dt/T)
= block_reward * W_total / (W1 * network_difficulty)
= earning(W_total)
Which means that a fair earning is expected for Charlie if
he comes and mines for a long time (until it reaches constant shares)
and then leaves the pool.
For example, if Charlie mines for T = 25 days
reaching constant shares
and then after mining for 10 more days he turns off his
miner. Then <R1> = <R3> = 2240 sat
and <R2> = 1760 sat
,
and a total expected earning of <R1 + R2 + R3> = 6240 sat
before his share count in the window is 0, or 176 sat/day
for
the ratio of total earnings divided by the work time.
Example 3. Charlie leaves early
Consider again the small miner Charlie, but this time he mines for some time t1 < T
, so his shares start to accumulate linearly
until, at time t1
, he turns off his miner;
then for some time his shares remain constant,
until at time T
his oldest share
falls out of the share window and his share count starts to decrease linearly until it
reaches zero at time T + t1
, see fig. 4.
The total work is W_total = H_charlie * t1
and the expected earnings are:
<R1> = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*t1/2)
<R2> = H_pool * block_reward / (Z * W1 * network_difficulty) * S*(T-t1)
<R3> = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*t1/2)
where S = H_charlie * t1 / W1
. When we add them up we find:
<R1 + R2 + R3> = block_reward * S / network_difficulty
= block_reward * W_total / (W1 * network_difficulty)
= earning(W_total)
Which means a fair earning is expected for Charlie even if he participates for
a short period of time.
For example, let t1 = 1 day
, it follows that <R1> = <R3> = 3.5 sat
and <R2> = 169 sat
, in total <R1 + R2 + R3> = 176 sat
or 176 sat/day
(earnings per time of work).
Example 4. Bob the big miner
Now assume, a big miner Bob enters the pool with H_bob = 1.25 EH/s
, doubling the pool's
hashrate.
Bob quickly starts adding shares and the pool would need to discard old shares
as twice as fast than previously to keep the window size at constant Z
. In other words
the relaxation time changes from T = 25.5 days
to T' = Z * W1 / (H_pool + H_bob) = 12.7 days
.
It will take Bob 12 days, until he reaches the maximum number of shares: S = Z/2 = 320T
.
After this moment, every time a block is found Bob will earn half of the block reward.
If Bob decides to leave after some time dt
of having a constant share count,
then his shares will start decreasing linearly with time, see fig. 5.
But since the pool has now less hashrate than when Bob was mining, it will take 25 days before
all of Bob's shares are gone. But still the expected number of blocks is 8.
Due to the fairness argument described above, each one of Bob
shares is as good as any other miner shares.
The total work done by Bob is W_total = H_bob * (T' + dt)
while the expected earnings on each
region are
<R1> = (H_pool+H_bob) * block_reward / (Z * W1 * network_difficulty) * (S*T'/2)
<R2> = (H_pool+H_bob) * block_reward / (Z * W1 * network_difficulty) * S*dt
<R3> = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*T)/2
again adding them up we find that
<R1 + R2 + R3> = block_reward / network_difficulty * (S + S*dt/T')
= block_reward * W_total / (W1*network_difficulty)
= earning(W_total)
Also for the big miner we verify that earnings are fair.
For instance if dt = 7 days
we find that <R1> = <R3> = 14 BTC
and <R2> = 15.4 BTC
, for a total expected earning of
<R1+R2+R3> = 43.3 BTC
or 2.2 BTC/day
(total earnings per day of work),
notice this is always 176 sat/day
for each TH/s
of hashrate.
Example 5. Bob the big miner leaves early
Now assume, Bob enters the pool but mines only for a short
period of time t1 < T'
.
While Bob is mining his shares grow linearly up to
S = t1 * H_bob
, then after he stops
the number of shares remain constant for some time dt
until
the oldest shares by Bob start to leave the share window:
t1 * (H_pool + H_bob) + dt * H_pool = Z * W1
Afterwards, his shares starts decreasing linearly
until zero at time t1 + T
; see fig. 6.
The total work done by Bob is W_total = H_bob * t1
while the expected earnings on each
region are:
<R1> = (H_pool+H_bob) * block_reward / (Z * W1 * network_difficulty) * (S*t1/2)
<R2> = H_pool * block_reward / (Z * W1 * network_difficulty) * S*dt
<R3> = H_pool * block_reward / (Z * W1 * network_difficulty) * S * (T-dt)/2
again adding them up we find that:
<R1 + R2 + R3> = block_reward / network_difficulty * S * (t1/T' + dt/T + 1 )/2
= block_reward * W_total / (W1 * network_difficulty)
= earning(W_total)
Earnings are always fair.
Now let's say t1 = 1 day
, during that period of time
the miner will earn <R1> = 0.086 BTC
. Then, the miner turns off
and during the following dt = (1-t1/T') * T = 23.5 days
in which the shares remain constant the miner will earn
<R2> = 2.027 BTC
.
Then finally the shares will start to decrease linearly for the next
T-dt = 2 days
and the miner will earn <R3> = 0.086 BTC
,
for a total expected earnings of <R1 + R2 + R3> = 2.2 BTC
or 2.2 BTC/day
(total earnings for time of work) or 176 sat/day
for each TH/s
.