Part A: Gini coefficient calculation
“Decentralization” is not rigorously defined. For now I will focus on just the decentralization of consensus voting power (as opposed to e.g. decentralizaiton of account balances), since that is most directly relevant to consensus safety, liveness, and governance, and since it is easy to measure and we have reason to believe we can measure it accurately (I expect most currently separate validators are not secretely operated by the same entitites).
The Gini coefficient of the validator voting stake distribution seems like a reasonable first stab at a metric. It almost certainly fail to encapsulate everything one might mean by “decentralization”, but it seems to capture an important essence - a “centralized” system with all voting power in the hands of a single entity will have a Gini coefficient around one, and a “decentralized” system with exactly equal voting power (such as 1P1V democracy) will have a Gini coefficient around zero. The Cosmos Hub will necessarily fall somewhere between those two extremes - a blockchain of one validator isn’t particularly compelling, but nor would be a blockchain where all users validate, since it would be far too slow and operationally expensive (and perhaps for other reasons - e.g. no one would be able to afford secure hardware).
The Gini coefficient, which is half the relative mean difference, can be calculated on any numerical distribution as follows:
>> import numpy as n
>> def gini(x):
return n.abs(n.subtract.outer(x, x)).mean() / n.mean(x) / 2
A few benchmarks first - the Gini coefficients of a random distribution, of an equal distribution, and of an extremely unequal distribution:
>> print(gini(n.random.rand(500)))
0.32322
>> print(gini(n.ones(500))
0.0
>> print(gini([1] + [0] * 499))
0.998
The Gini coefficient of the Cosmos Hub validators can then be calculated, using the Stargazer API:
>> import requests
>> res = requests.get('https://sgapi.certus.one/validators').json()
>> validator_weights = [v['weight'] for v in res]
Then calculate the Gini coefficient:
>> print(gini(validator_weights))
0.7816528136845804
Of course, this will vary if you run the command yourself according to the current data.
By comparison, the most unequal country by family income has a Gini coefficient of 0.632
. I doubt that’s a very meaningful benchmark. A better benchmark might be Gini coefficents of consensus in other blockchains. The best prior research I can find is here, which lists the Gini coefficients of Bitcoin mining as 0.40
(they sourced from this list of pools) and Ethereum mining as 0.82
(from this list) - that post is a year and a half old, so the values have likely changed since.
Many more interesting metrics could be calculated - Gini coefficients of code commits, of account balances (although may be inaccurate due to single users using many accounts), and of interchain token exchange volume (once IBC is deployed ) would all be quite pertinent. I think it would be particularly useful for block explorers or network statistics trackers to display some of these “decentralization stats”.