celestiaorg / supply

API that returns the current circulating and total supply of TIA
https://supply.celestia.org
3 stars 2 forks source link

Verify the total supply returned by the endpoint roughly matches the actual total supply #12

Closed rootulp closed 11 months ago

rootulp commented 11 months ago

Context

This repo calculates the total supply based on an approximation for inflation.

Problem

The actual total supply may not exactly match the total supply returned by this API.

Proposal

Fetch both values. Determine the error margin for this API. If it's sufficiently small, it's likely not an issue.

rootulp commented 11 months ago

I'm syncing a node on mainnet currently so that I can run

celestia-appd query bank total

In the meantime, http://0.0.0.0:8080/v0/total-supply reports a total supply of 10017534246.575279

rootulp commented 11 months ago

Update: my local node is only at block height 4350 and it's been syncing for a while so exploring alternatives...

rootulp commented 11 months ago

Created a consensus full node on Scaleway and will let it sync overnight

rootulp commented 11 months ago

Consensus full node is synced to tip:

root@rootul-mainnet-consensus:~# celestia-appd  status
{"NodeInfo":{"protocol_version":{"p2p":"8","block":"11","app":"1"},"id":"a0fd26f38d207811bde74ee90aea02ba26ee881e","listen_addr":"tcp://0.0.0.0:26656","network":"celestia","version":"1.3.0","channels":"40202122233038606100","moniker":"mainnet-node","other":{"tx_index":"off","rpc_address":"tcp://127.0.0.1:26657"}},"SyncInfo":{"latest_block_hash":"1E913811C71798BB765A65E40F50A39CF9BBF37A26BEBC23CEF0412376FE841C","latest_app_hash":"7F7ED7513A57100672DA5F34E4B1A246571FF1664F5E63CFE28C8D8FE07B6178","latest_block_height":"149953","latest_block_time":"2023-11-20T20:40:09.540192442Z","earliest_block_hash":"6BE39EFD10BA412A9DB5288488303F5DD32CF386707A5BEF33617F4C43301872","earliest_app_hash":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","earliest_block_height":"1","earliest_block_time":"2023-10-31T14:00:00Z","catching_up":false},"ValidatorInfo":{"Address":"941CCA5968EF7EDA83C7AFAD60DAB14DA29E5EC5","PubKey":{"type":"tendermint/PubKeyEd25519","value":"lr4aGSo9x3ZIxU7/uztGZnro3G4sNDgEunTg3nMe8Mw="},"VotingPower":"0"}}

and the total supply is

root@rootul-mainnet-consensus:~# celestia-appd query bank total
pagination:
  next_key: null
  total: "0"
supply:
- amount: "1004441609454260"
  denom: utia

and 1004441609454260 utia = 1004441609.454260 TIA.

The supply API currently shows 1004383561.643820 TIA. The difference is: 1004441609.454260 - 1004383561.643820 = 58047.8104399 TIA. 58047.8104399 / 1004441609.454260 = 0.00005779112 or .0057 % margin of error which seems acceptable.