Jormungandr: (enhancement) Enhance the output of `rest v0 settings get` command

Created on 2 Oct 2019  路  5Comments  路  Source: input-output-hk/jormungandr

Describe the bug
It would be useful to have slot_duration and slots_per_epoch displayed in the output of rest v0 settings get command (especially when using local scripts for different actions).

Additional context

$ Jcli rest v0 settings get --host "http://127.0.0.1:9000/api"
---
block0Hash: adbdd5ede31637f6c9bad5c271eec0bc3d0cb9efb86a5b913bb55cba549d0770
block0Time: "2019-02-22T07:53:34+00:00"
consensusVersion: genesis
currSlotStartTime: "2019-10-02T11:19:58+00:00"
fees:
  certificate: 10000
  coefficient: 50
  constant: 1000
maxTxsPerBlock: 255
enhancement good first issue

Most helpful comment

@rinor , putting your name on it, but obviously you don't have to do it. no pressure

All 5 comments

You mean smth like this:

block0Hash: dc47d16e0f5c56db286ec9bf2927dfcc5d493a1307bdb0fa5a66d041ba8256b2
block0Time: "2017-09-29T00:00:00+00:00"
consensusVersion: genesis
currSlotStartTime: "2019-10-02T14:13:30+00:00"
fees:
  certificate: 10000
  coefficient: 50
  constant: 10
maxTxsPerBlock: 255
slotDuration: 10
slotsPerEpoch: 1

anything else to be added?

Yeap. That would be ideal @rinor

probably this will need changes to https://github.com/input-output-hk/chain-libs and since there will be other things like reward_params or treasury_params, it would be nice to discuss what other info may be needed/preferred. However if you think that slot_duration and slots_per_epoch are enough for now I can try to implement a simple solution.

it is not _that_ hard to be honest,

here https://github.com/input-output-hk/jormungandr/blob/aec29a1ce5b6b361ad2180b4da95e4478275ba40/jormungandr/src/rest/v0/handlers.rs#L233

This is where we get the ledger _state_ at the current tip.

retrieving the slot duration

from the blockchain_tip value you can query the time frame: https://github.com/input-output-hk/jormungandr/blob/aec29a1ce5b6b361ad2180b4da95e4478275ba40/jormungandr/src/blockchain/reference.rs#L98-L101

which is this object: https://github.com/input-output-hk/chain-libs/blob/7d46837dc06033763277c81af4610f3ee954188c/chain-time/src/timeframe.rs#L27-L31

The only thing missing is an accessor to retrieve the slot duration

retrieving the number of slots per epoch

To retrieve the number of slots per epoch you need to go via the leadership: https://github.com/input-output-hk/jormungandr/blob/aec29a1ce5b6b361ad2180b4da95e4478275ba40/jormungandr/src/blockchain/reference.rs#L103-L105

which then you can get the TimeEra: https://github.com/input-output-hk/chain-libs/blob/7d46837dc06033763277c81af4610f3ee954188c/chain-impl-mockchain/src/leadership/mod.rs#L170-L174

which then you can extract: https://github.com/input-output-hk/chain-libs/blob/7d46837dc06033763277c81af4610f3ee954188c/chain-time/src/era.rs#L40-L42

should be pretty easy to do that part (a small PR is chain-libs)

@rinor , putting your name on it, but obviously you don't have to do it. no pressure

Was this page helpful?
0 / 5 - 0 ratings