IntersectMBO / cardano-node

The core component that is used to participate in a Cardano decentralised blockchain.
https://cardano.org
Apache License 2.0
3.06k stars 721 forks source link

[BUG] - `cardano-cli genesis create-staked` - wrong supply calculation #4556

Closed mkoura closed 1 year ago

mkoura commented 2 years ago

Internal/External Internal

Area Other Any other topic (Delegation, Ranking, ...).

Summary The cardano-cli genesis create-staked command calculates wrong values for amounts provided by --supply and --supply-delegated. Moreover, the supply distribution is not even across stake holders.

On master, command

cardano-cli genesis create-staked --genesis-dir ./create_staked --testnet-magic 42 --gen-pools 3 --gen-utxo-keys 1 --supply 11250000000000000 --gen-stake-delegs 3 --supply-delegated 5625000000000000

produces

  "initialFunds": {                                                                                                                                                                                                  
    "604d0e0e76cab5a2a555fc75155fd1da16f419eb0244c6db25431b540b": 20250000000000000,                                                                                                                                 
    "00b746543e04dfdf4896c98bb15043d8a49773f07aba9a12fa4bfd3ff8f4abc3fa15cdd7985dab83d3bb2d7e563e784f153df11926141eb0ca": 6000000000000000,                                                                          
    "003fda4ada3ac089f4718ef17e53b053b9d52f624fa99a97af2ec042d503f8f239cabc48211bbbc223b37182cd9e48b680f42645fbfd96d3c1": 1500000000000000,                                                                          
    "00b971958504ace5f5935a09f53d2c217be64e90b86e29d5c21fb05e347542b8dc32681e8f699807cd089ebe81c17aeaf9851b101a652458ce": 1500000000000000                                                                           
  },

Notice that the supply is not evenly distributed. The non-delegated supply is 1.8 x supply, the sum of delegated supply is 1.6 x supply-delegated.

With cardano-cli 1.35.3, the same cardano-cli genesis create-staked command as above produces

  "initialFunds": {                                                                                                                                                                                                  
    "000069e8386434384760d27bc56b4ea46153e64569dc69f70d193bb7f9990d846a566a8b0537d96b24a66a4986fd816f120d33ad7357ce8c4b": 1500000000000000,                                                                          
    "00069e090076834b90a6cfba0354d1c08ea98c5c5b0a779f14b72f25e11cc4b644bccff4bce828d519ff6da58b428c3ce0e44b7873e9affe5e": 1500000000000000,                                                                          
    "00b6b146e51260d83d3d90fdeecd03a5b6238fc292cfa3969b356ab33934392533f957313474d21d6ac780004b07a829838aa4cb6e02f28dad": 1500000000000000,                                                                          
    "608f8eb872777c385181e558fc274daea850adb5b0328d07a56159828d": 10125000000000000                                                                                                                                  
  }

In this case, the supply is evenly distributed across stake holders and each sum (delegated and non-delegated stake) doesn't exceed the provided supply.

Expected behavior The supply is evenly distributed and doesn't exceed the provided amount.

System info:

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

Jimbo4350 commented 1 year ago

@mkoura has this been resolved on master?

mkoura commented 1 year ago

@Jimbo4350 no, still present on master.

newhoggy commented 1 year ago

This is what happens when I try this on master:

$ cardano-cli version
cardano-cli 1.36.0 - darwin-aarch64 - ghc-8.10
git rev d9ff0ef9e53fad2761077b90aeeb0f337b863689
$ cardano-cli genesis create-staked --genesis-dir ./create_staked --testnet-magic 42 --gen-pools 3 --gen-utxo-keys 1 --supply 11250000000000000 --gen-stake-delegs 3 --supply-delegated 5625000000000000
generated genesis with: 3 genesis keys, 1 non-delegating UTxO keys, 3 stake pools, 3 delegating UTxO keys, 3 delegation map entries,
$ cat create_staked/genesis.json | jq .initialFunds
{
  "6070b0c5de1fdc3a9bf9b48eb112964fa7efe7cb8e7a8223a62b77c053": 10125000000000000,
  "009e87ae3ca7e162bc82027bc4ab5b0e37768eefc22fb18e10bd8b6d5a6c2fb48537d888d977ee76fca25ac88c94d689461257731e73afaa59": 1500000000000000,
  "00f379be67d3c2ee7a993b3a45f56fd2097873830387eabae4ff0c18f0b7e53bf2d9570c78ecbaf3a58926e57c93a7e2b8412ea20245ca8278": 1500000000000000,
  "00c5d9feff590ce9457f026a9eeabaf994309b0e1c8e0ca2c41158a06394b951edda2b604511f246ee8dcc185dc0bce2f1facdba23c45a48e4": 1500000000000000
}

I'm unable to reproduce the uneven distribution.

mkoura commented 1 year ago

@newhoggy I can confirm your results, looks like this was recently fixed by https://github.com/input-output-hk/cardano-node/pull/4765.